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
= (struct qeth_card
*) kmalloc(sizeof(struct qeth_card
),
304 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
305 memset(card
, 0, sizeof(struct qeth_card
));
306 if (qeth_setup_channel(&card
->read
)) {
310 if (qeth_setup_channel(&card
->write
)) {
311 qeth_clean_channel(&card
->read
);
319 __qeth_check_irb_error(struct ccw_device
*cdev
, struct irb
*irb
)
324 switch (PTR_ERR(irb
)) {
326 PRINT_WARN("i/o-error on device %s\n", cdev
->dev
.bus_id
);
327 QETH_DBF_TEXT(trace
, 2, "ckirberr");
328 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
331 PRINT_WARN("timeout on device %s\n", cdev
->dev
.bus_id
);
332 QETH_DBF_TEXT(trace
, 2, "ckirberr");
333 QETH_DBF_TEXT_(trace
, 2, " rc%d", -ETIMEDOUT
);
336 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb
),
338 QETH_DBF_TEXT(trace
, 2, "ckirberr");
339 QETH_DBF_TEXT(trace
, 2, " rc???");
345 qeth_get_problem(struct ccw_device
*cdev
, struct irb
*irb
)
350 sense
= (char *) irb
->ecw
;
351 cstat
= irb
->scsw
.cstat
;
352 dstat
= irb
->scsw
.dstat
;
354 if (cstat
& (SCHN_STAT_CHN_CTRL_CHK
| SCHN_STAT_INTF_CTRL_CHK
|
355 SCHN_STAT_CHN_DATA_CHK
| SCHN_STAT_CHAIN_CHECK
|
356 SCHN_STAT_PROT_CHECK
| SCHN_STAT_PROG_CHECK
)) {
357 QETH_DBF_TEXT(trace
,2, "CGENCHK");
358 PRINT_WARN("check on device %s, dstat=x%x, cstat=x%x ",
359 cdev
->dev
.bus_id
, dstat
, cstat
);
360 HEXDUMP16(WARN
, "irb: ", irb
);
361 HEXDUMP16(WARN
, "irb: ", ((char *) irb
) + 32);
365 if (dstat
& DEV_STAT_UNIT_CHECK
) {
366 if (sense
[SENSE_RESETTING_EVENT_BYTE
] &
367 SENSE_RESETTING_EVENT_FLAG
) {
368 QETH_DBF_TEXT(trace
,2,"REVIND");
371 if (sense
[SENSE_COMMAND_REJECT_BYTE
] &
372 SENSE_COMMAND_REJECT_FLAG
) {
373 QETH_DBF_TEXT(trace
,2,"CMDREJi");
376 if ((sense
[2] == 0xaf) && (sense
[3] == 0xfe)) {
377 QETH_DBF_TEXT(trace
,2,"AFFE");
380 if ((!sense
[0]) && (!sense
[1]) && (!sense
[2]) && (!sense
[3])) {
381 QETH_DBF_TEXT(trace
,2,"ZEROSEN");
384 QETH_DBF_TEXT(trace
,2,"DGENCHK");
389 static int qeth_issue_next_read(struct qeth_card
*);
395 qeth_irq(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
399 struct qeth_cmd_buffer
*buffer
;
400 struct qeth_channel
*channel
;
401 struct qeth_card
*card
;
403 QETH_DBF_TEXT(trace
,5,"irq");
405 if (__qeth_check_irb_error(cdev
, irb
))
407 cstat
= irb
->scsw
.cstat
;
408 dstat
= irb
->scsw
.dstat
;
410 card
= CARD_FROM_CDEV(cdev
);
414 if (card
->read
.ccwdev
== cdev
){
415 channel
= &card
->read
;
416 QETH_DBF_TEXT(trace
,5,"read");
417 } else if (card
->write
.ccwdev
== cdev
) {
418 channel
= &card
->write
;
419 QETH_DBF_TEXT(trace
,5,"write");
421 channel
= &card
->data
;
422 QETH_DBF_TEXT(trace
,5,"data");
424 atomic_set(&channel
->irq_pending
, 0);
426 if (irb
->scsw
.fctl
& (SCSW_FCTL_CLEAR_FUNC
))
427 channel
->state
= CH_STATE_STOPPED
;
429 if (irb
->scsw
.fctl
& (SCSW_FCTL_HALT_FUNC
))
430 channel
->state
= CH_STATE_HALTED
;
432 /*let's wake up immediately on data channel*/
433 if ((channel
== &card
->data
) && (intparm
!= 0))
436 if (intparm
== QETH_CLEAR_CHANNEL_PARM
) {
437 QETH_DBF_TEXT(trace
, 6, "clrchpar");
438 /* we don't have to handle this further */
441 if (intparm
== QETH_HALT_CHANNEL_PARM
) {
442 QETH_DBF_TEXT(trace
, 6, "hltchpar");
443 /* we don't have to handle this further */
446 if ((dstat
& DEV_STAT_UNIT_EXCEP
) ||
447 (dstat
& DEV_STAT_UNIT_CHECK
) ||
449 if (irb
->esw
.esw0
.erw
.cons
) {
450 /* TODO: we should make this s390dbf */
451 PRINT_WARN("sense data available on channel %s.\n",
452 CHANNEL_ID(channel
));
453 PRINT_WARN(" cstat 0x%X\n dstat 0x%X\n", cstat
, dstat
);
454 HEXDUMP16(WARN
,"irb: ",irb
);
455 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
457 rc
= qeth_get_problem(cdev
,irb
);
459 qeth_schedule_recovery(card
);
465 buffer
= (struct qeth_cmd_buffer
*) __va((addr_t
)intparm
);
466 buffer
->state
= BUF_STATE_PROCESSED
;
468 if (channel
== &card
->data
)
471 if (channel
== &card
->read
&&
472 channel
->state
== CH_STATE_UP
)
473 qeth_issue_next_read(card
);
475 tasklet_schedule(&channel
->irq_tasklet
);
478 wake_up(&card
->wait_q
);
482 * tasklet function scheduled from irq handler
485 qeth_irq_tasklet(unsigned long data
)
487 struct qeth_card
*card
;
488 struct qeth_channel
*channel
;
489 struct qeth_cmd_buffer
*iob
;
492 QETH_DBF_TEXT(trace
,5,"irqtlet");
493 channel
= (struct qeth_channel
*) data
;
495 index
= channel
->buf_no
;
496 card
= CARD_FROM_CDEV(channel
->ccwdev
);
497 while (iob
[index
].state
== BUF_STATE_PROCESSED
) {
498 if (iob
[index
].callback
!=NULL
) {
499 iob
[index
].callback(channel
,iob
+ index
);
501 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
503 channel
->buf_no
= index
;
504 wake_up(&card
->wait_q
);
507 static int qeth_stop_card(struct qeth_card
*, int);
510 __qeth_set_offline(struct ccwgroup_device
*cgdev
, int recovery_mode
)
512 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
513 int rc
= 0, rc2
= 0, rc3
= 0;
514 enum qeth_card_states recover_flag
;
516 QETH_DBF_TEXT(setup
, 3, "setoffl");
517 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
519 if (card
->dev
&& netif_carrier_ok(card
->dev
))
520 netif_carrier_off(card
->dev
);
521 recover_flag
= card
->state
;
522 if (qeth_stop_card(card
, recovery_mode
) == -ERESTARTSYS
){
523 PRINT_WARN("Stopping card %s interrupted by user!\n",
527 rc
= ccw_device_set_offline(CARD_DDEV(card
));
528 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
529 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
531 rc
= (rc2
) ? rc2
: rc3
;
533 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
534 if (recover_flag
== CARD_STATE_UP
)
535 card
->state
= CARD_STATE_RECOVER
;
536 qeth_notify_processes();
541 qeth_set_offline(struct ccwgroup_device
*cgdev
)
543 return __qeth_set_offline(cgdev
, 0);
547 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
);
551 qeth_remove_device(struct ccwgroup_device
*cgdev
)
553 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
556 QETH_DBF_TEXT(setup
, 3, "rmdev");
557 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
562 if (qeth_wait_for_threads(card
, 0xffffffff))
565 if (cgdev
->state
== CCWGROUP_ONLINE
){
566 card
->use_hard_stop
= 1;
567 qeth_set_offline(cgdev
);
569 /* remove form our internal list */
570 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
571 list_del(&card
->list
);
572 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
574 unregister_netdev(card
->dev
);
575 qeth_remove_device_attributes(&cgdev
->dev
);
576 qeth_free_card(card
);
577 cgdev
->dev
.driver_data
= NULL
;
578 put_device(&cgdev
->dev
);
582 qeth_register_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
584 qeth_deregister_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
587 * Add/remove address to/from card's ip list, i.e. try to add or remove
588 * reference to/from an IP address that is already registered on the card.
590 * 0 address was on card and its reference count has been adjusted,
591 * but is still > 0, so nothing has to be done
592 * also returns 0 if card was not on card and the todo was to delete
593 * the address -> there is also nothing to be done
594 * 1 address was not on card and the todo is to add it to the card's ip
596 * -1 address was on card and its reference count has been decremented
597 * to <= 0 by the todo -> address must be removed from card
600 __qeth_ref_ip_on_card(struct qeth_card
*card
, struct qeth_ipaddr
*todo
,
601 struct qeth_ipaddr
**__addr
)
603 struct qeth_ipaddr
*addr
;
606 list_for_each_entry(addr
, &card
->ip_list
, entry
) {
607 if (card
->options
.layer2
) {
608 if ((addr
->type
== todo
->type
) &&
609 (memcmp(&addr
->mac
, &todo
->mac
,
610 OSA_ADDR_LEN
) == 0)) {
616 if ((addr
->proto
== QETH_PROT_IPV4
) &&
617 (todo
->proto
== QETH_PROT_IPV4
) &&
618 (addr
->type
== todo
->type
) &&
619 (addr
->u
.a4
.addr
== todo
->u
.a4
.addr
) &&
620 (addr
->u
.a4
.mask
== todo
->u
.a4
.mask
)) {
624 if ((addr
->proto
== QETH_PROT_IPV6
) &&
625 (todo
->proto
== QETH_PROT_IPV6
) &&
626 (addr
->type
== todo
->type
) &&
627 (addr
->u
.a6
.pfxlen
== todo
->u
.a6
.pfxlen
) &&
628 (memcmp(&addr
->u
.a6
.addr
, &todo
->u
.a6
.addr
,
629 sizeof(struct in6_addr
)) == 0)) {
635 addr
->users
+= todo
->users
;
636 if (addr
->users
<= 0){
640 /* for VIPA and RXIP limit refcount to 1 */
641 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
646 if (todo
->users
> 0) {
647 /* for VIPA and RXIP limit refcount to 1 */
648 if (todo
->type
!= QETH_IP_TYPE_NORMAL
)
656 __qeth_address_exists_in_list(struct list_head
*list
, struct qeth_ipaddr
*addr
,
659 struct qeth_ipaddr
*tmp
;
661 list_for_each_entry(tmp
, list
, entry
) {
662 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
663 (addr
->proto
== QETH_PROT_IPV4
) &&
664 ((same_type
&& (tmp
->type
== addr
->type
)) ||
665 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
666 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) ){
669 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
670 (addr
->proto
== QETH_PROT_IPV6
) &&
671 ((same_type
&& (tmp
->type
== addr
->type
)) ||
672 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
673 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
674 sizeof(struct in6_addr
)) == 0) ) {
682 * Add IP to be added to todo list. If there is already an "add todo"
683 * in this list we just incremenent the reference count.
684 * Returns 0 if we just incremented reference count.
687 __qeth_insert_ip_todo(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int add
)
689 struct qeth_ipaddr
*tmp
, *t
;
692 list_for_each_entry_safe(tmp
, t
, card
->ip_tbd_list
, entry
) {
693 if ((addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
) &&
694 (tmp
->type
== QETH_IP_TYPE_DEL_ALL_MC
))
696 if (card
->options
.layer2
) {
697 if ((tmp
->type
== addr
->type
) &&
698 (tmp
->is_multicast
== addr
->is_multicast
) &&
699 (memcmp(&tmp
->mac
, &addr
->mac
,
700 OSA_ADDR_LEN
) == 0)) {
706 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
707 (addr
->proto
== QETH_PROT_IPV4
) &&
708 (tmp
->type
== addr
->type
) &&
709 (tmp
->is_multicast
== addr
->is_multicast
) &&
710 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) &&
711 (tmp
->u
.a4
.mask
== addr
->u
.a4
.mask
)) {
715 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
716 (addr
->proto
== QETH_PROT_IPV6
) &&
717 (tmp
->type
== addr
->type
) &&
718 (tmp
->is_multicast
== addr
->is_multicast
) &&
719 (tmp
->u
.a6
.pfxlen
== addr
->u
.a6
.pfxlen
) &&
720 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
721 sizeof(struct in6_addr
)) == 0)) {
727 if (addr
->users
!= 0)
728 tmp
->users
+= addr
->users
;
730 tmp
->users
+= add
? 1:-1;
731 if (tmp
->users
== 0) {
732 list_del(&tmp
->entry
);
737 if (addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
)
738 list_add(&addr
->entry
, card
->ip_tbd_list
);
740 if (addr
->users
== 0)
741 addr
->users
+= add
? 1:-1;
742 if (add
&& (addr
->type
== QETH_IP_TYPE_NORMAL
) &&
743 qeth_is_addr_covered_by_ipato(card
, addr
)){
744 QETH_DBF_TEXT(trace
, 2, "tkovaddr");
745 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
747 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
754 * Remove IP address from list
757 qeth_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
762 QETH_DBF_TEXT(trace
, 4, "delip");
764 if (card
->options
.layer2
)
765 QETH_DBF_HEX(trace
, 4, &addr
->mac
, 6);
766 else if (addr
->proto
== QETH_PROT_IPV4
)
767 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
769 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
770 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
772 spin_lock_irqsave(&card
->ip_lock
, flags
);
773 rc
= __qeth_insert_ip_todo(card
, addr
, 0);
774 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
779 qeth_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
784 QETH_DBF_TEXT(trace
, 4, "addip");
785 if (card
->options
.layer2
)
786 QETH_DBF_HEX(trace
, 4, &addr
->mac
, 6);
787 else if (addr
->proto
== QETH_PROT_IPV4
)
788 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
790 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
791 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
793 spin_lock_irqsave(&card
->ip_lock
, flags
);
794 rc
= __qeth_insert_ip_todo(card
, addr
, 1);
795 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
800 __qeth_delete_all_mc(struct qeth_card
*card
, unsigned long *flags
)
802 struct qeth_ipaddr
*addr
, *tmp
;
805 list_for_each_entry_safe(addr
, tmp
, &card
->ip_list
, entry
) {
806 if (addr
->is_multicast
) {
807 spin_unlock_irqrestore(&card
->ip_lock
, *flags
);
808 rc
= qeth_deregister_addr_entry(card
, addr
);
809 spin_lock_irqsave(&card
->ip_lock
, *flags
);
811 list_del(&addr
->entry
);
820 qeth_set_ip_addr_list(struct qeth_card
*card
)
822 struct list_head
*tbd_list
;
823 struct qeth_ipaddr
*todo
, *addr
;
827 QETH_DBF_TEXT(trace
, 2, "sdiplist");
828 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
830 spin_lock_irqsave(&card
->ip_lock
, flags
);
831 tbd_list
= card
->ip_tbd_list
;
832 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_ATOMIC
);
833 if (!card
->ip_tbd_list
) {
834 QETH_DBF_TEXT(trace
, 0, "silnomem");
835 card
->ip_tbd_list
= tbd_list
;
836 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
839 INIT_LIST_HEAD(card
->ip_tbd_list
);
841 while (!list_empty(tbd_list
)){
842 todo
= list_entry(tbd_list
->next
, struct qeth_ipaddr
, entry
);
843 list_del(&todo
->entry
);
844 if (todo
->type
== QETH_IP_TYPE_DEL_ALL_MC
){
845 __qeth_delete_all_mc(card
, &flags
);
849 rc
= __qeth_ref_ip_on_card(card
, todo
, &addr
);
851 /* nothing to be done; only adjusted refcount */
853 } else if (rc
== 1) {
854 /* new entry to be added to on-card list */
855 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
856 rc
= qeth_register_addr_entry(card
, todo
);
857 spin_lock_irqsave(&card
->ip_lock
, flags
);
859 list_add_tail(&todo
->entry
, &card
->ip_list
);
862 } else if (rc
== -1) {
863 /* on-card entry to be removed */
864 list_del_init(&addr
->entry
);
865 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
866 rc
= qeth_deregister_addr_entry(card
, addr
);
867 spin_lock_irqsave(&card
->ip_lock
, flags
);
871 list_add_tail(&addr
->entry
, &card
->ip_list
);
875 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
879 static void qeth_delete_mc_addresses(struct qeth_card
*);
880 static void qeth_add_multicast_ipv4(struct qeth_card
*);
881 static void qeth_layer2_add_multicast(struct qeth_card
*);
882 #ifdef CONFIG_QETH_IPV6
883 static void qeth_add_multicast_ipv6(struct qeth_card
*);
887 qeth_set_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
891 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
892 if ( !(card
->thread_allowed_mask
& thread
) ||
893 (card
->thread_start_mask
& thread
) ) {
894 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
897 card
->thread_start_mask
|= thread
;
898 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
903 qeth_clear_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
907 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
908 card
->thread_start_mask
&= ~thread
;
909 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
910 wake_up(&card
->wait_q
);
914 qeth_clear_thread_running_bit(struct qeth_card
*card
, unsigned long thread
)
918 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
919 card
->thread_running_mask
&= ~thread
;
920 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
921 wake_up(&card
->wait_q
);
925 __qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
930 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
931 if (card
->thread_start_mask
& thread
){
932 if ((card
->thread_allowed_mask
& thread
) &&
933 !(card
->thread_running_mask
& thread
)){
935 card
->thread_start_mask
&= ~thread
;
936 card
->thread_running_mask
|= thread
;
940 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
945 qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
949 wait_event(card
->wait_q
,
950 (rc
= __qeth_do_run_thread(card
, thread
)) >= 0);
955 qeth_register_ip_addresses(void *ptr
)
957 struct qeth_card
*card
;
959 card
= (struct qeth_card
*) ptr
;
960 daemonize("qeth_reg_ip");
961 QETH_DBF_TEXT(trace
,4,"regipth1");
962 if (!qeth_do_run_thread(card
, QETH_SET_IP_THREAD
))
964 QETH_DBF_TEXT(trace
,4,"regipth2");
965 qeth_set_ip_addr_list(card
);
966 qeth_clear_thread_running_bit(card
, QETH_SET_IP_THREAD
);
971 * Drive the SET_PROMISC_MODE thread
974 qeth_set_promisc_mode(void *ptr
)
976 struct qeth_card
*card
= (struct qeth_card
*) ptr
;
978 daemonize("qeth_setprm");
979 QETH_DBF_TEXT(trace
,4,"setprm1");
980 if (!qeth_do_run_thread(card
, QETH_SET_PROMISC_MODE_THREAD
))
982 QETH_DBF_TEXT(trace
,4,"setprm2");
983 qeth_setadp_promisc_mode(card
);
984 qeth_clear_thread_running_bit(card
, QETH_SET_PROMISC_MODE_THREAD
);
989 qeth_recover(void *ptr
)
991 struct qeth_card
*card
;
994 card
= (struct qeth_card
*) ptr
;
995 daemonize("qeth_recover");
996 QETH_DBF_TEXT(trace
,2,"recover1");
997 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
998 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
1000 QETH_DBF_TEXT(trace
,2,"recover2");
1001 PRINT_WARN("Recovery of device %s started ...\n",
1003 card
->use_hard_stop
= 1;
1004 __qeth_set_offline(card
->gdev
,1);
1005 rc
= __qeth_set_online(card
->gdev
,1);
1007 PRINT_INFO("Device %s successfully recovered!\n",
1010 PRINT_INFO("Device %s could not be recovered!\n",
1012 /* don't run another scheduled recovery */
1013 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
1014 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
1019 qeth_schedule_recovery(struct qeth_card
*card
)
1021 QETH_DBF_TEXT(trace
,2,"startrec");
1022 if (qeth_set_thread_start_bit(card
, QETH_RECOVER_THREAD
) == 0)
1023 schedule_work(&card
->kernel_thread_starter
);
1027 qeth_do_start_thread(struct qeth_card
*card
, unsigned long thread
)
1029 unsigned long flags
;
1032 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
1033 QETH_DBF_TEXT_(trace
, 4, " %02x%02x%02x",
1034 (u8
) card
->thread_start_mask
,
1035 (u8
) card
->thread_allowed_mask
,
1036 (u8
) card
->thread_running_mask
);
1037 rc
= (card
->thread_start_mask
& thread
);
1038 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
1043 qeth_start_kernel_thread(struct qeth_card
*card
)
1045 QETH_DBF_TEXT(trace
, 2, "strthrd");
1047 if (card
->read
.state
!= CH_STATE_UP
&&
1048 card
->write
.state
!= CH_STATE_UP
)
1051 if (qeth_do_start_thread(card
, QETH_SET_IP_THREAD
))
1052 kernel_thread(qeth_register_ip_addresses
, (void *)card
,SIGCHLD
);
1053 if (qeth_do_start_thread(card
, QETH_SET_PROMISC_MODE_THREAD
))
1054 kernel_thread(qeth_set_promisc_mode
, (void *)card
, SIGCHLD
);
1055 if (qeth_do_start_thread(card
, QETH_RECOVER_THREAD
))
1056 kernel_thread(qeth_recover
, (void *) card
, SIGCHLD
);
1061 qeth_set_intial_options(struct qeth_card
*card
)
1063 card
->options
.route4
.type
= NO_ROUTER
;
1064 #ifdef CONFIG_QETH_IPV6
1065 card
->options
.route6
.type
= NO_ROUTER
;
1066 #endif /* QETH_IPV6 */
1067 card
->options
.checksum_type
= QETH_CHECKSUM_DEFAULT
;
1068 card
->options
.broadcast_mode
= QETH_TR_BROADCAST_ALLRINGS
;
1069 card
->options
.macaddr_mode
= QETH_TR_MACADDR_NONCANONICAL
;
1070 card
->options
.fake_broadcast
= 0;
1071 card
->options
.add_hhlen
= DEFAULT_ADD_HHLEN
;
1072 card
->options
.fake_ll
= 0;
1073 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1074 card
->options
.layer2
= 1;
1076 card
->options
.layer2
= 0;
1080 * initialize channels ,card and all state machines
1083 qeth_setup_card(struct qeth_card
*card
)
1086 QETH_DBF_TEXT(setup
, 2, "setupcrd");
1087 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
1089 card
->read
.state
= CH_STATE_DOWN
;
1090 card
->write
.state
= CH_STATE_DOWN
;
1091 card
->data
.state
= CH_STATE_DOWN
;
1092 card
->state
= CARD_STATE_DOWN
;
1093 card
->lan_online
= 0;
1094 card
->use_hard_stop
= 0;
1096 #ifdef CONFIG_QETH_VLAN
1097 spin_lock_init(&card
->vlanlock
);
1098 card
->vlangrp
= NULL
;
1100 spin_lock_init(&card
->lock
);
1101 spin_lock_init(&card
->ip_lock
);
1102 spin_lock_init(&card
->thread_mask_lock
);
1103 card
->thread_start_mask
= 0;
1104 card
->thread_allowed_mask
= 0;
1105 card
->thread_running_mask
= 0;
1106 INIT_WORK(&card
->kernel_thread_starter
,
1107 (void *)qeth_start_kernel_thread
,card
);
1108 INIT_LIST_HEAD(&card
->ip_list
);
1109 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_KERNEL
);
1110 if (!card
->ip_tbd_list
) {
1111 QETH_DBF_TEXT(setup
, 0, "iptbdnom");
1114 INIT_LIST_HEAD(card
->ip_tbd_list
);
1115 INIT_LIST_HEAD(&card
->cmd_waiter_list
);
1116 init_waitqueue_head(&card
->wait_q
);
1117 /* intial options */
1118 qeth_set_intial_options(card
);
1119 /* IP address takeover */
1120 INIT_LIST_HEAD(&card
->ipato
.entries
);
1121 card
->ipato
.enabled
= 0;
1122 card
->ipato
.invert4
= 0;
1123 card
->ipato
.invert6
= 0;
1124 /* init QDIO stuff */
1125 qeth_init_qdio_info(card
);
1130 is_1920_device (struct qeth_card
*card
)
1132 int single_queue
= 0;
1133 struct ccw_device
*ccwdev
;
1134 struct channelPath_dsc
{
1145 QETH_DBF_TEXT(setup
, 2, "chk_1920");
1147 ccwdev
= card
->data
.ccwdev
;
1148 chp_dsc
= (struct channelPath_dsc
*)ccw_device_get_chp_desc(ccwdev
, 0);
1149 if (chp_dsc
!= NULL
) {
1150 /* CHPP field bit 6 == 1 -> single queue */
1151 single_queue
= ((chp_dsc
->chpp
& 0x02) == 0x02);
1154 QETH_DBF_TEXT_(setup
, 2, "rc:%x", single_queue
);
1155 return single_queue
;
1159 qeth_determine_card_type(struct qeth_card
*card
)
1163 QETH_DBF_TEXT(setup
, 2, "detcdtyp");
1165 card
->qdio
.do_prio_queueing
= QETH_PRIOQ_DEFAULT
;
1166 card
->qdio
.default_out_queue
= QETH_DEFAULT_QUEUE
;
1167 while (known_devices
[i
][4]) {
1168 if ((CARD_RDEV(card
)->id
.dev_type
== known_devices
[i
][2]) &&
1169 (CARD_RDEV(card
)->id
.dev_model
== known_devices
[i
][3])) {
1170 card
->info
.type
= known_devices
[i
][4];
1171 card
->qdio
.no_out_queues
= known_devices
[i
][8];
1172 card
->info
.is_multicast_different
= known_devices
[i
][9];
1173 if (is_1920_device(card
)) {
1174 PRINT_INFO("Priority Queueing not able "
1175 "due to hardware limitations!\n");
1176 card
->qdio
.no_out_queues
= 1;
1177 card
->qdio
.default_out_queue
= 0;
1183 card
->info
.type
= QETH_CARD_TYPE_UNKNOWN
;
1184 PRINT_ERR("unknown card type on device %s\n", CARD_BUS_ID(card
));
1189 qeth_probe_device(struct ccwgroup_device
*gdev
)
1191 struct qeth_card
*card
;
1193 unsigned long flags
;
1196 QETH_DBF_TEXT(setup
, 2, "probedev");
1199 if (!get_device(dev
))
1202 QETH_DBF_TEXT_(setup
, 2, "%s", gdev
->dev
.bus_id
);
1204 card
= qeth_alloc_card();
1207 QETH_DBF_TEXT_(setup
, 2, "1err%d", -ENOMEM
);
1210 card
->read
.ccwdev
= gdev
->cdev
[0];
1211 card
->write
.ccwdev
= gdev
->cdev
[1];
1212 card
->data
.ccwdev
= gdev
->cdev
[2];
1213 gdev
->dev
.driver_data
= card
;
1215 gdev
->cdev
[0]->handler
= qeth_irq
;
1216 gdev
->cdev
[1]->handler
= qeth_irq
;
1217 gdev
->cdev
[2]->handler
= qeth_irq
;
1219 if ((rc
= qeth_determine_card_type(card
))){
1220 PRINT_WARN("%s: not a valid card type\n", __func__
);
1221 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1223 qeth_free_card(card
);
1226 if ((rc
= qeth_setup_card(card
))){
1227 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1229 qeth_free_card(card
);
1232 rc
= qeth_create_device_attributes(dev
);
1235 qeth_free_card(card
);
1238 /* insert into our internal list */
1239 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
1240 list_add_tail(&card
->list
, &qeth_card_list
.list
);
1241 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
1247 qeth_get_unitaddr(struct qeth_card
*card
)
1253 QETH_DBF_TEXT(setup
, 2, "getunit");
1254 rc
= read_conf_data(CARD_DDEV(card
), (void **) &prcd
, &length
);
1256 PRINT_ERR("read_conf_data for device %s returned %i\n",
1257 CARD_DDEV_ID(card
), rc
);
1260 card
->info
.chpid
= prcd
[30];
1261 card
->info
.unit_addr2
= prcd
[31];
1262 card
->info
.cula
= prcd
[63];
1263 card
->info
.guestlan
= ((prcd
[0x10] == _ascebc
['V']) &&
1264 (prcd
[0x11] == _ascebc
['M']));
1269 qeth_init_tokens(struct qeth_card
*card
)
1271 card
->token
.issuer_rm_w
= 0x00010103UL
;
1272 card
->token
.cm_filter_w
= 0x00010108UL
;
1273 card
->token
.cm_connection_w
= 0x0001010aUL
;
1274 card
->token
.ulp_filter_w
= 0x0001010bUL
;
1275 card
->token
.ulp_connection_w
= 0x0001010dUL
;
1279 raw_devno_from_bus_id(char *id
)
1281 id
+= (strlen(id
) - 4);
1282 return (__u16
) simple_strtoul(id
, &id
, 16);
1288 qeth_setup_ccw(struct qeth_channel
*channel
,unsigned char *iob
, __u32 len
)
1290 struct qeth_card
*card
;
1292 QETH_DBF_TEXT(trace
, 4, "setupccw");
1293 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1294 if (channel
== &card
->read
)
1295 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1297 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1298 channel
->ccw
.count
= len
;
1299 channel
->ccw
.cda
= (__u32
) __pa(iob
);
1303 * get free buffer for ccws (IDX activation, lancmds,ipassists...)
1305 static struct qeth_cmd_buffer
*
1306 __qeth_get_buffer(struct qeth_channel
*channel
)
1310 QETH_DBF_TEXT(trace
, 6, "getbuff");
1311 index
= channel
->io_buf_no
;
1313 if (channel
->iob
[index
].state
== BUF_STATE_FREE
) {
1314 channel
->iob
[index
].state
= BUF_STATE_LOCKED
;
1315 channel
->io_buf_no
= (channel
->io_buf_no
+ 1) %
1317 memset(channel
->iob
[index
].data
, 0, QETH_BUFSIZE
);
1318 return channel
->iob
+ index
;
1320 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
1321 } while(index
!= channel
->io_buf_no
);
1327 * release command buffer
1330 qeth_release_buffer(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1332 unsigned long flags
;
1334 QETH_DBF_TEXT(trace
, 6, "relbuff");
1335 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1336 memset(iob
->data
, 0, QETH_BUFSIZE
);
1337 iob
->state
= BUF_STATE_FREE
;
1338 iob
->callback
= qeth_send_control_data_cb
;
1340 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1343 static struct qeth_cmd_buffer
*
1344 qeth_get_buffer(struct qeth_channel
*channel
)
1346 struct qeth_cmd_buffer
*buffer
= NULL
;
1347 unsigned long flags
;
1349 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1350 buffer
= __qeth_get_buffer(channel
);
1351 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1355 static struct qeth_cmd_buffer
*
1356 qeth_wait_for_buffer(struct qeth_channel
*channel
)
1358 struct qeth_cmd_buffer
*buffer
;
1359 wait_event(channel
->wait_q
,
1360 ((buffer
= qeth_get_buffer(channel
)) != NULL
));
1365 qeth_clear_cmd_buffers(struct qeth_channel
*channel
)
1369 for (cnt
=0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
1370 qeth_release_buffer(channel
,&channel
->iob
[cnt
]);
1371 channel
->buf_no
= 0;
1372 channel
->io_buf_no
= 0;
1376 * start IDX for read and write channel
1379 qeth_idx_activate_get_answer(struct qeth_channel
*channel
,
1380 void (*idx_reply_cb
)(struct qeth_channel
*,
1381 struct qeth_cmd_buffer
*))
1383 struct qeth_cmd_buffer
*iob
;
1384 unsigned long flags
;
1386 struct qeth_card
*card
;
1388 QETH_DBF_TEXT(setup
, 2, "idxanswr");
1389 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1390 iob
= qeth_get_buffer(channel
);
1391 iob
->callback
= idx_reply_cb
;
1392 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1393 channel
->ccw
.count
= QETH_BUFSIZE
;
1394 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1396 wait_event(card
->wait_q
,
1397 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1398 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1399 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1400 rc
= ccw_device_start(channel
->ccwdev
,
1401 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1402 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1405 PRINT_ERR("qeth: Error2 in activating channel rc=%d\n",rc
);
1406 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1407 atomic_set(&channel
->irq_pending
, 0);
1408 wake_up(&card
->wait_q
);
1411 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1412 channel
->state
== CH_STATE_UP
, QETH_TIMEOUT
);
1413 if (rc
== -ERESTARTSYS
)
1415 if (channel
->state
!= CH_STATE_UP
){
1417 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1418 qeth_clear_cmd_buffers(channel
);
1425 qeth_idx_activate_channel(struct qeth_channel
*channel
,
1426 void (*idx_reply_cb
)(struct qeth_channel
*,
1427 struct qeth_cmd_buffer
*))
1429 struct qeth_card
*card
;
1430 struct qeth_cmd_buffer
*iob
;
1431 unsigned long flags
;
1435 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1437 QETH_DBF_TEXT(setup
, 2, "idxactch");
1439 iob
= qeth_get_buffer(channel
);
1440 iob
->callback
= idx_reply_cb
;
1441 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1442 channel
->ccw
.count
= IDX_ACTIVATE_SIZE
;
1443 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1444 if (channel
== &card
->write
) {
1445 memcpy(iob
->data
, IDX_ACTIVATE_WRITE
, IDX_ACTIVATE_SIZE
);
1446 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1447 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1448 card
->seqno
.trans_hdr
++;
1450 memcpy(iob
->data
, IDX_ACTIVATE_READ
, IDX_ACTIVATE_SIZE
);
1451 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1452 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1454 memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1455 &card
->token
.issuer_rm_w
,QETH_MPC_TOKEN_LENGTH
);
1456 memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob
->data
),
1457 &card
->info
.func_level
,sizeof(__u16
));
1458 temp
= raw_devno_from_bus_id(CARD_DDEV_ID(card
));
1459 memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob
->data
), &temp
, 2);
1460 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
1461 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob
->data
), &temp
, 2);
1463 wait_event(card
->wait_q
,
1464 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1465 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1466 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1467 rc
= ccw_device_start(channel
->ccwdev
,
1468 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1469 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1472 PRINT_ERR("qeth: Error1 in activating channel. rc=%d\n",rc
);
1473 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
1474 atomic_set(&channel
->irq_pending
, 0);
1475 wake_up(&card
->wait_q
);
1478 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1479 channel
->state
== CH_STATE_ACTIVATING
, QETH_TIMEOUT
);
1480 if (rc
== -ERESTARTSYS
)
1482 if (channel
->state
!= CH_STATE_ACTIVATING
) {
1483 PRINT_WARN("qeth: IDX activate timed out!\n");
1484 QETH_DBF_TEXT_(setup
, 2, "2err%d", -ETIME
);
1485 qeth_clear_cmd_buffers(channel
);
1488 return qeth_idx_activate_get_answer(channel
,idx_reply_cb
);
1492 qeth_peer_func_level(int level
)
1494 if ((level
& 0xff) == 8)
1495 return (level
& 0xff) + 0x400;
1496 if (((level
>> 8) & 3) == 1)
1497 return (level
& 0xff) + 0x200;
1502 qeth_idx_write_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1504 struct qeth_card
*card
;
1507 QETH_DBF_TEXT(setup
,2, "idxwrcb");
1509 if (channel
->state
== CH_STATE_DOWN
) {
1510 channel
->state
= CH_STATE_ACTIVATING
;
1513 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1515 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1516 PRINT_ERR("IDX_ACTIVATE on write channel device %s: negative "
1517 "reply\n", CARD_WDEV_ID(card
));
1520 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1521 if ((temp
& ~0x0100) != qeth_peer_func_level(card
->info
.func_level
)) {
1522 PRINT_WARN("IDX_ACTIVATE on write channel device %s: "
1523 "function level mismatch "
1524 "(sent: 0x%x, received: 0x%x)\n",
1525 CARD_WDEV_ID(card
), card
->info
.func_level
, temp
);
1528 channel
->state
= CH_STATE_UP
;
1530 qeth_release_buffer(channel
, iob
);
1534 qeth_check_idx_response(unsigned char *buffer
)
1539 QETH_DBF_HEX(control
, 2, buffer
, QETH_DBF_CONTROL_LEN
);
1540 if ((buffer
[2] & 0xc0) == 0xc0) {
1541 PRINT_WARN("received an IDX TERMINATE "
1542 "with cause code 0x%02x%s\n",
1544 ((buffer
[4] == 0x22) ?
1545 " -- try another portname" : ""));
1546 QETH_DBF_TEXT(trace
, 2, "ckidxres");
1547 QETH_DBF_TEXT(trace
, 2, " idxterm");
1548 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
1555 qeth_idx_read_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1557 struct qeth_card
*card
;
1560 QETH_DBF_TEXT(setup
, 2, "idxrdcb");
1561 if (channel
->state
== CH_STATE_DOWN
) {
1562 channel
->state
= CH_STATE_ACTIVATING
;
1566 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1567 if (qeth_check_idx_response(iob
->data
)) {
1570 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1571 PRINT_ERR("IDX_ACTIVATE on read channel device %s: negative "
1572 "reply\n", CARD_RDEV_ID(card
));
1577 * temporary fix for microcode bug
1578 * to revert it,replace OR by AND
1580 if ( (!QETH_IDX_NO_PORTNAME_REQUIRED(iob
->data
)) ||
1581 (card
->info
.type
== QETH_CARD_TYPE_OSAE
) )
1582 card
->info
.portname_required
= 1;
1584 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1585 if (temp
!= qeth_peer_func_level(card
->info
.func_level
)) {
1586 PRINT_WARN("IDX_ACTIVATE on read channel device %s: function "
1587 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1588 CARD_RDEV_ID(card
), card
->info
.func_level
, temp
);
1591 memcpy(&card
->token
.issuer_rm_r
,
1592 QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1593 QETH_MPC_TOKEN_LENGTH
);
1594 memcpy(&card
->info
.mcl_level
[0],
1595 QETH_IDX_REPLY_LEVEL(iob
->data
), QETH_MCL_LENGTH
);
1596 channel
->state
= CH_STATE_UP
;
1598 qeth_release_buffer(channel
,iob
);
1602 qeth_issue_next_read(struct qeth_card
*card
)
1605 struct qeth_cmd_buffer
*iob
;
1607 QETH_DBF_TEXT(trace
,5,"issnxrd");
1608 if (card
->read
.state
!= CH_STATE_UP
)
1610 iob
= qeth_get_buffer(&card
->read
);
1612 PRINT_WARN("issue_next_read failed: no iob available!\n");
1615 qeth_setup_ccw(&card
->read
, iob
->data
, QETH_BUFSIZE
);
1616 wait_event(card
->wait_q
,
1617 atomic_cmpxchg(&card
->read
.irq_pending
, 0, 1) == 0);
1618 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1619 rc
= ccw_device_start(card
->read
.ccwdev
, &card
->read
.ccw
,
1620 (addr_t
) iob
, 0, 0);
1622 PRINT_ERR("Error in starting next read ccw! rc=%i\n", rc
);
1623 atomic_set(&card
->read
.irq_pending
, 0);
1624 qeth_schedule_recovery(card
);
1625 wake_up(&card
->wait_q
);
1630 static struct qeth_reply
*
1631 qeth_alloc_reply(struct qeth_card
*card
)
1633 struct qeth_reply
*reply
;
1635 reply
= kmalloc(sizeof(struct qeth_reply
), GFP_ATOMIC
);
1637 memset(reply
, 0, sizeof(struct qeth_reply
));
1638 atomic_set(&reply
->refcnt
, 1);
1645 qeth_get_reply(struct qeth_reply
*reply
)
1647 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1648 atomic_inc(&reply
->refcnt
);
1652 qeth_put_reply(struct qeth_reply
*reply
)
1654 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1655 if (atomic_dec_and_test(&reply
->refcnt
))
1660 qeth_cmd_timeout(unsigned long data
)
1662 struct qeth_reply
*reply
, *list_reply
, *r
;
1663 unsigned long flags
;
1665 reply
= (struct qeth_reply
*) data
;
1666 spin_lock_irqsave(&reply
->card
->lock
, flags
);
1667 list_for_each_entry_safe(list_reply
, r
,
1668 &reply
->card
->cmd_waiter_list
, list
) {
1669 if (reply
== list_reply
){
1670 qeth_get_reply(reply
);
1671 list_del_init(&reply
->list
);
1672 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1674 reply
->received
= 1;
1675 wake_up(&reply
->wait_q
);
1676 qeth_put_reply(reply
);
1680 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1684 static struct qeth_ipa_cmd
*
1685 qeth_check_ipa_data(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
)
1687 struct qeth_ipa_cmd
*cmd
= NULL
;
1689 QETH_DBF_TEXT(trace
,5,"chkipad");
1690 if (IS_IPA(iob
->data
)){
1691 cmd
= (struct qeth_ipa_cmd
*) PDU_ENCAPSULATION(iob
->data
);
1692 if (IS_IPA_REPLY(cmd
))
1695 switch (cmd
->hdr
.command
) {
1696 case IPA_CMD_STOPLAN
:
1697 PRINT_WARN("Link failure on %s (CHPID 0x%X) - "
1698 "there is a network problem or "
1699 "someone pulled the cable or "
1700 "disabled the port.\n",
1701 QETH_CARD_IFNAME(card
),
1703 card
->lan_online
= 0;
1704 if (card
->dev
&& netif_carrier_ok(card
->dev
))
1705 netif_carrier_off(card
->dev
);
1707 case IPA_CMD_STARTLAN
:
1708 PRINT_INFO("Link reestablished on %s "
1709 "(CHPID 0x%X). Scheduling "
1710 "IP address reset.\n",
1711 QETH_CARD_IFNAME(card
),
1713 qeth_schedule_recovery(card
);
1715 case IPA_CMD_MODCCID
:
1717 case IPA_CMD_REGISTER_LOCAL_ADDR
:
1718 QETH_DBF_TEXT(trace
,3, "irla");
1720 case IPA_CMD_UNREGISTER_LOCAL_ADDR
:
1721 QETH_DBF_TEXT(trace
,3, "urla");
1724 PRINT_WARN("Received data is IPA "
1725 "but not a reply!\n");
1734 * wake all waiting ipa commands
1737 qeth_clear_ipacmd_list(struct qeth_card
*card
)
1739 struct qeth_reply
*reply
, *r
;
1740 unsigned long flags
;
1742 QETH_DBF_TEXT(trace
, 4, "clipalst");
1744 spin_lock_irqsave(&card
->lock
, flags
);
1745 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1746 qeth_get_reply(reply
);
1748 reply
->received
= 1;
1749 list_del_init(&reply
->list
);
1750 wake_up(&reply
->wait_q
);
1751 qeth_put_reply(reply
);
1753 spin_unlock_irqrestore(&card
->lock
, flags
);
1757 qeth_send_control_data_cb(struct qeth_channel
*channel
,
1758 struct qeth_cmd_buffer
*iob
)
1760 struct qeth_card
*card
;
1761 struct qeth_reply
*reply
, *r
;
1762 struct qeth_ipa_cmd
*cmd
;
1763 unsigned long flags
;
1766 QETH_DBF_TEXT(trace
,4,"sndctlcb");
1768 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1769 if (qeth_check_idx_response(iob
->data
)) {
1770 qeth_clear_ipacmd_list(card
);
1771 qeth_schedule_recovery(card
);
1775 cmd
= qeth_check_ipa_data(card
, iob
);
1776 if ((cmd
== NULL
) && (card
->state
!= CARD_STATE_DOWN
))
1778 /*in case of OSN : check if cmd is set */
1779 if (card
->info
.type
== QETH_CARD_TYPE_OSN
&&
1781 cmd
->hdr
.command
!= IPA_CMD_STARTLAN
&&
1782 card
->osn_info
.assist_cb
!= NULL
) {
1783 card
->osn_info
.assist_cb(card
->dev
, cmd
);
1787 spin_lock_irqsave(&card
->lock
, flags
);
1788 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1789 if ((reply
->seqno
== QETH_IDX_COMMAND_SEQNO
) ||
1790 ((cmd
) && (reply
->seqno
== cmd
->hdr
.seqno
))) {
1791 qeth_get_reply(reply
);
1792 list_del_init(&reply
->list
);
1793 spin_unlock_irqrestore(&card
->lock
, flags
);
1795 if (reply
->callback
!= NULL
) {
1797 reply
->offset
= (__u16
)((char*)cmd
-
1799 keep_reply
= reply
->callback(card
,
1801 (unsigned long)cmd
);
1803 keep_reply
= reply
->callback(card
,
1805 (unsigned long)iob
);
1808 reply
->rc
= (u16
) cmd
->hdr
.return_code
;
1810 reply
->rc
= iob
->rc
;
1812 spin_lock_irqsave(&card
->lock
, flags
);
1813 list_add_tail(&reply
->list
,
1814 &card
->cmd_waiter_list
);
1815 spin_unlock_irqrestore(&card
->lock
, flags
);
1817 reply
->received
= 1;
1818 wake_up(&reply
->wait_q
);
1820 qeth_put_reply(reply
);
1824 spin_unlock_irqrestore(&card
->lock
, flags
);
1826 memcpy(&card
->seqno
.pdu_hdr_ack
,
1827 QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1828 QETH_SEQ_NO_LENGTH
);
1829 qeth_release_buffer(channel
,iob
);
1833 qeth_prepare_control_data(struct qeth_card
*card
, int len
,
1834 struct qeth_cmd_buffer
*iob
)
1836 qeth_setup_ccw(&card
->write
,iob
->data
,len
);
1837 iob
->callback
= qeth_release_buffer
;
1839 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1840 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1841 card
->seqno
.trans_hdr
++;
1842 memcpy(QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1843 &card
->seqno
.pdu_hdr
, QETH_SEQ_NO_LENGTH
);
1844 card
->seqno
.pdu_hdr
++;
1845 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob
->data
),
1846 &card
->seqno
.pdu_hdr_ack
, QETH_SEQ_NO_LENGTH
);
1847 QETH_DBF_HEX(control
, 2, iob
->data
, QETH_DBF_CONTROL_LEN
);
1851 qeth_send_control_data(struct qeth_card
*card
, int len
,
1852 struct qeth_cmd_buffer
*iob
,
1854 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
1859 unsigned long flags
;
1860 struct qeth_reply
*reply
= NULL
;
1861 struct timer_list timer
;
1863 QETH_DBF_TEXT(trace
, 2, "sendctl");
1865 reply
= qeth_alloc_reply(card
);
1867 PRINT_WARN("Could no alloc qeth_reply!\n");
1870 reply
->callback
= reply_cb
;
1871 reply
->param
= reply_param
;
1872 if (card
->state
== CARD_STATE_DOWN
)
1873 reply
->seqno
= QETH_IDX_COMMAND_SEQNO
;
1875 reply
->seqno
= card
->seqno
.ipa
++;
1877 timer
.function
= qeth_cmd_timeout
;
1878 timer
.data
= (unsigned long) reply
;
1879 init_waitqueue_head(&reply
->wait_q
);
1880 spin_lock_irqsave(&card
->lock
, flags
);
1881 list_add_tail(&reply
->list
, &card
->cmd_waiter_list
);
1882 spin_unlock_irqrestore(&card
->lock
, flags
);
1883 QETH_DBF_HEX(control
, 2, iob
->data
, QETH_DBF_CONTROL_LEN
);
1884 wait_event(card
->wait_q
,
1885 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1886 qeth_prepare_control_data(card
, len
, iob
);
1887 if (IS_IPA(iob
->data
))
1888 timer
.expires
= jiffies
+ QETH_IPA_TIMEOUT
;
1890 timer
.expires
= jiffies
+ QETH_TIMEOUT
;
1891 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1892 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1893 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1894 (addr_t
) iob
, 0, 0);
1895 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1897 PRINT_WARN("qeth_send_control_data: "
1898 "ccw_device_start rc = %i\n", rc
);
1899 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
1900 spin_lock_irqsave(&card
->lock
, flags
);
1901 list_del_init(&reply
->list
);
1902 qeth_put_reply(reply
);
1903 spin_unlock_irqrestore(&card
->lock
, flags
);
1904 qeth_release_buffer(iob
->channel
, iob
);
1905 atomic_set(&card
->write
.irq_pending
, 0);
1906 wake_up(&card
->wait_q
);
1910 wait_event(reply
->wait_q
, reply
->received
);
1911 del_timer_sync(&timer
);
1913 qeth_put_reply(reply
);
1918 qeth_osn_send_control_data(struct qeth_card
*card
, int len
,
1919 struct qeth_cmd_buffer
*iob
)
1921 unsigned long flags
;
1924 QETH_DBF_TEXT(trace
, 5, "osndctrd");
1926 wait_event(card
->wait_q
,
1927 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1928 qeth_prepare_control_data(card
, len
, iob
);
1929 QETH_DBF_TEXT(trace
, 6, "osnoirqp");
1930 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1931 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1932 (addr_t
) iob
, 0, 0);
1933 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1935 PRINT_WARN("qeth_osn_send_control_data: "
1936 "ccw_device_start rc = %i\n", rc
);
1937 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
1938 qeth_release_buffer(iob
->channel
, iob
);
1939 atomic_set(&card
->write
.irq_pending
, 0);
1940 wake_up(&card
->wait_q
);
1946 qeth_prepare_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1949 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
1950 memcpy(QETH_IPA_CMD_PROT_TYPE(iob
->data
),&prot_type
,1);
1951 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
1952 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
1956 qeth_osn_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1961 QETH_DBF_TEXT(trace
,4,"osndipa");
1963 qeth_prepare_ipa_cmd(card
, iob
, QETH_PROT_OSN2
);
1964 s1
= (u16
)(IPA_PDU_HEADER_SIZE
+ data_len
);
1966 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
1967 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
1968 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
1969 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
1970 return qeth_osn_send_control_data(card
, s1
, iob
);
1974 qeth_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1976 (struct qeth_card
*,struct qeth_reply
*, unsigned long),
1982 QETH_DBF_TEXT(trace
,4,"sendipa");
1984 if (card
->options
.layer2
)
1985 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1986 prot_type
= QETH_PROT_OSN2
;
1988 prot_type
= QETH_PROT_LAYER2
;
1990 prot_type
= QETH_PROT_TCPIP
;
1991 qeth_prepare_ipa_cmd(card
,iob
,prot_type
);
1992 rc
= qeth_send_control_data(card
, IPA_CMD_LENGTH
, iob
,
1993 reply_cb
, reply_param
);
1999 qeth_cm_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2002 struct qeth_cmd_buffer
*iob
;
2004 QETH_DBF_TEXT(setup
, 2, "cmenblcb");
2006 iob
= (struct qeth_cmd_buffer
*) data
;
2007 memcpy(&card
->token
.cm_filter_r
,
2008 QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2009 QETH_MPC_TOKEN_LENGTH
);
2010 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2015 qeth_cm_enable(struct qeth_card
*card
)
2018 struct qeth_cmd_buffer
*iob
;
2020 QETH_DBF_TEXT(setup
,2,"cmenable");
2022 iob
= qeth_wait_for_buffer(&card
->write
);
2023 memcpy(iob
->data
, CM_ENABLE
, CM_ENABLE_SIZE
);
2024 memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob
->data
),
2025 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2026 memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob
->data
),
2027 &card
->token
.cm_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2029 rc
= qeth_send_control_data(card
, CM_ENABLE_SIZE
, iob
,
2030 qeth_cm_enable_cb
, NULL
);
2035 qeth_cm_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2039 struct qeth_cmd_buffer
*iob
;
2041 QETH_DBF_TEXT(setup
, 2, "cmsetpcb");
2043 iob
= (struct qeth_cmd_buffer
*) data
;
2044 memcpy(&card
->token
.cm_connection_r
,
2045 QETH_CM_SETUP_RESP_DEST_ADDR(iob
->data
),
2046 QETH_MPC_TOKEN_LENGTH
);
2047 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2052 qeth_cm_setup(struct qeth_card
*card
)
2055 struct qeth_cmd_buffer
*iob
;
2057 QETH_DBF_TEXT(setup
,2,"cmsetup");
2059 iob
= qeth_wait_for_buffer(&card
->write
);
2060 memcpy(iob
->data
, CM_SETUP
, CM_SETUP_SIZE
);
2061 memcpy(QETH_CM_SETUP_DEST_ADDR(iob
->data
),
2062 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2063 memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob
->data
),
2064 &card
->token
.cm_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2065 memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob
->data
),
2066 &card
->token
.cm_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2067 rc
= qeth_send_control_data(card
, CM_SETUP_SIZE
, iob
,
2068 qeth_cm_setup_cb
, NULL
);
2074 qeth_ulp_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2078 __u16 mtu
, framesize
;
2081 struct qeth_cmd_buffer
*iob
;
2083 QETH_DBF_TEXT(setup
, 2, "ulpenacb");
2085 iob
= (struct qeth_cmd_buffer
*) data
;
2086 memcpy(&card
->token
.ulp_filter_r
,
2087 QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2088 QETH_MPC_TOKEN_LENGTH
);
2089 if (qeth_get_mtu_out_of_mpc(card
->info
.type
)) {
2090 memcpy(&framesize
, QETH_ULP_ENABLE_RESP_MAX_MTU(iob
->data
), 2);
2091 mtu
= qeth_get_mtu_outof_framesize(framesize
);
2094 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2097 card
->info
.max_mtu
= mtu
;
2098 card
->info
.initial_mtu
= mtu
;
2099 card
->qdio
.in_buf_size
= mtu
+ 2 * PAGE_SIZE
;
2101 card
->info
.initial_mtu
= qeth_get_initial_mtu_for_card(card
);
2102 card
->info
.max_mtu
= qeth_get_max_mtu_for_card(card
->info
.type
);
2103 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
2106 memcpy(&len
, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob
->data
), 2);
2107 if (len
>= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE
) {
2109 QETH_ULP_ENABLE_RESP_LINK_TYPE(iob
->data
), 1);
2110 card
->info
.link_type
= link_type
;
2112 card
->info
.link_type
= 0;
2113 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2118 qeth_ulp_enable(struct qeth_card
*card
)
2122 struct qeth_cmd_buffer
*iob
;
2124 /*FIXME: trace view callbacks*/
2125 QETH_DBF_TEXT(setup
,2,"ulpenabl");
2127 iob
= qeth_wait_for_buffer(&card
->write
);
2128 memcpy(iob
->data
, ULP_ENABLE
, ULP_ENABLE_SIZE
);
2130 *(QETH_ULP_ENABLE_LINKNUM(iob
->data
)) =
2131 (__u8
) card
->info
.portno
;
2132 if (card
->options
.layer2
)
2133 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2134 prot_type
= QETH_PROT_OSN2
;
2136 prot_type
= QETH_PROT_LAYER2
;
2138 prot_type
= QETH_PROT_TCPIP
;
2140 memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob
->data
),&prot_type
,1);
2141 memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob
->data
),
2142 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2143 memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob
->data
),
2144 &card
->token
.ulp_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2145 memcpy(QETH_ULP_ENABLE_PORTNAME_AND_LL(iob
->data
),
2146 card
->info
.portname
, 9);
2147 rc
= qeth_send_control_data(card
, ULP_ENABLE_SIZE
, iob
,
2148 qeth_ulp_enable_cb
, NULL
);
2154 __raw_devno_from_bus_id(char *id
)
2156 id
+= (strlen(id
) - 4);
2157 return (__u16
) simple_strtoul(id
, &id
, 16);
2161 qeth_ulp_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2164 struct qeth_cmd_buffer
*iob
;
2166 QETH_DBF_TEXT(setup
, 2, "ulpstpcb");
2168 iob
= (struct qeth_cmd_buffer
*) data
;
2169 memcpy(&card
->token
.ulp_connection_r
,
2170 QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob
->data
),
2171 QETH_MPC_TOKEN_LENGTH
);
2172 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2177 qeth_ulp_setup(struct qeth_card
*card
)
2181 struct qeth_cmd_buffer
*iob
;
2183 QETH_DBF_TEXT(setup
,2,"ulpsetup");
2185 iob
= qeth_wait_for_buffer(&card
->write
);
2186 memcpy(iob
->data
, ULP_SETUP
, ULP_SETUP_SIZE
);
2188 memcpy(QETH_ULP_SETUP_DEST_ADDR(iob
->data
),
2189 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2190 memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob
->data
),
2191 &card
->token
.ulp_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2192 memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob
->data
),
2193 &card
->token
.ulp_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2195 temp
= __raw_devno_from_bus_id(CARD_DDEV_ID(card
));
2196 memcpy(QETH_ULP_SETUP_CUA(iob
->data
), &temp
, 2);
2197 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
2198 memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob
->data
), &temp
, 2);
2199 rc
= qeth_send_control_data(card
, ULP_SETUP_SIZE
, iob
,
2200 qeth_ulp_setup_cb
, NULL
);
2205 qeth_check_qdio_errors(struct qdio_buffer
*buf
, unsigned int qdio_error
,
2206 unsigned int siga_error
, const char *dbftext
)
2208 if (qdio_error
|| siga_error
) {
2209 QETH_DBF_TEXT(trace
, 2, dbftext
);
2210 QETH_DBF_TEXT(qerr
, 2, dbftext
);
2211 QETH_DBF_TEXT_(qerr
, 2, " F15=%02X",
2212 buf
->element
[15].flags
& 0xff);
2213 QETH_DBF_TEXT_(qerr
, 2, " F14=%02X",
2214 buf
->element
[14].flags
& 0xff);
2215 QETH_DBF_TEXT_(qerr
, 2, " qerr=%X", qdio_error
);
2216 QETH_DBF_TEXT_(qerr
, 2, " serr=%X", siga_error
);
2222 static inline struct sk_buff
*
2223 qeth_get_skb(unsigned int length
, struct qeth_hdr
*hdr
)
2225 struct sk_buff
* skb
;
2229 if (hdr
->hdr
.osn
.id
== QETH_HEADER_TYPE_OSN
)
2230 add_len
= sizeof(struct qeth_hdr
);
2231 #ifdef CONFIG_QETH_VLAN
2233 add_len
= VLAN_HLEN
;
2235 skb
= dev_alloc_skb(length
+ add_len
);
2237 skb_reserve(skb
, add_len
);
2241 static inline struct sk_buff
*
2242 qeth_get_next_skb(struct qeth_card
*card
, struct qdio_buffer
*buffer
,
2243 struct qdio_buffer_element
**__element
, int *__offset
,
2244 struct qeth_hdr
**hdr
)
2246 struct qdio_buffer_element
*element
= *__element
;
2247 int offset
= *__offset
;
2248 struct sk_buff
*skb
= NULL
;
2253 QETH_DBF_TEXT(trace
,6,"nextskb");
2254 /* qeth_hdr must not cross element boundaries */
2255 if (element
->length
< offset
+ sizeof(struct qeth_hdr
)){
2256 if (qeth_is_last_sbale(element
))
2260 if (element
->length
< sizeof(struct qeth_hdr
))
2263 *hdr
= element
->addr
+ offset
;
2265 offset
+= sizeof(struct qeth_hdr
);
2266 if (card
->options
.layer2
)
2267 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2268 skb_len
= (*hdr
)->hdr
.osn
.pdu_length
;
2270 skb_len
= (*hdr
)->hdr
.l2
.pkt_length
;
2272 skb_len
= (*hdr
)->hdr
.l3
.length
;
2276 if (card
->options
.fake_ll
){
2277 if(card
->dev
->type
== ARPHRD_IEEE802_TR
){
2278 if (!(skb
= qeth_get_skb(skb_len
+QETH_FAKE_LL_LEN_TR
, *hdr
)))
2280 skb_reserve(skb
,QETH_FAKE_LL_LEN_TR
);
2282 if (!(skb
= qeth_get_skb(skb_len
+QETH_FAKE_LL_LEN_ETH
, *hdr
)))
2284 skb_reserve(skb
,QETH_FAKE_LL_LEN_ETH
);
2286 } else if (!(skb
= qeth_get_skb(skb_len
, *hdr
)))
2288 data_ptr
= element
->addr
+ offset
;
2290 data_len
= min(skb_len
, (int)(element
->length
- offset
));
2292 memcpy(skb_put(skb
, data_len
), data_ptr
, data_len
);
2293 skb_len
-= data_len
;
2295 if (qeth_is_last_sbale(element
)){
2296 QETH_DBF_TEXT(trace
,4,"unexeob");
2297 QETH_DBF_TEXT_(trace
,4,"%s",CARD_BUS_ID(card
));
2298 QETH_DBF_TEXT(qerr
,2,"unexeob");
2299 QETH_DBF_TEXT_(qerr
,2,"%s",CARD_BUS_ID(card
));
2300 QETH_DBF_HEX(misc
,4,buffer
,sizeof(*buffer
));
2301 dev_kfree_skb_any(skb
);
2302 card
->stats
.rx_errors
++;
2307 data_ptr
= element
->addr
;
2312 *__element
= element
;
2316 if (net_ratelimit()){
2317 PRINT_WARN("No memory for packet received on %s.\n",
2318 QETH_CARD_IFNAME(card
));
2319 QETH_DBF_TEXT(trace
,2,"noskbmem");
2320 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2322 card
->stats
.rx_dropped
++;
2326 static inline __be16
2327 qeth_type_trans(struct sk_buff
*skb
, struct net_device
*dev
)
2329 struct qeth_card
*card
;
2332 QETH_DBF_TEXT(trace
,6,"typtrans");
2334 card
= (struct qeth_card
*)dev
->priv
;
2336 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
2337 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
2338 return tr_type_trans(skb
,dev
);
2339 #endif /* CONFIG_TR */
2340 skb
->mac
.raw
= skb
->data
;
2341 skb_pull(skb
, ETH_HLEN
);
2344 if (*eth
->h_dest
& 1) {
2345 if (memcmp(eth
->h_dest
, dev
->broadcast
, ETH_ALEN
) == 0)
2346 skb
->pkt_type
= PACKET_BROADCAST
;
2348 skb
->pkt_type
= PACKET_MULTICAST
;
2349 } else if (memcmp(eth
->h_dest
, dev
->dev_addr
, ETH_ALEN
))
2350 skb
->pkt_type
= PACKET_OTHERHOST
;
2352 if (ntohs(eth
->h_proto
) >= 1536)
2353 return eth
->h_proto
;
2354 if (*(unsigned short *) (skb
->data
) == 0xFFFF)
2355 return htons(ETH_P_802_3
);
2356 return htons(ETH_P_802_2
);
2360 qeth_rebuild_skb_fake_ll_tr(struct qeth_card
*card
, struct sk_buff
*skb
,
2361 struct qeth_hdr
*hdr
)
2363 struct trh_hdr
*fake_hdr
;
2364 struct trllc
*fake_llc
;
2365 struct iphdr
*ip_hdr
;
2367 QETH_DBF_TEXT(trace
,5,"skbfktr");
2368 skb
->mac
.raw
= skb
->data
- QETH_FAKE_LL_LEN_TR
;
2369 /* this is a fake ethernet header */
2370 fake_hdr
= (struct trh_hdr
*) skb
->mac
.raw
;
2372 /* the destination MAC address */
2373 switch (skb
->pkt_type
){
2374 case PACKET_MULTICAST
:
2375 switch (skb
->protocol
){
2376 #ifdef CONFIG_QETH_IPV6
2377 case __constant_htons(ETH_P_IPV6
):
2378 ndisc_mc_map((struct in6_addr
*)
2379 skb
->data
+ QETH_FAKE_LL_V6_ADDR_POS
,
2380 fake_hdr
->daddr
, card
->dev
, 0);
2382 #endif /* CONFIG_QETH_IPV6 */
2383 case __constant_htons(ETH_P_IP
):
2384 ip_hdr
= (struct iphdr
*)skb
->data
;
2385 ip_tr_mc_map(ip_hdr
->daddr
, fake_hdr
->daddr
);
2388 memcpy(fake_hdr
->daddr
, card
->dev
->dev_addr
, TR_ALEN
);
2391 case PACKET_BROADCAST
:
2392 memset(fake_hdr
->daddr
, 0xff, TR_ALEN
);
2395 memcpy(fake_hdr
->daddr
, card
->dev
->dev_addr
, TR_ALEN
);
2397 /* the source MAC address */
2398 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
2399 memcpy(fake_hdr
->saddr
, &hdr
->hdr
.l3
.dest_addr
[2], TR_ALEN
);
2401 memset(fake_hdr
->saddr
, 0, TR_ALEN
);
2403 fake_llc
= (struct trllc
*)&(fake_hdr
->rcf
);
2404 fake_llc
->dsap
= EXTENDED_SAP
;
2405 fake_llc
->ssap
= EXTENDED_SAP
;
2406 fake_llc
->llc
= UI_CMD
;
2407 fake_llc
->protid
[0] = 0;
2408 fake_llc
->protid
[1] = 0;
2409 fake_llc
->protid
[2] = 0;
2410 fake_llc
->ethertype
= ETH_P_IP
;
2414 qeth_rebuild_skb_fake_ll_eth(struct qeth_card
*card
, struct sk_buff
*skb
,
2415 struct qeth_hdr
*hdr
)
2417 struct ethhdr
*fake_hdr
;
2418 struct iphdr
*ip_hdr
;
2420 QETH_DBF_TEXT(trace
,5,"skbfketh");
2421 skb
->mac
.raw
= skb
->data
- QETH_FAKE_LL_LEN_ETH
;
2422 /* this is a fake ethernet header */
2423 fake_hdr
= (struct ethhdr
*) skb
->mac
.raw
;
2425 /* the destination MAC address */
2426 switch (skb
->pkt_type
){
2427 case PACKET_MULTICAST
:
2428 switch (skb
->protocol
){
2429 #ifdef CONFIG_QETH_IPV6
2430 case __constant_htons(ETH_P_IPV6
):
2431 ndisc_mc_map((struct in6_addr
*)
2432 skb
->data
+ QETH_FAKE_LL_V6_ADDR_POS
,
2433 fake_hdr
->h_dest
, card
->dev
, 0);
2435 #endif /* CONFIG_QETH_IPV6 */
2436 case __constant_htons(ETH_P_IP
):
2437 ip_hdr
= (struct iphdr
*)skb
->data
;
2438 ip_eth_mc_map(ip_hdr
->daddr
, fake_hdr
->h_dest
);
2441 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2444 case PACKET_BROADCAST
:
2445 memset(fake_hdr
->h_dest
, 0xff, ETH_ALEN
);
2448 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2450 /* the source MAC address */
2451 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
2452 memcpy(fake_hdr
->h_source
, &hdr
->hdr
.l3
.dest_addr
[2], ETH_ALEN
);
2454 memset(fake_hdr
->h_source
, 0, ETH_ALEN
);
2456 fake_hdr
->h_proto
= skb
->protocol
;
2460 qeth_rebuild_skb_fake_ll(struct qeth_card
*card
, struct sk_buff
*skb
,
2461 struct qeth_hdr
*hdr
)
2463 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
2464 qeth_rebuild_skb_fake_ll_tr(card
, skb
, hdr
);
2466 qeth_rebuild_skb_fake_ll_eth(card
, skb
, hdr
);
2470 qeth_rebuild_skb_vlan(struct qeth_card
*card
, struct sk_buff
*skb
,
2471 struct qeth_hdr
*hdr
)
2473 #ifdef CONFIG_QETH_VLAN
2476 if (hdr
->hdr
.l3
.ext_flags
&
2477 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
2478 vlan_tag
= (u16
*) skb_push(skb
, VLAN_HLEN
);
2479 *vlan_tag
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
)?
2480 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
2481 *(vlan_tag
+ 1) = skb
->protocol
;
2482 skb
->protocol
= __constant_htons(ETH_P_8021Q
);
2484 #endif /* CONFIG_QETH_VLAN */
2488 qeth_layer2_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2489 struct qeth_hdr
*hdr
)
2491 unsigned short vlan_id
= 0;
2492 #ifdef CONFIG_QETH_VLAN
2493 struct vlan_hdr
*vhdr
;
2496 skb
->pkt_type
= PACKET_HOST
;
2497 skb
->protocol
= qeth_type_trans(skb
, skb
->dev
);
2498 if (card
->options
.checksum_type
== NO_CHECKSUMMING
)
2499 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2501 skb
->ip_summed
= CHECKSUM_NONE
;
2502 #ifdef CONFIG_QETH_VLAN
2503 if (hdr
->hdr
.l2
.flags
[2] & (QETH_LAYER2_FLAG_VLAN
)) {
2504 vhdr
= (struct vlan_hdr
*) skb
->data
;
2506 __constant_htons(vhdr
->h_vlan_encapsulated_proto
);
2507 vlan_id
= hdr
->hdr
.l2
.vlan_id
;
2508 skb_pull(skb
, VLAN_HLEN
);
2511 *((__u32
*)skb
->cb
) = ++card
->seqno
.pkt_seqno
;
2516 qeth_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2517 struct qeth_hdr
*hdr
)
2519 #ifdef CONFIG_QETH_IPV6
2520 if (hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
) {
2521 skb
->pkt_type
= PACKET_HOST
;
2522 skb
->protocol
= qeth_type_trans(skb
, card
->dev
);
2525 #endif /* CONFIG_QETH_IPV6 */
2526 skb
->protocol
= htons((hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
)? ETH_P_IPV6
:
2528 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
){
2529 case QETH_CAST_UNICAST
:
2530 skb
->pkt_type
= PACKET_HOST
;
2532 case QETH_CAST_MULTICAST
:
2533 skb
->pkt_type
= PACKET_MULTICAST
;
2534 card
->stats
.multicast
++;
2536 case QETH_CAST_BROADCAST
:
2537 skb
->pkt_type
= PACKET_BROADCAST
;
2538 card
->stats
.multicast
++;
2540 case QETH_CAST_ANYCAST
:
2541 case QETH_CAST_NOCAST
:
2543 skb
->pkt_type
= PACKET_HOST
;
2545 qeth_rebuild_skb_vlan(card
, skb
, hdr
);
2546 if (card
->options
.fake_ll
)
2547 qeth_rebuild_skb_fake_ll(card
, skb
, hdr
);
2549 skb
->mac
.raw
= skb
->data
;
2550 skb
->ip_summed
= card
->options
.checksum_type
;
2551 if (card
->options
.checksum_type
== HW_CHECKSUMMING
){
2552 if ( (hdr
->hdr
.l3
.ext_flags
&
2553 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2554 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
2555 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2556 QETH_HDR_EXT_CSUM_TRANSP_REQ
) )
2557 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2559 skb
->ip_summed
= SW_CHECKSUMMING
;
2564 qeth_process_inbound_buffer(struct qeth_card
*card
,
2565 struct qeth_qdio_buffer
*buf
, int index
)
2567 struct qdio_buffer_element
*element
;
2568 struct sk_buff
*skb
;
2569 struct qeth_hdr
*hdr
;
2574 /* get first element of current buffer */
2575 element
= (struct qdio_buffer_element
*)&buf
->buffer
->element
[0];
2577 #ifdef CONFIG_QETH_PERF_STATS
2578 card
->perf_stats
.bufs_rec
++;
2580 while((skb
= qeth_get_next_skb(card
, buf
->buffer
, &element
,
2582 skb
->dev
= card
->dev
;
2583 if (hdr
->hdr
.l2
.id
== QETH_HEADER_TYPE_LAYER2
)
2584 vlan_tag
= qeth_layer2_rebuild_skb(card
, skb
, hdr
);
2585 else if (hdr
->hdr
.l3
.id
== QETH_HEADER_TYPE_LAYER3
)
2586 qeth_rebuild_skb(card
, skb
, hdr
);
2587 else { /*in case of OSN*/
2588 skb_push(skb
, sizeof(struct qeth_hdr
));
2589 memcpy(skb
->data
, hdr
, sizeof(struct qeth_hdr
));
2591 /* is device UP ? */
2592 if (!(card
->dev
->flags
& IFF_UP
)){
2593 dev_kfree_skb_any(skb
);
2596 #ifdef CONFIG_QETH_VLAN
2598 vlan_hwaccel_rx(skb
, card
->vlangrp
, vlan_tag
);
2601 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2602 rxrc
= card
->osn_info
.data_cb(skb
);
2604 rxrc
= netif_rx(skb
);
2605 card
->dev
->last_rx
= jiffies
;
2606 card
->stats
.rx_packets
++;
2607 card
->stats
.rx_bytes
+= skb
->len
;
2611 static inline struct qeth_buffer_pool_entry
*
2612 qeth_get_buffer_pool_entry(struct qeth_card
*card
)
2614 struct qeth_buffer_pool_entry
*entry
;
2616 QETH_DBF_TEXT(trace
, 6, "gtbfplen");
2617 if (!list_empty(&card
->qdio
.in_buf_pool
.entry_list
)) {
2618 entry
= list_entry(card
->qdio
.in_buf_pool
.entry_list
.next
,
2619 struct qeth_buffer_pool_entry
, list
);
2620 list_del_init(&entry
->list
);
2627 qeth_init_input_buffer(struct qeth_card
*card
, struct qeth_qdio_buffer
*buf
)
2629 struct qeth_buffer_pool_entry
*pool_entry
;
2632 pool_entry
= qeth_get_buffer_pool_entry(card
);
2634 * since the buffer is accessed only from the input_tasklet
2635 * there shouldn't be a need to synchronize; also, since we use
2636 * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off
2639 BUG_ON(!pool_entry
);
2641 buf
->pool_entry
= pool_entry
;
2642 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
2643 buf
->buffer
->element
[i
].length
= PAGE_SIZE
;
2644 buf
->buffer
->element
[i
].addr
= pool_entry
->elements
[i
];
2645 if (i
== QETH_MAX_BUFFER_ELEMENTS(card
) - 1)
2646 buf
->buffer
->element
[i
].flags
= SBAL_FLAGS_LAST_ENTRY
;
2648 buf
->buffer
->element
[i
].flags
= 0;
2650 buf
->state
= QETH_QDIO_BUF_EMPTY
;
2654 qeth_clear_output_buffer(struct qeth_qdio_out_q
*queue
,
2655 struct qeth_qdio_out_buffer
*buf
)
2658 struct sk_buff
*skb
;
2660 /* is PCI flag set on buffer? */
2661 if (buf
->buffer
->element
[0].flags
& 0x40)
2662 atomic_dec(&queue
->set_pci_flags_count
);
2664 while ((skb
= skb_dequeue(&buf
->skb_list
))){
2665 atomic_dec(&skb
->users
);
2666 dev_kfree_skb_any(skb
);
2668 qeth_eddp_buf_release_contexts(buf
);
2669 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(queue
->card
); ++i
){
2670 buf
->buffer
->element
[i
].length
= 0;
2671 buf
->buffer
->element
[i
].addr
= NULL
;
2672 buf
->buffer
->element
[i
].flags
= 0;
2674 buf
->next_element_to_fill
= 0;
2675 atomic_set(&buf
->state
, QETH_QDIO_BUF_EMPTY
);
2679 qeth_queue_input_buffer(struct qeth_card
*card
, int index
)
2681 struct qeth_qdio_q
*queue
= card
->qdio
.in_q
;
2686 QETH_DBF_TEXT(trace
,6,"queinbuf");
2687 count
= (index
< queue
->next_buf_to_init
)?
2688 card
->qdio
.in_buf_pool
.buf_count
-
2689 (queue
->next_buf_to_init
- index
) :
2690 card
->qdio
.in_buf_pool
.buf_count
-
2691 (queue
->next_buf_to_init
+ QDIO_MAX_BUFFERS_PER_Q
- index
);
2692 /* only requeue at a certain threshold to avoid SIGAs */
2693 if (count
>= QETH_IN_BUF_REQUEUE_THRESHOLD(card
)){
2694 for (i
= queue
->next_buf_to_init
;
2695 i
< queue
->next_buf_to_init
+ count
; ++i
)
2696 qeth_init_input_buffer(card
,
2697 &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
]);
2699 * according to old code it should be avoided to requeue all
2700 * 128 buffers in order to benefit from PCI avoidance.
2701 * this function keeps at least one buffer (the buffer at
2702 * 'index') un-requeued -> this buffer is the first buffer that
2703 * will be requeued the next time
2705 #ifdef CONFIG_QETH_PERF_STATS
2706 card
->perf_stats
.inbound_do_qdio_cnt
++;
2707 card
->perf_stats
.inbound_do_qdio_start_time
= qeth_get_micros();
2709 rc
= do_QDIO(CARD_DDEV(card
),
2710 QDIO_FLAG_SYNC_INPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2711 0, queue
->next_buf_to_init
, count
, NULL
);
2712 #ifdef CONFIG_QETH_PERF_STATS
2713 card
->perf_stats
.inbound_do_qdio_time
+= qeth_get_micros() -
2714 card
->perf_stats
.inbound_do_qdio_start_time
;
2717 PRINT_WARN("qeth_queue_input_buffer's do_QDIO "
2718 "return %i (device %s).\n",
2719 rc
, CARD_DDEV_ID(card
));
2720 QETH_DBF_TEXT(trace
,2,"qinberr");
2721 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2723 queue
->next_buf_to_init
= (queue
->next_buf_to_init
+ count
) %
2724 QDIO_MAX_BUFFERS_PER_Q
;
2729 qeth_put_buffer_pool_entry(struct qeth_card
*card
,
2730 struct qeth_buffer_pool_entry
*entry
)
2732 QETH_DBF_TEXT(trace
, 6, "ptbfplen");
2733 list_add_tail(&entry
->list
, &card
->qdio
.in_buf_pool
.entry_list
);
2737 qeth_qdio_input_handler(struct ccw_device
* ccwdev
, unsigned int status
,
2738 unsigned int qdio_err
, unsigned int siga_err
,
2739 unsigned int queue
, int first_element
, int count
,
2740 unsigned long card_ptr
)
2742 struct net_device
*net_dev
;
2743 struct qeth_card
*card
;
2744 struct qeth_qdio_buffer
*buffer
;
2748 QETH_DBF_TEXT(trace
, 6, "qdinput");
2749 card
= (struct qeth_card
*) card_ptr
;
2750 net_dev
= card
->dev
;
2751 #ifdef CONFIG_QETH_PERF_STATS
2752 card
->perf_stats
.inbound_cnt
++;
2753 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
2755 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2756 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
2757 QETH_DBF_TEXT(trace
, 1,"qdinchk");
2758 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2759 QETH_DBF_TEXT_(trace
,1,"%04X%04X",first_element
,count
);
2760 QETH_DBF_TEXT_(trace
,1,"%04X%04X", queue
, status
);
2761 qeth_schedule_recovery(card
);
2765 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
2766 index
= i
% QDIO_MAX_BUFFERS_PER_Q
;
2767 buffer
= &card
->qdio
.in_q
->bufs
[index
];
2768 if (!((status
& QDIO_STATUS_LOOK_FOR_ERROR
) &&
2769 qeth_check_qdio_errors(buffer
->buffer
,
2770 qdio_err
, siga_err
,"qinerr")))
2771 qeth_process_inbound_buffer(card
, buffer
, index
);
2772 /* clear buffer and give back to hardware */
2773 qeth_put_buffer_pool_entry(card
, buffer
->pool_entry
);
2774 qeth_queue_input_buffer(card
, index
);
2776 #ifdef CONFIG_QETH_PERF_STATS
2777 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
2778 card
->perf_stats
.inbound_start_time
;
2783 qeth_handle_send_error(struct qeth_card
*card
,
2784 struct qeth_qdio_out_buffer
*buffer
,
2785 unsigned int qdio_err
, unsigned int siga_err
)
2787 int sbalf15
= buffer
->buffer
->element
[15].flags
& 0xff;
2788 int cc
= siga_err
& 3;
2790 QETH_DBF_TEXT(trace
, 6, "hdsnderr");
2791 qeth_check_qdio_errors(buffer
->buffer
, qdio_err
, siga_err
, "qouterr");
2795 QETH_DBF_TEXT(trace
, 1,"lnkfail");
2796 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2797 QETH_DBF_TEXT_(trace
,1,"%04x %02x",
2798 (u16
)qdio_err
, (u8
)sbalf15
);
2799 return QETH_SEND_ERROR_LINK_FAILURE
;
2801 return QETH_SEND_ERROR_NONE
;
2803 if (siga_err
& QDIO_SIGA_ERROR_B_BIT_SET
) {
2804 QETH_DBF_TEXT(trace
, 1, "SIGAcc2B");
2805 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2806 return QETH_SEND_ERROR_KICK_IT
;
2808 if ((sbalf15
>= 15) && (sbalf15
<= 31))
2809 return QETH_SEND_ERROR_RETRY
;
2810 return QETH_SEND_ERROR_LINK_FAILURE
;
2811 /* look at qdio_error and sbalf 15 */
2813 QETH_DBF_TEXT(trace
, 1, "SIGAcc1");
2814 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2815 return QETH_SEND_ERROR_LINK_FAILURE
;
2818 QETH_DBF_TEXT(trace
, 1, "SIGAcc3");
2819 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2820 return QETH_SEND_ERROR_KICK_IT
;
2825 qeth_flush_buffers(struct qeth_qdio_out_q
*queue
, int under_int
,
2826 int index
, int count
)
2828 struct qeth_qdio_out_buffer
*buf
;
2832 QETH_DBF_TEXT(trace
, 6, "flushbuf");
2834 for (i
= index
; i
< index
+ count
; ++i
) {
2835 buf
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
2836 buf
->buffer
->element
[buf
->next_element_to_fill
- 1].flags
|=
2837 SBAL_FLAGS_LAST_ENTRY
;
2839 if (queue
->card
->info
.type
== QETH_CARD_TYPE_IQD
)
2842 if (!queue
->do_pack
){
2843 if ((atomic_read(&queue
->used_buffers
) >=
2844 (QETH_HIGH_WATERMARK_PACK
-
2845 QETH_WATERMARK_PACK_FUZZ
)) &&
2846 !atomic_read(&queue
->set_pci_flags_count
)){
2847 /* it's likely that we'll go to packing
2849 atomic_inc(&queue
->set_pci_flags_count
);
2850 buf
->buffer
->element
[0].flags
|= 0x40;
2853 if (!atomic_read(&queue
->set_pci_flags_count
)){
2855 * there's no outstanding PCI any more, so we
2856 * have to request a PCI to be sure the the PCI
2857 * will wake at some time in the future then we
2858 * can flush packed buffers that might still be
2859 * hanging around, which can happen if no
2860 * further send was requested by the stack
2862 atomic_inc(&queue
->set_pci_flags_count
);
2863 buf
->buffer
->element
[0].flags
|= 0x40;
2868 queue
->card
->dev
->trans_start
= jiffies
;
2869 #ifdef CONFIG_QETH_PERF_STATS
2870 queue
->card
->perf_stats
.outbound_do_qdio_cnt
++;
2871 queue
->card
->perf_stats
.outbound_do_qdio_start_time
= qeth_get_micros();
2874 rc
= do_QDIO(CARD_DDEV(queue
->card
),
2875 QDIO_FLAG_SYNC_OUTPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2876 queue
->queue_no
, index
, count
, NULL
);
2878 rc
= do_QDIO(CARD_DDEV(queue
->card
), QDIO_FLAG_SYNC_OUTPUT
,
2879 queue
->queue_no
, index
, count
, NULL
);
2880 #ifdef CONFIG_QETH_PERF_STATS
2881 queue
->card
->perf_stats
.outbound_do_qdio_time
+= qeth_get_micros() -
2882 queue
->card
->perf_stats
.outbound_do_qdio_start_time
;
2885 QETH_DBF_TEXT(trace
, 2, "flushbuf");
2886 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
2887 QETH_DBF_TEXT_(trace
, 2, "%s", CARD_DDEV_ID(queue
->card
));
2888 queue
->card
->stats
.tx_errors
+= count
;
2889 /* this must not happen under normal circumstances. if it
2890 * happens something is really wrong -> recover */
2891 qeth_schedule_recovery(queue
->card
);
2894 atomic_add(count
, &queue
->used_buffers
);
2895 #ifdef CONFIG_QETH_PERF_STATS
2896 queue
->card
->perf_stats
.bufs_sent
+= count
;
2901 * Switched to packing state if the number of used buffers on a queue
2902 * reaches a certain limit.
2905 qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q
*queue
)
2907 if (!queue
->do_pack
) {
2908 if (atomic_read(&queue
->used_buffers
)
2909 >= QETH_HIGH_WATERMARK_PACK
){
2910 /* switch non-PACKING -> PACKING */
2911 QETH_DBF_TEXT(trace
, 6, "np->pack");
2912 #ifdef CONFIG_QETH_PERF_STATS
2913 queue
->card
->perf_stats
.sc_dp_p
++;
2921 * Switches from packing to non-packing mode. If there is a packing
2922 * buffer on the queue this buffer will be prepared to be flushed.
2923 * In that case 1 is returned to inform the caller. If no buffer
2924 * has to be flushed, zero is returned.
2927 qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q
*queue
)
2929 struct qeth_qdio_out_buffer
*buffer
;
2930 int flush_count
= 0;
2932 if (queue
->do_pack
) {
2933 if (atomic_read(&queue
->used_buffers
)
2934 <= QETH_LOW_WATERMARK_PACK
) {
2935 /* switch PACKING -> non-PACKING */
2936 QETH_DBF_TEXT(trace
, 6, "pack->np");
2937 #ifdef CONFIG_QETH_PERF_STATS
2938 queue
->card
->perf_stats
.sc_p_dp
++;
2941 /* flush packing buffers */
2942 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2943 if ((atomic_read(&buffer
->state
) ==
2944 QETH_QDIO_BUF_EMPTY
) &&
2945 (buffer
->next_element_to_fill
> 0)) {
2946 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
2948 queue
->next_buf_to_fill
=
2949 (queue
->next_buf_to_fill
+ 1) %
2950 QDIO_MAX_BUFFERS_PER_Q
;
2958 * Called to flush a packing buffer if no more pci flags are on the queue.
2959 * Checks if there is a packing buffer and prepares it to be flushed.
2960 * In that case returns 1, otherwise zero.
2963 qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q
*queue
)
2965 struct qeth_qdio_out_buffer
*buffer
;
2967 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2968 if((atomic_read(&buffer
->state
) == QETH_QDIO_BUF_EMPTY
) &&
2969 (buffer
->next_element_to_fill
> 0)){
2970 /* it's a packing buffer */
2971 atomic_set(&buffer
->state
, QETH_QDIO_BUF_PRIMED
);
2972 queue
->next_buf_to_fill
=
2973 (queue
->next_buf_to_fill
+ 1) % QDIO_MAX_BUFFERS_PER_Q
;
2980 qeth_check_outbound_queue(struct qeth_qdio_out_q
*queue
)
2984 int q_was_packing
= 0;
2987 * check if weed have to switch to non-packing mode or if
2988 * we have to get a pci flag out on the queue
2990 if ((atomic_read(&queue
->used_buffers
) <= QETH_LOW_WATERMARK_PACK
) ||
2991 !atomic_read(&queue
->set_pci_flags_count
)){
2992 if (atomic_swap(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
) ==
2993 QETH_OUT_Q_UNLOCKED
) {
2995 * If we get in here, there was no action in
2996 * do_send_packet. So, we check if there is a
2997 * packing buffer to be flushed here.
2999 netif_stop_queue(queue
->card
->dev
);
3000 index
= queue
->next_buf_to_fill
;
3001 q_was_packing
= queue
->do_pack
;
3002 flush_cnt
+= qeth_switch_to_nonpacking_if_needed(queue
);
3004 !atomic_read(&queue
->set_pci_flags_count
))
3006 qeth_flush_buffers_on_no_pci(queue
);
3007 #ifdef CONFIG_QETH_PERF_STATS
3009 queue
->card
->perf_stats
.bufs_sent_pack
+=
3013 qeth_flush_buffers(queue
, 1, index
, flush_cnt
);
3014 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
3020 qeth_qdio_output_handler(struct ccw_device
* ccwdev
, unsigned int status
,
3021 unsigned int qdio_error
, unsigned int siga_error
,
3022 unsigned int __queue
, int first_element
, int count
,
3023 unsigned long card_ptr
)
3025 struct qeth_card
*card
= (struct qeth_card
*) card_ptr
;
3026 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
[__queue
];
3027 struct qeth_qdio_out_buffer
*buffer
;
3030 QETH_DBF_TEXT(trace
, 6, "qdouhdl");
3031 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
3032 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
3033 QETH_DBF_TEXT(trace
, 2, "achkcond");
3034 QETH_DBF_TEXT_(trace
, 2, "%s", CARD_BUS_ID(card
));
3035 QETH_DBF_TEXT_(trace
, 2, "%08x", status
);
3036 netif_stop_queue(card
->dev
);
3037 qeth_schedule_recovery(card
);
3041 #ifdef CONFIG_QETH_PERF_STATS
3042 card
->perf_stats
.outbound_handler_cnt
++;
3043 card
->perf_stats
.outbound_handler_start_time
= qeth_get_micros();
3045 for(i
= first_element
; i
< (first_element
+ count
); ++i
){
3046 buffer
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
3047 /*we only handle the KICK_IT error by doing a recovery */
3048 if (qeth_handle_send_error(card
, buffer
,
3049 qdio_error
, siga_error
)
3050 == QETH_SEND_ERROR_KICK_IT
){
3051 netif_stop_queue(card
->dev
);
3052 qeth_schedule_recovery(card
);
3055 qeth_clear_output_buffer(queue
, buffer
);
3057 atomic_sub(count
, &queue
->used_buffers
);
3058 /* check if we need to do something on this outbound queue */
3059 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
3060 qeth_check_outbound_queue(queue
);
3062 netif_wake_queue(queue
->card
->dev
);
3063 #ifdef CONFIG_QETH_PERF_STATS
3064 card
->perf_stats
.outbound_handler_time
+= qeth_get_micros() -
3065 card
->perf_stats
.outbound_handler_start_time
;
3070 qeth_create_qib_param_field(struct qeth_card
*card
, char *param_field
)
3073 param_field
[0] = _ascebc
['P'];
3074 param_field
[1] = _ascebc
['C'];
3075 param_field
[2] = _ascebc
['I'];
3076 param_field
[3] = _ascebc
['T'];
3077 *((unsigned int *) (¶m_field
[4])) = QETH_PCI_THRESHOLD_A(card
);
3078 *((unsigned int *) (¶m_field
[8])) = QETH_PCI_THRESHOLD_B(card
);
3079 *((unsigned int *) (¶m_field
[12])) = QETH_PCI_TIMER_VALUE(card
);
3083 qeth_create_qib_param_field_blkt(struct qeth_card
*card
, char *param_field
)
3085 param_field
[16] = _ascebc
['B'];
3086 param_field
[17] = _ascebc
['L'];
3087 param_field
[18] = _ascebc
['K'];
3088 param_field
[19] = _ascebc
['T'];
3089 *((unsigned int *) (¶m_field
[20])) = card
->info
.blkt
.time_total
;
3090 *((unsigned int *) (¶m_field
[24])) = card
->info
.blkt
.inter_packet
;
3091 *((unsigned int *) (¶m_field
[28])) = card
->info
.blkt
.inter_packet_jumbo
;
3095 qeth_initialize_working_pool_list(struct qeth_card
*card
)
3097 struct qeth_buffer_pool_entry
*entry
;
3099 QETH_DBF_TEXT(trace
,5,"inwrklst");
3101 list_for_each_entry(entry
,
3102 &card
->qdio
.init_pool
.entry_list
, init_list
) {
3103 qeth_put_buffer_pool_entry(card
,entry
);
3108 qeth_clear_working_pool_list(struct qeth_card
*card
)
3110 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
3112 QETH_DBF_TEXT(trace
,5,"clwrklst");
3113 list_for_each_entry_safe(pool_entry
, tmp
,
3114 &card
->qdio
.in_buf_pool
.entry_list
, list
){
3115 list_del(&pool_entry
->list
);
3120 qeth_free_buffer_pool(struct qeth_card
*card
)
3122 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
3124 QETH_DBF_TEXT(trace
,5,"freepool");
3125 list_for_each_entry_safe(pool_entry
, tmp
,
3126 &card
->qdio
.init_pool
.entry_list
, init_list
){
3127 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
)
3128 free_page((unsigned long)pool_entry
->elements
[i
]);
3129 list_del(&pool_entry
->init_list
);
3135 qeth_alloc_buffer_pool(struct qeth_card
*card
)
3137 struct qeth_buffer_pool_entry
*pool_entry
;
3141 QETH_DBF_TEXT(trace
,5,"alocpool");
3142 for (i
= 0; i
< card
->qdio
.init_pool
.buf_count
; ++i
){
3143 pool_entry
= kmalloc(sizeof(*pool_entry
), GFP_KERNEL
);
3145 qeth_free_buffer_pool(card
);
3148 for(j
= 0; j
< QETH_MAX_BUFFER_ELEMENTS(card
); ++j
){
3149 ptr
= (void *) __get_free_page(GFP_KERNEL
|GFP_DMA
);
3152 free_page((unsigned long)
3153 pool_entry
->elements
[--j
]);
3155 qeth_free_buffer_pool(card
);
3158 pool_entry
->elements
[j
] = ptr
;
3160 list_add(&pool_entry
->init_list
,
3161 &card
->qdio
.init_pool
.entry_list
);
3167 qeth_realloc_buffer_pool(struct qeth_card
*card
, int bufcnt
)
3169 QETH_DBF_TEXT(trace
, 2, "realcbp");
3171 if ((card
->state
!= CARD_STATE_DOWN
) &&
3172 (card
->state
!= CARD_STATE_RECOVER
))
3175 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
3176 qeth_clear_working_pool_list(card
);
3177 qeth_free_buffer_pool(card
);
3178 card
->qdio
.in_buf_pool
.buf_count
= bufcnt
;
3179 card
->qdio
.init_pool
.buf_count
= bufcnt
;
3180 return qeth_alloc_buffer_pool(card
);
3184 qeth_alloc_qdio_buffers(struct qeth_card
*card
)
3188 QETH_DBF_TEXT(setup
, 2, "allcqdbf");
3190 if (card
->qdio
.state
== QETH_QDIO_ALLOCATED
)
3193 card
->qdio
.in_q
= kmalloc(sizeof(struct qeth_qdio_q
),
3194 GFP_KERNEL
|GFP_DMA
);
3195 if (!card
->qdio
.in_q
)
3197 QETH_DBF_TEXT(setup
, 2, "inq");
3198 QETH_DBF_HEX(setup
, 2, &card
->qdio
.in_q
, sizeof(void *));
3199 memset(card
->qdio
.in_q
, 0, sizeof(struct qeth_qdio_q
));
3200 /* give inbound qeth_qdio_buffers their qdio_buffers */
3201 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3202 card
->qdio
.in_q
->bufs
[i
].buffer
=
3203 &card
->qdio
.in_q
->qdio_bufs
[i
];
3204 /* inbound buffer pool */
3205 if (qeth_alloc_buffer_pool(card
)){
3206 kfree(card
->qdio
.in_q
);
3211 kmalloc(card
->qdio
.no_out_queues
*
3212 sizeof(struct qeth_qdio_out_q
*), GFP_KERNEL
);
3213 if (!card
->qdio
.out_qs
){
3214 qeth_free_buffer_pool(card
);
3217 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3218 card
->qdio
.out_qs
[i
] = kmalloc(sizeof(struct qeth_qdio_out_q
),
3219 GFP_KERNEL
|GFP_DMA
);
3220 if (!card
->qdio
.out_qs
[i
]){
3222 kfree(card
->qdio
.out_qs
[--i
]);
3223 kfree(card
->qdio
.out_qs
);
3226 QETH_DBF_TEXT_(setup
, 2, "outq %i", i
);
3227 QETH_DBF_HEX(setup
, 2, &card
->qdio
.out_qs
[i
], sizeof(void *));
3228 memset(card
->qdio
.out_qs
[i
], 0, sizeof(struct qeth_qdio_out_q
));
3229 card
->qdio
.out_qs
[i
]->queue_no
= i
;
3230 /* give outbound qeth_qdio_buffers their qdio_buffers */
3231 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3232 card
->qdio
.out_qs
[i
]->bufs
[j
].buffer
=
3233 &card
->qdio
.out_qs
[i
]->qdio_bufs
[j
];
3234 skb_queue_head_init(&card
->qdio
.out_qs
[i
]->bufs
[j
].
3236 INIT_LIST_HEAD(&card
->qdio
.out_qs
[i
]->bufs
[j
].ctx_list
);
3239 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3244 qeth_free_qdio_buffers(struct qeth_card
*card
)
3248 QETH_DBF_TEXT(trace
, 2, "freeqdbf");
3249 if (card
->qdio
.state
== QETH_QDIO_UNINITIALIZED
)
3251 kfree(card
->qdio
.in_q
);
3252 /* inbound buffer pool */
3253 qeth_free_buffer_pool(card
);
3254 /* free outbound qdio_qs */
3255 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3256 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3257 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3258 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3259 kfree(card
->qdio
.out_qs
[i
]);
3261 kfree(card
->qdio
.out_qs
);
3262 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3266 qeth_clear_qdio_buffers(struct qeth_card
*card
)
3270 QETH_DBF_TEXT(trace
, 2, "clearqdbf");
3271 /* clear outbound buffers to free skbs */
3272 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3273 if (card
->qdio
.out_qs
[i
]){
3274 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3275 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3276 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3281 qeth_init_qdio_info(struct qeth_card
*card
)
3283 QETH_DBF_TEXT(setup
, 4, "intqdinf");
3284 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3286 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
3287 card
->qdio
.init_pool
.buf_count
= QETH_IN_BUF_COUNT_DEFAULT
;
3288 card
->qdio
.in_buf_pool
.buf_count
= card
->qdio
.init_pool
.buf_count
;
3289 INIT_LIST_HEAD(&card
->qdio
.in_buf_pool
.entry_list
);
3290 INIT_LIST_HEAD(&card
->qdio
.init_pool
.entry_list
);
3294 qeth_init_qdio_queues(struct qeth_card
*card
)
3299 QETH_DBF_TEXT(setup
, 2, "initqdqs");
3302 memset(card
->qdio
.in_q
->qdio_bufs
, 0,
3303 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3304 qeth_initialize_working_pool_list(card
);
3305 /*give only as many buffers to hardware as we have buffer pool entries*/
3306 for (i
= 0; i
< card
->qdio
.in_buf_pool
.buf_count
- 1; ++i
)
3307 qeth_init_input_buffer(card
, &card
->qdio
.in_q
->bufs
[i
]);
3308 card
->qdio
.in_q
->next_buf_to_init
= card
->qdio
.in_buf_pool
.buf_count
- 1;
3309 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0, 0,
3310 card
->qdio
.in_buf_pool
.buf_count
- 1, NULL
);
3312 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3315 rc
= qdio_synchronize(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0);
3317 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3320 /* outbound queue */
3321 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3322 memset(card
->qdio
.out_qs
[i
]->qdio_bufs
, 0,
3323 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3324 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3325 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3326 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3328 card
->qdio
.out_qs
[i
]->card
= card
;
3329 card
->qdio
.out_qs
[i
]->next_buf_to_fill
= 0;
3330 card
->qdio
.out_qs
[i
]->do_pack
= 0;
3331 atomic_set(&card
->qdio
.out_qs
[i
]->used_buffers
,0);
3332 atomic_set(&card
->qdio
.out_qs
[i
]->set_pci_flags_count
, 0);
3333 atomic_set(&card
->qdio
.out_qs
[i
]->state
,
3334 QETH_OUT_Q_UNLOCKED
);
3340 qeth_qdio_establish(struct qeth_card
*card
)
3342 struct qdio_initialize init_data
;
3343 char *qib_param_field
;
3344 struct qdio_buffer
**in_sbal_ptrs
;
3345 struct qdio_buffer
**out_sbal_ptrs
;
3349 QETH_DBF_TEXT(setup
, 2, "qdioest");
3351 qib_param_field
= kmalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(char),
3353 if (!qib_param_field
)
3356 memset(qib_param_field
, 0, QDIO_MAX_BUFFERS_PER_Q
* sizeof(char));
3358 qeth_create_qib_param_field(card
, qib_param_field
);
3359 qeth_create_qib_param_field_blkt(card
, qib_param_field
);
3361 in_sbal_ptrs
= kmalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(void *),
3363 if (!in_sbal_ptrs
) {
3364 kfree(qib_param_field
);
3367 for(i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3368 in_sbal_ptrs
[i
] = (struct qdio_buffer
*)
3369 virt_to_phys(card
->qdio
.in_q
->bufs
[i
].buffer
);
3372 kmalloc(card
->qdio
.no_out_queues
* QDIO_MAX_BUFFERS_PER_Q
*
3373 sizeof(void *), GFP_KERNEL
);
3374 if (!out_sbal_ptrs
) {
3375 kfree(in_sbal_ptrs
);
3376 kfree(qib_param_field
);
3379 for(i
= 0, k
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3380 for(j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
, ++k
){
3381 out_sbal_ptrs
[k
] = (struct qdio_buffer
*)
3382 virt_to_phys(card
->qdio
.out_qs
[i
]->
3386 memset(&init_data
, 0, sizeof(struct qdio_initialize
));
3387 init_data
.cdev
= CARD_DDEV(card
);
3388 init_data
.q_format
= qeth_get_qdio_q_format(card
);
3389 init_data
.qib_param_field_format
= 0;
3390 init_data
.qib_param_field
= qib_param_field
;
3391 init_data
.min_input_threshold
= QETH_MIN_INPUT_THRESHOLD
;
3392 init_data
.max_input_threshold
= QETH_MAX_INPUT_THRESHOLD
;
3393 init_data
.min_output_threshold
= QETH_MIN_OUTPUT_THRESHOLD
;
3394 init_data
.max_output_threshold
= QETH_MAX_OUTPUT_THRESHOLD
;
3395 init_data
.no_input_qs
= 1;
3396 init_data
.no_output_qs
= card
->qdio
.no_out_queues
;
3397 init_data
.input_handler
= (qdio_handler_t
*)
3398 qeth_qdio_input_handler
;
3399 init_data
.output_handler
= (qdio_handler_t
*)
3400 qeth_qdio_output_handler
;
3401 init_data
.int_parm
= (unsigned long) card
;
3402 init_data
.flags
= QDIO_INBOUND_0COPY_SBALS
|
3403 QDIO_OUTBOUND_0COPY_SBALS
|
3404 QDIO_USE_OUTBOUND_PCIS
;
3405 init_data
.input_sbal_addr_array
= (void **) in_sbal_ptrs
;
3406 init_data
.output_sbal_addr_array
= (void **) out_sbal_ptrs
;
3408 if (!(rc
= qdio_initialize(&init_data
)))
3409 card
->qdio
.state
= QETH_QDIO_ESTABLISHED
;
3411 kfree(out_sbal_ptrs
);
3412 kfree(in_sbal_ptrs
);
3413 kfree(qib_param_field
);
3418 qeth_qdio_activate(struct qeth_card
*card
)
3420 QETH_DBF_TEXT(setup
,3,"qdioact");
3421 return qdio_activate(CARD_DDEV(card
), 0);
3425 qeth_clear_channel(struct qeth_channel
*channel
)
3427 unsigned long flags
;
3428 struct qeth_card
*card
;
3431 QETH_DBF_TEXT(trace
,3,"clearch");
3432 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3433 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3434 rc
= ccw_device_clear(channel
->ccwdev
, QETH_CLEAR_CHANNEL_PARM
);
3435 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3439 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3440 channel
->state
==CH_STATE_STOPPED
, QETH_TIMEOUT
);
3441 if (rc
== -ERESTARTSYS
)
3443 if (channel
->state
!= CH_STATE_STOPPED
)
3445 channel
->state
= CH_STATE_DOWN
;
3450 qeth_halt_channel(struct qeth_channel
*channel
)
3452 unsigned long flags
;
3453 struct qeth_card
*card
;
3456 QETH_DBF_TEXT(trace
,3,"haltch");
3457 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3458 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3459 rc
= ccw_device_halt(channel
->ccwdev
, QETH_HALT_CHANNEL_PARM
);
3460 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3464 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3465 channel
->state
==CH_STATE_HALTED
, QETH_TIMEOUT
);
3466 if (rc
== -ERESTARTSYS
)
3468 if (channel
->state
!= CH_STATE_HALTED
)
3474 qeth_halt_channels(struct qeth_card
*card
)
3476 int rc1
= 0, rc2
=0, rc3
= 0;
3478 QETH_DBF_TEXT(trace
,3,"haltchs");
3479 rc1
= qeth_halt_channel(&card
->read
);
3480 rc2
= qeth_halt_channel(&card
->write
);
3481 rc3
= qeth_halt_channel(&card
->data
);
3489 qeth_clear_channels(struct qeth_card
*card
)
3491 int rc1
= 0, rc2
=0, rc3
= 0;
3493 QETH_DBF_TEXT(trace
,3,"clearchs");
3494 rc1
= qeth_clear_channel(&card
->read
);
3495 rc2
= qeth_clear_channel(&card
->write
);
3496 rc3
= qeth_clear_channel(&card
->data
);
3505 qeth_clear_halt_card(struct qeth_card
*card
, int halt
)
3509 QETH_DBF_TEXT(trace
,3,"clhacrd");
3510 QETH_DBF_HEX(trace
, 3, &card
, sizeof(void *));
3513 rc
= qeth_halt_channels(card
);
3516 return qeth_clear_channels(card
);
3520 qeth_qdio_clear_card(struct qeth_card
*card
, int use_halt
)
3524 QETH_DBF_TEXT(trace
,3,"qdioclr");
3525 if (card
->qdio
.state
== QETH_QDIO_ESTABLISHED
){
3526 if ((rc
= qdio_cleanup(CARD_DDEV(card
),
3527 (card
->info
.type
== QETH_CARD_TYPE_IQD
) ?
3528 QDIO_FLAG_CLEANUP_USING_HALT
:
3529 QDIO_FLAG_CLEANUP_USING_CLEAR
)))
3530 QETH_DBF_TEXT_(trace
, 3, "1err%d", rc
);
3531 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3533 if ((rc
= qeth_clear_halt_card(card
, use_halt
)))
3534 QETH_DBF_TEXT_(trace
, 3, "2err%d", rc
);
3535 card
->state
= CARD_STATE_DOWN
;
3540 qeth_dm_act(struct qeth_card
*card
)
3543 struct qeth_cmd_buffer
*iob
;
3545 QETH_DBF_TEXT(setup
,2,"dmact");
3547 iob
= qeth_wait_for_buffer(&card
->write
);
3548 memcpy(iob
->data
, DM_ACT
, DM_ACT_SIZE
);
3550 memcpy(QETH_DM_ACT_DEST_ADDR(iob
->data
),
3551 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3552 memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob
->data
),
3553 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3554 rc
= qeth_send_control_data(card
, DM_ACT_SIZE
, iob
, NULL
, NULL
);
3559 qeth_mpc_initialize(struct qeth_card
*card
)
3563 QETH_DBF_TEXT(setup
,2,"mpcinit");
3565 if ((rc
= qeth_issue_next_read(card
))){
3566 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3569 if ((rc
= qeth_cm_enable(card
))){
3570 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3573 if ((rc
= qeth_cm_setup(card
))){
3574 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
3577 if ((rc
= qeth_ulp_enable(card
))){
3578 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
3581 if ((rc
= qeth_ulp_setup(card
))){
3582 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3585 if ((rc
= qeth_alloc_qdio_buffers(card
))){
3586 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3589 if ((rc
= qeth_qdio_establish(card
))){
3590 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
3591 qeth_free_qdio_buffers(card
);
3594 if ((rc
= qeth_qdio_activate(card
))){
3595 QETH_DBF_TEXT_(setup
, 2, "7err%d", rc
);
3598 if ((rc
= qeth_dm_act(card
))){
3599 QETH_DBF_TEXT_(setup
, 2, "8err%d", rc
);
3605 qeth_qdio_clear_card(card
, card
->info
.type
!=QETH_CARD_TYPE_IQD
);
3609 static struct net_device
*
3610 qeth_get_netdevice(enum qeth_card_types type
, enum qeth_link_types linktype
)
3612 struct net_device
*dev
= NULL
;
3615 case QETH_CARD_TYPE_OSAE
:
3617 case QETH_LINK_TYPE_LANE_TR
:
3618 case QETH_LINK_TYPE_HSTR
:
3620 dev
= alloc_trdev(0);
3621 #endif /* CONFIG_TR */
3624 dev
= alloc_etherdev(0);
3627 case QETH_CARD_TYPE_IQD
:
3628 dev
= alloc_netdev(0, "hsi%d", ether_setup
);
3630 case QETH_CARD_TYPE_OSN
:
3631 dev
= alloc_netdev(0, "osn%d", ether_setup
);
3634 dev
= alloc_etherdev(0);
3639 /*hard_header fake function; used in case fake_ll is set */
3641 qeth_fake_header(struct sk_buff
*skb
, struct net_device
*dev
,
3642 unsigned short type
, void *daddr
, void *saddr
,
3645 if(dev
->type
== ARPHRD_IEEE802_TR
){
3646 struct trh_hdr
*hdr
;
3647 hdr
= (struct trh_hdr
*)skb_push(skb
, QETH_FAKE_LL_LEN_TR
);
3648 memcpy(hdr
->saddr
, dev
->dev_addr
, TR_ALEN
);
3649 memcpy(hdr
->daddr
, "FAKELL", TR_ALEN
);
3650 return QETH_FAKE_LL_LEN_TR
;
3654 hdr
= (struct ethhdr
*)skb_push(skb
, QETH_FAKE_LL_LEN_ETH
);
3655 memcpy(hdr
->h_source
, dev
->dev_addr
, ETH_ALEN
);
3656 memcpy(hdr
->h_dest
, "FAKELL", ETH_ALEN
);
3657 if (type
!= ETH_P_802_3
)
3658 hdr
->h_proto
= htons(type
);
3660 hdr
->h_proto
= htons(len
);
3661 return QETH_FAKE_LL_LEN_ETH
;
3667 qeth_send_packet(struct qeth_card
*, struct sk_buff
*);
3670 qeth_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
3673 struct qeth_card
*card
;
3675 QETH_DBF_TEXT(trace
, 6, "hrdstxmi");
3676 card
= (struct qeth_card
*)dev
->priv
;
3678 card
->stats
.tx_dropped
++;
3679 card
->stats
.tx_errors
++;
3680 /* return OK; otherwise ksoftirqd goes to 100% */
3681 return NETDEV_TX_OK
;
3683 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
3684 card
->stats
.tx_dropped
++;
3685 card
->stats
.tx_errors
++;
3686 card
->stats
.tx_carrier_errors
++;
3687 dev_kfree_skb_any(skb
);
3688 /* return OK; otherwise ksoftirqd goes to 100% */
3689 return NETDEV_TX_OK
;
3691 #ifdef CONFIG_QETH_PERF_STATS
3692 card
->perf_stats
.outbound_cnt
++;
3693 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
3695 netif_stop_queue(dev
);
3696 if ((rc
= qeth_send_packet(card
, skb
))) {
3698 return NETDEV_TX_BUSY
;
3700 card
->stats
.tx_errors
++;
3701 card
->stats
.tx_dropped
++;
3702 dev_kfree_skb_any(skb
);
3703 /*set to OK; otherwise ksoftirqd goes to 100% */
3707 netif_wake_queue(dev
);
3708 #ifdef CONFIG_QETH_PERF_STATS
3709 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
3710 card
->perf_stats
.outbound_start_time
;
3716 qeth_verify_vlan_dev(struct net_device
*dev
, struct qeth_card
*card
)
3719 #ifdef CONFIG_QETH_VLAN
3720 struct vlan_group
*vg
;
3723 if (!(vg
= card
->vlangrp
))
3726 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++){
3727 if (vg
->vlan_devices
[i
] == dev
){
3728 rc
= QETH_VLAN_CARD
;
3732 if (rc
&& !(VLAN_DEV_INFO(dev
)->real_dev
->priv
== (void *)card
))
3740 qeth_verify_dev(struct net_device
*dev
)
3742 struct qeth_card
*card
;
3743 unsigned long flags
;
3746 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
3747 list_for_each_entry(card
, &qeth_card_list
.list
, list
){
3748 if (card
->dev
== dev
){
3749 rc
= QETH_REAL_CARD
;
3752 rc
= qeth_verify_vlan_dev(dev
, card
);
3756 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
3761 static struct qeth_card
*
3762 qeth_get_card_from_dev(struct net_device
*dev
)
3764 struct qeth_card
*card
= NULL
;
3767 rc
= qeth_verify_dev(dev
);
3768 if (rc
== QETH_REAL_CARD
)
3769 card
= (struct qeth_card
*)dev
->priv
;
3770 else if (rc
== QETH_VLAN_CARD
)
3771 card
= (struct qeth_card
*)
3772 VLAN_DEV_INFO(dev
)->real_dev
->priv
;
3774 QETH_DBF_TEXT_(trace
, 4, "%d", rc
);
3779 qeth_tx_timeout(struct net_device
*dev
)
3781 struct qeth_card
*card
;
3783 card
= (struct qeth_card
*) dev
->priv
;
3784 card
->stats
.tx_errors
++;
3785 qeth_schedule_recovery(card
);
3789 qeth_open(struct net_device
*dev
)
3791 struct qeth_card
*card
;
3793 QETH_DBF_TEXT(trace
, 4, "qethopen");
3795 card
= (struct qeth_card
*) dev
->priv
;
3797 if (card
->state
!= CARD_STATE_SOFTSETUP
)
3800 if ( (card
->info
.type
!= QETH_CARD_TYPE_OSN
) &&
3801 (card
->options
.layer2
) &&
3802 (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))) {
3803 QETH_DBF_TEXT(trace
,4,"nomacadr");
3806 card
->dev
->flags
|= IFF_UP
;
3807 netif_start_queue(dev
);
3808 card
->data
.state
= CH_STATE_UP
;
3809 card
->state
= CARD_STATE_UP
;
3811 if (!card
->lan_online
&& netif_carrier_ok(dev
))
3812 netif_carrier_off(dev
);
3817 qeth_stop(struct net_device
*dev
)
3819 struct qeth_card
*card
;
3821 QETH_DBF_TEXT(trace
, 4, "qethstop");
3823 card
= (struct qeth_card
*) dev
->priv
;
3825 netif_stop_queue(dev
);
3826 card
->dev
->flags
&= ~IFF_UP
;
3827 if (card
->state
== CARD_STATE_UP
)
3828 card
->state
= CARD_STATE_SOFTSETUP
;
3833 qeth_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
3835 int cast_type
= RTN_UNSPEC
;
3837 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
3840 if (skb
->dst
&& skb
->dst
->neighbour
){
3841 cast_type
= skb
->dst
->neighbour
->type
;
3842 if ((cast_type
== RTN_BROADCAST
) ||
3843 (cast_type
== RTN_MULTICAST
) ||
3844 (cast_type
== RTN_ANYCAST
))
3849 /* try something else */
3850 if (skb
->protocol
== ETH_P_IPV6
)
3851 return (skb
->nh
.raw
[24] == 0xff) ? RTN_MULTICAST
: 0;
3852 else if (skb
->protocol
== ETH_P_IP
)
3853 return ((skb
->nh
.raw
[16] & 0xf0) == 0xe0) ? RTN_MULTICAST
: 0;
3855 if (!memcmp(skb
->data
, skb
->dev
->broadcast
, 6))
3856 return RTN_BROADCAST
;
3860 hdr_mac
= *((u16
*)skb
->data
);
3862 switch (card
->info
.link_type
) {
3863 case QETH_LINK_TYPE_HSTR
:
3864 case QETH_LINK_TYPE_LANE_TR
:
3865 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
3866 (hdr_mac
== QETH_TR_MAC_C
))
3867 return RTN_MULTICAST
;
3869 /* eth or so multicast? */
3871 if ((hdr_mac
== QETH_ETH_MAC_V4
) ||
3872 (hdr_mac
== QETH_ETH_MAC_V6
))
3873 return RTN_MULTICAST
;
3880 qeth_get_priority_queue(struct qeth_card
*card
, struct sk_buff
*skb
,
3881 int ipv
, int cast_type
)
3883 if (!ipv
&& (card
->info
.type
== QETH_CARD_TYPE_OSAE
))
3884 return card
->qdio
.default_out_queue
;
3885 switch (card
->qdio
.no_out_queues
) {
3887 if (cast_type
&& card
->info
.is_multicast_different
)
3888 return card
->info
.is_multicast_different
&
3889 (card
->qdio
.no_out_queues
- 1);
3890 if (card
->qdio
.do_prio_queueing
&& (ipv
== 4)) {
3891 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_TOS
){
3892 if (skb
->nh
.iph
->tos
& IP_TOS_NOTIMPORTANT
)
3894 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHRELIABILITY
)
3896 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHTHROUGHPUT
)
3898 if (skb
->nh
.iph
->tos
& IP_TOS_LOWDELAY
)
3901 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_PREC
)
3902 return 3 - (skb
->nh
.iph
->tos
>> 6);
3903 } else if (card
->qdio
.do_prio_queueing
&& (ipv
== 6)) {
3906 return card
->qdio
.default_out_queue
;
3907 case 1: /* fallthrough for single-out-queue 1920-device */
3909 return card
->qdio
.default_out_queue
;
3914 qeth_get_ip_version(struct sk_buff
*skb
)
3916 switch (skb
->protocol
) {
3927 qeth_prepare_skb(struct qeth_card
*card
, struct sk_buff
**skb
,
3928 struct qeth_hdr
**hdr
, int ipv
)
3931 #ifdef CONFIG_QETH_VLAN
3935 QETH_DBF_TEXT(trace
, 6, "prepskb");
3936 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
3937 *hdr
= (struct qeth_hdr
*)(*skb
)->data
;
3940 rc
= qeth_realloc_headroom(card
, skb
, sizeof(struct qeth_hdr
));
3943 #ifdef CONFIG_QETH_VLAN
3944 if (card
->vlangrp
&& vlan_tx_tag_present(*skb
) &&
3945 ((ipv
== 6) || card
->options
.layer2
) ) {
3947 * Move the mac addresses (6 bytes src, 6 bytes dest)
3948 * to the beginning of the new header. We are using three
3949 * memcpys instead of one memmove to save cycles.
3951 skb_push(*skb
, VLAN_HLEN
);
3952 memcpy((*skb
)->data
, (*skb
)->data
+ 4, 4);
3953 memcpy((*skb
)->data
+ 4, (*skb
)->data
+ 8, 4);
3954 memcpy((*skb
)->data
+ 8, (*skb
)->data
+ 12, 4);
3955 tag
= (u16
*)((*skb
)->data
+ 12);
3957 * first two bytes = ETH_P_8021Q (0x8100)
3958 * second two bytes = VLANID
3960 *tag
= __constant_htons(ETH_P_8021Q
);
3961 *(tag
+ 1) = htons(vlan_tx_tag_get(*skb
));
3964 *hdr
= (struct qeth_hdr
*)
3965 qeth_push_skb(card
, skb
, sizeof(struct qeth_hdr
));
3972 qeth_get_qeth_hdr_flags4(int cast_type
)
3974 if (cast_type
== RTN_MULTICAST
)
3975 return QETH_CAST_MULTICAST
;
3976 if (cast_type
== RTN_BROADCAST
)
3977 return QETH_CAST_BROADCAST
;
3978 return QETH_CAST_UNICAST
;
3982 qeth_get_qeth_hdr_flags6(int cast_type
)
3984 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
3985 if (cast_type
== RTN_MULTICAST
)
3986 return ct
| QETH_CAST_MULTICAST
;
3987 if (cast_type
== RTN_ANYCAST
)
3988 return ct
| QETH_CAST_ANYCAST
;
3989 if (cast_type
== RTN_BROADCAST
)
3990 return ct
| QETH_CAST_BROADCAST
;
3991 return ct
| QETH_CAST_UNICAST
;
3995 qeth_layer2_get_packet_type(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
3996 struct sk_buff
*skb
)
4000 if (!memcmp(skb
->data
+QETH_HEADER_SIZE
,
4001 skb
->dev
->broadcast
,6)) { /* broadcast? */
4002 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4003 QETH_LAYER2_FLAG_BROADCAST
<< 8;
4006 hdr_mac
=*((__u16
*)skb
->data
);
4008 switch (card
->info
.link_type
) {
4009 case QETH_LINK_TYPE_HSTR
:
4010 case QETH_LINK_TYPE_LANE_TR
:
4011 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
4012 (hdr_mac
== QETH_TR_MAC_C
) )
4013 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4014 QETH_LAYER2_FLAG_MULTICAST
<< 8;
4016 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4017 QETH_LAYER2_FLAG_UNICAST
<< 8;
4019 /* eth or so multicast? */
4021 if ( (hdr_mac
==QETH_ETH_MAC_V4
) ||
4022 (hdr_mac
==QETH_ETH_MAC_V6
) )
4023 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4024 QETH_LAYER2_FLAG_MULTICAST
<< 8;
4026 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4027 QETH_LAYER2_FLAG_UNICAST
<< 8;
4032 qeth_layer2_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
4033 struct sk_buff
*skb
, int cast_type
)
4035 memset(hdr
, 0, sizeof(struct qeth_hdr
));
4036 hdr
->hdr
.l2
.id
= QETH_HEADER_TYPE_LAYER2
;
4038 /* set byte 0 to "0x02" and byte 3 to casting flags */
4039 if (cast_type
==RTN_MULTICAST
)
4040 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_MULTICAST
<< 8;
4041 else if (cast_type
==RTN_BROADCAST
)
4042 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_BROADCAST
<< 8;
4044 qeth_layer2_get_packet_type(card
, hdr
, skb
);
4046 hdr
->hdr
.l2
.pkt_length
= skb
->len
-QETH_HEADER_SIZE
;
4047 #ifdef CONFIG_QETH_VLAN
4048 /* VSWITCH relies on the VLAN
4049 * information to be present in
4050 * the QDIO header */
4051 if ((card
->vlangrp
!= NULL
) &&
4052 vlan_tx_tag_present(skb
)) {
4053 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_VLAN
<< 8;
4054 hdr
->hdr
.l2
.vlan_id
= vlan_tx_tag_get(skb
);
4060 qeth_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
4061 struct sk_buff
*skb
, int ipv
, int cast_type
)
4063 QETH_DBF_TEXT(trace
, 6, "fillhdr");
4065 memset(hdr
, 0, sizeof(struct qeth_hdr
));
4066 if (card
->options
.layer2
) {
4067 qeth_layer2_fill_header(card
, hdr
, skb
, cast_type
);
4070 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
4071 hdr
->hdr
.l3
.ext_flags
= 0;
4072 #ifdef CONFIG_QETH_VLAN
4074 * before we're going to overwrite this location with next hop ip.
4075 * v6 uses passthrough, v4 sets the tag in the QDIO header.
4077 if (card
->vlangrp
&& vlan_tx_tag_present(skb
)) {
4078 hdr
->hdr
.l3
.ext_flags
= (ipv
== 4) ?
4079 QETH_HDR_EXT_VLAN_FRAME
:
4080 QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
4081 hdr
->hdr
.l3
.vlan_id
= vlan_tx_tag_get(skb
);
4083 #endif /* CONFIG_QETH_VLAN */
4084 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
4085 if (ipv
== 4) { /* IPv4 */
4086 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags4(cast_type
);
4087 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
4088 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
4089 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
4090 *((u32
*) skb
->dst
->neighbour
->primary_key
);
4092 /* fill in destination address used in ip header */
4093 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) = skb
->nh
.iph
->daddr
;
4095 } else if (ipv
== 6) { /* IPv6 or passthru */
4096 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags6(cast_type
);
4097 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
4098 memcpy(hdr
->hdr
.l3
.dest_addr
,
4099 skb
->dst
->neighbour
->primary_key
, 16);
4101 /* fill in destination address used in ip header */
4102 memcpy(hdr
->hdr
.l3
.dest_addr
, &skb
->nh
.ipv6h
->daddr
, 16);
4104 } else { /* passthrough */
4105 if((skb
->dev
->type
== ARPHRD_IEEE802_TR
) &&
4106 !memcmp(skb
->data
+ sizeof(struct qeth_hdr
) +
4107 sizeof(__u16
), skb
->dev
->broadcast
, 6)) {
4108 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
4110 } else if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
4111 skb
->dev
->broadcast
, 6)) { /* broadcast? */
4112 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
4115 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
4116 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
4117 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
4123 __qeth_fill_buffer(struct sk_buff
*skb
, struct qdio_buffer
*buffer
,
4124 int is_tso
, int *next_element_to_fill
)
4126 int length
= skb
->len
;
4132 element
= *next_element_to_fill
;
4134 first_lap
= (is_tso
== 0 ? 1 : 0);
4136 while (length
> 0) {
4137 /* length_here is the remaining amount of data in this page */
4138 length_here
= PAGE_SIZE
- ((unsigned long) data
% PAGE_SIZE
);
4139 if (length
< length_here
)
4140 length_here
= length
;
4142 buffer
->element
[element
].addr
= data
;
4143 buffer
->element
[element
].length
= length_here
;
4144 length
-= length_here
;
4147 buffer
->element
[element
].flags
= 0;
4149 buffer
->element
[element
].flags
=
4150 SBAL_FLAGS_LAST_FRAG
;
4153 buffer
->element
[element
].flags
=
4154 SBAL_FLAGS_FIRST_FRAG
;
4156 buffer
->element
[element
].flags
=
4157 SBAL_FLAGS_MIDDLE_FRAG
;
4159 data
+= length_here
;
4163 *next_element_to_fill
= element
;
4167 qeth_fill_buffer(struct qeth_qdio_out_q
*queue
,
4168 struct qeth_qdio_out_buffer
*buf
,
4169 struct sk_buff
*skb
)
4171 struct qdio_buffer
*buffer
;
4172 struct qeth_hdr_tso
*hdr
;
4173 int flush_cnt
= 0, hdr_len
, large_send
= 0;
4175 QETH_DBF_TEXT(trace
, 6, "qdfillbf");
4177 buffer
= buf
->buffer
;
4178 atomic_inc(&skb
->users
);
4179 skb_queue_tail(&buf
->skb_list
, skb
);
4181 hdr
= (struct qeth_hdr_tso
*) skb
->data
;
4182 /*check first on TSO ....*/
4183 if (hdr
->hdr
.hdr
.l3
.id
== QETH_HEADER_TYPE_TSO
) {
4184 int element
= buf
->next_element_to_fill
;
4186 hdr_len
= sizeof(struct qeth_hdr_tso
) + hdr
->ext
.dg_hdr_len
;
4187 /*fill first buffer entry only with header information */
4188 buffer
->element
[element
].addr
= skb
->data
;
4189 buffer
->element
[element
].length
= hdr_len
;
4190 buffer
->element
[element
].flags
= SBAL_FLAGS_FIRST_FRAG
;
4191 buf
->next_element_to_fill
++;
4192 skb
->data
+= hdr_len
;
4193 skb
->len
-= hdr_len
;
4196 if (skb_shinfo(skb
)->nr_frags
== 0)
4197 __qeth_fill_buffer(skb
, buffer
, large_send
,
4198 (int *)&buf
->next_element_to_fill
);
4200 __qeth_fill_buffer_frag(skb
, buffer
, large_send
,
4201 (int *)&buf
->next_element_to_fill
);
4203 if (!queue
->do_pack
) {
4204 QETH_DBF_TEXT(trace
, 6, "fillbfnp");
4205 /* set state to PRIMED -> will be flushed */
4206 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4209 QETH_DBF_TEXT(trace
, 6, "fillbfpa");
4210 #ifdef CONFIG_QETH_PERF_STATS
4211 queue
->card
->perf_stats
.skbs_sent_pack
++;
4213 if (buf
->next_element_to_fill
>=
4214 QETH_MAX_BUFFER_ELEMENTS(queue
->card
)) {
4216 * packed buffer if full -> set state PRIMED
4217 * -> will be flushed
4219 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4227 qeth_do_send_packet_fast(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4228 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4229 int elements_needed
,
4230 struct qeth_eddp_context
*ctx
)
4232 struct qeth_qdio_out_buffer
*buffer
;
4233 int buffers_needed
= 0;
4237 QETH_DBF_TEXT(trace
, 6, "dosndpfa");
4239 /* spin until we get the queue ... */
4240 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4241 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4242 /* ... now we've got the queue */
4243 index
= queue
->next_buf_to_fill
;
4244 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4246 * check if buffer is empty to make sure that we do not 'overtake'
4247 * ourselves and try to fill a buffer that is already primed
4249 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
) {
4250 card
->stats
.tx_dropped
++;
4251 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4255 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ 1) %
4256 QDIO_MAX_BUFFERS_PER_Q
;
4258 buffers_needed
= qeth_eddp_check_buffers_for_context(queue
,ctx
);
4259 if (buffers_needed
< 0) {
4260 card
->stats
.tx_dropped
++;
4261 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4264 queue
->next_buf_to_fill
=
4265 (queue
->next_buf_to_fill
+ buffers_needed
) %
4266 QDIO_MAX_BUFFERS_PER_Q
;
4268 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4270 qeth_fill_buffer(queue
, buffer
, skb
);
4271 qeth_flush_buffers(queue
, 0, index
, 1);
4273 flush_cnt
= qeth_eddp_fill_buffer(queue
, ctx
, index
);
4274 WARN_ON(buffers_needed
!= flush_cnt
);
4275 qeth_flush_buffers(queue
, 0, index
, flush_cnt
);
4281 qeth_do_send_packet(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4282 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4283 int elements_needed
, struct qeth_eddp_context
*ctx
)
4285 struct qeth_qdio_out_buffer
*buffer
;
4287 int flush_count
= 0;
4292 QETH_DBF_TEXT(trace
, 6, "dosndpkt");
4294 /* spin until we get the queue ... */
4295 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4296 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4297 start_index
= queue
->next_buf_to_fill
;
4298 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4300 * check if buffer is empty to make sure that we do not 'overtake'
4301 * ourselves and try to fill a buffer that is already primed
4303 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
){
4304 card
->stats
.tx_dropped
++;
4305 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4308 /* check if we need to switch packing state of this queue */
4309 qeth_switch_to_packing_if_needed(queue
);
4310 if (queue
->do_pack
){
4313 /* does packet fit in current buffer? */
4314 if((QETH_MAX_BUFFER_ELEMENTS(card
) -
4315 buffer
->next_element_to_fill
) < elements_needed
){
4316 /* ... no -> set state PRIMED */
4317 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
4319 queue
->next_buf_to_fill
=
4320 (queue
->next_buf_to_fill
+ 1) %
4321 QDIO_MAX_BUFFERS_PER_Q
;
4322 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4323 /* we did a step forward, so check buffer state
4325 if (atomic_read(&buffer
->state
) !=
4326 QETH_QDIO_BUF_EMPTY
){
4327 card
->stats
.tx_dropped
++;
4328 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4329 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4334 /* check if we have enough elements (including following
4335 * free buffers) to handle eddp context */
4336 if (qeth_eddp_check_buffers_for_context(queue
,ctx
) < 0){
4337 printk("eddp tx_dropped 1\n");
4338 card
->stats
.tx_dropped
++;
4345 tmp
= qeth_fill_buffer(queue
, buffer
, skb
);
4347 tmp
= qeth_eddp_fill_buffer(queue
,ctx
,queue
->next_buf_to_fill
);
4349 printk("eddp tx_dropped 2\n");
4350 card
->stats
.tx_dropped
++;
4355 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ tmp
) %
4356 QDIO_MAX_BUFFERS_PER_Q
;
4360 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4361 else if (!atomic_read(&queue
->set_pci_flags_count
))
4362 atomic_swap(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
);
4364 * queue->state will go from LOCKED -> UNLOCKED or from
4365 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
4366 * (switch packing state or flush buffer to get another pci flag out).
4367 * In that case we will enter this loop
4369 while (atomic_dec_return(&queue
->state
)){
4371 start_index
= queue
->next_buf_to_fill
;
4372 /* check if we can go back to non-packing state */
4373 flush_count
+= qeth_switch_to_nonpacking_if_needed(queue
);
4375 * check if we need to flush a packing buffer to get a pci
4376 * flag out on the queue
4378 if (!flush_count
&& !atomic_read(&queue
->set_pci_flags_count
))
4379 flush_count
+= qeth_flush_buffers_on_no_pci(queue
);
4381 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4383 /* at this point the queue is UNLOCKED again */
4384 #ifdef CONFIG_QETH_PERF_STATS
4386 queue
->card
->perf_stats
.bufs_sent_pack
+= flush_count
;
4387 #endif /* CONFIG_QETH_PERF_STATS */
4393 qeth_get_elements_no(struct qeth_card
*card
, void *hdr
,
4394 struct sk_buff
*skb
, int elems
)
4396 int elements_needed
= 0;
4398 if (skb_shinfo(skb
)->nr_frags
> 0) {
4399 elements_needed
= (skb_shinfo(skb
)->nr_frags
+ 1);
4401 if (elements_needed
== 0 )
4402 elements_needed
= 1 + (((((unsigned long) hdr
) % PAGE_SIZE
)
4403 + skb
->len
) >> PAGE_SHIFT
);
4404 if ((elements_needed
+ elems
) > QETH_MAX_BUFFER_ELEMENTS(card
)){
4405 PRINT_ERR("qeth_do_send_packet: invalid size of "
4406 "IP packet (Number=%d / Length=%d). Discarded.\n",
4407 (elements_needed
+elems
), skb
->len
);
4410 return elements_needed
;
4414 qeth_send_packet(struct qeth_card
*card
, struct sk_buff
*skb
)
4418 struct qeth_qdio_out_q
*queue
;
4419 struct qeth_hdr
*hdr
= NULL
;
4420 int elements_needed
= 0;
4421 enum qeth_large_send_types large_send
= QETH_LARGE_SEND_NO
;
4422 struct qeth_eddp_context
*ctx
= NULL
;
4423 int tx_bytes
= skb
->len
;
4426 QETH_DBF_TEXT(trace
, 6, "sendpkt");
4428 if (!card
->options
.layer2
) {
4429 ipv
= qeth_get_ip_version(skb
);
4430 if ((card
->dev
->hard_header
== qeth_fake_header
) && ipv
) {
4431 if ((skb
= qeth_pskb_unshare(skb
,GFP_ATOMIC
)) == NULL
) {
4432 card
->stats
.tx_dropped
++;
4433 dev_kfree_skb_irq(skb
);
4436 if(card
->dev
->type
== ARPHRD_IEEE802_TR
){
4437 skb_pull(skb
, QETH_FAKE_LL_LEN_TR
);
4439 skb_pull(skb
, QETH_FAKE_LL_LEN_ETH
);
4443 if ((card
->info
.type
== QETH_CARD_TYPE_OSN
) &&
4444 (skb
->protocol
== htons(ETH_P_IPV6
))) {
4445 dev_kfree_skb_any(skb
);
4448 cast_type
= qeth_get_cast_type(card
, skb
);
4449 if ((cast_type
== RTN_BROADCAST
) &&
4450 (card
->info
.broadcast_capable
== 0)){
4451 card
->stats
.tx_dropped
++;
4452 card
->stats
.tx_errors
++;
4453 dev_kfree_skb_any(skb
);
4454 return NETDEV_TX_OK
;
4456 queue
= card
->qdio
.out_qs
4457 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
4459 if (skb_shinfo(skb
)->tso_size
)
4460 large_send
= card
->options
.large_send
;
4462 /*are we able to do TSO ? If so ,prepare and send it from here */
4463 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
4464 (cast_type
== RTN_UNSPEC
)) {
4465 rc
= qeth_tso_prepare_packet(card
, skb
, ipv
, cast_type
);
4467 card
->stats
.tx_dropped
++;
4468 card
->stats
.tx_errors
++;
4469 dev_kfree_skb_any(skb
);
4470 return NETDEV_TX_OK
;
4474 if ((rc
= qeth_prepare_skb(card
, &skb
, &hdr
, ipv
))) {
4475 QETH_DBF_TEXT_(trace
, 4, "pskbe%d", rc
);
4478 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
4479 qeth_fill_header(card
, hdr
, skb
, ipv
, cast_type
);
4482 if (large_send
== QETH_LARGE_SEND_EDDP
) {
4483 ctx
= qeth_eddp_create_context(card
, skb
, hdr
);
4485 PRINT_WARN("could not create eddp context\n");
4489 int elems
= qeth_get_elements_no(card
,(void*) hdr
, skb
,
4493 elements_needed
+= elems
;
4496 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
4497 rc
= qeth_do_send_packet(card
, queue
, skb
, hdr
,
4498 elements_needed
, ctx
);
4500 rc
= qeth_do_send_packet_fast(card
, queue
, skb
, hdr
,
4501 elements_needed
, ctx
);
4503 card
->stats
.tx_packets
++;
4504 card
->stats
.tx_bytes
+= tx_bytes
;
4505 #ifdef CONFIG_QETH_PERF_STATS
4506 if (skb_shinfo(skb
)->tso_size
&&
4507 !(large_send
== QETH_LARGE_SEND_NO
)) {
4508 card
->perf_stats
.large_send_bytes
+= skb
->len
;
4509 card
->perf_stats
.large_send_cnt
++;
4511 if (skb_shinfo(skb
)->nr_frags
> 0){
4512 card
->perf_stats
.sg_skbs_sent
++;
4513 /* nr_frags + skb->data */
4514 card
->perf_stats
.sg_frags_sent
+=
4515 skb_shinfo(skb
)->nr_frags
+ 1;
4517 #endif /* CONFIG_QETH_PERF_STATS */
4520 /* drop creator's reference */
4521 qeth_eddp_put_context(ctx
);
4522 /* free skb; it's not referenced by a buffer */
4524 dev_kfree_skb_any(skb
);
4531 qeth_mdio_read(struct net_device
*dev
, int phy_id
, int regnum
)
4533 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
4537 case MII_BMCR
: /* Basic mode control register */
4539 if ((card
->info
.link_type
!= QETH_LINK_TYPE_GBIT_ETH
)&&
4540 (card
->info
.link_type
!= QETH_LINK_TYPE_OSN
) &&
4541 (card
->info
.link_type
!= QETH_LINK_TYPE_10GBIT_ETH
))
4542 rc
|= BMCR_SPEED100
;
4544 case MII_BMSR
: /* Basic mode status register */
4545 rc
= BMSR_ERCAP
| BMSR_ANEGCOMPLETE
| BMSR_LSTATUS
|
4546 BMSR_10HALF
| BMSR_10FULL
| BMSR_100HALF
| BMSR_100FULL
|
4549 case MII_PHYSID1
: /* PHYS ID 1 */
4550 rc
= (dev
->dev_addr
[0] << 16) | (dev
->dev_addr
[1] << 8) |
4552 rc
= (rc
>> 5) & 0xFFFF;
4554 case MII_PHYSID2
: /* PHYS ID 2 */
4555 rc
= (dev
->dev_addr
[2] << 10) & 0xFFFF;
4557 case MII_ADVERTISE
: /* Advertisement control reg */
4560 case MII_LPA
: /* Link partner ability reg */
4561 rc
= LPA_10HALF
| LPA_10FULL
| LPA_100HALF
| LPA_100FULL
|
4562 LPA_100BASE4
| LPA_LPACK
;
4564 case MII_EXPANSION
: /* Expansion register */
4566 case MII_DCOUNTER
: /* disconnect counter */
4568 case MII_FCSCOUNTER
: /* false carrier counter */
4570 case MII_NWAYTEST
: /* N-way auto-neg test register */
4572 case MII_RERRCOUNTER
: /* rx error counter */
4573 rc
= card
->stats
.rx_errors
;
4575 case MII_SREVISION
: /* silicon revision */
4577 case MII_RESV1
: /* reserved 1 */
4579 case MII_LBRERROR
: /* loopback, rx, bypass error */
4581 case MII_PHYADDR
: /* physical address */
4583 case MII_RESV2
: /* reserved 2 */
4585 case MII_TPISTATUS
: /* TPI status for 10mbps */
4587 case MII_NCONFIG
: /* network interface config */
4596 static inline const char *
4597 qeth_arp_get_error_cause(int *rc
)
4600 case QETH_IPA_ARP_RC_FAILED
:
4602 return "operation failed";
4603 case QETH_IPA_ARP_RC_NOTSUPP
:
4605 return "operation not supported";
4606 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
4608 return "argument out of range";
4609 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
4611 return "query operation not supported";
4612 case QETH_IPA_ARP_RC_Q_NO_DATA
:
4614 return "no query data available";
4616 return "unknown error";
4621 qeth_send_simple_setassparms(struct qeth_card
*, enum qeth_ipa_funcs
,
4625 qeth_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
4630 QETH_DBF_TEXT(trace
,3,"arpstnoe");
4633 * currently GuestLAN only supports the ARP assist function
4634 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
4635 * thus we say EOPNOTSUPP for this ARP function
4637 if (card
->info
.guestlan
)
4639 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4640 PRINT_WARN("ARP processing not supported "
4641 "on %s!\n", QETH_CARD_IFNAME(card
));
4644 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
4645 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
4649 PRINT_WARN("Could not set number of ARP entries on %s: "
4651 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4658 qeth_copy_arp_entries_stripped(struct qeth_arp_query_info
*qinfo
,
4659 struct qeth_arp_query_data
*qdata
,
4660 int entry_size
, int uentry_size
)
4666 entry_ptr
= (char *)&qdata
->data
;
4667 uentry_ptr
= (char *)(qinfo
->udata
+ qinfo
->udata_offset
);
4668 for (i
= 0; i
< qdata
->no_entries
; ++i
){
4669 /* strip off 32 bytes "media specific information" */
4670 memcpy(uentry_ptr
, (entry_ptr
+ 32), entry_size
- 32);
4671 entry_ptr
+= entry_size
;
4672 uentry_ptr
+= uentry_size
;
4677 qeth_arp_query_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4680 struct qeth_ipa_cmd
*cmd
;
4681 struct qeth_arp_query_data
*qdata
;
4682 struct qeth_arp_query_info
*qinfo
;
4687 QETH_DBF_TEXT(trace
,4,"arpquecb");
4689 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4690 cmd
= (struct qeth_ipa_cmd
*) data
;
4691 if (cmd
->hdr
.return_code
) {
4692 QETH_DBF_TEXT_(trace
,4,"qaer1%i", cmd
->hdr
.return_code
);
4695 if (cmd
->data
.setassparms
.hdr
.return_code
) {
4696 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
4697 QETH_DBF_TEXT_(trace
,4,"qaer2%i", cmd
->hdr
.return_code
);
4700 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
4701 switch(qdata
->reply_bits
){
4703 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry5
);
4704 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4705 uentry_size
= sizeof(struct qeth_arp_qi_entry5_short
);
4708 /* fall through to default */
4710 /* tr is the same as eth -> entry7 */
4711 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry7
);
4712 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4713 uentry_size
= sizeof(struct qeth_arp_qi_entry7_short
);
4716 /* check if there is enough room in userspace */
4717 if ((qinfo
->udata_len
- qinfo
->udata_offset
) <
4718 qdata
->no_entries
* uentry_size
){
4719 QETH_DBF_TEXT_(trace
, 4, "qaer3%i", -ENOMEM
);
4720 cmd
->hdr
.return_code
= -ENOMEM
;
4721 PRINT_WARN("query ARP user space buffer is too small for "
4722 "the returned number of ARP entries. "
4723 "Aborting query!\n");
4726 QETH_DBF_TEXT_(trace
, 4, "anore%i",
4727 cmd
->data
.setassparms
.hdr
.number_of_replies
);
4728 QETH_DBF_TEXT_(trace
, 4, "aseqn%i", cmd
->data
.setassparms
.hdr
.seq_no
);
4729 QETH_DBF_TEXT_(trace
, 4, "anoen%i", qdata
->no_entries
);
4731 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) {
4732 /* strip off "media specific information" */
4733 qeth_copy_arp_entries_stripped(qinfo
, qdata
, entry_size
,
4736 /*copy entries to user buffer*/
4737 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4738 (char *)&qdata
->data
, qdata
->no_entries
*uentry_size
);
4740 qinfo
->no_entries
+= qdata
->no_entries
;
4741 qinfo
->udata_offset
+= (qdata
->no_entries
*uentry_size
);
4742 /* check if all replies received ... */
4743 if (cmd
->data
.setassparms
.hdr
.seq_no
<
4744 cmd
->data
.setassparms
.hdr
.number_of_replies
)
4746 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
4747 /* keep STRIP_ENTRIES flag so the user program can distinguish
4748 * stripped entries from normal ones */
4749 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4750 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
4751 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
,&qdata
->reply_bits
,2);
4755 memcpy(qinfo
->udata
, &i
, 4);
4760 qeth_send_ipa_arp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4761 int len
, int (*reply_cb
)(struct qeth_card
*,
4762 struct qeth_reply
*,
4766 QETH_DBF_TEXT(trace
,4,"sendarp");
4768 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4769 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4770 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4771 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4772 reply_cb
, reply_param
);
4776 qeth_send_ipa_snmp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4777 int len
, int (*reply_cb
)(struct qeth_card
*,
4778 struct qeth_reply
*,
4784 QETH_DBF_TEXT(trace
,4,"sendsnmp");
4786 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4787 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4788 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4789 /* adjust PDU length fields in IPA_PDU_HEADER */
4790 s1
= (u32
) IPA_PDU_HEADER_SIZE
+ len
;
4792 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
4793 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
4794 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
4795 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
4796 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4797 reply_cb
, reply_param
);
4800 static struct qeth_cmd_buffer
*
4801 qeth_get_setassparms_cmd(struct qeth_card
*, enum qeth_ipa_funcs
,
4802 __u16
, __u16
, enum qeth_prot_versions
);
4804 qeth_arp_query(struct qeth_card
*card
, char *udata
)
4806 struct qeth_cmd_buffer
*iob
;
4807 struct qeth_arp_query_info qinfo
= {0, };
4811 QETH_DBF_TEXT(trace
,3,"arpquery");
4813 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
4814 IPA_ARP_PROCESSING
)) {
4815 PRINT_WARN("ARP processing not supported "
4816 "on %s!\n", QETH_CARD_IFNAME(card
));
4819 /* get size of userspace buffer and mask_bits -> 6 bytes */
4820 if (copy_from_user(&qinfo
, udata
, 6))
4822 if (!(qinfo
.udata
= kmalloc(qinfo
.udata_len
, GFP_KERNEL
)))
4824 memset(qinfo
.udata
, 0, qinfo
.udata_len
);
4825 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
4826 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
4827 IPA_CMD_ASS_ARP_QUERY_INFO
,
4828 sizeof(int),QETH_PROT_IPV4
);
4830 rc
= qeth_send_ipa_arp_cmd(card
, iob
,
4831 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
4832 qeth_arp_query_cb
, (void *)&qinfo
);
4835 PRINT_WARN("Error while querying ARP cache on %s: %s "
4837 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4839 copy_to_user(udata
, qinfo
.udata
, 4);
4841 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4848 * SNMP command callback
4851 qeth_snmp_command_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4852 unsigned long sdata
)
4854 struct qeth_ipa_cmd
*cmd
;
4855 struct qeth_arp_query_info
*qinfo
;
4856 struct qeth_snmp_cmd
*snmp
;
4857 unsigned char *data
;
4860 QETH_DBF_TEXT(trace
,3,"snpcmdcb");
4862 cmd
= (struct qeth_ipa_cmd
*) sdata
;
4863 data
= (unsigned char *)((char *)cmd
- reply
->offset
);
4864 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4865 snmp
= &cmd
->data
.setadapterparms
.data
.snmp
;
4867 if (cmd
->hdr
.return_code
) {
4868 QETH_DBF_TEXT_(trace
,4,"scer1%i", cmd
->hdr
.return_code
);
4871 if (cmd
->data
.setadapterparms
.hdr
.return_code
) {
4872 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
4873 QETH_DBF_TEXT_(trace
,4,"scer2%i", cmd
->hdr
.return_code
);
4876 data_len
= *((__u16
*)QETH_IPA_PDU_LEN_PDU1(data
));
4877 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1)
4878 data_len
-= (__u16
)((char *)&snmp
->data
- (char *)cmd
);
4880 data_len
-= (__u16
)((char*)&snmp
->request
- (char *)cmd
);
4882 /* check if there is enough room in userspace */
4883 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < data_len
) {
4884 QETH_DBF_TEXT_(trace
, 4, "scer3%i", -ENOMEM
);
4885 cmd
->hdr
.return_code
= -ENOMEM
;
4888 QETH_DBF_TEXT_(trace
, 4, "snore%i",
4889 cmd
->data
.setadapterparms
.hdr
.used_total
);
4890 QETH_DBF_TEXT_(trace
, 4, "sseqn%i", cmd
->data
.setadapterparms
.hdr
.seq_no
);
4891 /*copy entries to user buffer*/
4892 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1) {
4893 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4895 data_len
+ offsetof(struct qeth_snmp_cmd
,data
));
4896 qinfo
->udata_offset
+= offsetof(struct qeth_snmp_cmd
, data
);
4898 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4899 (char *)&snmp
->request
, data_len
);
4901 qinfo
->udata_offset
+= data_len
;
4902 /* check if all replies received ... */
4903 QETH_DBF_TEXT_(trace
, 4, "srtot%i",
4904 cmd
->data
.setadapterparms
.hdr
.used_total
);
4905 QETH_DBF_TEXT_(trace
, 4, "srseq%i",
4906 cmd
->data
.setadapterparms
.hdr
.seq_no
);
4907 if (cmd
->data
.setadapterparms
.hdr
.seq_no
<
4908 cmd
->data
.setadapterparms
.hdr
.used_total
)
4913 static struct qeth_cmd_buffer
*
4914 qeth_get_ipacmd_buffer(struct qeth_card
*, enum qeth_ipa_cmds
,
4915 enum qeth_prot_versions
);
4917 static struct qeth_cmd_buffer
*
4918 qeth_get_adapter_cmd(struct qeth_card
*card
, __u32 command
, __u32 cmdlen
)
4920 struct qeth_cmd_buffer
*iob
;
4921 struct qeth_ipa_cmd
*cmd
;
4923 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETADAPTERPARMS
,
4925 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4926 cmd
->data
.setadapterparms
.hdr
.cmdlength
= cmdlen
;
4927 cmd
->data
.setadapterparms
.hdr
.command_code
= command
;
4928 cmd
->data
.setadapterparms
.hdr
.used_total
= 1;
4929 cmd
->data
.setadapterparms
.hdr
.seq_no
= 1;
4935 * function to send SNMP commands to OSA-E card
4938 qeth_snmp_command(struct qeth_card
*card
, char *udata
)
4940 struct qeth_cmd_buffer
*iob
;
4941 struct qeth_ipa_cmd
*cmd
;
4942 struct qeth_snmp_ureq
*ureq
;
4944 struct qeth_arp_query_info qinfo
= {0, };
4947 QETH_DBF_TEXT(trace
,3,"snmpcmd");
4949 if (card
->info
.guestlan
)
4952 if ((!qeth_adp_supported(card
,IPA_SETADP_SET_SNMP_CONTROL
)) &&
4953 (!card
->options
.layer2
) ) {
4954 PRINT_WARN("SNMP Query MIBS not supported "
4955 "on %s!\n", QETH_CARD_IFNAME(card
));
4958 /* skip 4 bytes (data_len struct member) to get req_len */
4959 if (copy_from_user(&req_len
, udata
+ sizeof(int), sizeof(int)))
4961 ureq
= kmalloc(req_len
+sizeof(struct qeth_snmp_ureq_hdr
), GFP_KERNEL
);
4963 QETH_DBF_TEXT(trace
, 2, "snmpnome");
4966 if (copy_from_user(ureq
, udata
,
4967 req_len
+sizeof(struct qeth_snmp_ureq_hdr
))){
4971 qinfo
.udata_len
= ureq
->hdr
.data_len
;
4972 if (!(qinfo
.udata
= kmalloc(qinfo
.udata_len
, GFP_KERNEL
))){
4976 memset(qinfo
.udata
, 0, qinfo
.udata_len
);
4977 qinfo
.udata_offset
= sizeof(struct qeth_snmp_ureq_hdr
);
4979 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_SNMP_CONTROL
,
4980 QETH_SNMP_SETADP_CMDLENGTH
+ req_len
);
4981 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4982 memcpy(&cmd
->data
.setadapterparms
.data
.snmp
, &ureq
->cmd
, req_len
);
4983 rc
= qeth_send_ipa_snmp_cmd(card
, iob
, QETH_SETADP_BASE_LEN
+ req_len
,
4984 qeth_snmp_command_cb
, (void *)&qinfo
);
4986 PRINT_WARN("SNMP command failed on %s: (0x%x)\n",
4987 QETH_CARD_IFNAME(card
), rc
);
4989 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4997 qeth_default_setassparms_cb(struct qeth_card
*, struct qeth_reply
*,
5001 qeth_default_setadapterparms_cb(struct qeth_card
*card
,
5002 struct qeth_reply
*reply
,
5003 unsigned long data
);
5005 qeth_send_setassparms(struct qeth_card
*, struct qeth_cmd_buffer
*,
5008 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
5012 qeth_arp_add_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
5014 struct qeth_cmd_buffer
*iob
;
5019 QETH_DBF_TEXT(trace
,3,"arpadent");
5022 * currently GuestLAN only supports the ARP assist function
5023 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
5024 * thus we say EOPNOTSUPP for this ARP function
5026 if (card
->info
.guestlan
)
5028 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5029 PRINT_WARN("ARP processing not supported "
5030 "on %s!\n", QETH_CARD_IFNAME(card
));
5034 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
5035 IPA_CMD_ASS_ARP_ADD_ENTRY
,
5036 sizeof(struct qeth_arp_cache_entry
),
5038 rc
= qeth_send_setassparms(card
, iob
,
5039 sizeof(struct qeth_arp_cache_entry
),
5040 (unsigned long) entry
,
5041 qeth_default_setassparms_cb
, NULL
);
5044 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
5045 PRINT_WARN("Could not add ARP entry for address %s on %s: "
5047 buf
, QETH_CARD_IFNAME(card
),
5048 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
5054 qeth_arp_remove_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
5056 struct qeth_cmd_buffer
*iob
;
5057 char buf
[16] = {0, };
5061 QETH_DBF_TEXT(trace
,3,"arprment");
5064 * currently GuestLAN only supports the ARP assist function
5065 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
5066 * thus we say EOPNOTSUPP for this ARP function
5068 if (card
->info
.guestlan
)
5070 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5071 PRINT_WARN("ARP processing not supported "
5072 "on %s!\n", QETH_CARD_IFNAME(card
));
5075 memcpy(buf
, entry
, 12);
5076 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
5077 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
5080 rc
= qeth_send_setassparms(card
, iob
,
5081 12, (unsigned long)buf
,
5082 qeth_default_setassparms_cb
, NULL
);
5086 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
5087 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
5089 buf
, QETH_CARD_IFNAME(card
),
5090 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
5096 qeth_arp_flush_cache(struct qeth_card
*card
)
5101 QETH_DBF_TEXT(trace
,3,"arpflush");
5104 * currently GuestLAN only supports the ARP assist function
5105 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
5106 * thus we say EOPNOTSUPP for this ARP function
5108 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
5110 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5111 PRINT_WARN("ARP processing not supported "
5112 "on %s!\n", QETH_CARD_IFNAME(card
));
5115 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
5116 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
5119 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
5120 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
5127 qeth_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
5129 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5130 struct qeth_arp_cache_entry arp_entry
;
5131 struct mii_ioctl_data
*mii_data
;
5137 if ((card
->state
!= CARD_STATE_UP
) &&
5138 (card
->state
!= CARD_STATE_SOFTSETUP
))
5141 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
5145 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
5146 if ( !capable(CAP_NET_ADMIN
) ||
5147 (card
->options
.layer2
) ) {
5151 rc
= qeth_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
5153 case SIOC_QETH_ARP_QUERY_INFO
:
5154 if ( !capable(CAP_NET_ADMIN
) ||
5155 (card
->options
.layer2
) ) {
5159 rc
= qeth_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
5161 case SIOC_QETH_ARP_ADD_ENTRY
:
5162 if ( !capable(CAP_NET_ADMIN
) ||
5163 (card
->options
.layer2
) ) {
5167 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
5168 sizeof(struct qeth_arp_cache_entry
)))
5171 rc
= qeth_arp_add_entry(card
, &arp_entry
);
5173 case SIOC_QETH_ARP_REMOVE_ENTRY
:
5174 if ( !capable(CAP_NET_ADMIN
) ||
5175 (card
->options
.layer2
) ) {
5179 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
5180 sizeof(struct qeth_arp_cache_entry
)))
5183 rc
= qeth_arp_remove_entry(card
, &arp_entry
);
5185 case SIOC_QETH_ARP_FLUSH_CACHE
:
5186 if ( !capable(CAP_NET_ADMIN
) ||
5187 (card
->options
.layer2
) ) {
5191 rc
= qeth_arp_flush_cache(card
);
5193 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
5194 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
5196 case SIOC_QETH_GET_CARD_TYPE
:
5197 if ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
5198 !card
->info
.guestlan
)
5203 mii_data
= if_mii(rq
);
5204 mii_data
->phy_id
= 0;
5207 mii_data
= if_mii(rq
);
5208 if (mii_data
->phy_id
!= 0)
5211 mii_data
->val_out
= qeth_mdio_read(dev
,mii_data
->phy_id
,
5218 QETH_DBF_TEXT_(trace
, 2, "ioce%d", rc
);
5222 static struct net_device_stats
*
5223 qeth_get_stats(struct net_device
*dev
)
5225 struct qeth_card
*card
;
5227 card
= (struct qeth_card
*) (dev
->priv
);
5229 QETH_DBF_TEXT(trace
,5,"getstat");
5231 return &card
->stats
;
5235 qeth_change_mtu(struct net_device
*dev
, int new_mtu
)
5237 struct qeth_card
*card
;
5240 card
= (struct qeth_card
*) (dev
->priv
);
5242 QETH_DBF_TEXT(trace
,4,"chgmtu");
5243 sprintf(dbf_text
, "%8x", new_mtu
);
5244 QETH_DBF_TEXT(trace
,4,dbf_text
);
5248 if (new_mtu
> 65535)
5250 if ((!qeth_is_supported(card
,IPA_IP_FRAGMENTATION
)) &&
5251 (!qeth_mtu_is_valid(card
, new_mtu
)))
5257 #ifdef CONFIG_QETH_VLAN
5259 qeth_vlan_rx_register(struct net_device
*dev
, struct vlan_group
*grp
)
5261 struct qeth_card
*card
;
5262 unsigned long flags
;
5264 QETH_DBF_TEXT(trace
,4,"vlanreg");
5266 card
= (struct qeth_card
*) dev
->priv
;
5267 spin_lock_irqsave(&card
->vlanlock
, flags
);
5268 card
->vlangrp
= grp
;
5269 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5273 qeth_free_vlan_buffer(struct qeth_card
*card
, struct qeth_qdio_out_buffer
*buf
,
5277 struct sk_buff
*skb
;
5278 struct sk_buff_head tmp_list
;
5280 skb_queue_head_init(&tmp_list
);
5281 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
5282 while ((skb
= skb_dequeue(&buf
->skb_list
))){
5283 if (vlan_tx_tag_present(skb
) &&
5284 (vlan_tx_tag_get(skb
) == vid
)) {
5285 atomic_dec(&skb
->users
);
5288 skb_queue_tail(&tmp_list
, skb
);
5291 while ((skb
= skb_dequeue(&tmp_list
)))
5292 skb_queue_tail(&buf
->skb_list
, skb
);
5296 qeth_free_vlan_skbs(struct qeth_card
*card
, unsigned short vid
)
5300 QETH_DBF_TEXT(trace
, 4, "frvlskbs");
5301 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
5302 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
5303 qeth_free_vlan_buffer(card
, &card
->qdio
.
5304 out_qs
[i
]->bufs
[j
], vid
);
5309 qeth_free_vlan_addresses4(struct qeth_card
*card
, unsigned short vid
)
5311 struct in_device
*in_dev
;
5312 struct in_ifaddr
*ifa
;
5313 struct qeth_ipaddr
*addr
;
5315 QETH_DBF_TEXT(trace
, 4, "frvaddr4");
5318 in_dev
= __in_dev_get_rcu(card
->vlangrp
->vlan_devices
[vid
]);
5321 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
5322 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5324 addr
->u
.a4
.addr
= ifa
->ifa_address
;
5325 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
5326 addr
->type
= QETH_IP_TYPE_NORMAL
;
5327 if (!qeth_delete_ip(card
, addr
))
5336 qeth_free_vlan_addresses6(struct qeth_card
*card
, unsigned short vid
)
5338 #ifdef CONFIG_QETH_IPV6
5339 struct inet6_dev
*in6_dev
;
5340 struct inet6_ifaddr
*ifa
;
5341 struct qeth_ipaddr
*addr
;
5343 QETH_DBF_TEXT(trace
, 4, "frvaddr6");
5345 in6_dev
= in6_dev_get(card
->vlangrp
->vlan_devices
[vid
]);
5348 for (ifa
= in6_dev
->addr_list
; ifa
; ifa
= ifa
->lst_next
){
5349 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5351 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
5352 sizeof(struct in6_addr
));
5353 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
5354 addr
->type
= QETH_IP_TYPE_NORMAL
;
5355 if (!qeth_delete_ip(card
, addr
))
5359 in6_dev_put(in6_dev
);
5360 #endif /* CONFIG_QETH_IPV6 */
5364 qeth_free_vlan_addresses(struct qeth_card
*card
, unsigned short vid
)
5366 if (card
->options
.layer2
|| !card
->vlangrp
)
5368 qeth_free_vlan_addresses4(card
, vid
);
5369 qeth_free_vlan_addresses6(card
, vid
);
5373 qeth_layer2_send_setdelvlan_cb(struct qeth_card
*card
,
5374 struct qeth_reply
*reply
,
5377 struct qeth_ipa_cmd
*cmd
;
5379 QETH_DBF_TEXT(trace
, 2, "L2sdvcb");
5380 cmd
= (struct qeth_ipa_cmd
*) data
;
5381 if (cmd
->hdr
.return_code
) {
5382 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5383 "Continuing\n",cmd
->data
.setdelvlan
.vlan_id
,
5384 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
5385 QETH_DBF_TEXT_(trace
, 2, "L2VL%4x", cmd
->hdr
.command
);
5386 QETH_DBF_TEXT_(trace
, 2, "L2%s", CARD_BUS_ID(card
));
5387 QETH_DBF_TEXT_(trace
, 2, "err%d", cmd
->hdr
.return_code
);
5393 qeth_layer2_send_setdelvlan(struct qeth_card
*card
, __u16 i
,
5394 enum qeth_ipa_cmds ipacmd
)
5396 struct qeth_ipa_cmd
*cmd
;
5397 struct qeth_cmd_buffer
*iob
;
5399 QETH_DBF_TEXT_(trace
, 4, "L2sdv%x",ipacmd
);
5400 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5401 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5402 cmd
->data
.setdelvlan
.vlan_id
= i
;
5403 return qeth_send_ipa_cmd(card
, iob
,
5404 qeth_layer2_send_setdelvlan_cb
, NULL
);
5408 qeth_layer2_process_vlans(struct qeth_card
*card
, int clear
)
5412 QETH_DBF_TEXT(trace
, 3, "L2prcvln");
5416 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5417 if (card
->vlangrp
->vlan_devices
[i
] == NULL
)
5420 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_DELVLAN
);
5422 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_SETVLAN
);
5426 /*add_vid is layer 2 used only ....*/
5428 qeth_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
5430 struct qeth_card
*card
;
5432 QETH_DBF_TEXT_(trace
, 4, "aid:%d", vid
);
5434 card
= (struct qeth_card
*) dev
->priv
;
5435 if (!card
->options
.layer2
)
5437 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_SETVLAN
);
5440 /*... kill_vid used for both modes*/
5442 qeth_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
5444 struct qeth_card
*card
;
5445 unsigned long flags
;
5447 QETH_DBF_TEXT_(trace
, 4, "kid:%d", vid
);
5449 card
= (struct qeth_card
*) dev
->priv
;
5450 /* free all skbs for the vlan device */
5451 qeth_free_vlan_skbs(card
, vid
);
5452 spin_lock_irqsave(&card
->vlanlock
, flags
);
5453 /* unregister IP addresses of vlan device */
5454 qeth_free_vlan_addresses(card
, vid
);
5456 card
->vlangrp
->vlan_devices
[vid
] = NULL
;
5457 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5458 if (card
->options
.layer2
)
5459 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_DELVLAN
);
5460 qeth_set_multicast_list(card
->dev
);
5464 * Examine hardware response to SET_PROMISC_MODE
5467 qeth_setadp_promisc_mode_cb(struct qeth_card
*card
,
5468 struct qeth_reply
*reply
,
5471 struct qeth_ipa_cmd
*cmd
;
5472 struct qeth_ipacmd_setadpparms
*setparms
;
5474 QETH_DBF_TEXT(trace
,4,"prmadpcb");
5476 cmd
= (struct qeth_ipa_cmd
*) data
;
5477 setparms
= &(cmd
->data
.setadapterparms
);
5479 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
5480 if (cmd
->hdr
.return_code
) {
5481 QETH_DBF_TEXT_(trace
,4,"prmrc%2.2x",cmd
->hdr
.return_code
);
5482 setparms
->data
.mode
= SET_PROMISC_MODE_OFF
;
5484 card
->info
.promisc_mode
= setparms
->data
.mode
;
5488 * Set promiscuous mode (on or off) (SET_PROMISC_MODE command)
5491 qeth_setadp_promisc_mode(struct qeth_card
*card
)
5493 enum qeth_ipa_promisc_modes mode
;
5494 struct net_device
*dev
= card
->dev
;
5495 struct qeth_cmd_buffer
*iob
;
5496 struct qeth_ipa_cmd
*cmd
;
5498 QETH_DBF_TEXT(trace
, 4, "setprom");
5500 if (((dev
->flags
& IFF_PROMISC
) &&
5501 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
5502 (!(dev
->flags
& IFF_PROMISC
) &&
5503 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
5505 mode
= SET_PROMISC_MODE_OFF
;
5506 if (dev
->flags
& IFF_PROMISC
)
5507 mode
= SET_PROMISC_MODE_ON
;
5508 QETH_DBF_TEXT_(trace
, 4, "mode:%x", mode
);
5510 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_PROMISC_MODE
,
5511 sizeof(struct qeth_ipacmd_setadpparms
));
5512 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+ IPA_PDU_HEADER_SIZE
);
5513 cmd
->data
.setadapterparms
.data
.mode
= mode
;
5514 qeth_send_ipa_cmd(card
, iob
, qeth_setadp_promisc_mode_cb
, NULL
);
5518 * set multicast address on card
5521 qeth_set_multicast_list(struct net_device
*dev
)
5523 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
5525 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
5528 QETH_DBF_TEXT(trace
, 3, "setmulti");
5529 qeth_delete_mc_addresses(card
);
5530 if (card
->options
.layer2
) {
5531 qeth_layer2_add_multicast(card
);
5534 qeth_add_multicast_ipv4(card
);
5535 #ifdef CONFIG_QETH_IPV6
5536 qeth_add_multicast_ipv6(card
);
5539 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
5540 schedule_work(&card
->kernel_thread_starter
);
5541 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
5543 if (qeth_set_thread_start_bit(card
, QETH_SET_PROMISC_MODE_THREAD
)==0)
5544 schedule_work(&card
->kernel_thread_starter
);
5548 qeth_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
5554 qeth_get_mac_for_ipm(__u32 ipm
, char *mac
, struct net_device
*dev
)
5556 if (dev
->type
== ARPHRD_IEEE802_TR
)
5557 ip_tr_mc_map(ipm
, mac
);
5559 ip_eth_mc_map(ipm
, mac
);
5562 static struct qeth_ipaddr
*
5563 qeth_get_addr_buffer(enum qeth_prot_versions prot
)
5565 struct qeth_ipaddr
*addr
;
5567 addr
= kmalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
5569 PRINT_WARN("Not enough memory to add address\n");
5572 memset(addr
,0,sizeof(struct qeth_ipaddr
));
5573 addr
->type
= QETH_IP_TYPE_NORMAL
;
5579 qeth_osn_assist(struct net_device
*dev
,
5583 struct qeth_cmd_buffer
*iob
;
5584 struct qeth_card
*card
;
5587 QETH_DBF_TEXT(trace
, 2, "osnsdmc");
5590 card
= (struct qeth_card
*)dev
->priv
;
5593 if ((card
->state
!= CARD_STATE_UP
) &&
5594 (card
->state
!= CARD_STATE_SOFTSETUP
))
5596 iob
= qeth_wait_for_buffer(&card
->write
);
5597 memcpy(iob
->data
+IPA_PDU_HEADER_SIZE
, data
, data_len
);
5598 rc
= qeth_osn_send_ipa_cmd(card
, iob
, data_len
);
5602 static struct net_device
*
5603 qeth_netdev_by_devno(unsigned char *read_dev_no
)
5605 struct qeth_card
*card
;
5606 struct net_device
*ndev
;
5607 unsigned char *readno
;
5608 __u16 temp_dev_no
, card_dev_no
;
5610 unsigned long flags
;
5613 memcpy(&temp_dev_no
, read_dev_no
, 2);
5614 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
5615 list_for_each_entry(card
, &qeth_card_list
.list
, list
) {
5616 readno
= CARD_RDEV_ID(card
);
5617 readno
+= (strlen(readno
) - 4);
5618 card_dev_no
= simple_strtoul(readno
, &endp
, 16);
5619 if (card_dev_no
== temp_dev_no
) {
5624 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
5629 qeth_osn_register(unsigned char *read_dev_no
,
5630 struct net_device
**dev
,
5631 int (*assist_cb
)(struct net_device
*, void *),
5632 int (*data_cb
)(struct sk_buff
*))
5634 struct qeth_card
* card
;
5636 QETH_DBF_TEXT(trace
, 2, "osnreg");
5637 *dev
= qeth_netdev_by_devno(read_dev_no
);
5640 card
= (struct qeth_card
*)(*dev
)->priv
;
5643 if ((assist_cb
== NULL
) || (data_cb
== NULL
))
5645 card
->osn_info
.assist_cb
= assist_cb
;
5646 card
->osn_info
.data_cb
= data_cb
;
5651 qeth_osn_deregister(struct net_device
* dev
)
5653 struct qeth_card
*card
;
5655 QETH_DBF_TEXT(trace
, 2, "osndereg");
5658 card
= (struct qeth_card
*)dev
->priv
;
5661 card
->osn_info
.assist_cb
= NULL
;
5662 card
->osn_info
.data_cb
= NULL
;
5667 qeth_delete_mc_addresses(struct qeth_card
*card
)
5669 struct qeth_ipaddr
*iptodo
;
5670 unsigned long flags
;
5672 QETH_DBF_TEXT(trace
,4,"delmc");
5673 iptodo
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5675 QETH_DBF_TEXT(trace
, 2, "dmcnomem");
5678 iptodo
->type
= QETH_IP_TYPE_DEL_ALL_MC
;
5679 spin_lock_irqsave(&card
->ip_lock
, flags
);
5680 if (!__qeth_insert_ip_todo(card
, iptodo
, 0))
5682 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
5686 qeth_add_mc(struct qeth_card
*card
, struct in_device
*in4_dev
)
5688 struct qeth_ipaddr
*ipm
;
5689 struct ip_mc_list
*im4
;
5690 char buf
[MAX_ADDR_LEN
];
5692 QETH_DBF_TEXT(trace
,4,"addmc");
5693 for (im4
= in4_dev
->mc_list
; im4
; im4
= im4
->next
) {
5694 qeth_get_mac_for_ipm(im4
->multiaddr
, buf
, in4_dev
->dev
);
5695 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5698 ipm
->u
.a4
.addr
= im4
->multiaddr
;
5699 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5700 ipm
->is_multicast
= 1;
5701 if (!qeth_add_ip(card
,ipm
))
5707 qeth_add_vlan_mc(struct qeth_card
*card
)
5709 #ifdef CONFIG_QETH_VLAN
5710 struct in_device
*in_dev
;
5711 struct vlan_group
*vg
;
5714 QETH_DBF_TEXT(trace
,4,"addmcvl");
5715 if ( ((card
->options
.layer2
== 0) &&
5716 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5717 (card
->vlangrp
== NULL
) )
5721 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5722 if (vg
->vlan_devices
[i
] == NULL
||
5723 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5725 in_dev
= in_dev_get(vg
->vlan_devices
[i
]);
5728 read_lock(&in_dev
->mc_list_lock
);
5729 qeth_add_mc(card
,in_dev
);
5730 read_unlock(&in_dev
->mc_list_lock
);
5737 qeth_add_multicast_ipv4(struct qeth_card
*card
)
5739 struct in_device
*in4_dev
;
5741 QETH_DBF_TEXT(trace
,4,"chkmcv4");
5742 in4_dev
= in_dev_get(card
->dev
);
5743 if (in4_dev
== NULL
)
5745 read_lock(&in4_dev
->mc_list_lock
);
5746 qeth_add_mc(card
, in4_dev
);
5747 qeth_add_vlan_mc(card
);
5748 read_unlock(&in4_dev
->mc_list_lock
);
5749 in_dev_put(in4_dev
);
5753 qeth_layer2_add_multicast(struct qeth_card
*card
)
5755 struct qeth_ipaddr
*ipm
;
5756 struct dev_mc_list
*dm
;
5758 QETH_DBF_TEXT(trace
,4,"L2addmc");
5759 for (dm
= card
->dev
->mc_list
; dm
; dm
= dm
->next
) {
5760 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5763 memcpy(ipm
->mac
,dm
->dmi_addr
,MAX_ADDR_LEN
);
5764 ipm
->is_multicast
= 1;
5765 if (!qeth_add_ip(card
, ipm
))
5770 #ifdef CONFIG_QETH_IPV6
5772 qeth_add_mc6(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
5774 struct qeth_ipaddr
*ipm
;
5775 struct ifmcaddr6
*im6
;
5776 char buf
[MAX_ADDR_LEN
];
5778 QETH_DBF_TEXT(trace
,4,"addmc6");
5779 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
5780 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
5781 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5784 ipm
->is_multicast
= 1;
5785 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5786 memcpy(&ipm
->u
.a6
.addr
,&im6
->mca_addr
.s6_addr
,
5787 sizeof(struct in6_addr
));
5788 if (!qeth_add_ip(card
,ipm
))
5794 qeth_add_vlan_mc6(struct qeth_card
*card
)
5796 #ifdef CONFIG_QETH_VLAN
5797 struct inet6_dev
*in_dev
;
5798 struct vlan_group
*vg
;
5801 QETH_DBF_TEXT(trace
,4,"admc6vl");
5802 if ( ((card
->options
.layer2
== 0) &&
5803 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5804 (card
->vlangrp
== NULL
))
5808 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5809 if (vg
->vlan_devices
[i
] == NULL
||
5810 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5812 in_dev
= in6_dev_get(vg
->vlan_devices
[i
]);
5815 read_lock(&in_dev
->lock
);
5816 qeth_add_mc6(card
,in_dev
);
5817 read_unlock(&in_dev
->lock
);
5818 in6_dev_put(in_dev
);
5820 #endif /* CONFIG_QETH_VLAN */
5824 qeth_add_multicast_ipv6(struct qeth_card
*card
)
5826 struct inet6_dev
*in6_dev
;
5828 QETH_DBF_TEXT(trace
,4,"chkmcv6");
5829 if (!qeth_is_supported(card
, IPA_IPV6
))
5831 in6_dev
= in6_dev_get(card
->dev
);
5832 if (in6_dev
== NULL
)
5834 read_lock(&in6_dev
->lock
);
5835 qeth_add_mc6(card
, in6_dev
);
5836 qeth_add_vlan_mc6(card
);
5837 read_unlock(&in6_dev
->lock
);
5838 in6_dev_put(in6_dev
);
5840 #endif /* CONFIG_QETH_IPV6 */
5843 qeth_layer2_send_setdelmac(struct qeth_card
*card
, __u8
*mac
,
5844 enum qeth_ipa_cmds ipacmd
,
5845 int (*reply_cb
) (struct qeth_card
*,
5849 struct qeth_ipa_cmd
*cmd
;
5850 struct qeth_cmd_buffer
*iob
;
5852 QETH_DBF_TEXT(trace
, 2, "L2sdmac");
5853 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5854 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5855 cmd
->data
.setdelmac
.mac_length
= OSA_ADDR_LEN
;
5856 memcpy(&cmd
->data
.setdelmac
.mac
, mac
, OSA_ADDR_LEN
);
5857 return qeth_send_ipa_cmd(card
, iob
, reply_cb
, NULL
);
5861 qeth_layer2_send_setgroupmac_cb(struct qeth_card
*card
,
5862 struct qeth_reply
*reply
,
5865 struct qeth_ipa_cmd
*cmd
;
5868 QETH_DBF_TEXT(trace
, 2, "L2Sgmacb");
5869 cmd
= (struct qeth_ipa_cmd
*) data
;
5870 mac
= &cmd
->data
.setdelmac
.mac
[0];
5871 /* MAC already registered, needed in couple/uncouple case */
5872 if (cmd
->hdr
.return_code
== 0x2005) {
5873 PRINT_WARN("Group MAC %02x:%02x:%02x:%02x:%02x:%02x " \
5874 "already existing on %s \n",
5875 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5876 QETH_CARD_IFNAME(card
));
5877 cmd
->hdr
.return_code
= 0;
5879 if (cmd
->hdr
.return_code
)
5880 PRINT_ERR("Could not set group MAC " \
5881 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5882 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5883 QETH_CARD_IFNAME(card
),cmd
->hdr
.return_code
);
5888 qeth_layer2_send_setgroupmac(struct qeth_card
*card
, __u8
*mac
)
5890 QETH_DBF_TEXT(trace
, 2, "L2Sgmac");
5891 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETGMAC
,
5892 qeth_layer2_send_setgroupmac_cb
);
5896 qeth_layer2_send_delgroupmac_cb(struct qeth_card
*card
,
5897 struct qeth_reply
*reply
,
5900 struct qeth_ipa_cmd
*cmd
;
5903 QETH_DBF_TEXT(trace
, 2, "L2Dgmacb");
5904 cmd
= (struct qeth_ipa_cmd
*) data
;
5905 mac
= &cmd
->data
.setdelmac
.mac
[0];
5906 if (cmd
->hdr
.return_code
)
5907 PRINT_ERR("Could not delete group MAC " \
5908 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5909 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5910 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
5915 qeth_layer2_send_delgroupmac(struct qeth_card
*card
, __u8
*mac
)
5917 QETH_DBF_TEXT(trace
, 2, "L2Dgmac");
5918 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELGMAC
,
5919 qeth_layer2_send_delgroupmac_cb
);
5923 qeth_layer2_send_setmac_cb(struct qeth_card
*card
,
5924 struct qeth_reply
*reply
,
5927 struct qeth_ipa_cmd
*cmd
;
5929 QETH_DBF_TEXT(trace
, 2, "L2Smaccb");
5930 cmd
= (struct qeth_ipa_cmd
*) data
;
5931 if (cmd
->hdr
.return_code
) {
5932 QETH_DBF_TEXT_(trace
, 2, "L2er%x", cmd
->hdr
.return_code
);
5933 PRINT_WARN("Error in registering MAC address on " \
5934 "device %s: x%x\n", CARD_BUS_ID(card
),
5935 cmd
->hdr
.return_code
);
5936 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
5937 cmd
->hdr
.return_code
= -EIO
;
5939 card
->info
.mac_bits
|= QETH_LAYER2_MAC_REGISTERED
;
5940 memcpy(card
->dev
->dev_addr
,cmd
->data
.setdelmac
.mac
,
5942 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
5943 "successfully registered on device %s\n",
5944 card
->dev
->dev_addr
[0], card
->dev
->dev_addr
[1],
5945 card
->dev
->dev_addr
[2], card
->dev
->dev_addr
[3],
5946 card
->dev
->dev_addr
[4], card
->dev
->dev_addr
[5],
5953 qeth_layer2_send_setmac(struct qeth_card
*card
, __u8
*mac
)
5955 QETH_DBF_TEXT(trace
, 2, "L2Setmac");
5956 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
,
5957 qeth_layer2_send_setmac_cb
);
5961 qeth_layer2_send_delmac_cb(struct qeth_card
*card
,
5962 struct qeth_reply
*reply
,
5965 struct qeth_ipa_cmd
*cmd
;
5967 QETH_DBF_TEXT(trace
, 2, "L2Dmaccb");
5968 cmd
= (struct qeth_ipa_cmd
*) data
;
5969 if (cmd
->hdr
.return_code
) {
5970 PRINT_WARN("Error in deregistering MAC address on " \
5971 "device %s: x%x\n", CARD_BUS_ID(card
),
5972 cmd
->hdr
.return_code
);
5973 QETH_DBF_TEXT_(trace
, 2, "err%d", cmd
->hdr
.return_code
);
5974 cmd
->hdr
.return_code
= -EIO
;
5977 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
5982 qeth_layer2_send_delmac(struct qeth_card
*card
, __u8
*mac
)
5984 QETH_DBF_TEXT(trace
, 2, "L2Delmac");
5985 if (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))
5987 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELVMAC
,
5988 qeth_layer2_send_delmac_cb
);
5992 qeth_layer2_set_mac_address(struct net_device
*dev
, void *p
)
5994 struct sockaddr
*addr
= p
;
5995 struct qeth_card
*card
;
5998 QETH_DBF_TEXT(trace
, 3, "setmac");
6000 if (qeth_verify_dev(dev
) != QETH_REAL_CARD
) {
6001 QETH_DBF_TEXT(trace
, 3, "setmcINV");
6004 card
= (struct qeth_card
*) dev
->priv
;
6006 if (!card
->options
.layer2
) {
6007 PRINT_WARN("Setting MAC address on %s is not supported "
6008 "in Layer 3 mode.\n", dev
->name
);
6009 QETH_DBF_TEXT(trace
, 3, "setmcLY3");
6012 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
6013 PRINT_WARN("Setting MAC address on %s is not supported.\n",
6015 QETH_DBF_TEXT(trace
, 3, "setmcOSN");
6018 QETH_DBF_TEXT_(trace
, 3, "%s", CARD_BUS_ID(card
));
6019 QETH_DBF_HEX(trace
, 3, addr
->sa_data
, OSA_ADDR_LEN
);
6020 rc
= qeth_layer2_send_delmac(card
, &card
->dev
->dev_addr
[0]);
6022 rc
= qeth_layer2_send_setmac(card
, addr
->sa_data
);
6027 qeth_fill_ipacmd_header(struct qeth_card
*card
, struct qeth_ipa_cmd
*cmd
,
6028 __u8 command
, enum qeth_prot_versions prot
)
6030 memset(cmd
, 0, sizeof (struct qeth_ipa_cmd
));
6031 cmd
->hdr
.command
= command
;
6032 cmd
->hdr
.initiator
= IPA_CMD_INITIATOR_HOST
;
6033 cmd
->hdr
.seqno
= card
->seqno
.ipa
;
6034 cmd
->hdr
.adapter_type
= qeth_get_ipa_adp_type(card
->info
.link_type
);
6035 cmd
->hdr
.rel_adapter_no
= (__u8
) card
->info
.portno
;
6036 if (card
->options
.layer2
)
6037 cmd
->hdr
.prim_version_no
= 2;
6039 cmd
->hdr
.prim_version_no
= 1;
6040 cmd
->hdr
.param_count
= 1;
6041 cmd
->hdr
.prot_version
= prot
;
6042 cmd
->hdr
.ipa_supported
= 0;
6043 cmd
->hdr
.ipa_enabled
= 0;
6046 static struct qeth_cmd_buffer
*
6047 qeth_get_ipacmd_buffer(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
6048 enum qeth_prot_versions prot
)
6050 struct qeth_cmd_buffer
*iob
;
6051 struct qeth_ipa_cmd
*cmd
;
6053 iob
= qeth_wait_for_buffer(&card
->write
);
6054 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6055 qeth_fill_ipacmd_header(card
, cmd
, ipacmd
, prot
);
6061 qeth_send_setdelmc(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int ipacmd
)
6064 struct qeth_cmd_buffer
*iob
;
6065 struct qeth_ipa_cmd
*cmd
;
6067 QETH_DBF_TEXT(trace
,4,"setdelmc");
6069 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
6070 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6071 memcpy(&cmd
->data
.setdelipm
.mac
,addr
->mac
, OSA_ADDR_LEN
);
6072 if (addr
->proto
== QETH_PROT_IPV6
)
6073 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
6074 sizeof(struct in6_addr
));
6076 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
,4);
6078 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6083 qeth_fill_netmask(u8
*netmask
, unsigned int len
)
6086 for (i
=0;i
<16;i
++) {
6091 netmask
[i
] = (u8
)(0xFF00>>j
);
6098 qeth_send_setdelip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
,
6099 int ipacmd
, unsigned int flags
)
6102 struct qeth_cmd_buffer
*iob
;
6103 struct qeth_ipa_cmd
*cmd
;
6106 QETH_DBF_TEXT(trace
,4,"setdelip");
6107 QETH_DBF_TEXT_(trace
,4,"flags%02X", flags
);
6109 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
6110 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6111 if (addr
->proto
== QETH_PROT_IPV6
) {
6112 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
6113 sizeof(struct in6_addr
));
6114 qeth_fill_netmask(netmask
,addr
->u
.a6
.pfxlen
);
6115 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
6116 sizeof(struct in6_addr
));
6117 cmd
->data
.setdelip6
.flags
= flags
;
6119 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
6120 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
6121 cmd
->data
.setdelip4
.flags
= flags
;
6124 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6130 qeth_layer2_register_addr_entry(struct qeth_card
*card
,
6131 struct qeth_ipaddr
*addr
)
6133 if (!addr
->is_multicast
)
6135 QETH_DBF_TEXT(trace
, 2, "setgmac");
6136 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
6137 return qeth_layer2_send_setgroupmac(card
, &addr
->mac
[0]);
6141 qeth_layer2_deregister_addr_entry(struct qeth_card
*card
,
6142 struct qeth_ipaddr
*addr
)
6144 if (!addr
->is_multicast
)
6146 QETH_DBF_TEXT(trace
, 2, "delgmac");
6147 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
6148 return qeth_layer2_send_delgroupmac(card
, &addr
->mac
[0]);
6152 qeth_layer3_register_addr_entry(struct qeth_card
*card
,
6153 struct qeth_ipaddr
*addr
)
6159 if (addr
->proto
== QETH_PROT_IPV4
) {
6160 QETH_DBF_TEXT(trace
, 2,"setaddr4");
6161 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
6162 } else if (addr
->proto
== QETH_PROT_IPV6
) {
6163 QETH_DBF_TEXT(trace
, 2, "setaddr6");
6164 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
6165 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
6167 QETH_DBF_TEXT(trace
, 2, "setaddr?");
6168 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
6171 if (addr
->is_multicast
)
6172 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
6174 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
6177 QETH_DBF_TEXT(trace
, 2, "failed");
6178 } while ((--cnt
> 0) && rc
);
6180 QETH_DBF_TEXT(trace
, 2, "FAILED");
6181 qeth_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
6182 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
6189 qeth_layer3_deregister_addr_entry(struct qeth_card
*card
,
6190 struct qeth_ipaddr
*addr
)
6195 if (addr
->proto
== QETH_PROT_IPV4
) {
6196 QETH_DBF_TEXT(trace
, 2,"deladdr4");
6197 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
6198 } else if (addr
->proto
== QETH_PROT_IPV6
) {
6199 QETH_DBF_TEXT(trace
, 2, "deladdr6");
6200 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
6201 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
6203 QETH_DBF_TEXT(trace
, 2, "deladdr?");
6204 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
6206 if (addr
->is_multicast
)
6207 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
6209 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
6212 QETH_DBF_TEXT(trace
, 2, "failed");
6213 /* TODO: re-activate this warning as soon as we have a
6215 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
6216 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
6224 qeth_register_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
6226 if (card
->options
.layer2
)
6227 return qeth_layer2_register_addr_entry(card
, addr
);
6229 return qeth_layer3_register_addr_entry(card
, addr
);
6233 qeth_deregister_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
6235 if (card
->options
.layer2
)
6236 return qeth_layer2_deregister_addr_entry(card
, addr
);
6238 return qeth_layer3_deregister_addr_entry(card
, addr
);
6242 qeth_ethtool_get_tx_csum(struct net_device
*dev
)
6244 /* We may need to say that we support tx csum offload if
6245 * we do EDDP or TSO. There are discussions going on to
6246 * enforce rules in the stack and in ethtool that make
6247 * SG and TSO depend on HW_CSUM. At the moment there are
6249 * If we say yes here, we have to checksum outbound packets
6255 qeth_ethtool_set_tx_csum(struct net_device
*dev
, u32 data
)
6261 qeth_ethtool_get_rx_csum(struct net_device
*dev
)
6263 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6265 return (card
->options
.checksum_type
== HW_CHECKSUMMING
);
6269 qeth_ethtool_set_rx_csum(struct net_device
*dev
, u32 data
)
6271 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6273 if ((card
->state
!= CARD_STATE_DOWN
) &&
6274 (card
->state
!= CARD_STATE_RECOVER
))
6277 card
->options
.checksum_type
= HW_CHECKSUMMING
;
6279 card
->options
.checksum_type
= SW_CHECKSUMMING
;
6284 qeth_ethtool_get_sg(struct net_device
*dev
)
6286 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6288 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
6289 (dev
->features
& NETIF_F_SG
));
6293 qeth_ethtool_set_sg(struct net_device
*dev
, u32 data
)
6295 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6298 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
6299 dev
->features
|= NETIF_F_SG
;
6301 dev
->features
&= ~NETIF_F_SG
;
6305 dev
->features
&= ~NETIF_F_SG
;
6310 qeth_ethtool_get_tso(struct net_device
*dev
)
6312 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6314 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
6315 (dev
->features
& NETIF_F_TSO
));
6319 qeth_ethtool_set_tso(struct net_device
*dev
, u32 data
)
6321 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6324 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
6325 dev
->features
|= NETIF_F_TSO
;
6327 dev
->features
&= ~NETIF_F_TSO
;
6331 dev
->features
&= ~NETIF_F_TSO
;
6335 static struct ethtool_ops qeth_ethtool_ops
= {
6336 .get_tx_csum
= qeth_ethtool_get_tx_csum
,
6337 .set_tx_csum
= qeth_ethtool_set_tx_csum
,
6338 .get_rx_csum
= qeth_ethtool_get_rx_csum
,
6339 .set_rx_csum
= qeth_ethtool_set_rx_csum
,
6340 .get_sg
= qeth_ethtool_get_sg
,
6341 .set_sg
= qeth_ethtool_set_sg
,
6342 .get_tso
= qeth_ethtool_get_tso
,
6343 .set_tso
= qeth_ethtool_set_tso
,
6347 qeth_netdev_init(struct net_device
*dev
)
6349 struct qeth_card
*card
;
6351 card
= (struct qeth_card
*) dev
->priv
;
6353 QETH_DBF_TEXT(trace
,3,"initdev");
6355 dev
->tx_timeout
= &qeth_tx_timeout
;
6356 dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
6357 dev
->open
= qeth_open
;
6358 dev
->stop
= qeth_stop
;
6359 dev
->hard_start_xmit
= qeth_hard_start_xmit
;
6360 dev
->do_ioctl
= qeth_do_ioctl
;
6361 dev
->get_stats
= qeth_get_stats
;
6362 dev
->change_mtu
= qeth_change_mtu
;
6363 dev
->neigh_setup
= qeth_neigh_setup
;
6364 dev
->set_multicast_list
= qeth_set_multicast_list
;
6365 #ifdef CONFIG_QETH_VLAN
6366 dev
->vlan_rx_register
= qeth_vlan_rx_register
;
6367 dev
->vlan_rx_kill_vid
= qeth_vlan_rx_kill_vid
;
6368 dev
->vlan_rx_add_vid
= qeth_vlan_rx_add_vid
;
6370 dev
->hard_header
= card
->orig_hard_header
;
6371 if (qeth_get_netdev_flags(card
) & IFF_NOARP
) {
6372 dev
->rebuild_header
= NULL
;
6373 dev
->hard_header
= NULL
;
6374 if (card
->options
.fake_ll
)
6375 dev
->hard_header
= qeth_fake_header
;
6376 dev
->header_cache_update
= NULL
;
6377 dev
->hard_header_cache
= NULL
;
6379 #ifdef CONFIG_QETH_IPV6
6380 /*IPv6 address autoconfiguration stuff*/
6381 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
6382 card
->dev
->dev_id
= card
->info
.unique_id
& 0xffff;
6384 dev
->hard_header_parse
= NULL
;
6385 dev
->set_mac_address
= qeth_layer2_set_mac_address
;
6386 dev
->flags
|= qeth_get_netdev_flags(card
);
6387 if ((card
->options
.fake_broadcast
) ||
6388 (card
->info
.broadcast_capable
))
6389 dev
->flags
|= IFF_BROADCAST
;
6390 dev
->hard_header_len
=
6391 qeth_get_hlen(card
->info
.link_type
) + card
->options
.add_hhlen
;
6392 dev
->addr_len
= OSA_ADDR_LEN
;
6393 dev
->mtu
= card
->info
.initial_mtu
;
6394 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
6395 SET_ETHTOOL_OPS(dev
, &qeth_ethtool_ops
);
6396 SET_MODULE_OWNER(dev
);
6401 qeth_init_func_level(struct qeth_card
*card
)
6403 if (card
->ipato
.enabled
) {
6404 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6405 card
->info
.func_level
=
6406 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT
;
6408 card
->info
.func_level
=
6409 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT
;
6411 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6412 /*FIXME:why do we have same values for dis and ena for osae??? */
6413 card
->info
.func_level
=
6414 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT
;
6416 card
->info
.func_level
=
6417 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT
;
6422 * hardsetup card, initialize MPC and QDIO stuff
6425 qeth_hardsetup_card(struct qeth_card
*card
)
6430 QETH_DBF_TEXT(setup
, 2, "hrdsetup");
6434 PRINT_WARN("Retrying to do IDX activates.\n");
6435 ccw_device_set_offline(CARD_DDEV(card
));
6436 ccw_device_set_offline(CARD_WDEV(card
));
6437 ccw_device_set_offline(CARD_RDEV(card
));
6438 ccw_device_set_online(CARD_RDEV(card
));
6439 ccw_device_set_online(CARD_WDEV(card
));
6440 ccw_device_set_online(CARD_DDEV(card
));
6442 rc
= qeth_qdio_clear_card(card
,card
->info
.type
!=QETH_CARD_TYPE_IQD
);
6443 if (rc
== -ERESTARTSYS
) {
6444 QETH_DBF_TEXT(setup
, 2, "break1");
6447 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
6453 if ((rc
= qeth_get_unitaddr(card
))){
6454 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
6457 qeth_init_tokens(card
);
6458 qeth_init_func_level(card
);
6459 rc
= qeth_idx_activate_channel(&card
->read
, qeth_idx_read_cb
);
6460 if (rc
== -ERESTARTSYS
) {
6461 QETH_DBF_TEXT(setup
, 2, "break2");
6464 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
6470 rc
= qeth_idx_activate_channel(&card
->write
, qeth_idx_write_cb
);
6471 if (rc
== -ERESTARTSYS
) {
6472 QETH_DBF_TEXT(setup
, 2, "break3");
6475 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
6481 if ((rc
= qeth_mpc_initialize(card
))){
6482 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
6485 /*network device will be recovered*/
6487 card
->dev
->hard_header
= card
->orig_hard_header
;
6490 /* at first set_online allocate netdev */
6491 card
->dev
= qeth_get_netdevice(card
->info
.type
,
6492 card
->info
.link_type
);
6494 qeth_qdio_clear_card(card
, card
->info
.type
!=
6495 QETH_CARD_TYPE_IQD
);
6497 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
6500 card
->dev
->priv
= card
;
6501 card
->orig_hard_header
= card
->dev
->hard_header
;
6502 card
->dev
->type
= qeth_get_arphdr_type(card
->info
.type
,
6503 card
->info
.link_type
);
6504 card
->dev
->init
= qeth_netdev_init
;
6507 PRINT_ERR("Initialization in hardsetup failed! rc=%d\n", rc
);
6512 qeth_default_setassparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6515 struct qeth_ipa_cmd
*cmd
;
6517 QETH_DBF_TEXT(trace
,4,"defadpcb");
6519 cmd
= (struct qeth_ipa_cmd
*) data
;
6520 if (cmd
->hdr
.return_code
== 0){
6521 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
6522 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
6523 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6524 #ifdef CONFIG_QETH_IPV6
6525 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
6526 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6529 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
6530 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
6531 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
6532 QETH_DBF_TEXT_(trace
, 3, "csum:%d", card
->info
.csum_mask
);
6538 qeth_default_setadapterparms_cb(struct qeth_card
*card
,
6539 struct qeth_reply
*reply
,
6542 struct qeth_ipa_cmd
*cmd
;
6544 QETH_DBF_TEXT(trace
,4,"defadpcb");
6546 cmd
= (struct qeth_ipa_cmd
*) data
;
6547 if (cmd
->hdr
.return_code
== 0)
6548 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
6555 qeth_query_setadapterparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6558 struct qeth_ipa_cmd
*cmd
;
6560 QETH_DBF_TEXT(trace
,3,"quyadpcb");
6562 cmd
= (struct qeth_ipa_cmd
*) data
;
6563 if (cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
& 0x7f)
6564 card
->info
.link_type
=
6565 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
;
6566 card
->options
.adp
.supported_funcs
=
6567 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.supported_cmds
;
6568 return qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
6572 qeth_query_setadapterparms(struct qeth_card
*card
)
6575 struct qeth_cmd_buffer
*iob
;
6577 QETH_DBF_TEXT(trace
,3,"queryadp");
6578 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_COMMANDS_SUPPORTED
,
6579 sizeof(struct qeth_ipacmd_setadpparms
));
6580 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_setadapterparms_cb
, NULL
);
6585 qeth_setadpparms_change_macaddr_cb(struct qeth_card
*card
,
6586 struct qeth_reply
*reply
,
6589 struct qeth_ipa_cmd
*cmd
;
6591 QETH_DBF_TEXT(trace
,4,"chgmaccb");
6593 cmd
= (struct qeth_ipa_cmd
*) data
;
6594 if (!card
->options
.layer2
|| card
->info
.guestlan
||
6595 !(card
->info
.mac_bits
& QETH_LAYER2_MAC_READ
)) {
6596 memcpy(card
->dev
->dev_addr
,
6597 &cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
6599 card
->info
.mac_bits
|= QETH_LAYER2_MAC_READ
;
6601 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
6606 qeth_setadpparms_change_macaddr(struct qeth_card
*card
)
6609 struct qeth_cmd_buffer
*iob
;
6610 struct qeth_ipa_cmd
*cmd
;
6612 QETH_DBF_TEXT(trace
,4,"chgmac");
6614 iob
= qeth_get_adapter_cmd(card
,IPA_SETADP_ALTER_MAC_ADDRESS
,
6615 sizeof(struct qeth_ipacmd_setadpparms
));
6616 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6617 cmd
->data
.setadapterparms
.data
.change_addr
.cmd
= CHANGE_ADDR_READ_MAC
;
6618 cmd
->data
.setadapterparms
.data
.change_addr
.addr_size
= OSA_ADDR_LEN
;
6619 memcpy(&cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
6620 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6621 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_change_macaddr_cb
,
6627 qeth_send_setadp_mode(struct qeth_card
*card
, __u32 command
, __u32 mode
)
6630 struct qeth_cmd_buffer
*iob
;
6631 struct qeth_ipa_cmd
*cmd
;
6633 QETH_DBF_TEXT(trace
,4,"adpmode");
6635 iob
= qeth_get_adapter_cmd(card
, command
,
6636 sizeof(struct qeth_ipacmd_setadpparms
));
6637 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6638 cmd
->data
.setadapterparms
.data
.mode
= mode
;
6639 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_default_setadapterparms_cb
,
6645 qeth_setadapter_hstr(struct qeth_card
*card
)
6649 QETH_DBF_TEXT(trace
,4,"adphstr");
6651 if (qeth_adp_supported(card
,IPA_SETADP_SET_BROADCAST_MODE
)) {
6652 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_SET_BROADCAST_MODE
,
6653 card
->options
.broadcast_mode
);
6655 PRINT_WARN("couldn't set broadcast mode on "
6657 CARD_BUS_ID(card
), rc
);
6658 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_ALTER_MAC_ADDRESS
,
6659 card
->options
.macaddr_mode
);
6661 PRINT_WARN("couldn't set macaddr mode on "
6662 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
6665 if (card
->options
.broadcast_mode
== QETH_TR_BROADCAST_LOCAL
)
6666 PRINT_WARN("set adapter parameters not available "
6667 "to set broadcast mode, using ALLRINGS "
6668 "on device %s:\n", CARD_BUS_ID(card
));
6669 if (card
->options
.macaddr_mode
== QETH_TR_MACADDR_CANONICAL
)
6670 PRINT_WARN("set adapter parameters not available "
6671 "to set macaddr mode, using NONCANONICAL "
6672 "on device %s:\n", CARD_BUS_ID(card
));
6677 qeth_setadapter_parms(struct qeth_card
*card
)
6681 QETH_DBF_TEXT(setup
, 2, "setadprm");
6683 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)){
6684 PRINT_WARN("set adapter parameters not supported "
6687 QETH_DBF_TEXT(setup
, 2, " notsupp");
6690 rc
= qeth_query_setadapterparms(card
);
6692 PRINT_WARN("couldn't set adapter parameters on device %s: "
6693 "x%x\n", CARD_BUS_ID(card
), rc
);
6696 if (qeth_adp_supported(card
,IPA_SETADP_ALTER_MAC_ADDRESS
)) {
6697 rc
= qeth_setadpparms_change_macaddr(card
);
6699 PRINT_WARN("couldn't get MAC address on "
6701 CARD_BUS_ID(card
), rc
);
6704 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
6705 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
6706 rc
= qeth_setadapter_hstr(card
);
6712 qeth_layer2_initialize(struct qeth_card
*card
)
6717 QETH_DBF_TEXT(setup
, 2, "doL2init");
6718 QETH_DBF_TEXT_(setup
, 2, "doL2%s", CARD_BUS_ID(card
));
6720 rc
= qeth_query_setadapterparms(card
);
6722 PRINT_WARN("could not query adapter parameters on device %s: "
6723 "x%x\n", CARD_BUS_ID(card
), rc
);
6726 rc
= qeth_setadpparms_change_macaddr(card
);
6728 PRINT_WARN("couldn't get MAC address on "
6730 CARD_BUS_ID(card
), rc
);
6731 QETH_DBF_TEXT_(setup
, 2,"1err%d",rc
);
6734 QETH_DBF_HEX(setup
,2, card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6736 rc
= qeth_layer2_send_setmac(card
, &card
->dev
->dev_addr
[0]);
6738 QETH_DBF_TEXT_(setup
, 2,"2err%d",rc
);
6744 qeth_send_startstoplan(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
6745 enum qeth_prot_versions prot
)
6748 struct qeth_cmd_buffer
*iob
;
6750 iob
= qeth_get_ipacmd_buffer(card
,ipacmd
,prot
);
6751 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6757 qeth_send_startlan(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6761 QETH_DBF_TEXT_(setup
, 2, "strtlan%i", prot
);
6763 rc
= qeth_send_startstoplan(card
, IPA_CMD_STARTLAN
, prot
);
6768 qeth_send_stoplan(struct qeth_card
*card
)
6773 * TODO: according to the IPA format document page 14,
6774 * TCP/IP (we!) never issue a STOPLAN
6777 QETH_DBF_TEXT(trace
, 2, "stoplan");
6779 rc
= qeth_send_startstoplan(card
, IPA_CMD_STOPLAN
, QETH_PROT_IPV4
);
6784 qeth_query_ipassists_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6787 struct qeth_ipa_cmd
*cmd
;
6789 QETH_DBF_TEXT(setup
, 2, "qipasscb");
6791 cmd
= (struct qeth_ipa_cmd
*) data
;
6792 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
6793 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6794 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6795 /* Disable IPV6 support hard coded for Hipersockets */
6796 if(card
->info
.type
== QETH_CARD_TYPE_IQD
)
6797 card
->options
.ipa4
.supported_funcs
&= ~IPA_IPV6
;
6799 #ifdef CONFIG_QETH_IPV6
6800 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6801 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6804 QETH_DBF_TEXT(setup
, 2, "suppenbl");
6805 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_supported
);
6806 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_enabled
);
6811 qeth_query_ipassists(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6814 struct qeth_cmd_buffer
*iob
;
6816 QETH_DBF_TEXT_(setup
, 2, "qipassi%i", prot
);
6817 if (card
->options
.layer2
) {
6818 QETH_DBF_TEXT(setup
, 2, "noprmly2");
6822 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_QIPASSIST
,prot
);
6823 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_ipassists_cb
, NULL
);
6827 static struct qeth_cmd_buffer
*
6828 qeth_get_setassparms_cmd(struct qeth_card
*card
, enum qeth_ipa_funcs ipa_func
,
6829 __u16 cmd_code
, __u16 len
,
6830 enum qeth_prot_versions prot
)
6832 struct qeth_cmd_buffer
*iob
;
6833 struct qeth_ipa_cmd
*cmd
;
6835 QETH_DBF_TEXT(trace
,4,"getasscm");
6836 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETASSPARMS
,prot
);
6838 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6839 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
6840 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
6841 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
6842 cmd
->data
.setassparms
.hdr
.return_code
= 0;
6843 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
6849 qeth_send_setassparms(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
6850 __u16 len
, long data
,
6852 (struct qeth_card
*,struct qeth_reply
*,unsigned long),
6856 struct qeth_ipa_cmd
*cmd
;
6858 QETH_DBF_TEXT(trace
,4,"sendassp");
6860 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6861 if (len
<= sizeof(__u32
))
6862 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
6863 else /* (len > sizeof(__u32)) */
6864 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
6866 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
6870 #ifdef CONFIG_QETH_IPV6
6872 qeth_send_simple_setassparms_ipv6(struct qeth_card
*card
,
6873 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
6877 struct qeth_cmd_buffer
*iob
;
6879 QETH_DBF_TEXT(trace
,4,"simassp6");
6880 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6882 rc
= qeth_send_setassparms(card
, iob
, 0, 0,
6883 qeth_default_setassparms_cb
, NULL
);
6889 qeth_send_simple_setassparms(struct qeth_card
*card
,
6890 enum qeth_ipa_funcs ipa_func
,
6891 __u16 cmd_code
, long data
)
6895 struct qeth_cmd_buffer
*iob
;
6897 QETH_DBF_TEXT(trace
,4,"simassp4");
6899 length
= sizeof(__u32
);
6900 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6901 length
, QETH_PROT_IPV4
);
6902 rc
= qeth_send_setassparms(card
, iob
, length
, data
,
6903 qeth_default_setassparms_cb
, NULL
);
6908 qeth_start_ipa_arp_processing(struct qeth_card
*card
)
6912 QETH_DBF_TEXT(trace
,3,"ipaarp");
6914 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
6915 PRINT_WARN("ARP processing not supported "
6916 "on %s!\n", QETH_CARD_IFNAME(card
));
6919 rc
= qeth_send_simple_setassparms(card
,IPA_ARP_PROCESSING
,
6920 IPA_CMD_ASS_START
, 0);
6922 PRINT_WARN("Could not start ARP processing "
6923 "assist on %s: 0x%x\n",
6924 QETH_CARD_IFNAME(card
), rc
);
6930 qeth_start_ipa_ip_fragmentation(struct qeth_card
*card
)
6934 QETH_DBF_TEXT(trace
,3,"ipaipfrg");
6936 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
6937 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
6938 QETH_CARD_IFNAME(card
));
6942 rc
= qeth_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
6943 IPA_CMD_ASS_START
, 0);
6945 PRINT_WARN("Could not start Hardware IP fragmentation "
6946 "assist on %s: 0x%x\n",
6947 QETH_CARD_IFNAME(card
), rc
);
6949 PRINT_INFO("Hardware IP fragmentation enabled \n");
6954 qeth_start_ipa_source_mac(struct qeth_card
*card
)
6958 QETH_DBF_TEXT(trace
,3,"stsrcmac");
6960 if (!card
->options
.fake_ll
)
6963 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
6964 PRINT_INFO("Inbound source address not "
6965 "supported on %s\n", QETH_CARD_IFNAME(card
));
6969 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
6970 IPA_CMD_ASS_START
, 0);
6972 PRINT_WARN("Could not start inbound source "
6973 "assist on %s: 0x%x\n",
6974 QETH_CARD_IFNAME(card
), rc
);
6979 qeth_start_ipa_vlan(struct qeth_card
*card
)
6983 QETH_DBF_TEXT(trace
,3,"strtvlan");
6985 #ifdef CONFIG_QETH_VLAN
6986 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
6987 PRINT_WARN("VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
6991 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
6992 IPA_CMD_ASS_START
,0);
6994 PRINT_WARN("Could not start vlan "
6995 "assist on %s: 0x%x\n",
6996 QETH_CARD_IFNAME(card
), rc
);
6998 PRINT_INFO("VLAN enabled \n");
6999 card
->dev
->features
|=
7000 NETIF_F_HW_VLAN_FILTER
|
7001 NETIF_F_HW_VLAN_TX
|
7004 #endif /* QETH_VLAN */
7009 qeth_start_ipa_multicast(struct qeth_card
*card
)
7013 QETH_DBF_TEXT(trace
,3,"stmcast");
7015 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
7016 PRINT_WARN("Multicast not supported on %s\n",
7017 QETH_CARD_IFNAME(card
));
7021 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
7022 IPA_CMD_ASS_START
,0);
7024 PRINT_WARN("Could not start multicast "
7025 "assist on %s: rc=%i\n",
7026 QETH_CARD_IFNAME(card
), rc
);
7028 PRINT_INFO("Multicast enabled\n");
7029 card
->dev
->flags
|= IFF_MULTICAST
;
7034 #ifdef CONFIG_QETH_IPV6
7036 qeth_softsetup_ipv6(struct qeth_card
*card
)
7040 QETH_DBF_TEXT(trace
,3,"softipv6");
7042 netif_stop_queue(card
->dev
);
7043 rc
= qeth_send_startlan(card
, QETH_PROT_IPV6
);
7045 PRINT_ERR("IPv6 startlan failed on %s\n",
7046 QETH_CARD_IFNAME(card
));
7049 netif_wake_queue(card
->dev
);
7050 rc
= qeth_query_ipassists(card
,QETH_PROT_IPV6
);
7052 PRINT_ERR("IPv6 query ipassist failed on %s\n",
7053 QETH_CARD_IFNAME(card
));
7056 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
7057 IPA_CMD_ASS_START
, 3);
7059 PRINT_WARN("IPv6 start assist (version 4) failed "
7061 QETH_CARD_IFNAME(card
), rc
);
7064 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
7067 PRINT_WARN("IPV6 start assist (version 6) failed "
7069 QETH_CARD_IFNAME(card
), rc
);
7072 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
7075 PRINT_WARN("Could not enable passthrough "
7077 QETH_CARD_IFNAME(card
), rc
);
7080 PRINT_INFO("IPV6 enabled \n");
7087 qeth_start_ipa_ipv6(struct qeth_card
*card
)
7090 #ifdef CONFIG_QETH_IPV6
7091 QETH_DBF_TEXT(trace
,3,"strtipv6");
7093 if (!qeth_is_supported(card
, IPA_IPV6
)) {
7094 PRINT_WARN("IPv6 not supported on %s\n",
7095 QETH_CARD_IFNAME(card
));
7098 rc
= qeth_softsetup_ipv6(card
);
7104 qeth_start_ipa_broadcast(struct qeth_card
*card
)
7108 QETH_DBF_TEXT(trace
,3,"stbrdcst");
7109 card
->info
.broadcast_capable
= 0;
7110 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
7111 PRINT_WARN("Broadcast not supported on %s\n",
7112 QETH_CARD_IFNAME(card
));
7116 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7117 IPA_CMD_ASS_START
, 0);
7119 PRINT_WARN("Could not enable broadcasting filtering "
7121 QETH_CARD_IFNAME(card
), rc
);
7125 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7126 IPA_CMD_ASS_CONFIGURE
, 1);
7128 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
7129 QETH_CARD_IFNAME(card
), rc
);
7132 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
7133 PRINT_INFO("Broadcast enabled \n");
7134 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7135 IPA_CMD_ASS_ENABLE
, 1);
7137 PRINT_WARN("Could not set up broadcast echo filtering on "
7138 "%s: 0x%x\n", QETH_CARD_IFNAME(card
), rc
);
7141 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
7143 if (card
->info
.broadcast_capable
)
7144 card
->dev
->flags
|= IFF_BROADCAST
;
7146 card
->dev
->flags
&= ~IFF_BROADCAST
;
7151 qeth_send_checksum_command(struct qeth_card
*card
)
7155 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
7156 IPA_CMD_ASS_START
, 0);
7158 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
7159 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7160 QETH_CARD_IFNAME(card
), rc
);
7163 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
7165 card
->info
.csum_mask
);
7167 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
7168 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7169 QETH_CARD_IFNAME(card
), rc
);
7176 qeth_start_ipa_checksum(struct qeth_card
*card
)
7180 QETH_DBF_TEXT(trace
,3,"strtcsum");
7182 if (card
->options
.checksum_type
== NO_CHECKSUMMING
) {
7183 PRINT_WARN("Using no checksumming on %s.\n",
7184 QETH_CARD_IFNAME(card
));
7187 if (card
->options
.checksum_type
== SW_CHECKSUMMING
) {
7188 PRINT_WARN("Using SW checksumming on %s.\n",
7189 QETH_CARD_IFNAME(card
));
7192 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
7193 PRINT_WARN("Inbound HW Checksumming not "
7194 "supported on %s,\ncontinuing "
7195 "using Inbound SW Checksumming\n",
7196 QETH_CARD_IFNAME(card
));
7197 card
->options
.checksum_type
= SW_CHECKSUMMING
;
7200 rc
= qeth_send_checksum_command(card
);
7202 PRINT_INFO("HW Checksumming (inbound) enabled \n");
7208 qeth_start_ipa_tso(struct qeth_card
*card
)
7212 QETH_DBF_TEXT(trace
,3,"sttso");
7214 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
7215 PRINT_WARN("Outbound TSO not supported on %s\n",
7216 QETH_CARD_IFNAME(card
));
7219 rc
= qeth_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
7220 IPA_CMD_ASS_START
,0);
7222 PRINT_WARN("Could not start outbound TSO "
7223 "assist on %s: rc=%i\n",
7224 QETH_CARD_IFNAME(card
), rc
);
7226 PRINT_INFO("Outbound TSO enabled\n");
7228 if (rc
&& (card
->options
.large_send
== QETH_LARGE_SEND_TSO
)){
7229 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
7230 card
->dev
->features
&= ~ (NETIF_F_TSO
| NETIF_F_SG
);
7236 qeth_start_ipassists(struct qeth_card
*card
)
7238 QETH_DBF_TEXT(trace
,3,"strtipas");
7239 qeth_start_ipa_arp_processing(card
); /* go on*/
7240 qeth_start_ipa_ip_fragmentation(card
); /* go on*/
7241 qeth_start_ipa_source_mac(card
); /* go on*/
7242 qeth_start_ipa_vlan(card
); /* go on*/
7243 qeth_start_ipa_multicast(card
); /* go on*/
7244 qeth_start_ipa_ipv6(card
); /* go on*/
7245 qeth_start_ipa_broadcast(card
); /* go on*/
7246 qeth_start_ipa_checksum(card
); /* go on*/
7247 qeth_start_ipa_tso(card
); /* go on*/
7252 qeth_send_setrouting(struct qeth_card
*card
, enum qeth_routing_types type
,
7253 enum qeth_prot_versions prot
)
7256 struct qeth_ipa_cmd
*cmd
;
7257 struct qeth_cmd_buffer
*iob
;
7259 QETH_DBF_TEXT(trace
,4,"setroutg");
7260 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
7261 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7262 cmd
->data
.setrtg
.type
= (type
);
7263 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
7270 qeth_correct_routing_type(struct qeth_card
*card
, enum qeth_routing_types
*type
,
7271 enum qeth_prot_versions prot
)
7273 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
7276 case PRIMARY_CONNECTOR
:
7277 case SECONDARY_CONNECTOR
:
7278 case MULTICAST_ROUTER
:
7286 case PRIMARY_ROUTER
:
7287 case SECONDARY_ROUTER
:
7289 case MULTICAST_ROUTER
:
7290 if (qeth_is_ipafunc_supported(card
, prot
,
7298 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
7299 "Router status set to 'no router'.\n",
7300 ((*type
== PRIMARY_ROUTER
)? "primary router" :
7301 (*type
== SECONDARY_ROUTER
)? "secondary router" :
7302 (*type
== PRIMARY_CONNECTOR
)? "primary connector" :
7303 (*type
== SECONDARY_CONNECTOR
)? "secondary connector" :
7304 (*type
== MULTICAST_ROUTER
)? "multicast router" :
7311 qeth_setrouting_v4(struct qeth_card
*card
)
7315 QETH_DBF_TEXT(trace
,3,"setrtg4");
7317 qeth_correct_routing_type(card
, &card
->options
.route4
.type
,
7320 rc
= qeth_send_setrouting(card
, card
->options
.route4
.type
,
7323 card
->options
.route4
.type
= NO_ROUTER
;
7324 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7325 "Type set to 'no router'.\n",
7326 rc
, QETH_CARD_IFNAME(card
));
7332 qeth_setrouting_v6(struct qeth_card
*card
)
7336 QETH_DBF_TEXT(trace
,3,"setrtg6");
7337 #ifdef CONFIG_QETH_IPV6
7339 qeth_correct_routing_type(card
, &card
->options
.route6
.type
,
7342 rc
= qeth_send_setrouting(card
, card
->options
.route6
.type
,
7345 card
->options
.route6
.type
= NO_ROUTER
;
7346 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7347 "Type set to 'no router'.\n",
7348 rc
, QETH_CARD_IFNAME(card
));
7355 qeth_set_large_send(struct qeth_card
*card
, enum qeth_large_send_types type
)
7359 if (card
->dev
== NULL
) {
7360 card
->options
.large_send
= type
;
7363 netif_stop_queue(card
->dev
);
7364 card
->options
.large_send
= type
;
7365 switch (card
->options
.large_send
) {
7366 case QETH_LARGE_SEND_EDDP
:
7367 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
7369 case QETH_LARGE_SEND_TSO
:
7370 if (qeth_is_supported(card
, IPA_OUTBOUND_TSO
)){
7371 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
7373 PRINT_WARN("TSO not supported on %s. "
7374 "large_send set to 'no'.\n",
7376 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
7377 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
7381 default: /* includes QETH_LARGE_SEND_NO */
7382 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
7385 netif_wake_queue(card
->dev
);
7390 * softsetup card: init IPA stuff
7393 qeth_softsetup_card(struct qeth_card
*card
)
7397 QETH_DBF_TEXT(setup
, 2, "softsetp");
7399 if ((rc
= qeth_send_startlan(card
, QETH_PROT_IPV4
))){
7400 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7402 PRINT_WARN("LAN on card %s if offline! "
7403 "Continuing softsetup.\n",
7405 card
->lan_online
= 0;
7409 card
->lan_online
= 1;
7410 if (card
->info
.type
==QETH_CARD_TYPE_OSN
)
7412 qeth_set_large_send(card
, card
->options
.large_send
);
7413 if (card
->options
.layer2
) {
7414 card
->dev
->features
|=
7415 NETIF_F_HW_VLAN_FILTER
|
7416 NETIF_F_HW_VLAN_TX
|
7418 card
->dev
->flags
|=IFF_MULTICAST
|IFF_BROADCAST
;
7419 card
->info
.broadcast_capable
=1;
7420 if ((rc
= qeth_layer2_initialize(card
))) {
7421 QETH_DBF_TEXT_(setup
, 2, "L2err%d", rc
);
7424 #ifdef CONFIG_QETH_VLAN
7425 qeth_layer2_process_vlans(card
, 0);
7429 if ((rc
= qeth_setadapter_parms(card
)))
7430 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7431 if ((rc
= qeth_start_ipassists(card
)))
7432 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7433 if ((rc
= qeth_setrouting_v4(card
)))
7434 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7435 if ((rc
= qeth_setrouting_v6(card
)))
7436 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7438 netif_stop_queue(card
->dev
);
7442 #ifdef CONFIG_QETH_IPV6
7444 qeth_get_unique_id_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
7447 struct qeth_ipa_cmd
*cmd
;
7449 cmd
= (struct qeth_ipa_cmd
*) data
;
7450 if (cmd
->hdr
.return_code
== 0)
7451 card
->info
.unique_id
= *((__u16
*)
7452 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
7454 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7455 UNIQUE_ID_NOT_BY_CARD
;
7456 PRINT_WARN("couldn't get a unique id from the card on device "
7457 "%s (result=x%x), using default id. ipv6 "
7458 "autoconfig on other lpars may lead to duplicate "
7459 "ip addresses. please use manually "
7460 "configured ones.\n",
7461 CARD_BUS_ID(card
), cmd
->hdr
.return_code
);
7468 qeth_put_unique_id(struct qeth_card
*card
)
7472 #ifdef CONFIG_QETH_IPV6
7473 struct qeth_cmd_buffer
*iob
;
7474 struct qeth_ipa_cmd
*cmd
;
7476 QETH_DBF_TEXT(trace
,2,"puniqeid");
7478 if ((card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
) ==
7479 UNIQUE_ID_NOT_BY_CARD
)
7481 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_DESTROY_ADDR
,
7483 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7484 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7485 card
->info
.unique_id
;
7486 memcpy(&cmd
->data
.create_destroy_addr
.unique_id
[0],
7487 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
7488 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
7490 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7491 UNIQUE_ID_NOT_BY_CARD
;
7500 qeth_clear_ip_list(struct qeth_card
*card
, int clean
, int recover
)
7502 struct qeth_ipaddr
*addr
, *tmp
;
7503 unsigned long flags
;
7505 QETH_DBF_TEXT(trace
,4,"clearip");
7506 spin_lock_irqsave(&card
->ip_lock
, flags
);
7507 /* clear todo list */
7508 list_for_each_entry_safe(addr
, tmp
, card
->ip_tbd_list
, entry
){
7509 list_del(&addr
->entry
);
7513 while (!list_empty(&card
->ip_list
)) {
7514 addr
= list_entry(card
->ip_list
.next
,
7515 struct qeth_ipaddr
, entry
);
7516 list_del_init(&addr
->entry
);
7518 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7519 qeth_deregister_addr_entry(card
, addr
);
7520 spin_lock_irqsave(&card
->ip_lock
, flags
);
7522 if (!recover
|| addr
->is_multicast
) {
7526 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
7528 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7532 qeth_set_allowed_threads(struct qeth_card
*card
, unsigned long threads
,
7533 int clear_start_mask
)
7535 unsigned long flags
;
7537 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7538 card
->thread_allowed_mask
= threads
;
7539 if (clear_start_mask
)
7540 card
->thread_start_mask
&= threads
;
7541 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7542 wake_up(&card
->wait_q
);
7546 qeth_threads_running(struct qeth_card
*card
, unsigned long threads
)
7548 unsigned long flags
;
7551 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7552 rc
= (card
->thread_running_mask
& threads
);
7553 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7558 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
)
7560 return wait_event_interruptible(card
->wait_q
,
7561 qeth_threads_running(card
, threads
) == 0);
7565 qeth_stop_card(struct qeth_card
*card
, int recovery_mode
)
7569 QETH_DBF_TEXT(setup
,2,"stopcard");
7570 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7572 qeth_set_allowed_threads(card
, 0, 1);
7573 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
))
7574 return -ERESTARTSYS
;
7575 if (card
->read
.state
== CH_STATE_UP
&&
7576 card
->write
.state
== CH_STATE_UP
&&
7577 (card
->state
== CARD_STATE_UP
)) {
7578 if (recovery_mode
&&
7579 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
7580 qeth_stop(card
->dev
);
7583 dev_close(card
->dev
);
7586 if (!card
->use_hard_stop
) {
7587 __u8
*mac
= &card
->dev
->dev_addr
[0];
7588 rc
= qeth_layer2_send_delmac(card
, mac
);
7589 QETH_DBF_TEXT_(setup
, 2, "Lerr%d", rc
);
7590 if ((rc
= qeth_send_stoplan(card
)))
7591 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7593 card
->state
= CARD_STATE_SOFTSETUP
;
7595 if (card
->state
== CARD_STATE_SOFTSETUP
) {
7596 #ifdef CONFIG_QETH_VLAN
7597 if (card
->options
.layer2
)
7598 qeth_layer2_process_vlans(card
, 1);
7600 qeth_clear_ip_list(card
, !card
->use_hard_stop
, 1);
7601 qeth_clear_ipacmd_list(card
);
7602 card
->state
= CARD_STATE_HARDSETUP
;
7604 if (card
->state
== CARD_STATE_HARDSETUP
) {
7605 if ((!card
->use_hard_stop
) &&
7606 (!card
->options
.layer2
))
7607 if ((rc
= qeth_put_unique_id(card
)))
7608 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7609 qeth_qdio_clear_card(card
, 0);
7610 qeth_clear_qdio_buffers(card
);
7611 qeth_clear_working_pool_list(card
);
7612 card
->state
= CARD_STATE_DOWN
;
7614 if (card
->state
== CARD_STATE_DOWN
) {
7615 qeth_clear_cmd_buffers(&card
->read
);
7616 qeth_clear_cmd_buffers(&card
->write
);
7618 card
->use_hard_stop
= 0;
7624 qeth_get_unique_id(struct qeth_card
*card
)
7627 #ifdef CONFIG_QETH_IPV6
7628 struct qeth_cmd_buffer
*iob
;
7629 struct qeth_ipa_cmd
*cmd
;
7631 QETH_DBF_TEXT(setup
, 2, "guniqeid");
7633 if (!qeth_is_supported(card
,IPA_IPV6
)) {
7634 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7635 UNIQUE_ID_NOT_BY_CARD
;
7639 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
7641 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7642 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7643 card
->info
.unique_id
;
7645 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_get_unique_id_cb
, NULL
);
7647 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7648 UNIQUE_ID_NOT_BY_CARD
;
7653 qeth_print_status_with_portname(struct qeth_card
*card
)
7658 sprintf(dbf_text
, "%s", card
->info
.portname
+ 1);
7659 for (i
= 0; i
< 8; i
++)
7661 (char) _ebcasc
[(__u8
) dbf_text
[i
]];
7663 printk("qeth: Device %s/%s/%s is a%s card%s%s%s\n"
7664 "with link type %s (portname: %s)\n",
7668 qeth_get_cardname(card
),
7669 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7670 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7671 (card
->info
.mcl_level
[0]) ? ")" : "",
7672 qeth_get_cardname_short(card
),
7678 qeth_print_status_no_portname(struct qeth_card
*card
)
7680 if (card
->info
.portname
[0])
7681 printk("qeth: Device %s/%s/%s is a%s "
7682 "card%s%s%s\nwith link type %s "
7683 "(no portname needed by interface).\n",
7687 qeth_get_cardname(card
),
7688 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7689 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7690 (card
->info
.mcl_level
[0]) ? ")" : "",
7691 qeth_get_cardname_short(card
));
7693 printk("qeth: Device %s/%s/%s is a%s "
7694 "card%s%s%s\nwith link type %s.\n",
7698 qeth_get_cardname(card
),
7699 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7700 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7701 (card
->info
.mcl_level
[0]) ? ")" : "",
7702 qeth_get_cardname_short(card
));
7706 qeth_print_status_message(struct qeth_card
*card
)
7708 switch (card
->info
.type
) {
7709 case QETH_CARD_TYPE_OSAE
:
7710 /* VM will use a non-zero first character
7711 * to indicate a HiperSockets like reporting
7712 * of the level OSA sets the first character to zero
7714 if (!card
->info
.mcl_level
[0]) {
7715 sprintf(card
->info
.mcl_level
,"%02x%02x",
7716 card
->info
.mcl_level
[2],
7717 card
->info
.mcl_level
[3]);
7719 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7723 case QETH_CARD_TYPE_IQD
:
7724 card
->info
.mcl_level
[0] = (char) _ebcasc
[(__u8
)
7725 card
->info
.mcl_level
[0]];
7726 card
->info
.mcl_level
[1] = (char) _ebcasc
[(__u8
)
7727 card
->info
.mcl_level
[1]];
7728 card
->info
.mcl_level
[2] = (char) _ebcasc
[(__u8
)
7729 card
->info
.mcl_level
[2]];
7730 card
->info
.mcl_level
[3] = (char) _ebcasc
[(__u8
)
7731 card
->info
.mcl_level
[3]];
7732 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7735 memset(&card
->info
.mcl_level
[0], 0, QETH_MCL_LENGTH
+ 1);
7737 if (card
->info
.portname_required
)
7738 qeth_print_status_with_portname(card
);
7740 qeth_print_status_no_portname(card
);
7744 qeth_register_netdev(struct qeth_card
*card
)
7746 QETH_DBF_TEXT(setup
, 3, "regnetd");
7747 if (card
->dev
->reg_state
!= NETREG_UNINITIALIZED
) {
7748 qeth_netdev_init(card
->dev
);
7752 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
7753 return register_netdev(card
->dev
);
7757 qeth_start_again(struct qeth_card
*card
, int recovery_mode
)
7759 QETH_DBF_TEXT(setup
,2, "startag");
7761 if (recovery_mode
&&
7762 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
7763 qeth_open(card
->dev
);
7766 dev_open(card
->dev
);
7769 /* this also sets saved unicast addresses */
7770 qeth_set_multicast_list(card
->dev
);
7774 /* Layer 2 specific stuff */
7775 #define IGNORE_PARAM_EQ(option,value,reset_value,msg) \
7776 if (card->options.option == value) { \
7777 PRINT_ERR("%s not supported with layer 2 " \
7778 "functionality, ignoring option on read" \
7779 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7780 card->options.option = reset_value; \
7782 #define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \
7783 if (card->options.option != value) { \
7784 PRINT_ERR("%s not supported with layer 2 " \
7785 "functionality, ignoring option on read" \
7786 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7787 card->options.option = reset_value; \
7791 static void qeth_make_parameters_consistent(struct qeth_card
*card
)
7794 if (card
->options
.layer2
== 0)
7796 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
7798 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
7799 PRINT_ERR("Device %s does not support layer 2 functionality." \
7800 " Ignoring layer2 option.\n",CARD_BUS_ID(card
));
7801 card
->options
.layer2
= 0;
7804 IGNORE_PARAM_NEQ(route4
.type
, NO_ROUTER
, NO_ROUTER
,
7805 "Routing options are");
7806 #ifdef CONFIG_QETH_IPV6
7807 IGNORE_PARAM_NEQ(route6
.type
, NO_ROUTER
, NO_ROUTER
,
7808 "Routing options are");
7810 IGNORE_PARAM_EQ(checksum_type
, HW_CHECKSUMMING
,
7811 QETH_CHECKSUM_DEFAULT
,
7812 "Checksumming options are");
7813 IGNORE_PARAM_NEQ(broadcast_mode
, QETH_TR_BROADCAST_ALLRINGS
,
7814 QETH_TR_BROADCAST_ALLRINGS
,
7815 "Broadcast mode options are");
7816 IGNORE_PARAM_NEQ(macaddr_mode
, QETH_TR_MACADDR_NONCANONICAL
,
7817 QETH_TR_MACADDR_NONCANONICAL
,
7818 "Canonical MAC addr options are");
7819 IGNORE_PARAM_NEQ(fake_broadcast
, 0, 0,
7820 "Broadcast faking options are");
7821 IGNORE_PARAM_NEQ(add_hhlen
, DEFAULT_ADD_HHLEN
,
7822 DEFAULT_ADD_HHLEN
,"Option add_hhlen is");
7823 IGNORE_PARAM_NEQ(fake_ll
, 0, 0,"Option fake_ll is");
7828 __qeth_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
7830 struct qeth_card
*card
= gdev
->dev
.driver_data
;
7832 enum qeth_card_states recover_flag
;
7835 QETH_DBF_TEXT(setup
,2, "setonlin");
7836 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7838 qeth_set_allowed_threads(card
, QETH_RECOVER_THREAD
, 1);
7839 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
)){
7840 PRINT_WARN("set_online of card %s interrupted by user!\n",
7842 return -ERESTARTSYS
;
7845 recover_flag
= card
->state
;
7846 if ((rc
= ccw_device_set_online(CARD_RDEV(card
))) ||
7847 (rc
= ccw_device_set_online(CARD_WDEV(card
))) ||
7848 (rc
= ccw_device_set_online(CARD_DDEV(card
)))){
7849 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7853 qeth_make_parameters_consistent(card
);
7855 if ((rc
= qeth_hardsetup_card(card
))){
7856 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7859 card
->state
= CARD_STATE_HARDSETUP
;
7861 if (!(rc
= qeth_query_ipassists(card
,QETH_PROT_IPV4
)))
7862 rc
= qeth_get_unique_id(card
);
7864 if (rc
&& card
->options
.layer2
== 0) {
7865 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7868 qeth_print_status_message(card
);
7869 if ((rc
= qeth_register_netdev(card
))){
7870 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7873 if ((rc
= qeth_softsetup_card(card
))){
7874 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7877 card
->state
= CARD_STATE_SOFTSETUP
;
7879 if ((rc
= qeth_init_qdio_queues(card
))){
7880 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
7883 netif_carrier_on(card
->dev
);
7885 qeth_set_allowed_threads(card
, 0xffffffff, 0);
7886 if (recover_flag
== CARD_STATE_RECOVER
)
7887 qeth_start_again(card
, recovery_mode
);
7888 qeth_notify_processes();
7891 card
->use_hard_stop
= 1;
7892 qeth_stop_card(card
, 0);
7893 ccw_device_set_offline(CARD_DDEV(card
));
7894 ccw_device_set_offline(CARD_WDEV(card
));
7895 ccw_device_set_offline(CARD_RDEV(card
));
7896 if (recover_flag
== CARD_STATE_RECOVER
)
7897 card
->state
= CARD_STATE_RECOVER
;
7899 card
->state
= CARD_STATE_DOWN
;
7904 qeth_set_online(struct ccwgroup_device
*gdev
)
7906 return __qeth_set_online(gdev
, 0);
7909 static struct ccw_device_id qeth_ids
[] = {
7910 {CCW_DEVICE(0x1731, 0x01), driver_info
:QETH_CARD_TYPE_OSAE
},
7911 {CCW_DEVICE(0x1731, 0x05), driver_info
:QETH_CARD_TYPE_IQD
},
7912 {CCW_DEVICE(0x1731, 0x06), driver_info
:QETH_CARD_TYPE_OSN
},
7915 MODULE_DEVICE_TABLE(ccw
, qeth_ids
);
7917 struct device
*qeth_root_dev
= NULL
;
7919 struct ccwgroup_driver qeth_ccwgroup_driver
= {
7920 .owner
= THIS_MODULE
,
7922 .driver_id
= 0xD8C5E3C8,
7923 .probe
= qeth_probe_device
,
7924 .remove
= qeth_remove_device
,
7925 .set_online
= qeth_set_online
,
7926 .set_offline
= qeth_set_offline
,
7929 struct ccw_driver qeth_ccw_driver
= {
7932 .probe
= ccwgroup_probe_ccwdev
,
7933 .remove
= ccwgroup_remove_ccwdev
,
7938 qeth_unregister_dbf_views(void)
7941 debug_unregister(qeth_dbf_setup
);
7943 debug_unregister(qeth_dbf_qerr
);
7945 debug_unregister(qeth_dbf_sense
);
7947 debug_unregister(qeth_dbf_misc
);
7949 debug_unregister(qeth_dbf_data
);
7950 if (qeth_dbf_control
)
7951 debug_unregister(qeth_dbf_control
);
7953 debug_unregister(qeth_dbf_trace
);
7956 qeth_register_dbf_views(void)
7958 qeth_dbf_setup
= debug_register(QETH_DBF_SETUP_NAME
,
7959 QETH_DBF_SETUP_PAGES
,
7960 QETH_DBF_SETUP_NR_AREAS
,
7961 QETH_DBF_SETUP_LEN
);
7962 qeth_dbf_misc
= debug_register(QETH_DBF_MISC_NAME
,
7963 QETH_DBF_MISC_PAGES
,
7964 QETH_DBF_MISC_NR_AREAS
,
7966 qeth_dbf_data
= debug_register(QETH_DBF_DATA_NAME
,
7967 QETH_DBF_DATA_PAGES
,
7968 QETH_DBF_DATA_NR_AREAS
,
7970 qeth_dbf_control
= debug_register(QETH_DBF_CONTROL_NAME
,
7971 QETH_DBF_CONTROL_PAGES
,
7972 QETH_DBF_CONTROL_NR_AREAS
,
7973 QETH_DBF_CONTROL_LEN
);
7974 qeth_dbf_sense
= debug_register(QETH_DBF_SENSE_NAME
,
7975 QETH_DBF_SENSE_PAGES
,
7976 QETH_DBF_SENSE_NR_AREAS
,
7977 QETH_DBF_SENSE_LEN
);
7978 qeth_dbf_qerr
= debug_register(QETH_DBF_QERR_NAME
,
7979 QETH_DBF_QERR_PAGES
,
7980 QETH_DBF_QERR_NR_AREAS
,
7982 qeth_dbf_trace
= debug_register(QETH_DBF_TRACE_NAME
,
7983 QETH_DBF_TRACE_PAGES
,
7984 QETH_DBF_TRACE_NR_AREAS
,
7985 QETH_DBF_TRACE_LEN
);
7987 if ((qeth_dbf_setup
== NULL
) || (qeth_dbf_misc
== NULL
) ||
7988 (qeth_dbf_data
== NULL
) || (qeth_dbf_control
== NULL
) ||
7989 (qeth_dbf_sense
== NULL
) || (qeth_dbf_qerr
== NULL
) ||
7990 (qeth_dbf_trace
== NULL
)) {
7991 qeth_unregister_dbf_views();
7994 debug_register_view(qeth_dbf_setup
, &debug_hex_ascii_view
);
7995 debug_set_level(qeth_dbf_setup
, QETH_DBF_SETUP_LEVEL
);
7997 debug_register_view(qeth_dbf_misc
, &debug_hex_ascii_view
);
7998 debug_set_level(qeth_dbf_misc
, QETH_DBF_MISC_LEVEL
);
8000 debug_register_view(qeth_dbf_data
, &debug_hex_ascii_view
);
8001 debug_set_level(qeth_dbf_data
, QETH_DBF_DATA_LEVEL
);
8003 debug_register_view(qeth_dbf_control
, &debug_hex_ascii_view
);
8004 debug_set_level(qeth_dbf_control
, QETH_DBF_CONTROL_LEVEL
);
8006 debug_register_view(qeth_dbf_sense
, &debug_hex_ascii_view
);
8007 debug_set_level(qeth_dbf_sense
, QETH_DBF_SENSE_LEVEL
);
8009 debug_register_view(qeth_dbf_qerr
, &debug_hex_ascii_view
);
8010 debug_set_level(qeth_dbf_qerr
, QETH_DBF_QERR_LEVEL
);
8012 debug_register_view(qeth_dbf_trace
, &debug_hex_ascii_view
);
8013 debug_set_level(qeth_dbf_trace
, QETH_DBF_TRACE_LEVEL
);
8018 #ifdef CONFIG_QETH_IPV6
8019 extern struct neigh_table arp_tbl
;
8020 static struct neigh_ops
*arp_direct_ops
;
8021 static int (*qeth_old_arp_constructor
) (struct neighbour
*);
8023 static struct neigh_ops arp_direct_ops_template
= {
8027 .error_report
= NULL
,
8028 .output
= dev_queue_xmit
,
8029 .connected_output
= dev_queue_xmit
,
8030 .hh_output
= dev_queue_xmit
,
8031 .queue_xmit
= dev_queue_xmit
8035 qeth_arp_constructor(struct neighbour
*neigh
)
8037 struct net_device
*dev
= neigh
->dev
;
8038 struct in_device
*in_dev
;
8039 struct neigh_parms
*parms
;
8040 struct qeth_card
*card
;
8042 card
= qeth_get_card_from_dev(dev
);
8045 if((card
->options
.layer2
) ||
8046 (card
->dev
->hard_header
== qeth_fake_header
))
8050 in_dev
= __in_dev_get_rcu(dev
);
8051 if (in_dev
== NULL
) {
8056 parms
= in_dev
->arp_parms
;
8057 __neigh_parms_put(neigh
->parms
);
8058 neigh
->parms
= neigh_parms_clone(parms
);
8061 neigh
->type
= inet_addr_type(*(u32
*) neigh
->primary_key
);
8062 neigh
->nud_state
= NUD_NOARP
;
8063 neigh
->ops
= arp_direct_ops
;
8064 neigh
->output
= neigh
->ops
->queue_xmit
;
8067 return qeth_old_arp_constructor(neigh
);
8069 #endif /*CONFIG_QETH_IPV6*/
8072 * IP address takeover related functions
8075 qeth_clear_ipato_list(struct qeth_card
*card
)
8077 struct qeth_ipato_entry
*ipatoe
, *tmp
;
8078 unsigned long flags
;
8080 spin_lock_irqsave(&card
->ip_lock
, flags
);
8081 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
8082 list_del(&ipatoe
->entry
);
8085 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8089 qeth_add_ipato_entry(struct qeth_card
*card
, struct qeth_ipato_entry
*new)
8091 struct qeth_ipato_entry
*ipatoe
;
8092 unsigned long flags
;
8095 QETH_DBF_TEXT(trace
, 2, "addipato");
8096 spin_lock_irqsave(&card
->ip_lock
, flags
);
8097 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
8098 if (ipatoe
->proto
!= new->proto
)
8100 if (!memcmp(ipatoe
->addr
, new->addr
,
8101 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
8102 (ipatoe
->mask_bits
== new->mask_bits
)){
8103 PRINT_WARN("ipato entry already exists!\n");
8109 list_add_tail(&new->entry
, &card
->ipato
.entries
);
8111 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8116 qeth_del_ipato_entry(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8117 u8
*addr
, int mask_bits
)
8119 struct qeth_ipato_entry
*ipatoe
, *tmp
;
8120 unsigned long flags
;
8122 QETH_DBF_TEXT(trace
, 2, "delipato");
8123 spin_lock_irqsave(&card
->ip_lock
, flags
);
8124 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
){
8125 if (ipatoe
->proto
!= proto
)
8127 if (!memcmp(ipatoe
->addr
, addr
,
8128 (proto
== QETH_PROT_IPV4
)? 4:16) &&
8129 (ipatoe
->mask_bits
== mask_bits
)){
8130 list_del(&ipatoe
->entry
);
8134 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8138 qeth_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
8143 for (i
= 0; i
< len
; ++i
){
8145 for (j
= 7; j
>= 0; --j
){
8146 bits
[i
*8 + j
] = octet
& 1;
8153 qeth_is_addr_covered_by_ipato(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
8155 struct qeth_ipato_entry
*ipatoe
;
8156 u8 addr_bits
[128] = {0, };
8157 u8 ipatoe_bits
[128] = {0, };
8160 if (!card
->ipato
.enabled
)
8163 qeth_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
8164 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
8165 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
8166 if (addr
->proto
!= ipatoe
->proto
)
8168 qeth_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
8169 (ipatoe
->proto
==QETH_PROT_IPV4
) ?
8171 if (addr
->proto
== QETH_PROT_IPV4
)
8172 rc
= !memcmp(addr_bits
, ipatoe_bits
,
8173 min(32, ipatoe
->mask_bits
));
8175 rc
= !memcmp(addr_bits
, ipatoe_bits
,
8176 min(128, ipatoe
->mask_bits
));
8181 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
8183 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
8190 * VIPA related functions
8193 qeth_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8196 struct qeth_ipaddr
*ipaddr
;
8197 unsigned long flags
;
8200 ipaddr
= qeth_get_addr_buffer(proto
);
8202 if (proto
== QETH_PROT_IPV4
){
8203 QETH_DBF_TEXT(trace
, 2, "addvipa4");
8204 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8205 ipaddr
->u
.a4
.mask
= 0;
8206 #ifdef CONFIG_QETH_IPV6
8207 } else if (proto
== QETH_PROT_IPV6
){
8208 QETH_DBF_TEXT(trace
, 2, "addvipa6");
8209 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8210 ipaddr
->u
.a6
.pfxlen
= 0;
8213 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
8214 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
8215 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
8218 spin_lock_irqsave(&card
->ip_lock
, flags
);
8219 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
8220 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
8222 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8224 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
8227 if (!qeth_add_ip(card
, ipaddr
))
8229 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8230 schedule_work(&card
->kernel_thread_starter
);
8235 qeth_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8238 struct qeth_ipaddr
*ipaddr
;
8240 ipaddr
= qeth_get_addr_buffer(proto
);
8242 if (proto
== QETH_PROT_IPV4
){
8243 QETH_DBF_TEXT(trace
, 2, "delvipa4");
8244 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8245 ipaddr
->u
.a4
.mask
= 0;
8246 #ifdef CONFIG_QETH_IPV6
8247 } else if (proto
== QETH_PROT_IPV6
){
8248 QETH_DBF_TEXT(trace
, 2, "delvipa6");
8249 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8250 ipaddr
->u
.a6
.pfxlen
= 0;
8253 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
8256 if (!qeth_delete_ip(card
, ipaddr
))
8258 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8259 schedule_work(&card
->kernel_thread_starter
);
8263 * proxy ARP related functions
8266 qeth_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8269 struct qeth_ipaddr
*ipaddr
;
8270 unsigned long flags
;
8273 ipaddr
= qeth_get_addr_buffer(proto
);
8275 if (proto
== QETH_PROT_IPV4
){
8276 QETH_DBF_TEXT(trace
, 2, "addrxip4");
8277 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8278 ipaddr
->u
.a4
.mask
= 0;
8279 #ifdef CONFIG_QETH_IPV6
8280 } else if (proto
== QETH_PROT_IPV6
){
8281 QETH_DBF_TEXT(trace
, 2, "addrxip6");
8282 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8283 ipaddr
->u
.a6
.pfxlen
= 0;
8286 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
8287 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
8288 ipaddr
->del_flags
= 0;
8291 spin_lock_irqsave(&card
->ip_lock
, flags
);
8292 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
8293 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
8295 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8297 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
8300 if (!qeth_add_ip(card
, ipaddr
))
8302 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8303 schedule_work(&card
->kernel_thread_starter
);
8308 qeth_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8311 struct qeth_ipaddr
*ipaddr
;
8313 ipaddr
= qeth_get_addr_buffer(proto
);
8315 if (proto
== QETH_PROT_IPV4
){
8316 QETH_DBF_TEXT(trace
, 2, "addrxip4");
8317 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8318 ipaddr
->u
.a4
.mask
= 0;
8319 #ifdef CONFIG_QETH_IPV6
8320 } else if (proto
== QETH_PROT_IPV6
){
8321 QETH_DBF_TEXT(trace
, 2, "addrxip6");
8322 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8323 ipaddr
->u
.a6
.pfxlen
= 0;
8326 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
8329 if (!qeth_delete_ip(card
, ipaddr
))
8331 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8332 schedule_work(&card
->kernel_thread_starter
);
8339 qeth_ip_event(struct notifier_block
*this,
8340 unsigned long event
,void *ptr
)
8342 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
8343 struct net_device
*dev
=(struct net_device
*) ifa
->ifa_dev
->dev
;
8344 struct qeth_ipaddr
*addr
;
8345 struct qeth_card
*card
;
8347 QETH_DBF_TEXT(trace
,3,"ipevent");
8348 card
= qeth_get_card_from_dev(dev
);
8351 if (card
->options
.layer2
)
8354 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
8356 addr
->u
.a4
.addr
= ifa
->ifa_address
;
8357 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
8358 addr
->type
= QETH_IP_TYPE_NORMAL
;
8364 if (!qeth_add_ip(card
, addr
))
8368 if (!qeth_delete_ip(card
, addr
))
8374 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8375 schedule_work(&card
->kernel_thread_starter
);
8380 static struct notifier_block qeth_ip_notifier
= {
8385 #ifdef CONFIG_QETH_IPV6
8387 * IPv6 event handler
8390 qeth_ip6_event(struct notifier_block
*this,
8391 unsigned long event
,void *ptr
)
8394 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
8395 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
8396 struct qeth_ipaddr
*addr
;
8397 struct qeth_card
*card
;
8399 QETH_DBF_TEXT(trace
,3,"ip6event");
8401 card
= qeth_get_card_from_dev(dev
);
8404 if (!qeth_is_supported(card
, IPA_IPV6
))
8407 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
8409 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
8410 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
8411 addr
->type
= QETH_IP_TYPE_NORMAL
;
8417 if (!qeth_add_ip(card
, addr
))
8421 if (!qeth_delete_ip(card
, addr
))
8427 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8428 schedule_work(&card
->kernel_thread_starter
);
8433 static struct notifier_block qeth_ip6_notifier
= {
8440 __qeth_reboot_event_card(struct device
*dev
, void *data
)
8442 struct qeth_card
*card
;
8444 card
= (struct qeth_card
*) dev
->driver_data
;
8445 qeth_clear_ip_list(card
, 0, 0);
8446 qeth_qdio_clear_card(card
, 0);
8451 qeth_reboot_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
8454 driver_for_each_device(&qeth_ccwgroup_driver
.driver
, NULL
, NULL
,
8455 __qeth_reboot_event_card
);
8460 static struct notifier_block qeth_reboot_notifier
= {
8466 qeth_register_notifiers(void)
8470 QETH_DBF_TEXT(trace
,5,"regnotif");
8471 if ((r
= register_reboot_notifier(&qeth_reboot_notifier
)))
8473 if ((r
= register_inetaddr_notifier(&qeth_ip_notifier
)))
8475 #ifdef CONFIG_QETH_IPV6
8476 if ((r
= register_inet6addr_notifier(&qeth_ip6_notifier
)))
8481 #ifdef CONFIG_QETH_IPV6
8483 unregister_inetaddr_notifier(&qeth_ip_notifier
);
8486 unregister_reboot_notifier(&qeth_reboot_notifier
);
8491 * unregister all event notifiers
8494 qeth_unregister_notifiers(void)
8497 QETH_DBF_TEXT(trace
,5,"unregnot");
8498 BUG_ON(unregister_reboot_notifier(&qeth_reboot_notifier
));
8499 BUG_ON(unregister_inetaddr_notifier(&qeth_ip_notifier
));
8500 #ifdef CONFIG_QETH_IPV6
8501 BUG_ON(unregister_inet6addr_notifier(&qeth_ip6_notifier
));
8502 #endif /* QETH_IPV6 */
8506 #ifdef CONFIG_QETH_IPV6
8508 qeth_ipv6_init(void)
8510 qeth_old_arp_constructor
= arp_tbl
.constructor
;
8511 write_lock(&arp_tbl
.lock
);
8512 arp_tbl
.constructor
= qeth_arp_constructor
;
8513 write_unlock(&arp_tbl
.lock
);
8515 arp_direct_ops
= (struct neigh_ops
*)
8516 kmalloc(sizeof(struct neigh_ops
), GFP_KERNEL
);
8517 if (!arp_direct_ops
)
8520 memcpy(arp_direct_ops
, &arp_direct_ops_template
,
8521 sizeof(struct neigh_ops
));
8527 qeth_ipv6_uninit(void)
8529 write_lock(&arp_tbl
.lock
);
8530 arp_tbl
.constructor
= qeth_old_arp_constructor
;
8531 write_unlock(&arp_tbl
.lock
);
8532 kfree(arp_direct_ops
);
8534 #endif /* CONFIG_QETH_IPV6 */
8537 qeth_sysfs_unregister(void)
8539 qeth_remove_driver_attributes();
8540 ccw_driver_unregister(&qeth_ccw_driver
);
8541 ccwgroup_driver_unregister(&qeth_ccwgroup_driver
);
8542 s390_root_dev_unregister(qeth_root_dev
);
8545 * register qeth at sysfs
8548 qeth_sysfs_register(void)
8552 rc
= ccwgroup_driver_register(&qeth_ccwgroup_driver
);
8555 rc
= ccw_driver_register(&qeth_ccw_driver
);
8558 rc
= qeth_create_driver_attributes();
8561 qeth_root_dev
= s390_root_dev_register("qeth");
8562 if (IS_ERR(qeth_root_dev
)) {
8563 rc
= PTR_ERR(qeth_root_dev
);
8577 PRINT_INFO("loading %s\n", version
);
8579 INIT_LIST_HEAD(&qeth_card_list
.list
);
8580 INIT_LIST_HEAD(&qeth_notify_list
);
8581 spin_lock_init(&qeth_notify_lock
);
8582 rwlock_init(&qeth_card_list
.rwlock
);
8584 if (qeth_register_dbf_views())
8586 if (qeth_sysfs_register())
8589 #ifdef CONFIG_QETH_IPV6
8590 if (qeth_ipv6_init()) {
8591 PRINT_ERR("Out of memory during ipv6 init.\n");
8594 #endif /* QETH_IPV6 */
8595 if (qeth_register_notifiers())
8597 if (qeth_create_procfs_entries())
8603 qeth_unregister_notifiers();
8605 #ifdef CONFIG_QETH_IPV6
8607 #endif /* QETH_IPV6 */
8609 qeth_sysfs_unregister();
8610 qeth_unregister_dbf_views();
8612 PRINT_ERR("Initialization failed");
8617 __exit
qeth_exit(void)
8619 struct qeth_card
*card
, *tmp
;
8620 unsigned long flags
;
8622 QETH_DBF_TEXT(trace
,1, "cleanup.");
8625 * Weed would not need to clean up our devices here, because the
8626 * common device layer calls qeth_remove_device for each device
8627 * as soon as we unregister our driver (done in qeth_sysfs_unregister).
8628 * But we do cleanup here so we can do a "soft" shutdown of our cards.
8629 * qeth_remove_device called by the common device layer would otherwise
8630 * do a "hard" shutdown (card->use_hard_stop is set to one in
8631 * qeth_remove_device).
8634 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
8635 list_for_each_entry_safe(card
, tmp
, &qeth_card_list
.list
, list
){
8636 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8637 qeth_set_offline(card
->gdev
);
8638 qeth_remove_device(card
->gdev
);
8641 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8642 #ifdef CONFIG_QETH_IPV6
8645 qeth_unregister_notifiers();
8646 qeth_remove_procfs_entries();
8647 qeth_sysfs_unregister();
8648 qeth_unregister_dbf_views();
8649 printk("qeth: removed\n");
8652 EXPORT_SYMBOL(qeth_osn_register
);
8653 EXPORT_SYMBOL(qeth_osn_deregister
);
8654 EXPORT_SYMBOL(qeth_osn_assist
);
8655 module_init(qeth_init
);
8656 module_exit(qeth_exit
);
8657 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
8658 MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \
8659 "Copyright 2000,2003 IBM Corporation\n");
8661 MODULE_LICENSE("GPL");