3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.206 $)
5 * Linux on zSeries OSA Express and HiperSockets support
7 * Copyright 2000,2003 IBM Corporation
9 * Author(s): Original Code written by
10 * Utz Bacher (utz.bacher@de.ibm.com)
12 * Frank Pavlic (pavlic@de.ibm.com) and
13 * Thomas Spatzier <tspat@de.ibm.com>
15 * $Revision: 1.206 $ $Date: 2005/03/24 09:04:18 $
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option)
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 * eye catcher; just for debugging purposes
41 #include <linux/config.h>
42 #include <linux/module.h>
43 #include <linux/moduleparam.h>
44 #include <linux/string.h>
45 #include <linux/errno.h>
48 #include <linux/inetdevice.h>
49 #include <linux/netdevice.h>
50 #include <linux/sched.h>
51 #include <linux/workqueue.h>
52 #include <linux/kernel.h>
53 #include <linux/slab.h>
54 #include <linux/interrupt.h>
55 #include <linux/tcp.h>
56 #include <linux/icmp.h>
57 #include <linux/skbuff.h>
59 #include <linux/igmp.h>
60 #include <linux/init.h>
61 #include <linux/reboot.h>
62 #include <linux/mii.h>
63 #include <linux/rcupdate.h>
64 #include <linux/ethtool.h>
68 #include <net/route.h>
70 #include <asm/ebcdic.h>
73 #include <asm/timex.h>
74 #include <asm/semaphore.h>
75 #include <asm/uaccess.h>
80 #include "qeth_eddp.h"
83 #define VERSION_QETH_C "$Revision: 1.206 $"
84 static const char *version
= "qeth S/390 OSA-Express driver";
87 * Debug Facility Stuff
89 static debug_info_t
*qeth_dbf_setup
= NULL
;
90 static debug_info_t
*qeth_dbf_data
= NULL
;
91 static debug_info_t
*qeth_dbf_misc
= NULL
;
92 static debug_info_t
*qeth_dbf_control
= NULL
;
93 debug_info_t
*qeth_dbf_trace
= NULL
;
94 static debug_info_t
*qeth_dbf_sense
= NULL
;
95 static debug_info_t
*qeth_dbf_qerr
= NULL
;
97 DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf
);
100 * some more definitions and declarations
102 static unsigned int known_devices
[][10] = QETH_MODELLIST_ARRAY
;
104 /* list of our cards */
105 struct qeth_card_list_struct qeth_card_list
;
106 /*process list want to be notified*/
107 spinlock_t qeth_notify_lock
;
108 struct list_head qeth_notify_list
;
110 static void qeth_send_control_data_cb(struct qeth_channel
*,
111 struct qeth_cmd_buffer
*);
114 * here we go with function implementation
117 qeth_init_qdio_info(struct qeth_card
*card
);
120 qeth_init_qdio_queues(struct qeth_card
*card
);
123 qeth_alloc_qdio_buffers(struct qeth_card
*card
);
126 qeth_free_qdio_buffers(struct qeth_card
*);
129 qeth_clear_qdio_buffers(struct qeth_card
*);
132 qeth_clear_ip_list(struct qeth_card
*, int, int);
135 qeth_clear_ipacmd_list(struct qeth_card
*);
138 qeth_qdio_clear_card(struct qeth_card
*, int);
141 qeth_clear_working_pool_list(struct qeth_card
*);
144 qeth_clear_cmd_buffers(struct qeth_channel
*);
147 qeth_stop(struct net_device
*);
150 qeth_clear_ipato_list(struct qeth_card
*);
153 qeth_is_addr_covered_by_ipato(struct qeth_card
*, struct qeth_ipaddr
*);
156 qeth_irq_tasklet(unsigned long);
159 qeth_set_online(struct ccwgroup_device
*);
161 static struct qeth_ipaddr
*
162 qeth_get_addr_buffer(enum qeth_prot_versions
);
165 qeth_set_multicast_list(struct net_device
*);
168 qeth_notify_processes(void)
170 /*notify all registered processes */
171 struct qeth_notify_list_struct
*n_entry
;
173 QETH_DBF_TEXT(trace
,3,"procnoti");
174 spin_lock(&qeth_notify_lock
);
175 list_for_each_entry(n_entry
, &qeth_notify_list
, list
) {
176 send_sig(n_entry
->signum
, n_entry
->task
, 1);
178 spin_unlock(&qeth_notify_lock
);
182 qeth_notifier_unregister(struct task_struct
*p
)
184 struct qeth_notify_list_struct
*n_entry
, *tmp
;
186 QETH_DBF_TEXT(trace
, 2, "notunreg");
187 spin_lock(&qeth_notify_lock
);
188 list_for_each_entry_safe(n_entry
, tmp
, &qeth_notify_list
, list
) {
189 if (n_entry
->task
== p
) {
190 list_del(&n_entry
->list
);
196 spin_unlock(&qeth_notify_lock
);
200 qeth_notifier_register(struct task_struct
*p
, int signum
)
202 struct qeth_notify_list_struct
*n_entry
;
205 /*check first if entry already exists*/
206 spin_lock(&qeth_notify_lock
);
207 list_for_each_entry(n_entry
, &qeth_notify_list
, list
) {
208 if (n_entry
->task
== p
) {
209 n_entry
->signum
= signum
;
210 spin_unlock(&qeth_notify_lock
);
214 spin_unlock(&qeth_notify_lock
);
216 n_entry
= (struct qeth_notify_list_struct
*)
217 kmalloc(sizeof(struct qeth_notify_list_struct
),GFP_KERNEL
);
221 n_entry
->signum
= signum
;
222 spin_lock(&qeth_notify_lock
);
223 list_add(&n_entry
->list
,&qeth_notify_list
);
224 spin_unlock(&qeth_notify_lock
);
230 * free channel command buffers
233 qeth_clean_channel(struct qeth_channel
*channel
)
237 QETH_DBF_TEXT(setup
, 2, "freech");
238 for (cnt
= 0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
239 kfree(channel
->iob
[cnt
].data
);
246 qeth_free_card(struct qeth_card
*card
)
249 QETH_DBF_TEXT(setup
, 2, "freecrd");
250 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
251 qeth_clean_channel(&card
->read
);
252 qeth_clean_channel(&card
->write
);
254 free_netdev(card
->dev
);
255 qeth_clear_ip_list(card
, 0, 0);
256 qeth_clear_ipato_list(card
);
257 kfree(card
->ip_tbd_list
);
258 qeth_free_qdio_buffers(card
);
263 * alloc memory for command buffer per channel
266 qeth_setup_channel(struct qeth_channel
*channel
)
270 QETH_DBF_TEXT(setup
, 2, "setupch");
271 for (cnt
=0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++) {
272 channel
->iob
[cnt
].data
= (char *)
273 kmalloc(QETH_BUFSIZE
, GFP_DMA
|GFP_KERNEL
);
274 if (channel
->iob
[cnt
].data
== NULL
)
276 channel
->iob
[cnt
].state
= BUF_STATE_FREE
;
277 channel
->iob
[cnt
].channel
= channel
;
278 channel
->iob
[cnt
].callback
= qeth_send_control_data_cb
;
279 channel
->iob
[cnt
].rc
= 0;
281 if (cnt
< QETH_CMD_BUFFER_NO
) {
283 kfree(channel
->iob
[cnt
].data
);
287 channel
->io_buf_no
= 0;
288 atomic_set(&channel
->irq_pending
, 0);
289 spin_lock_init(&channel
->iob_lock
);
291 init_waitqueue_head(&channel
->wait_q
);
292 channel
->irq_tasklet
.data
= (unsigned long) channel
;
293 channel
->irq_tasklet
.func
= qeth_irq_tasklet
;
298 * alloc memory for card structure
300 static struct qeth_card
*
301 qeth_alloc_card(void)
303 struct qeth_card
*card
;
305 QETH_DBF_TEXT(setup
, 2, "alloccrd");
306 card
= (struct qeth_card
*) kmalloc(sizeof(struct qeth_card
),
310 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
311 memset(card
, 0, sizeof(struct qeth_card
));
312 if (qeth_setup_channel(&card
->read
)) {
316 if (qeth_setup_channel(&card
->write
)) {
317 qeth_clean_channel(&card
->read
);
325 __qeth_check_irb_error(struct ccw_device
*cdev
, struct irb
*irb
)
330 switch (PTR_ERR(irb
)) {
332 PRINT_WARN("i/o-error on device %s\n", cdev
->dev
.bus_id
);
333 QETH_DBF_TEXT(trace
, 2, "ckirberr");
334 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
337 PRINT_WARN("timeout on device %s\n", cdev
->dev
.bus_id
);
338 QETH_DBF_TEXT(trace
, 2, "ckirberr");
339 QETH_DBF_TEXT_(trace
, 2, " rc%d", -ETIMEDOUT
);
342 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb
),
344 QETH_DBF_TEXT(trace
, 2, "ckirberr");
345 QETH_DBF_TEXT(trace
, 2, " rc???");
351 qeth_get_problem(struct ccw_device
*cdev
, struct irb
*irb
)
356 sense
= (char *) irb
->ecw
;
357 cstat
= irb
->scsw
.cstat
;
358 dstat
= irb
->scsw
.dstat
;
360 if (cstat
& (SCHN_STAT_CHN_CTRL_CHK
| SCHN_STAT_INTF_CTRL_CHK
|
361 SCHN_STAT_CHN_DATA_CHK
| SCHN_STAT_CHAIN_CHECK
|
362 SCHN_STAT_PROT_CHECK
| SCHN_STAT_PROG_CHECK
)) {
363 QETH_DBF_TEXT(trace
,2, "CGENCHK");
364 PRINT_WARN("check on device %s, dstat=x%x, cstat=x%x ",
365 cdev
->dev
.bus_id
, dstat
, cstat
);
366 HEXDUMP16(WARN
, "irb: ", irb
);
367 HEXDUMP16(WARN
, "irb: ", ((char *) irb
) + 32);
371 if (dstat
& DEV_STAT_UNIT_CHECK
) {
372 if (sense
[SENSE_RESETTING_EVENT_BYTE
] &
373 SENSE_RESETTING_EVENT_FLAG
) {
374 QETH_DBF_TEXT(trace
,2,"REVIND");
377 if (sense
[SENSE_COMMAND_REJECT_BYTE
] &
378 SENSE_COMMAND_REJECT_FLAG
) {
379 QETH_DBF_TEXT(trace
,2,"CMDREJi");
382 if ((sense
[2] == 0xaf) && (sense
[3] == 0xfe)) {
383 QETH_DBF_TEXT(trace
,2,"AFFE");
386 if ((!sense
[0]) && (!sense
[1]) && (!sense
[2]) && (!sense
[3])) {
387 QETH_DBF_TEXT(trace
,2,"ZEROSEN");
390 QETH_DBF_TEXT(trace
,2,"DGENCHK");
395 static int qeth_issue_next_read(struct qeth_card
*);
401 qeth_irq(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
405 struct qeth_cmd_buffer
*buffer
;
406 struct qeth_channel
*channel
;
407 struct qeth_card
*card
;
409 QETH_DBF_TEXT(trace
,5,"irq");
411 if (__qeth_check_irb_error(cdev
, irb
))
413 cstat
= irb
->scsw
.cstat
;
414 dstat
= irb
->scsw
.dstat
;
416 card
= CARD_FROM_CDEV(cdev
);
420 if (card
->read
.ccwdev
== cdev
){
421 channel
= &card
->read
;
422 QETH_DBF_TEXT(trace
,5,"read");
423 } else if (card
->write
.ccwdev
== cdev
) {
424 channel
= &card
->write
;
425 QETH_DBF_TEXT(trace
,5,"write");
427 channel
= &card
->data
;
428 QETH_DBF_TEXT(trace
,5,"data");
430 atomic_set(&channel
->irq_pending
, 0);
432 if (irb
->scsw
.fctl
& (SCSW_FCTL_CLEAR_FUNC
))
433 channel
->state
= CH_STATE_STOPPED
;
435 if (irb
->scsw
.fctl
& (SCSW_FCTL_HALT_FUNC
))
436 channel
->state
= CH_STATE_HALTED
;
438 /*let's wake up immediately on data channel*/
439 if ((channel
== &card
->data
) && (intparm
!= 0))
442 if (intparm
== QETH_CLEAR_CHANNEL_PARM
) {
443 QETH_DBF_TEXT(trace
, 6, "clrchpar");
444 /* we don't have to handle this further */
447 if (intparm
== QETH_HALT_CHANNEL_PARM
) {
448 QETH_DBF_TEXT(trace
, 6, "hltchpar");
449 /* we don't have to handle this further */
452 if ((dstat
& DEV_STAT_UNIT_EXCEP
) ||
453 (dstat
& DEV_STAT_UNIT_CHECK
) ||
455 if (irb
->esw
.esw0
.erw
.cons
) {
456 /* TODO: we should make this s390dbf */
457 PRINT_WARN("sense data available on channel %s.\n",
458 CHANNEL_ID(channel
));
459 PRINT_WARN(" cstat 0x%X\n dstat 0x%X\n", cstat
, dstat
);
460 HEXDUMP16(WARN
,"irb: ",irb
);
461 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
463 rc
= qeth_get_problem(cdev
,irb
);
465 qeth_schedule_recovery(card
);
471 buffer
= (struct qeth_cmd_buffer
*) __va((addr_t
)intparm
);
472 buffer
->state
= BUF_STATE_PROCESSED
;
474 if (channel
== &card
->data
)
477 if (channel
== &card
->read
&&
478 channel
->state
== CH_STATE_UP
)
479 qeth_issue_next_read(card
);
481 tasklet_schedule(&channel
->irq_tasklet
);
484 wake_up(&card
->wait_q
);
488 * tasklet function scheduled from irq handler
491 qeth_irq_tasklet(unsigned long data
)
493 struct qeth_card
*card
;
494 struct qeth_channel
*channel
;
495 struct qeth_cmd_buffer
*iob
;
498 QETH_DBF_TEXT(trace
,5,"irqtlet");
499 channel
= (struct qeth_channel
*) data
;
501 index
= channel
->buf_no
;
502 card
= CARD_FROM_CDEV(channel
->ccwdev
);
503 while (iob
[index
].state
== BUF_STATE_PROCESSED
) {
504 if (iob
[index
].callback
!=NULL
) {
505 iob
[index
].callback(channel
,iob
+ index
);
507 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
509 channel
->buf_no
= index
;
510 wake_up(&card
->wait_q
);
513 static int qeth_stop_card(struct qeth_card
*);
516 qeth_set_offline(struct ccwgroup_device
*cgdev
)
518 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
520 enum qeth_card_states recover_flag
;
522 QETH_DBF_TEXT(setup
, 3, "setoffl");
523 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
525 recover_flag
= card
->state
;
526 if (qeth_stop_card(card
) == -ERESTARTSYS
){
527 PRINT_WARN("Stopping card %s interrupted by user!\n",
531 if ((rc
= ccw_device_set_offline(CARD_DDEV(card
))) ||
532 (rc
= ccw_device_set_offline(CARD_WDEV(card
))) ||
533 (rc
= ccw_device_set_offline(CARD_RDEV(card
)))) {
534 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
536 if (recover_flag
== CARD_STATE_UP
)
537 card
->state
= CARD_STATE_RECOVER
;
538 qeth_notify_processes();
543 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
);
547 qeth_remove_device(struct ccwgroup_device
*cgdev
)
549 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
552 QETH_DBF_TEXT(setup
, 3, "rmdev");
553 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
558 if (qeth_wait_for_threads(card
, 0xffffffff))
561 if (cgdev
->state
== CCWGROUP_ONLINE
){
562 card
->use_hard_stop
= 1;
563 qeth_set_offline(cgdev
);
565 /* remove form our internal list */
566 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
567 list_del(&card
->list
);
568 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
570 unregister_netdev(card
->dev
);
571 qeth_remove_device_attributes(&cgdev
->dev
);
572 qeth_free_card(card
);
573 cgdev
->dev
.driver_data
= NULL
;
574 put_device(&cgdev
->dev
);
578 qeth_register_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
580 qeth_deregister_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
583 * Add/remove address to/from card's ip list, i.e. try to add or remove
584 * reference to/from an IP address that is already registered on the card.
586 * 0 address was on card and its reference count has been adjusted,
587 * but is still > 0, so nothing has to be done
588 * also returns 0 if card was not on card and the todo was to delete
589 * the address -> there is also nothing to be done
590 * 1 address was not on card and the todo is to add it to the card's ip
592 * -1 address was on card and its reference count has been decremented
593 * to <= 0 by the todo -> address must be removed from card
596 __qeth_ref_ip_on_card(struct qeth_card
*card
, struct qeth_ipaddr
*todo
,
597 struct qeth_ipaddr
**__addr
)
599 struct qeth_ipaddr
*addr
;
602 list_for_each_entry(addr
, &card
->ip_list
, entry
) {
603 if ((addr
->proto
== QETH_PROT_IPV4
) &&
604 (todo
->proto
== QETH_PROT_IPV4
) &&
605 (addr
->type
== todo
->type
) &&
606 (addr
->u
.a4
.addr
== todo
->u
.a4
.addr
) &&
607 (addr
->u
.a4
.mask
== todo
->u
.a4
.mask
) ){
611 if ((addr
->proto
== QETH_PROT_IPV6
) &&
612 (todo
->proto
== QETH_PROT_IPV6
) &&
613 (addr
->type
== todo
->type
) &&
614 (addr
->u
.a6
.pfxlen
== todo
->u
.a6
.pfxlen
) &&
615 (memcmp(&addr
->u
.a6
.addr
, &todo
->u
.a6
.addr
,
616 sizeof(struct in6_addr
)) == 0)) {
622 addr
->users
+= todo
->users
;
623 if (addr
->users
<= 0){
627 /* for VIPA and RXIP limit refcount to 1 */
628 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
633 if (todo
->users
> 0){
634 /* for VIPA and RXIP limit refcount to 1 */
635 if (todo
->type
!= QETH_IP_TYPE_NORMAL
)
643 __qeth_address_exists_in_list(struct list_head
*list
, struct qeth_ipaddr
*addr
,
646 struct qeth_ipaddr
*tmp
;
648 list_for_each_entry(tmp
, list
, entry
) {
649 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
650 (addr
->proto
== QETH_PROT_IPV4
) &&
651 ((same_type
&& (tmp
->type
== addr
->type
)) ||
652 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
653 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) ){
656 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
657 (addr
->proto
== QETH_PROT_IPV6
) &&
658 ((same_type
&& (tmp
->type
== addr
->type
)) ||
659 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
660 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
661 sizeof(struct in6_addr
)) == 0) ) {
669 * Add IP to be added to todo list. If there is already an "add todo"
670 * in this list we just incremenent the reference count.
671 * Returns 0 if we just incremented reference count.
674 __qeth_insert_ip_todo(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int add
)
676 struct qeth_ipaddr
*tmp
, *t
;
679 list_for_each_entry_safe(tmp
, t
, card
->ip_tbd_list
, entry
) {
680 if ((addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
) &&
681 (tmp
->type
== QETH_IP_TYPE_DEL_ALL_MC
))
683 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
684 (addr
->proto
== QETH_PROT_IPV4
) &&
685 (tmp
->type
== addr
->type
) &&
686 (tmp
->is_multicast
== addr
->is_multicast
) &&
687 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) &&
688 (tmp
->u
.a4
.mask
== addr
->u
.a4
.mask
) ){
692 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
693 (addr
->proto
== QETH_PROT_IPV6
) &&
694 (tmp
->type
== addr
->type
) &&
695 (tmp
->is_multicast
== addr
->is_multicast
) &&
696 (tmp
->u
.a6
.pfxlen
== addr
->u
.a6
.pfxlen
) &&
697 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
698 sizeof(struct in6_addr
)) == 0) ){
704 if (addr
->users
!= 0)
705 tmp
->users
+= addr
->users
;
707 tmp
->users
+= add
? 1:-1;
708 if (tmp
->users
== 0){
709 list_del(&tmp
->entry
);
714 if (addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
)
715 list_add(&addr
->entry
, card
->ip_tbd_list
);
717 if (addr
->users
== 0)
718 addr
->users
+= add
? 1:-1;
719 if (add
&& (addr
->type
== QETH_IP_TYPE_NORMAL
) &&
720 qeth_is_addr_covered_by_ipato(card
, addr
)){
721 QETH_DBF_TEXT(trace
, 2, "tkovaddr");
722 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
724 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
731 * Remove IP address from list
734 qeth_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
739 QETH_DBF_TEXT(trace
,4,"delip");
740 if (addr
->proto
== QETH_PROT_IPV4
)
741 QETH_DBF_HEX(trace
,4,&addr
->u
.a4
.addr
,4);
743 QETH_DBF_HEX(trace
,4,&addr
->u
.a6
.addr
,8);
744 QETH_DBF_HEX(trace
,4,((char *)&addr
->u
.a6
.addr
)+8,8);
746 spin_lock_irqsave(&card
->ip_lock
, flags
);
747 rc
= __qeth_insert_ip_todo(card
, addr
, 0);
748 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
753 qeth_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
758 QETH_DBF_TEXT(trace
,4,"addip");
759 if (addr
->proto
== QETH_PROT_IPV4
)
760 QETH_DBF_HEX(trace
,4,&addr
->u
.a4
.addr
,4);
762 QETH_DBF_HEX(trace
,4,&addr
->u
.a6
.addr
,8);
763 QETH_DBF_HEX(trace
,4,((char *)&addr
->u
.a6
.addr
)+8,8);
765 spin_lock_irqsave(&card
->ip_lock
, flags
);
766 rc
= __qeth_insert_ip_todo(card
, addr
, 1);
767 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
772 __qeth_delete_all_mc(struct qeth_card
*card
, unsigned long *flags
)
774 struct qeth_ipaddr
*addr
, *tmp
;
777 list_for_each_entry_safe(addr
, tmp
, &card
->ip_list
, entry
) {
778 if (addr
->is_multicast
) {
779 spin_unlock_irqrestore(&card
->ip_lock
, *flags
);
780 rc
= qeth_deregister_addr_entry(card
, addr
);
781 spin_lock_irqsave(&card
->ip_lock
, *flags
);
783 list_del(&addr
->entry
);
791 qeth_set_ip_addr_list(struct qeth_card
*card
)
793 struct list_head
*tbd_list
;
794 struct qeth_ipaddr
*todo
, *addr
;
798 QETH_DBF_TEXT(trace
, 2, "sdiplist");
799 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
801 spin_lock_irqsave(&card
->ip_lock
, flags
);
802 tbd_list
= card
->ip_tbd_list
;
803 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_ATOMIC
);
804 if (!card
->ip_tbd_list
) {
805 QETH_DBF_TEXT(trace
, 0, "silnomem");
806 card
->ip_tbd_list
= tbd_list
;
807 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
810 INIT_LIST_HEAD(card
->ip_tbd_list
);
812 while (!list_empty(tbd_list
)){
813 todo
= list_entry(tbd_list
->next
, struct qeth_ipaddr
, entry
);
814 list_del(&todo
->entry
);
815 if (todo
->type
== QETH_IP_TYPE_DEL_ALL_MC
){
816 __qeth_delete_all_mc(card
, &flags
);
820 rc
= __qeth_ref_ip_on_card(card
, todo
, &addr
);
822 /* nothing to be done; only adjusted refcount */
824 } else if (rc
== 1) {
825 /* new entry to be added to on-card list */
826 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
827 rc
= qeth_register_addr_entry(card
, todo
);
828 spin_lock_irqsave(&card
->ip_lock
, flags
);
830 list_add_tail(&todo
->entry
, &card
->ip_list
);
833 } else if (rc
== -1) {
834 /* on-card entry to be removed */
835 list_del_init(&addr
->entry
);
836 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
837 rc
= qeth_deregister_addr_entry(card
, addr
);
838 spin_lock_irqsave(&card
->ip_lock
, flags
);
842 list_add_tail(&addr
->entry
, &card
->ip_list
);
846 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
850 static void qeth_delete_mc_addresses(struct qeth_card
*);
851 static void qeth_add_multicast_ipv4(struct qeth_card
*);
852 #ifdef CONFIG_QETH_IPV6
853 static void qeth_add_multicast_ipv6(struct qeth_card
*);
857 qeth_set_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
861 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
862 if ( !(card
->thread_allowed_mask
& thread
) ||
863 (card
->thread_start_mask
& thread
) ) {
864 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
867 card
->thread_start_mask
|= thread
;
868 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
873 qeth_clear_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
877 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
878 card
->thread_start_mask
&= ~thread
;
879 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
880 wake_up(&card
->wait_q
);
884 qeth_clear_thread_running_bit(struct qeth_card
*card
, unsigned long thread
)
888 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
889 card
->thread_running_mask
&= ~thread
;
890 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
891 wake_up(&card
->wait_q
);
895 __qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
900 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
901 if (card
->thread_start_mask
& thread
){
902 if ((card
->thread_allowed_mask
& thread
) &&
903 !(card
->thread_running_mask
& thread
)){
905 card
->thread_start_mask
&= ~thread
;
906 card
->thread_running_mask
|= thread
;
910 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
915 qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
919 wait_event(card
->wait_q
,
920 (rc
= __qeth_do_run_thread(card
, thread
)) >= 0);
925 qeth_register_ip_addresses(void *ptr
)
927 struct qeth_card
*card
;
929 card
= (struct qeth_card
*) ptr
;
930 daemonize("qeth_reg_ip");
931 QETH_DBF_TEXT(trace
,4,"regipth1");
932 if (!qeth_do_run_thread(card
, QETH_SET_IP_THREAD
))
934 QETH_DBF_TEXT(trace
,4,"regipth2");
935 qeth_set_ip_addr_list(card
);
936 qeth_clear_thread_running_bit(card
, QETH_SET_IP_THREAD
);
941 qeth_recover(void *ptr
)
943 struct qeth_card
*card
;
946 card
= (struct qeth_card
*) ptr
;
947 daemonize("qeth_recover");
948 QETH_DBF_TEXT(trace
,2,"recover1");
949 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
950 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
952 QETH_DBF_TEXT(trace
,2,"recover2");
953 PRINT_WARN("Recovery of device %s started ...\n",
955 card
->use_hard_stop
= 1;
956 qeth_set_offline(card
->gdev
);
957 rc
= qeth_set_online(card
->gdev
);
959 PRINT_INFO("Device %s successfully recovered!\n",
962 PRINT_INFO("Device %s could not be recovered!\n",
964 /* don't run another scheduled recovery */
965 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
966 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
971 qeth_schedule_recovery(struct qeth_card
*card
)
973 QETH_DBF_TEXT(trace
,2,"startrec");
975 if (qeth_set_thread_start_bit(card
, QETH_RECOVER_THREAD
) == 0)
976 schedule_work(&card
->kernel_thread_starter
);
980 qeth_do_start_thread(struct qeth_card
*card
, unsigned long thread
)
985 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
986 QETH_DBF_TEXT_(trace
, 4, " %02x%02x%02x",
987 (u8
) card
->thread_start_mask
,
988 (u8
) card
->thread_allowed_mask
,
989 (u8
) card
->thread_running_mask
);
990 rc
= (card
->thread_start_mask
& thread
);
991 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
996 qeth_start_kernel_thread(struct qeth_card
*card
)
998 QETH_DBF_TEXT(trace
, 2, "strthrd");
1000 if (card
->read
.state
!= CH_STATE_UP
&&
1001 card
->write
.state
!= CH_STATE_UP
)
1004 if (qeth_do_start_thread(card
, QETH_SET_IP_THREAD
))
1005 kernel_thread(qeth_register_ip_addresses
, (void *)card
,SIGCHLD
);
1006 if (qeth_do_start_thread(card
, QETH_RECOVER_THREAD
))
1007 kernel_thread(qeth_recover
, (void *) card
, SIGCHLD
);
1012 qeth_set_intial_options(struct qeth_card
*card
)
1014 card
->options
.route4
.type
= NO_ROUTER
;
1015 #ifdef CONFIG_QETH_IPV6
1016 card
->options
.route6
.type
= NO_ROUTER
;
1017 #endif /* QETH_IPV6 */
1018 card
->options
.checksum_type
= QETH_CHECKSUM_DEFAULT
;
1019 card
->options
.broadcast_mode
= QETH_TR_BROADCAST_ALLRINGS
;
1020 card
->options
.macaddr_mode
= QETH_TR_MACADDR_NONCANONICAL
;
1021 card
->options
.fake_broadcast
= 0;
1022 card
->options
.add_hhlen
= DEFAULT_ADD_HHLEN
;
1023 card
->options
.fake_ll
= 0;
1024 card
->options
.layer2
= 0;
1028 * initialize channels ,card and all state machines
1031 qeth_setup_card(struct qeth_card
*card
)
1034 QETH_DBF_TEXT(setup
, 2, "setupcrd");
1035 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
1037 card
->read
.state
= CH_STATE_DOWN
;
1038 card
->write
.state
= CH_STATE_DOWN
;
1039 card
->data
.state
= CH_STATE_DOWN
;
1040 card
->state
= CARD_STATE_DOWN
;
1041 card
->lan_online
= 0;
1042 card
->use_hard_stop
= 0;
1044 #ifdef CONFIG_QETH_VLAN
1045 spin_lock_init(&card
->vlanlock
);
1046 card
->vlangrp
= NULL
;
1048 spin_lock_init(&card
->ip_lock
);
1049 spin_lock_init(&card
->thread_mask_lock
);
1050 card
->thread_start_mask
= 0;
1051 card
->thread_allowed_mask
= 0;
1052 card
->thread_running_mask
= 0;
1053 INIT_WORK(&card
->kernel_thread_starter
,
1054 (void *)qeth_start_kernel_thread
,card
);
1055 INIT_LIST_HEAD(&card
->ip_list
);
1056 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_KERNEL
);
1057 if (!card
->ip_tbd_list
) {
1058 QETH_DBF_TEXT(setup
, 0, "iptbdnom");
1061 INIT_LIST_HEAD(card
->ip_tbd_list
);
1062 INIT_LIST_HEAD(&card
->cmd_waiter_list
);
1063 init_waitqueue_head(&card
->wait_q
);
1064 /* intial options */
1065 qeth_set_intial_options(card
);
1066 /* IP address takeover */
1067 INIT_LIST_HEAD(&card
->ipato
.entries
);
1068 card
->ipato
.enabled
= 0;
1069 card
->ipato
.invert4
= 0;
1070 card
->ipato
.invert6
= 0;
1071 /* init QDIO stuff */
1072 qeth_init_qdio_info(card
);
1077 is_1920_device (struct qeth_card
*card
)
1079 int single_queue
= 0;
1080 struct ccw_device
*ccwdev
;
1081 struct channelPath_dsc
{
1092 QETH_DBF_TEXT(setup
, 2, "chk_1920");
1094 ccwdev
= card
->data
.ccwdev
;
1095 chp_dsc
= (struct channelPath_dsc
*)ccw_device_get_chp_desc(ccwdev
, 0);
1096 if (chp_dsc
!= NULL
) {
1097 /* CHPP field bit 6 == 1 -> single queue */
1098 single_queue
= ((chp_dsc
->chpp
& 0x02) == 0x02);
1101 QETH_DBF_TEXT_(setup
, 2, "rc:%x", single_queue
);
1102 return single_queue
;
1106 qeth_determine_card_type(struct qeth_card
*card
)
1110 QETH_DBF_TEXT(setup
, 2, "detcdtyp");
1112 while (known_devices
[i
][4]) {
1113 if ((CARD_RDEV(card
)->id
.dev_type
== known_devices
[i
][2]) &&
1114 (CARD_RDEV(card
)->id
.dev_model
== known_devices
[i
][3])) {
1115 card
->info
.type
= known_devices
[i
][4];
1116 if (is_1920_device(card
)) {
1117 PRINT_INFO("Priority Queueing not able "
1118 "due to hardware limitations!\n");
1119 card
->qdio
.no_out_queues
= 1;
1120 card
->qdio
.default_out_queue
= 0;
1122 card
->qdio
.no_out_queues
= known_devices
[i
][8];
1124 card
->info
.is_multicast_different
= known_devices
[i
][9];
1129 card
->info
.type
= QETH_CARD_TYPE_UNKNOWN
;
1130 PRINT_ERR("unknown card type on device %s\n", CARD_BUS_ID(card
));
1135 qeth_probe_device(struct ccwgroup_device
*gdev
)
1137 struct qeth_card
*card
;
1139 unsigned long flags
;
1142 QETH_DBF_TEXT(setup
, 2, "probedev");
1145 if (!get_device(dev
))
1148 card
= qeth_alloc_card();
1151 QETH_DBF_TEXT_(setup
, 2, "1err%d", -ENOMEM
);
1154 card
->read
.ccwdev
= gdev
->cdev
[0];
1155 card
->write
.ccwdev
= gdev
->cdev
[1];
1156 card
->data
.ccwdev
= gdev
->cdev
[2];
1158 if ((rc
= qeth_setup_card(card
))){
1159 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1161 qeth_free_card(card
);
1164 gdev
->dev
.driver_data
= card
;
1166 gdev
->cdev
[0]->handler
= qeth_irq
;
1167 gdev
->cdev
[1]->handler
= qeth_irq
;
1168 gdev
->cdev
[2]->handler
= qeth_irq
;
1170 rc
= qeth_create_device_attributes(dev
);
1173 qeth_free_card(card
);
1176 if ((rc
= qeth_determine_card_type(card
))){
1177 PRINT_WARN("%s: not a valid card type\n", __func__
);
1178 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1180 qeth_free_card(card
);
1183 /* insert into our internal list */
1184 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
1185 list_add_tail(&card
->list
, &qeth_card_list
.list
);
1186 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
1192 qeth_get_unitaddr(struct qeth_card
*card
)
1198 QETH_DBF_TEXT(setup
, 2, "getunit");
1199 rc
= read_conf_data(CARD_DDEV(card
), (void **) &prcd
, &length
);
1201 PRINT_ERR("read_conf_data for device %s returned %i\n",
1202 CARD_DDEV_ID(card
), rc
);
1205 card
->info
.chpid
= prcd
[30];
1206 card
->info
.unit_addr2
= prcd
[31];
1207 card
->info
.cula
= prcd
[63];
1208 card
->info
.guestlan
= ((prcd
[0x10] == _ascebc
['V']) &&
1209 (prcd
[0x11] == _ascebc
['M']));
1214 qeth_init_tokens(struct qeth_card
*card
)
1216 card
->token
.issuer_rm_w
= 0x00010103UL
;
1217 card
->token
.cm_filter_w
= 0x00010108UL
;
1218 card
->token
.cm_connection_w
= 0x0001010aUL
;
1219 card
->token
.ulp_filter_w
= 0x0001010bUL
;
1220 card
->token
.ulp_connection_w
= 0x0001010dUL
;
1224 raw_devno_from_bus_id(char *id
)
1226 id
+= (strlen(id
) - 4);
1227 return (__u16
) simple_strtoul(id
, &id
, 16);
1233 qeth_setup_ccw(struct qeth_channel
*channel
,unsigned char *iob
, __u32 len
)
1235 struct qeth_card
*card
;
1237 QETH_DBF_TEXT(trace
, 4, "setupccw");
1238 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1239 if (channel
== &card
->read
)
1240 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1242 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1243 channel
->ccw
.count
= len
;
1244 channel
->ccw
.cda
= (__u32
) __pa(iob
);
1248 * get free buffer for ccws (IDX activation, lancmds,ipassists...)
1250 static struct qeth_cmd_buffer
*
1251 __qeth_get_buffer(struct qeth_channel
*channel
)
1255 QETH_DBF_TEXT(trace
, 6, "getbuff");
1256 index
= channel
->io_buf_no
;
1258 if (channel
->iob
[index
].state
== BUF_STATE_FREE
) {
1259 channel
->iob
[index
].state
= BUF_STATE_LOCKED
;
1260 channel
->io_buf_no
= (channel
->io_buf_no
+ 1) %
1262 memset(channel
->iob
[index
].data
, 0, QETH_BUFSIZE
);
1263 return channel
->iob
+ index
;
1265 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
1266 } while(index
!= channel
->io_buf_no
);
1272 * release command buffer
1275 qeth_release_buffer(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1277 unsigned long flags
;
1279 QETH_DBF_TEXT(trace
, 6, "relbuff");
1280 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1281 memset(iob
->data
, 0, QETH_BUFSIZE
);
1282 iob
->state
= BUF_STATE_FREE
;
1283 iob
->callback
= qeth_send_control_data_cb
;
1285 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1288 static struct qeth_cmd_buffer
*
1289 qeth_get_buffer(struct qeth_channel
*channel
)
1291 struct qeth_cmd_buffer
*buffer
= NULL
;
1292 unsigned long flags
;
1294 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1295 buffer
= __qeth_get_buffer(channel
);
1296 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1300 static struct qeth_cmd_buffer
*
1301 qeth_wait_for_buffer(struct qeth_channel
*channel
)
1303 struct qeth_cmd_buffer
*buffer
;
1304 wait_event(channel
->wait_q
,
1305 ((buffer
= qeth_get_buffer(channel
)) != NULL
));
1310 qeth_clear_cmd_buffers(struct qeth_channel
*channel
)
1314 for (cnt
=0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
1315 qeth_release_buffer(channel
,&channel
->iob
[cnt
]);
1316 channel
->buf_no
= 0;
1317 channel
->io_buf_no
= 0;
1321 * start IDX for read and write channel
1324 qeth_idx_activate_get_answer(struct qeth_channel
*channel
,
1325 void (*idx_reply_cb
)(struct qeth_channel
*,
1326 struct qeth_cmd_buffer
*))
1328 struct qeth_cmd_buffer
*iob
;
1329 unsigned long flags
;
1331 struct qeth_card
*card
;
1333 QETH_DBF_TEXT(setup
, 2, "idxanswr");
1334 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1335 iob
= qeth_get_buffer(channel
);
1336 iob
->callback
= idx_reply_cb
;
1337 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1338 channel
->ccw
.count
= QETH_BUFSIZE
;
1339 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1341 wait_event(card
->wait_q
,
1342 atomic_compare_and_swap(0,1,&channel
->irq_pending
) == 0);
1343 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1344 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1345 rc
= ccw_device_start(channel
->ccwdev
,
1346 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1347 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1350 PRINT_ERR("qeth: Error2 in activating channel rc=%d\n",rc
);
1351 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1352 atomic_set(&channel
->irq_pending
, 0);
1353 wake_up(&card
->wait_q
);
1356 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1357 channel
->state
== CH_STATE_UP
, QETH_TIMEOUT
);
1358 if (rc
== -ERESTARTSYS
)
1360 if (channel
->state
!= CH_STATE_UP
){
1362 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1363 qeth_clear_cmd_buffers(channel
);
1370 qeth_idx_activate_channel(struct qeth_channel
*channel
,
1371 void (*idx_reply_cb
)(struct qeth_channel
*,
1372 struct qeth_cmd_buffer
*))
1374 struct qeth_card
*card
;
1375 struct qeth_cmd_buffer
*iob
;
1376 unsigned long flags
;
1380 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1382 QETH_DBF_TEXT(setup
, 2, "idxactch");
1384 iob
= qeth_get_buffer(channel
);
1385 iob
->callback
= idx_reply_cb
;
1386 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1387 channel
->ccw
.count
= IDX_ACTIVATE_SIZE
;
1388 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1389 if (channel
== &card
->write
) {
1390 memcpy(iob
->data
, IDX_ACTIVATE_WRITE
, IDX_ACTIVATE_SIZE
);
1391 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1392 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1393 card
->seqno
.trans_hdr
++;
1395 memcpy(iob
->data
, IDX_ACTIVATE_READ
, IDX_ACTIVATE_SIZE
);
1396 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1397 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1399 memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1400 &card
->token
.issuer_rm_w
,QETH_MPC_TOKEN_LENGTH
);
1401 memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob
->data
),
1402 &card
->info
.func_level
,sizeof(__u16
));
1403 temp
= raw_devno_from_bus_id(CARD_DDEV_ID(card
));
1404 memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob
->data
), &temp
, 2);
1405 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
1406 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob
->data
), &temp
, 2);
1408 wait_event(card
->wait_q
,
1409 atomic_compare_and_swap(0,1,&channel
->irq_pending
) == 0);
1410 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1411 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1412 rc
= ccw_device_start(channel
->ccwdev
,
1413 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1414 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1417 PRINT_ERR("qeth: Error1 in activating channel. rc=%d\n",rc
);
1418 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
1419 atomic_set(&channel
->irq_pending
, 0);
1420 wake_up(&card
->wait_q
);
1423 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1424 channel
->state
== CH_STATE_ACTIVATING
, QETH_TIMEOUT
);
1425 if (rc
== -ERESTARTSYS
)
1427 if (channel
->state
!= CH_STATE_ACTIVATING
) {
1428 PRINT_WARN("qeth: IDX activate timed out!\n");
1429 QETH_DBF_TEXT_(setup
, 2, "2err%d", -ETIME
);
1430 qeth_clear_cmd_buffers(channel
);
1433 return qeth_idx_activate_get_answer(channel
,idx_reply_cb
);
1437 qeth_peer_func_level(int level
)
1439 if ((level
& 0xff) == 8)
1440 return (level
& 0xff) + 0x400;
1441 if (((level
>> 8) & 3) == 1)
1442 return (level
& 0xff) + 0x200;
1447 qeth_idx_write_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1449 struct qeth_card
*card
;
1452 QETH_DBF_TEXT(setup
,2, "idxwrcb");
1454 if (channel
->state
== CH_STATE_DOWN
) {
1455 channel
->state
= CH_STATE_ACTIVATING
;
1458 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1460 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1461 PRINT_ERR("IDX_ACTIVATE on write channel device %s: negative "
1462 "reply\n", CARD_WDEV_ID(card
));
1465 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1466 if ((temp
& ~0x0100) != qeth_peer_func_level(card
->info
.func_level
)) {
1467 PRINT_WARN("IDX_ACTIVATE on write channel device %s: "
1468 "function level mismatch "
1469 "(sent: 0x%x, received: 0x%x)\n",
1470 CARD_WDEV_ID(card
), card
->info
.func_level
, temp
);
1473 channel
->state
= CH_STATE_UP
;
1475 qeth_release_buffer(channel
, iob
);
1479 qeth_check_idx_response(unsigned char *buffer
)
1484 QETH_DBF_HEX(control
, 2, buffer
, QETH_DBF_CONTROL_LEN
);
1485 if ((buffer
[2] & 0xc0) == 0xc0) {
1486 PRINT_WARN("received an IDX TERMINATE "
1487 "with cause code 0x%02x%s\n",
1489 ((buffer
[4] == 0x22) ?
1490 " -- try another portname" : ""));
1491 QETH_DBF_TEXT(trace
, 2, "ckidxres");
1492 QETH_DBF_TEXT(trace
, 2, " idxterm");
1493 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
1500 qeth_idx_read_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1502 struct qeth_card
*card
;
1505 QETH_DBF_TEXT(setup
, 2, "idxrdcb");
1506 if (channel
->state
== CH_STATE_DOWN
) {
1507 channel
->state
= CH_STATE_ACTIVATING
;
1511 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1512 if (qeth_check_idx_response(iob
->data
)) {
1515 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1516 PRINT_ERR("IDX_ACTIVATE on read channel device %s: negative "
1517 "reply\n", CARD_RDEV_ID(card
));
1522 * temporary fix for microcode bug
1523 * to revert it,replace OR by AND
1525 if ( (!QETH_IDX_NO_PORTNAME_REQUIRED(iob
->data
)) ||
1526 (card
->info
.type
== QETH_CARD_TYPE_OSAE
) )
1527 card
->info
.portname_required
= 1;
1529 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1530 if (temp
!= qeth_peer_func_level(card
->info
.func_level
)) {
1531 PRINT_WARN("IDX_ACTIVATE on read channel device %s: function "
1532 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1533 CARD_RDEV_ID(card
), card
->info
.func_level
, temp
);
1536 memcpy(&card
->token
.issuer_rm_r
,
1537 QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1538 QETH_MPC_TOKEN_LENGTH
);
1539 memcpy(&card
->info
.mcl_level
[0],
1540 QETH_IDX_REPLY_LEVEL(iob
->data
), QETH_MCL_LENGTH
);
1541 channel
->state
= CH_STATE_UP
;
1543 qeth_release_buffer(channel
,iob
);
1547 qeth_issue_next_read(struct qeth_card
*card
)
1550 struct qeth_cmd_buffer
*iob
;
1552 QETH_DBF_TEXT(trace
,5,"issnxrd");
1553 if (card
->read
.state
!= CH_STATE_UP
)
1555 iob
= qeth_get_buffer(&card
->read
);
1557 PRINT_WARN("issue_next_read failed: no iob available!\n");
1560 qeth_setup_ccw(&card
->read
, iob
->data
, QETH_BUFSIZE
);
1561 wait_event(card
->wait_q
,
1562 atomic_compare_and_swap(0,1,&card
->read
.irq_pending
) == 0);
1563 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1564 rc
= ccw_device_start(card
->read
.ccwdev
, &card
->read
.ccw
,
1565 (addr_t
) iob
, 0, 0);
1567 PRINT_ERR("Error in starting next read ccw! rc=%i\n", rc
);
1568 atomic_set(&card
->read
.irq_pending
, 0);
1569 qeth_schedule_recovery(card
);
1570 wake_up(&card
->wait_q
);
1575 static struct qeth_reply
*
1576 qeth_alloc_reply(struct qeth_card
*card
)
1578 struct qeth_reply
*reply
;
1580 reply
= kmalloc(sizeof(struct qeth_reply
), GFP_ATOMIC
);
1582 memset(reply
, 0, sizeof(struct qeth_reply
));
1583 atomic_set(&reply
->refcnt
, 1);
1590 qeth_get_reply(struct qeth_reply
*reply
)
1592 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1593 atomic_inc(&reply
->refcnt
);
1597 qeth_put_reply(struct qeth_reply
*reply
)
1599 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1600 if (atomic_dec_and_test(&reply
->refcnt
))
1605 qeth_cmd_timeout(unsigned long data
)
1607 struct qeth_reply
*reply
, *list_reply
, *r
;
1608 unsigned long flags
;
1610 reply
= (struct qeth_reply
*) data
;
1611 spin_lock_irqsave(&reply
->card
->lock
, flags
);
1612 list_for_each_entry_safe(list_reply
, r
,
1613 &reply
->card
->cmd_waiter_list
, list
) {
1614 if (reply
== list_reply
){
1615 qeth_get_reply(reply
);
1616 list_del_init(&reply
->list
);
1617 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1619 reply
->received
= 1;
1620 wake_up(&reply
->wait_q
);
1621 qeth_put_reply(reply
);
1625 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1629 qeth_reset_ip_addresses(struct qeth_card
*card
)
1631 QETH_DBF_TEXT(trace
, 2, "rstipadd");
1633 qeth_clear_ip_list(card
, 0, 1);
1634 /* this function will also schedule the SET_IP_THREAD */
1635 qeth_set_multicast_list(card
->dev
);
1638 static struct qeth_ipa_cmd
*
1639 qeth_check_ipa_data(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
)
1641 struct qeth_ipa_cmd
*cmd
= NULL
;
1643 QETH_DBF_TEXT(trace
,5,"chkipad");
1644 if (IS_IPA(iob
->data
)){
1645 cmd
= (struct qeth_ipa_cmd
*) PDU_ENCAPSULATION(iob
->data
);
1646 if (IS_IPA_REPLY(cmd
))
1649 switch (cmd
->hdr
.command
) {
1650 case IPA_CMD_STOPLAN
:
1651 PRINT_WARN("Link failure on %s (CHPID 0x%X) - "
1652 "there is a network problem or "
1653 "someone pulled the cable or "
1654 "disabled the port.\n",
1655 QETH_CARD_IFNAME(card
),
1657 card
->lan_online
= 0;
1658 netif_carrier_off(card
->dev
);
1660 case IPA_CMD_STARTLAN
:
1661 PRINT_INFO("Link reestablished on %s "
1662 "(CHPID 0x%X). Scheduling "
1663 "IP address reset.\n",
1664 QETH_CARD_IFNAME(card
),
1666 card
->lan_online
= 1;
1667 netif_carrier_on(card
->dev
);
1668 qeth_reset_ip_addresses(card
);
1670 case IPA_CMD_REGISTER_LOCAL_ADDR
:
1671 QETH_DBF_TEXT(trace
,3, "irla");
1673 case IPA_CMD_UNREGISTER_LOCAL_ADDR
:
1674 QETH_DBF_TEXT(trace
,3, "urla");
1677 PRINT_WARN("Received data is IPA "
1678 "but not a reply!\n");
1687 * wake all waiting ipa commands
1690 qeth_clear_ipacmd_list(struct qeth_card
*card
)
1692 struct qeth_reply
*reply
, *r
;
1693 unsigned long flags
;
1695 QETH_DBF_TEXT(trace
, 4, "clipalst");
1697 spin_lock_irqsave(&card
->lock
, flags
);
1698 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1699 qeth_get_reply(reply
);
1701 reply
->received
= 1;
1702 list_del_init(&reply
->list
);
1703 wake_up(&reply
->wait_q
);
1704 qeth_put_reply(reply
);
1706 spin_unlock_irqrestore(&card
->lock
, flags
);
1710 qeth_send_control_data_cb(struct qeth_channel
*channel
,
1711 struct qeth_cmd_buffer
*iob
)
1713 struct qeth_card
*card
;
1714 struct qeth_reply
*reply
, *r
;
1715 struct qeth_ipa_cmd
*cmd
;
1716 unsigned long flags
;
1719 QETH_DBF_TEXT(trace
,4,"sndctlcb");
1721 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1722 if (qeth_check_idx_response(iob
->data
)) {
1723 qeth_clear_ipacmd_list(card
);
1724 qeth_schedule_recovery(card
);
1728 cmd
= qeth_check_ipa_data(card
, iob
);
1729 if ((cmd
== NULL
) && (card
->state
!= CARD_STATE_DOWN
))
1732 spin_lock_irqsave(&card
->lock
, flags
);
1733 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1734 if ((reply
->seqno
== QETH_IDX_COMMAND_SEQNO
) ||
1735 ((cmd
) && (reply
->seqno
== cmd
->hdr
.seqno
))) {
1736 qeth_get_reply(reply
);
1737 list_del_init(&reply
->list
);
1738 spin_unlock_irqrestore(&card
->lock
, flags
);
1740 if (reply
->callback
!= NULL
) {
1742 reply
->offset
= (__u16
)((char*)cmd
-
1744 keep_reply
= reply
->callback(card
,
1746 (unsigned long)cmd
);
1749 keep_reply
= reply
->callback(card
,
1751 (unsigned long)iob
);
1754 reply
->rc
= (u16
) cmd
->hdr
.return_code
;
1756 reply
->rc
= iob
->rc
;
1758 spin_lock_irqsave(&card
->lock
, flags
);
1759 list_add_tail(&reply
->list
,
1760 &card
->cmd_waiter_list
);
1761 spin_unlock_irqrestore(&card
->lock
, flags
);
1763 reply
->received
= 1;
1764 wake_up(&reply
->wait_q
);
1766 qeth_put_reply(reply
);
1770 spin_unlock_irqrestore(&card
->lock
, flags
);
1772 memcpy(&card
->seqno
.pdu_hdr_ack
,
1773 QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1774 QETH_SEQ_NO_LENGTH
);
1775 qeth_release_buffer(channel
,iob
);
1779 qeth_send_control_data(struct qeth_card
*card
, int len
,
1780 struct qeth_cmd_buffer
*iob
,
1782 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
1787 unsigned long flags
;
1788 struct qeth_reply
*reply
;
1789 struct timer_list timer
;
1791 QETH_DBF_TEXT(trace
, 2, "sendctl");
1793 qeth_setup_ccw(&card
->write
,iob
->data
,len
);
1795 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1796 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1797 card
->seqno
.trans_hdr
++;
1799 memcpy(QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1800 &card
->seqno
.pdu_hdr
, QETH_SEQ_NO_LENGTH
);
1801 card
->seqno
.pdu_hdr
++;
1802 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob
->data
),
1803 &card
->seqno
.pdu_hdr_ack
, QETH_SEQ_NO_LENGTH
);
1804 iob
->callback
= qeth_release_buffer
;
1806 reply
= qeth_alloc_reply(card
);
1808 PRINT_WARN("Could no alloc qeth_reply!\n");
1811 reply
->callback
= reply_cb
;
1812 reply
->param
= reply_param
;
1813 if (card
->state
== CARD_STATE_DOWN
)
1814 reply
->seqno
= QETH_IDX_COMMAND_SEQNO
;
1816 reply
->seqno
= card
->seqno
.ipa
++;
1818 timer
.function
= qeth_cmd_timeout
;
1819 timer
.data
= (unsigned long) reply
;
1820 if (IS_IPA(iob
->data
))
1821 timer
.expires
= jiffies
+ QETH_IPA_TIMEOUT
;
1823 timer
.expires
= jiffies
+ QETH_TIMEOUT
;
1824 init_waitqueue_head(&reply
->wait_q
);
1825 spin_lock_irqsave(&card
->lock
, flags
);
1826 list_add_tail(&reply
->list
, &card
->cmd_waiter_list
);
1827 spin_unlock_irqrestore(&card
->lock
, flags
);
1828 QETH_DBF_HEX(control
, 2, iob
->data
, QETH_DBF_CONTROL_LEN
);
1829 wait_event(card
->wait_q
,
1830 atomic_compare_and_swap(0,1,&card
->write
.irq_pending
) == 0);
1831 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1832 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1833 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1834 (addr_t
) iob
, 0, 0);
1835 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1837 PRINT_WARN("qeth_send_control_data: "
1838 "ccw_device_start rc = %i\n", rc
);
1839 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
1840 spin_lock_irqsave(&card
->lock
, flags
);
1841 list_del_init(&reply
->list
);
1842 qeth_put_reply(reply
);
1843 spin_unlock_irqrestore(&card
->lock
, flags
);
1844 qeth_release_buffer(iob
->channel
, iob
);
1845 atomic_set(&card
->write
.irq_pending
, 0);
1846 wake_up(&card
->wait_q
);
1850 wait_event(reply
->wait_q
, reply
->received
);
1851 del_timer_sync(&timer
);
1853 qeth_put_reply(reply
);
1858 qeth_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1860 (struct qeth_card
*,struct qeth_reply
*, unsigned long),
1866 QETH_DBF_TEXT(trace
,4,"sendipa");
1868 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
1870 if (card
->options
.layer2
)
1871 prot_type
= QETH_PROT_LAYER2
;
1873 prot_type
= QETH_PROT_TCPIP
;
1875 memcpy(QETH_IPA_CMD_PROT_TYPE(iob
->data
),&prot_type
,1);
1876 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
1877 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
1879 rc
= qeth_send_control_data(card
, IPA_CMD_LENGTH
, iob
,
1880 reply_cb
, reply_param
);
1886 qeth_cm_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1889 struct qeth_cmd_buffer
*iob
;
1891 QETH_DBF_TEXT(setup
, 2, "cmenblcb");
1893 iob
= (struct qeth_cmd_buffer
*) data
;
1894 memcpy(&card
->token
.cm_filter_r
,
1895 QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
1896 QETH_MPC_TOKEN_LENGTH
);
1897 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
1902 qeth_cm_enable(struct qeth_card
*card
)
1905 struct qeth_cmd_buffer
*iob
;
1907 QETH_DBF_TEXT(setup
,2,"cmenable");
1909 iob
= qeth_wait_for_buffer(&card
->write
);
1910 memcpy(iob
->data
, CM_ENABLE
, CM_ENABLE_SIZE
);
1911 memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob
->data
),
1912 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
1913 memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob
->data
),
1914 &card
->token
.cm_filter_w
, QETH_MPC_TOKEN_LENGTH
);
1916 rc
= qeth_send_control_data(card
, CM_ENABLE_SIZE
, iob
,
1917 qeth_cm_enable_cb
, NULL
);
1922 qeth_cm_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1926 struct qeth_cmd_buffer
*iob
;
1928 QETH_DBF_TEXT(setup
, 2, "cmsetpcb");
1930 iob
= (struct qeth_cmd_buffer
*) data
;
1931 memcpy(&card
->token
.cm_connection_r
,
1932 QETH_CM_SETUP_RESP_DEST_ADDR(iob
->data
),
1933 QETH_MPC_TOKEN_LENGTH
);
1934 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
1939 qeth_cm_setup(struct qeth_card
*card
)
1942 struct qeth_cmd_buffer
*iob
;
1944 QETH_DBF_TEXT(setup
,2,"cmsetup");
1946 iob
= qeth_wait_for_buffer(&card
->write
);
1947 memcpy(iob
->data
, CM_SETUP
, CM_SETUP_SIZE
);
1948 memcpy(QETH_CM_SETUP_DEST_ADDR(iob
->data
),
1949 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
1950 memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob
->data
),
1951 &card
->token
.cm_connection_w
, QETH_MPC_TOKEN_LENGTH
);
1952 memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob
->data
),
1953 &card
->token
.cm_filter_r
, QETH_MPC_TOKEN_LENGTH
);
1954 rc
= qeth_send_control_data(card
, CM_SETUP_SIZE
, iob
,
1955 qeth_cm_setup_cb
, NULL
);
1961 qeth_ulp_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1965 __u16 mtu
, framesize
;
1968 struct qeth_cmd_buffer
*iob
;
1970 QETH_DBF_TEXT(setup
, 2, "ulpenacb");
1972 iob
= (struct qeth_cmd_buffer
*) data
;
1973 memcpy(&card
->token
.ulp_filter_r
,
1974 QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
1975 QETH_MPC_TOKEN_LENGTH
);
1976 if (qeth_get_mtu_out_of_mpc(card
->info
.type
)) {
1977 memcpy(&framesize
, QETH_ULP_ENABLE_RESP_MAX_MTU(iob
->data
), 2);
1978 mtu
= qeth_get_mtu_outof_framesize(framesize
);
1981 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
1984 card
->info
.max_mtu
= mtu
;
1985 card
->info
.initial_mtu
= mtu
;
1986 card
->qdio
.in_buf_size
= mtu
+ 2 * PAGE_SIZE
;
1988 card
->info
.initial_mtu
= qeth_get_initial_mtu_for_card(card
);
1989 card
->info
.max_mtu
= qeth_get_max_mtu_for_card(card
->info
.type
);
1990 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
1993 memcpy(&len
, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob
->data
), 2);
1994 if (len
>= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE
) {
1996 QETH_ULP_ENABLE_RESP_LINK_TYPE(iob
->data
), 1);
1997 card
->info
.link_type
= link_type
;
1999 card
->info
.link_type
= 0;
2000 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2005 qeth_ulp_enable(struct qeth_card
*card
)
2009 struct qeth_cmd_buffer
*iob
;
2011 /*FIXME: trace view callbacks*/
2012 QETH_DBF_TEXT(setup
,2,"ulpenabl");
2014 iob
= qeth_wait_for_buffer(&card
->write
);
2015 memcpy(iob
->data
, ULP_ENABLE
, ULP_ENABLE_SIZE
);
2017 *(QETH_ULP_ENABLE_LINKNUM(iob
->data
)) =
2018 (__u8
) card
->info
.portno
;
2019 if (card
->options
.layer2
)
2020 prot_type
= QETH_PROT_LAYER2
;
2022 prot_type
= QETH_PROT_TCPIP
;
2024 memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob
->data
),&prot_type
,1);
2025 memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob
->data
),
2026 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2027 memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob
->data
),
2028 &card
->token
.ulp_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2029 memcpy(QETH_ULP_ENABLE_PORTNAME_AND_LL(iob
->data
),
2030 card
->info
.portname
, 9);
2031 rc
= qeth_send_control_data(card
, ULP_ENABLE_SIZE
, iob
,
2032 qeth_ulp_enable_cb
, NULL
);
2038 __raw_devno_from_bus_id(char *id
)
2040 id
+= (strlen(id
) - 4);
2041 return (__u16
) simple_strtoul(id
, &id
, 16);
2045 qeth_ulp_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2048 struct qeth_cmd_buffer
*iob
;
2050 QETH_DBF_TEXT(setup
, 2, "ulpstpcb");
2052 iob
= (struct qeth_cmd_buffer
*) data
;
2053 memcpy(&card
->token
.ulp_connection_r
,
2054 QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob
->data
),
2055 QETH_MPC_TOKEN_LENGTH
);
2056 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2061 qeth_ulp_setup(struct qeth_card
*card
)
2065 struct qeth_cmd_buffer
*iob
;
2067 QETH_DBF_TEXT(setup
,2,"ulpsetup");
2069 iob
= qeth_wait_for_buffer(&card
->write
);
2070 memcpy(iob
->data
, ULP_SETUP
, ULP_SETUP_SIZE
);
2072 memcpy(QETH_ULP_SETUP_DEST_ADDR(iob
->data
),
2073 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2074 memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob
->data
),
2075 &card
->token
.ulp_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2076 memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob
->data
),
2077 &card
->token
.ulp_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2079 temp
= __raw_devno_from_bus_id(CARD_DDEV_ID(card
));
2080 memcpy(QETH_ULP_SETUP_CUA(iob
->data
), &temp
, 2);
2081 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
2082 memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob
->data
), &temp
, 2);
2083 rc
= qeth_send_control_data(card
, ULP_SETUP_SIZE
, iob
,
2084 qeth_ulp_setup_cb
, NULL
);
2089 qeth_check_for_inbound_error(struct qeth_qdio_buffer
*buf
,
2090 unsigned int qdio_error
,
2091 unsigned int siga_error
)
2095 if (qdio_error
|| siga_error
) {
2096 QETH_DBF_TEXT(trace
, 2, "qdinerr");
2097 QETH_DBF_TEXT(qerr
, 2, "qdinerr");
2098 QETH_DBF_TEXT_(qerr
, 2, " F15=%02X",
2099 buf
->buffer
->element
[15].flags
& 0xff);
2100 QETH_DBF_TEXT_(qerr
, 2, " F14=%02X",
2101 buf
->buffer
->element
[14].flags
& 0xff);
2102 QETH_DBF_TEXT_(qerr
, 2, " qerr=%X", qdio_error
);
2103 QETH_DBF_TEXT_(qerr
, 2, " serr=%X", siga_error
);
2109 static inline struct sk_buff
*
2110 qeth_get_skb(unsigned int length
)
2112 struct sk_buff
* skb
;
2113 #ifdef CONFIG_QETH_VLAN
2114 if ((skb
= dev_alloc_skb(length
+ VLAN_HLEN
)))
2115 skb_reserve(skb
, VLAN_HLEN
);
2117 skb
= dev_alloc_skb(length
);
2122 static inline struct sk_buff
*
2123 qeth_get_next_skb(struct qeth_card
*card
, struct qdio_buffer
*buffer
,
2124 struct qdio_buffer_element
**__element
, int *__offset
,
2125 struct qeth_hdr
**hdr
)
2127 struct qdio_buffer_element
*element
= *__element
;
2128 int offset
= *__offset
;
2129 struct sk_buff
*skb
= NULL
;
2134 QETH_DBF_TEXT(trace
,6,"nextskb");
2135 /* qeth_hdr must not cross element boundaries */
2136 if (element
->length
< offset
+ sizeof(struct qeth_hdr
)){
2137 if (qeth_is_last_sbale(element
))
2141 if (element
->length
< sizeof(struct qeth_hdr
))
2144 *hdr
= element
->addr
+ offset
;
2146 offset
+= sizeof(struct qeth_hdr
);
2147 if (card
->options
.layer2
)
2148 skb_len
= (*hdr
)->hdr
.l2
.pkt_length
;
2150 skb_len
= (*hdr
)->hdr
.l3
.length
;
2154 if (card
->options
.fake_ll
){
2155 if (!(skb
= qeth_get_skb(skb_len
+ QETH_FAKE_LL_LEN
)))
2157 skb_pull(skb
, QETH_FAKE_LL_LEN
);
2158 } else if (!(skb
= qeth_get_skb(skb_len
)))
2160 data_ptr
= element
->addr
+ offset
;
2162 data_len
= min(skb_len
, (int)(element
->length
- offset
));
2164 memcpy(skb_put(skb
, data_len
), data_ptr
, data_len
);
2165 skb_len
-= data_len
;
2167 if (qeth_is_last_sbale(element
)){
2168 QETH_DBF_TEXT(trace
,4,"unexeob");
2169 QETH_DBF_TEXT_(trace
,4,"%s",CARD_BUS_ID(card
));
2170 QETH_DBF_TEXT(qerr
,2,"unexeob");
2171 QETH_DBF_TEXT_(qerr
,2,"%s",CARD_BUS_ID(card
));
2172 QETH_DBF_HEX(misc
,4,buffer
,sizeof(*buffer
));
2173 dev_kfree_skb_any(skb
);
2174 card
->stats
.rx_errors
++;
2179 data_ptr
= element
->addr
;
2184 *__element
= element
;
2188 if (net_ratelimit()){
2189 PRINT_WARN("No memory for packet received on %s.\n",
2190 QETH_CARD_IFNAME(card
));
2191 QETH_DBF_TEXT(trace
,2,"noskbmem");
2192 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2194 card
->stats
.rx_dropped
++;
2198 static inline unsigned short
2199 qeth_type_trans(struct sk_buff
*skb
, struct net_device
*dev
)
2201 struct qeth_card
*card
;
2204 QETH_DBF_TEXT(trace
,6,"typtrans");
2206 card
= (struct qeth_card
*)dev
->priv
;
2208 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
2209 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
2210 return tr_type_trans(skb
,dev
);
2211 #endif /* CONFIG_TR */
2212 skb
->mac
.raw
= skb
->data
;
2213 skb_pull(skb
, ETH_HLEN
);
2216 if (*eth
->h_dest
& 1) {
2217 if (memcmp(eth
->h_dest
, dev
->broadcast
, ETH_ALEN
) == 0)
2218 skb
->pkt_type
= PACKET_BROADCAST
;
2220 skb
->pkt_type
= PACKET_MULTICAST
;
2221 } else if (memcmp(eth
->h_dest
, dev
->dev_addr
, ETH_ALEN
))
2222 skb
->pkt_type
= PACKET_OTHERHOST
;
2224 if (ntohs(eth
->h_proto
) >= 1536)
2225 return eth
->h_proto
;
2226 if (*(unsigned short *) (skb
->data
) == 0xFFFF)
2227 return htons(ETH_P_802_3
);
2228 return htons(ETH_P_802_2
);
2232 qeth_rebuild_skb_fake_ll(struct qeth_card
*card
, struct sk_buff
*skb
,
2233 struct qeth_hdr
*hdr
)
2235 struct ethhdr
*fake_hdr
;
2236 struct iphdr
*ip_hdr
;
2238 QETH_DBF_TEXT(trace
,5,"skbfake");
2239 skb
->mac
.raw
= skb
->data
- QETH_FAKE_LL_LEN
;
2240 /* this is a fake ethernet header */
2241 fake_hdr
= (struct ethhdr
*) skb
->mac
.raw
;
2243 /* the destination MAC address */
2244 switch (skb
->pkt_type
){
2245 case PACKET_MULTICAST
:
2246 switch (skb
->protocol
){
2247 #ifdef CONFIG_QETH_IPV6
2248 case __constant_htons(ETH_P_IPV6
):
2249 ndisc_mc_map((struct in6_addr
*)
2250 skb
->data
+ QETH_FAKE_LL_V6_ADDR_POS
,
2251 fake_hdr
->h_dest
, card
->dev
, 0);
2253 #endif /* CONFIG_QETH_IPV6 */
2254 case __constant_htons(ETH_P_IP
):
2255 ip_hdr
= (struct iphdr
*)skb
->data
;
2256 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
2257 ip_tr_mc_map(ip_hdr
->daddr
, fake_hdr
->h_dest
);
2259 ip_eth_mc_map(ip_hdr
->daddr
, fake_hdr
->h_dest
);
2262 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2265 case PACKET_BROADCAST
:
2266 memset(fake_hdr
->h_dest
, 0xff, ETH_ALEN
);
2269 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2271 /* the source MAC address */
2272 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
2273 memcpy(fake_hdr
->h_source
, &hdr
->hdr
.l3
.dest_addr
[2], ETH_ALEN
);
2275 memset(fake_hdr
->h_source
, 0, ETH_ALEN
);
2277 fake_hdr
->h_proto
= skb
->protocol
;
2281 qeth_rebuild_skb_vlan(struct qeth_card
*card
, struct sk_buff
*skb
,
2282 struct qeth_hdr
*hdr
)
2284 #ifdef CONFIG_QETH_VLAN
2287 if (hdr
->hdr
.l3
.ext_flags
&
2288 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
2289 vlan_tag
= (u16
*) skb_push(skb
, VLAN_HLEN
);
2290 *vlan_tag
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
)?
2291 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
2292 *(vlan_tag
+ 1) = skb
->protocol
;
2293 skb
->protocol
= __constant_htons(ETH_P_8021Q
);
2295 #endif /* CONFIG_QETH_VLAN */
2299 qeth_layer2_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2300 struct qeth_hdr
*hdr
)
2302 unsigned short vlan_id
= 0;
2303 #ifdef CONFIG_QETH_VLAN
2304 struct vlan_hdr
*vhdr
;
2307 skb
->pkt_type
= PACKET_HOST
;
2308 skb
->protocol
= qeth_type_trans(skb
, skb
->dev
);
2309 if (card
->options
.checksum_type
== NO_CHECKSUMMING
)
2310 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2312 skb
->ip_summed
= CHECKSUM_NONE
;
2313 #ifdef CONFIG_QETH_VLAN
2314 if (hdr
->hdr
.l2
.flags
[2] & (QETH_LAYER2_FLAG_VLAN
)) {
2315 vhdr
= (struct vlan_hdr
*) skb
->data
;
2317 __constant_htons(vhdr
->h_vlan_encapsulated_proto
);
2318 vlan_id
= hdr
->hdr
.l2
.vlan_id
;
2319 skb_pull(skb
, VLAN_HLEN
);
2326 qeth_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2327 struct qeth_hdr
*hdr
)
2329 #ifdef CONFIG_QETH_IPV6
2330 if (hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
) {
2331 skb
->pkt_type
= PACKET_HOST
;
2332 skb
->protocol
= qeth_type_trans(skb
, card
->dev
);
2335 #endif /* CONFIG_QETH_IPV6 */
2336 skb
->protocol
= htons((hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
)? ETH_P_IPV6
:
2338 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
){
2339 case QETH_CAST_UNICAST
:
2340 skb
->pkt_type
= PACKET_HOST
;
2342 case QETH_CAST_MULTICAST
:
2343 skb
->pkt_type
= PACKET_MULTICAST
;
2344 card
->stats
.multicast
++;
2346 case QETH_CAST_BROADCAST
:
2347 skb
->pkt_type
= PACKET_BROADCAST
;
2348 card
->stats
.multicast
++;
2350 case QETH_CAST_ANYCAST
:
2351 case QETH_CAST_NOCAST
:
2353 skb
->pkt_type
= PACKET_HOST
;
2355 qeth_rebuild_skb_vlan(card
, skb
, hdr
);
2356 if (card
->options
.fake_ll
)
2357 qeth_rebuild_skb_fake_ll(card
, skb
, hdr
);
2359 skb
->mac
.raw
= skb
->data
;
2360 skb
->ip_summed
= card
->options
.checksum_type
;
2361 if (card
->options
.checksum_type
== HW_CHECKSUMMING
){
2362 if ( (hdr
->hdr
.l3
.ext_flags
&
2363 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2364 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
2365 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2366 QETH_HDR_EXT_CSUM_TRANSP_REQ
) )
2367 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2369 skb
->ip_summed
= SW_CHECKSUMMING
;
2374 qeth_process_inbound_buffer(struct qeth_card
*card
,
2375 struct qeth_qdio_buffer
*buf
, int index
)
2377 struct qdio_buffer_element
*element
;
2378 struct sk_buff
*skb
;
2379 struct qeth_hdr
*hdr
;
2384 /* get first element of current buffer */
2385 element
= (struct qdio_buffer_element
*)&buf
->buffer
->element
[0];
2387 #ifdef CONFIG_QETH_PERF_STATS
2388 card
->perf_stats
.bufs_rec
++;
2390 while((skb
= qeth_get_next_skb(card
, buf
->buffer
, &element
,
2392 skb
->dev
= card
->dev
;
2393 if (hdr
->hdr
.l2
.id
== QETH_HEADER_TYPE_LAYER2
)
2394 vlan_tag
= qeth_layer2_rebuild_skb(card
, skb
, hdr
);
2396 qeth_rebuild_skb(card
, skb
, hdr
);
2397 /* is device UP ? */
2398 if (!(card
->dev
->flags
& IFF_UP
)){
2399 dev_kfree_skb_any(skb
);
2402 #ifdef CONFIG_QETH_VLAN
2404 vlan_hwaccel_rx(skb
, card
->vlangrp
, vlan_tag
);
2407 rxrc
= netif_rx(skb
);
2408 card
->dev
->last_rx
= jiffies
;
2409 card
->stats
.rx_packets
++;
2410 card
->stats
.rx_bytes
+= skb
->len
;
2414 static inline struct qeth_buffer_pool_entry
*
2415 qeth_get_buffer_pool_entry(struct qeth_card
*card
)
2417 struct qeth_buffer_pool_entry
*entry
;
2419 QETH_DBF_TEXT(trace
, 6, "gtbfplen");
2420 if (!list_empty(&card
->qdio
.in_buf_pool
.entry_list
)) {
2421 entry
= list_entry(card
->qdio
.in_buf_pool
.entry_list
.next
,
2422 struct qeth_buffer_pool_entry
, list
);
2423 list_del_init(&entry
->list
);
2430 qeth_init_input_buffer(struct qeth_card
*card
, struct qeth_qdio_buffer
*buf
)
2432 struct qeth_buffer_pool_entry
*pool_entry
;
2435 pool_entry
= qeth_get_buffer_pool_entry(card
);
2437 * since the buffer is accessed only from the input_tasklet
2438 * there shouldn't be a need to synchronize; also, since we use
2439 * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off
2442 BUG_ON(!pool_entry
);
2444 buf
->pool_entry
= pool_entry
;
2445 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
2446 buf
->buffer
->element
[i
].length
= PAGE_SIZE
;
2447 buf
->buffer
->element
[i
].addr
= pool_entry
->elements
[i
];
2448 if (i
== QETH_MAX_BUFFER_ELEMENTS(card
) - 1)
2449 buf
->buffer
->element
[i
].flags
= SBAL_FLAGS_LAST_ENTRY
;
2451 buf
->buffer
->element
[i
].flags
= 0;
2453 buf
->state
= QETH_QDIO_BUF_EMPTY
;
2457 qeth_clear_output_buffer(struct qeth_qdio_out_q
*queue
,
2458 struct qeth_qdio_out_buffer
*buf
)
2461 struct sk_buff
*skb
;
2463 /* is PCI flag set on buffer? */
2464 if (buf
->buffer
->element
[0].flags
& 0x40)
2465 atomic_dec(&queue
->set_pci_flags_count
);
2467 while ((skb
= skb_dequeue(&buf
->skb_list
))){
2468 atomic_dec(&skb
->users
);
2469 dev_kfree_skb_any(skb
);
2471 qeth_eddp_buf_release_contexts(buf
);
2472 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(queue
->card
); ++i
){
2473 buf
->buffer
->element
[i
].length
= 0;
2474 buf
->buffer
->element
[i
].addr
= NULL
;
2475 buf
->buffer
->element
[i
].flags
= 0;
2477 buf
->next_element_to_fill
= 0;
2478 atomic_set(&buf
->state
, QETH_QDIO_BUF_EMPTY
);
2482 qeth_queue_input_buffer(struct qeth_card
*card
, int index
)
2484 struct qeth_qdio_q
*queue
= card
->qdio
.in_q
;
2489 QETH_DBF_TEXT(trace
,6,"queinbuf");
2490 count
= (index
< queue
->next_buf_to_init
)?
2491 card
->qdio
.in_buf_pool
.buf_count
-
2492 (queue
->next_buf_to_init
- index
) :
2493 card
->qdio
.in_buf_pool
.buf_count
-
2494 (queue
->next_buf_to_init
+ QDIO_MAX_BUFFERS_PER_Q
- index
);
2495 /* only requeue at a certain threshold to avoid SIGAs */
2496 if (count
>= QETH_IN_BUF_REQUEUE_THRESHOLD(card
)){
2497 for (i
= queue
->next_buf_to_init
;
2498 i
< queue
->next_buf_to_init
+ count
; ++i
)
2499 qeth_init_input_buffer(card
,
2500 &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
]);
2502 * according to old code it should be avoided to requeue all
2503 * 128 buffers in order to benefit from PCI avoidance.
2504 * this function keeps at least one buffer (the buffer at
2505 * 'index') un-requeued -> this buffer is the first buffer that
2506 * will be requeued the next time
2508 #ifdef CONFIG_QETH_PERF_STATS
2509 card
->perf_stats
.inbound_do_qdio_cnt
++;
2510 card
->perf_stats
.inbound_do_qdio_start_time
= qeth_get_micros();
2512 rc
= do_QDIO(CARD_DDEV(card
),
2513 QDIO_FLAG_SYNC_INPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2514 0, queue
->next_buf_to_init
, count
, NULL
);
2515 #ifdef CONFIG_QETH_PERF_STATS
2516 card
->perf_stats
.inbound_do_qdio_time
+= qeth_get_micros() -
2517 card
->perf_stats
.inbound_do_qdio_start_time
;
2520 PRINT_WARN("qeth_queue_input_buffer's do_QDIO "
2521 "return %i (device %s).\n",
2522 rc
, CARD_DDEV_ID(card
));
2523 QETH_DBF_TEXT(trace
,2,"qinberr");
2524 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2526 queue
->next_buf_to_init
= (queue
->next_buf_to_init
+ count
) %
2527 QDIO_MAX_BUFFERS_PER_Q
;
2532 qeth_put_buffer_pool_entry(struct qeth_card
*card
,
2533 struct qeth_buffer_pool_entry
*entry
)
2535 QETH_DBF_TEXT(trace
, 6, "ptbfplen");
2536 list_add_tail(&entry
->list
, &card
->qdio
.in_buf_pool
.entry_list
);
2540 qeth_qdio_input_handler(struct ccw_device
* ccwdev
, unsigned int status
,
2541 unsigned int qdio_err
, unsigned int siga_err
,
2542 unsigned int queue
, int first_element
, int count
,
2543 unsigned long card_ptr
)
2545 struct net_device
*net_dev
;
2546 struct qeth_card
*card
;
2547 struct qeth_qdio_buffer
*buffer
;
2551 QETH_DBF_TEXT(trace
, 6, "qdinput");
2552 card
= (struct qeth_card
*) card_ptr
;
2553 net_dev
= card
->dev
;
2554 #ifdef CONFIG_QETH_PERF_STATS
2555 card
->perf_stats
.inbound_cnt
++;
2556 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
2558 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2559 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
2560 QETH_DBF_TEXT(trace
, 1,"qdinchk");
2561 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2562 QETH_DBF_TEXT_(trace
,1,"%04X%04X",first_element
,count
);
2563 QETH_DBF_TEXT_(trace
,1,"%04X%04X", queue
, status
);
2564 qeth_schedule_recovery(card
);
2568 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
2569 index
= i
% QDIO_MAX_BUFFERS_PER_Q
;
2570 buffer
= &card
->qdio
.in_q
->bufs
[index
];
2571 if (!((status
== QDIO_STATUS_LOOK_FOR_ERROR
) &&
2572 qeth_check_for_inbound_error(buffer
, qdio_err
, siga_err
)))
2573 qeth_process_inbound_buffer(card
, buffer
, index
);
2574 /* clear buffer and give back to hardware */
2575 qeth_put_buffer_pool_entry(card
, buffer
->pool_entry
);
2576 qeth_queue_input_buffer(card
, index
);
2578 #ifdef CONFIG_QETH_PERF_STATS
2579 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
2580 card
->perf_stats
.inbound_start_time
;
2585 qeth_handle_send_error(struct qeth_card
*card
,
2586 struct qeth_qdio_out_buffer
*buffer
,
2587 int qdio_err
, int siga_err
)
2589 int sbalf15
= buffer
->buffer
->element
[15].flags
& 0xff;
2590 int cc
= siga_err
& 3;
2592 QETH_DBF_TEXT(trace
, 6, "hdsnderr");
2596 QETH_DBF_TEXT(trace
, 1,"lnkfail");
2597 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2598 QETH_DBF_TEXT_(trace
,1,"%04x %02x",
2599 (u16
)qdio_err
, (u8
)sbalf15
);
2600 return QETH_SEND_ERROR_LINK_FAILURE
;
2602 return QETH_SEND_ERROR_NONE
;
2604 if (siga_err
& QDIO_SIGA_ERROR_B_BIT_SET
) {
2605 QETH_DBF_TEXT(trace
, 1, "SIGAcc2B");
2606 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2607 return QETH_SEND_ERROR_KICK_IT
;
2609 if ((sbalf15
>= 15) && (sbalf15
<= 31))
2610 return QETH_SEND_ERROR_RETRY
;
2611 return QETH_SEND_ERROR_LINK_FAILURE
;
2612 /* look at qdio_error and sbalf 15 */
2614 QETH_DBF_TEXT(trace
, 1, "SIGAcc1");
2615 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2616 return QETH_SEND_ERROR_LINK_FAILURE
;
2618 QETH_DBF_TEXT(trace
, 1, "SIGAcc3");
2619 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2620 return QETH_SEND_ERROR_KICK_IT
;
2622 return QETH_SEND_ERROR_LINK_FAILURE
;
2626 qeth_flush_buffers(struct qeth_qdio_out_q
*queue
, int under_int
,
2627 int index
, int count
)
2629 struct qeth_qdio_out_buffer
*buf
;
2633 QETH_DBF_TEXT(trace
, 6, "flushbuf");
2635 for (i
= index
; i
< index
+ count
; ++i
) {
2636 buf
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
2637 buf
->buffer
->element
[buf
->next_element_to_fill
- 1].flags
|=
2638 SBAL_FLAGS_LAST_ENTRY
;
2640 if (queue
->card
->info
.type
== QETH_CARD_TYPE_IQD
)
2643 if (!queue
->do_pack
){
2644 if ((atomic_read(&queue
->used_buffers
) >=
2645 (QETH_HIGH_WATERMARK_PACK
-
2646 QETH_WATERMARK_PACK_FUZZ
)) &&
2647 !atomic_read(&queue
->set_pci_flags_count
)){
2648 /* it's likely that we'll go to packing
2650 atomic_inc(&queue
->set_pci_flags_count
);
2651 buf
->buffer
->element
[0].flags
|= 0x40;
2654 if (!atomic_read(&queue
->set_pci_flags_count
)){
2656 * there's no outstanding PCI any more, so we
2657 * have to request a PCI to be sure the the PCI
2658 * will wake at some time in the future then we
2659 * can flush packed buffers that might still be
2660 * hanging around, which can happen if no
2661 * further send was requested by the stack
2663 atomic_inc(&queue
->set_pci_flags_count
);
2664 buf
->buffer
->element
[0].flags
|= 0x40;
2669 queue
->card
->dev
->trans_start
= jiffies
;
2670 #ifdef CONFIG_QETH_PERF_STATS
2671 queue
->card
->perf_stats
.outbound_do_qdio_cnt
++;
2672 queue
->card
->perf_stats
.outbound_do_qdio_start_time
= qeth_get_micros();
2675 rc
= do_QDIO(CARD_DDEV(queue
->card
),
2676 QDIO_FLAG_SYNC_OUTPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2677 queue
->queue_no
, index
, count
, NULL
);
2679 rc
= do_QDIO(CARD_DDEV(queue
->card
), QDIO_FLAG_SYNC_OUTPUT
,
2680 queue
->queue_no
, index
, count
, NULL
);
2681 #ifdef CONFIG_QETH_PERF_STATS
2682 queue
->card
->perf_stats
.outbound_do_qdio_time
+= qeth_get_micros() -
2683 queue
->card
->perf_stats
.outbound_do_qdio_start_time
;
2686 QETH_DBF_SPRINTF(trace
, 0, "qeth_flush_buffers: do_QDIO "
2687 "returned error (%i) on device %s.",
2688 rc
, CARD_DDEV_ID(queue
->card
));
2689 QETH_DBF_TEXT(trace
, 2, "flushbuf");
2690 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
2691 queue
->card
->stats
.tx_errors
+= count
;
2692 /* this must not happen under normal circumstances. if it
2693 * happens something is really wrong -> recover */
2694 qeth_schedule_recovery(queue
->card
);
2697 atomic_add(count
, &queue
->used_buffers
);
2698 #ifdef CONFIG_QETH_PERF_STATS
2699 queue
->card
->perf_stats
.bufs_sent
+= count
;
2704 * Switched to packing state if the number of used buffers on a queue
2705 * reaches a certain limit.
2708 qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q
*queue
)
2710 if (!queue
->do_pack
) {
2711 if (atomic_read(&queue
->used_buffers
)
2712 >= QETH_HIGH_WATERMARK_PACK
){
2713 /* switch non-PACKING -> PACKING */
2714 QETH_DBF_TEXT(trace
, 6, "np->pack");
2715 #ifdef CONFIG_QETH_PERF_STATS
2716 queue
->card
->perf_stats
.sc_dp_p
++;
2724 * Switches from packing to non-packing mode. If there is a packing
2725 * buffer on the queue this buffer will be prepared to be flushed.
2726 * In that case 1 is returned to inform the caller. If no buffer
2727 * has to be flushed, zero is returned.
2730 qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q
*queue
)
2732 struct qeth_qdio_out_buffer
*buffer
;
2733 int flush_count
= 0;
2735 if (queue
->do_pack
) {
2736 if (atomic_read(&queue
->used_buffers
)
2737 <= QETH_LOW_WATERMARK_PACK
) {
2738 /* switch PACKING -> non-PACKING */
2739 QETH_DBF_TEXT(trace
, 6, "pack->np");
2740 #ifdef CONFIG_QETH_PERF_STATS
2741 queue
->card
->perf_stats
.sc_p_dp
++;
2744 /* flush packing buffers */
2745 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2746 if ((atomic_read(&buffer
->state
) ==
2747 QETH_QDIO_BUF_EMPTY
) &&
2748 (buffer
->next_element_to_fill
> 0)) {
2749 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
2751 queue
->next_buf_to_fill
=
2752 (queue
->next_buf_to_fill
+ 1) %
2753 QDIO_MAX_BUFFERS_PER_Q
;
2761 * Called to flush a packing buffer if no more pci flags are on the queue.
2762 * Checks if there is a packing buffer and prepares it to be flushed.
2763 * In that case returns 1, otherwise zero.
2766 qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q
*queue
)
2768 struct qeth_qdio_out_buffer
*buffer
;
2770 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2771 if((atomic_read(&buffer
->state
) == QETH_QDIO_BUF_EMPTY
) &&
2772 (buffer
->next_element_to_fill
> 0)){
2773 /* it's a packing buffer */
2774 atomic_set(&buffer
->state
, QETH_QDIO_BUF_PRIMED
);
2775 queue
->next_buf_to_fill
=
2776 (queue
->next_buf_to_fill
+ 1) % QDIO_MAX_BUFFERS_PER_Q
;
2783 qeth_check_outbound_queue(struct qeth_qdio_out_q
*queue
)
2787 int q_was_packing
= 0;
2790 * check if weed have to switch to non-packing mode or if
2791 * we have to get a pci flag out on the queue
2793 if ((atomic_read(&queue
->used_buffers
) <= QETH_LOW_WATERMARK_PACK
) ||
2794 !atomic_read(&queue
->set_pci_flags_count
)){
2795 if (atomic_swap(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
) ==
2796 QETH_OUT_Q_UNLOCKED
) {
2798 * If we get in here, there was no action in
2799 * do_send_packet. So, we check if there is a
2800 * packing buffer to be flushed here.
2802 netif_stop_queue(queue
->card
->dev
);
2803 index
= queue
->next_buf_to_fill
;
2804 q_was_packing
= queue
->do_pack
;
2805 flush_cnt
+= qeth_switch_to_nonpacking_if_needed(queue
);
2807 !atomic_read(&queue
->set_pci_flags_count
))
2809 qeth_flush_buffers_on_no_pci(queue
);
2810 #ifdef CONFIG_QETH_PERF_STATS
2812 queue
->card
->perf_stats
.bufs_sent_pack
+=
2816 qeth_flush_buffers(queue
, 1, index
, flush_cnt
);
2817 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
2823 qeth_qdio_output_handler(struct ccw_device
* ccwdev
, unsigned int status
,
2824 unsigned int qdio_error
, unsigned int siga_error
,
2825 unsigned int __queue
, int first_element
, int count
,
2826 unsigned long card_ptr
)
2828 struct qeth_card
*card
= (struct qeth_card
*) card_ptr
;
2829 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
[__queue
];
2830 struct qeth_qdio_out_buffer
*buffer
;
2833 QETH_DBF_TEXT(trace
, 6, "qdouhdl");
2834 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2835 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
2836 QETH_DBF_SPRINTF(trace
, 2, "On device %s: "
2837 "received active check "
2838 "condition (0x%08x).",
2839 CARD_BUS_ID(card
), status
);
2840 QETH_DBF_TEXT(trace
, 2, "chkcond");
2841 QETH_DBF_TEXT_(trace
, 2, "%08x", status
);
2842 netif_stop_queue(card
->dev
);
2843 qeth_schedule_recovery(card
);
2847 #ifdef CONFIG_QETH_PERF_STATS
2848 card
->perf_stats
.outbound_handler_cnt
++;
2849 card
->perf_stats
.outbound_handler_start_time
= qeth_get_micros();
2851 for(i
= first_element
; i
< (first_element
+ count
); ++i
){
2852 buffer
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
2853 /*we only handle the KICK_IT error by doing a recovery */
2854 if (qeth_handle_send_error(card
, buffer
, qdio_error
, siga_error
)
2855 == QETH_SEND_ERROR_KICK_IT
){
2856 netif_stop_queue(card
->dev
);
2857 qeth_schedule_recovery(card
);
2860 qeth_clear_output_buffer(queue
, buffer
);
2862 atomic_sub(count
, &queue
->used_buffers
);
2863 /* check if we need to do something on this outbound queue */
2864 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
2865 qeth_check_outbound_queue(queue
);
2867 netif_wake_queue(queue
->card
->dev
);
2868 #ifdef CONFIG_QETH_PERF_STATS
2869 card
->perf_stats
.outbound_handler_time
+= qeth_get_micros() -
2870 card
->perf_stats
.outbound_handler_start_time
;
2875 qeth_create_qib_param_field(struct qeth_card
*card
, char *param_field
)
2878 param_field
[0] = _ascebc
['P'];
2879 param_field
[1] = _ascebc
['C'];
2880 param_field
[2] = _ascebc
['I'];
2881 param_field
[3] = _ascebc
['T'];
2882 *((unsigned int *) (¶m_field
[4])) = QETH_PCI_THRESHOLD_A(card
);
2883 *((unsigned int *) (¶m_field
[8])) = QETH_PCI_THRESHOLD_B(card
);
2884 *((unsigned int *) (¶m_field
[12])) = QETH_PCI_TIMER_VALUE(card
);
2888 qeth_create_qib_param_field_blkt(struct qeth_card
*card
, char *param_field
)
2890 param_field
[16] = _ascebc
['B'];
2891 param_field
[17] = _ascebc
['L'];
2892 param_field
[18] = _ascebc
['K'];
2893 param_field
[19] = _ascebc
['T'];
2894 *((unsigned int *) (¶m_field
[20])) = card
->info
.blkt
.time_total
;
2895 *((unsigned int *) (¶m_field
[24])) = card
->info
.blkt
.inter_packet
;
2896 *((unsigned int *) (¶m_field
[28])) = card
->info
.blkt
.inter_packet_jumbo
;
2900 qeth_initialize_working_pool_list(struct qeth_card
*card
)
2902 struct qeth_buffer_pool_entry
*entry
;
2904 QETH_DBF_TEXT(trace
,5,"inwrklst");
2906 list_for_each_entry(entry
,
2907 &card
->qdio
.init_pool
.entry_list
, init_list
) {
2908 qeth_put_buffer_pool_entry(card
,entry
);
2913 qeth_clear_working_pool_list(struct qeth_card
*card
)
2915 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
2917 QETH_DBF_TEXT(trace
,5,"clwrklst");
2918 list_for_each_entry_safe(pool_entry
, tmp
,
2919 &card
->qdio
.in_buf_pool
.entry_list
, list
){
2920 list_del(&pool_entry
->list
);
2925 qeth_free_buffer_pool(struct qeth_card
*card
)
2927 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
2929 QETH_DBF_TEXT(trace
,5,"freepool");
2930 list_for_each_entry_safe(pool_entry
, tmp
,
2931 &card
->qdio
.init_pool
.entry_list
, init_list
){
2932 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
)
2933 free_page((unsigned long)pool_entry
->elements
[i
]);
2934 list_del(&pool_entry
->init_list
);
2940 qeth_alloc_buffer_pool(struct qeth_card
*card
)
2942 struct qeth_buffer_pool_entry
*pool_entry
;
2946 QETH_DBF_TEXT(trace
,5,"alocpool");
2947 for (i
= 0; i
< card
->qdio
.init_pool
.buf_count
; ++i
){
2948 pool_entry
= kmalloc(sizeof(*pool_entry
), GFP_KERNEL
);
2950 qeth_free_buffer_pool(card
);
2953 for(j
= 0; j
< QETH_MAX_BUFFER_ELEMENTS(card
); ++j
){
2954 ptr
= (void *) __get_free_page(GFP_KERNEL
);
2957 free_page((unsigned long)
2958 pool_entry
->elements
[--j
]);
2960 qeth_free_buffer_pool(card
);
2963 pool_entry
->elements
[j
] = ptr
;
2965 list_add(&pool_entry
->init_list
,
2966 &card
->qdio
.init_pool
.entry_list
);
2972 qeth_realloc_buffer_pool(struct qeth_card
*card
, int bufcnt
)
2974 QETH_DBF_TEXT(trace
, 2, "realcbp");
2976 if ((card
->state
!= CARD_STATE_DOWN
) &&
2977 (card
->state
!= CARD_STATE_RECOVER
))
2980 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
2981 qeth_clear_working_pool_list(card
);
2982 qeth_free_buffer_pool(card
);
2983 card
->qdio
.in_buf_pool
.buf_count
= bufcnt
;
2984 card
->qdio
.init_pool
.buf_count
= bufcnt
;
2985 return qeth_alloc_buffer_pool(card
);
2989 qeth_alloc_qdio_buffers(struct qeth_card
*card
)
2993 QETH_DBF_TEXT(setup
, 2, "allcqdbf");
2995 if (card
->qdio
.state
== QETH_QDIO_ALLOCATED
)
2998 card
->qdio
.in_q
= kmalloc(sizeof(struct qeth_qdio_q
), GFP_KERNEL
);
2999 if (!card
->qdio
.in_q
)
3001 QETH_DBF_TEXT(setup
, 2, "inq");
3002 QETH_DBF_HEX(setup
, 2, &card
->qdio
.in_q
, sizeof(void *));
3003 memset(card
->qdio
.in_q
, 0, sizeof(struct qeth_qdio_q
));
3004 /* give inbound qeth_qdio_buffers their qdio_buffers */
3005 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3006 card
->qdio
.in_q
->bufs
[i
].buffer
=
3007 &card
->qdio
.in_q
->qdio_bufs
[i
];
3008 /* inbound buffer pool */
3009 if (qeth_alloc_buffer_pool(card
)){
3010 kfree(card
->qdio
.in_q
);
3015 kmalloc(card
->qdio
.no_out_queues
*
3016 sizeof(struct qeth_qdio_out_q
*), GFP_KERNEL
);
3017 if (!card
->qdio
.out_qs
){
3018 qeth_free_buffer_pool(card
);
3021 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3022 card
->qdio
.out_qs
[i
] = kmalloc(sizeof(struct qeth_qdio_out_q
),
3024 if (!card
->qdio
.out_qs
[i
]){
3026 kfree(card
->qdio
.out_qs
[--i
]);
3027 kfree(card
->qdio
.out_qs
);
3030 QETH_DBF_TEXT_(setup
, 2, "outq %i", i
);
3031 QETH_DBF_HEX(setup
, 2, &card
->qdio
.out_qs
[i
], sizeof(void *));
3032 memset(card
->qdio
.out_qs
[i
], 0, sizeof(struct qeth_qdio_out_q
));
3033 card
->qdio
.out_qs
[i
]->queue_no
= i
;
3034 /* give outbound qeth_qdio_buffers their qdio_buffers */
3035 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3036 card
->qdio
.out_qs
[i
]->bufs
[j
].buffer
=
3037 &card
->qdio
.out_qs
[i
]->qdio_bufs
[j
];
3038 skb_queue_head_init(&card
->qdio
.out_qs
[i
]->bufs
[j
].
3040 INIT_LIST_HEAD(&card
->qdio
.out_qs
[i
]->bufs
[j
].ctx_list
);
3043 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3048 qeth_free_qdio_buffers(struct qeth_card
*card
)
3052 QETH_DBF_TEXT(trace
, 2, "freeqdbf");
3053 if (card
->qdio
.state
== QETH_QDIO_UNINITIALIZED
)
3055 kfree(card
->qdio
.in_q
);
3056 /* inbound buffer pool */
3057 qeth_free_buffer_pool(card
);
3058 /* free outbound qdio_qs */
3059 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3060 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3061 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3062 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3063 kfree(card
->qdio
.out_qs
[i
]);
3065 kfree(card
->qdio
.out_qs
);
3066 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3070 qeth_clear_qdio_buffers(struct qeth_card
*card
)
3074 QETH_DBF_TEXT(trace
, 2, "clearqdbf");
3075 /* clear outbound buffers to free skbs */
3076 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3077 if (card
->qdio
.out_qs
[i
]){
3078 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3079 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3080 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3085 qeth_init_qdio_info(struct qeth_card
*card
)
3087 QETH_DBF_TEXT(setup
, 4, "intqdinf");
3088 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3090 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
3091 card
->qdio
.init_pool
.buf_count
= QETH_IN_BUF_COUNT_DEFAULT
;
3092 card
->qdio
.in_buf_pool
.buf_count
= card
->qdio
.init_pool
.buf_count
;
3093 INIT_LIST_HEAD(&card
->qdio
.in_buf_pool
.entry_list
);
3094 INIT_LIST_HEAD(&card
->qdio
.init_pool
.entry_list
);
3096 card
->qdio
.do_prio_queueing
= QETH_PRIOQ_DEFAULT
;
3097 card
->qdio
.default_out_queue
= QETH_DEFAULT_QUEUE
;
3101 qeth_init_qdio_queues(struct qeth_card
*card
)
3106 QETH_DBF_TEXT(setup
, 2, "initqdqs");
3109 memset(card
->qdio
.in_q
->qdio_bufs
, 0,
3110 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3111 qeth_initialize_working_pool_list(card
);
3112 /*give only as many buffers to hardware as we have buffer pool entries*/
3113 for (i
= 0; i
< card
->qdio
.in_buf_pool
.buf_count
- 1; ++i
)
3114 qeth_init_input_buffer(card
, &card
->qdio
.in_q
->bufs
[i
]);
3115 card
->qdio
.in_q
->next_buf_to_init
= card
->qdio
.in_buf_pool
.buf_count
- 1;
3116 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0, 0,
3117 card
->qdio
.in_buf_pool
.buf_count
- 1, NULL
);
3119 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3122 rc
= qdio_synchronize(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0);
3124 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3127 /* outbound queue */
3128 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3129 memset(card
->qdio
.out_qs
[i
]->qdio_bufs
, 0,
3130 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3131 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3132 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3133 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3135 card
->qdio
.out_qs
[i
]->card
= card
;
3136 card
->qdio
.out_qs
[i
]->next_buf_to_fill
= 0;
3137 card
->qdio
.out_qs
[i
]->do_pack
= 0;
3138 atomic_set(&card
->qdio
.out_qs
[i
]->used_buffers
,0);
3139 atomic_set(&card
->qdio
.out_qs
[i
]->set_pci_flags_count
, 0);
3140 atomic_set(&card
->qdio
.out_qs
[i
]->state
,
3141 QETH_OUT_Q_UNLOCKED
);
3147 qeth_qdio_establish(struct qeth_card
*card
)
3149 struct qdio_initialize init_data
;
3150 char *qib_param_field
;
3151 struct qdio_buffer
**in_sbal_ptrs
;
3152 struct qdio_buffer
**out_sbal_ptrs
;
3156 QETH_DBF_TEXT(setup
, 2, "qdioest");
3158 qib_param_field
= kmalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(char),
3160 if (!qib_param_field
)
3163 memset(qib_param_field
, 0, QDIO_MAX_BUFFERS_PER_Q
* sizeof(char));
3165 qeth_create_qib_param_field(card
, qib_param_field
);
3166 qeth_create_qib_param_field_blkt(card
, qib_param_field
);
3168 in_sbal_ptrs
= kmalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(void *),
3170 if (!in_sbal_ptrs
) {
3171 kfree(qib_param_field
);
3174 for(i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3175 in_sbal_ptrs
[i
] = (struct qdio_buffer
*)
3176 virt_to_phys(card
->qdio
.in_q
->bufs
[i
].buffer
);
3179 kmalloc(card
->qdio
.no_out_queues
* QDIO_MAX_BUFFERS_PER_Q
*
3180 sizeof(void *), GFP_KERNEL
);
3181 if (!out_sbal_ptrs
) {
3182 kfree(in_sbal_ptrs
);
3183 kfree(qib_param_field
);
3186 for(i
= 0, k
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3187 for(j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
, ++k
){
3188 out_sbal_ptrs
[k
] = (struct qdio_buffer
*)
3189 virt_to_phys(card
->qdio
.out_qs
[i
]->
3193 memset(&init_data
, 0, sizeof(struct qdio_initialize
));
3194 init_data
.cdev
= CARD_DDEV(card
);
3195 init_data
.q_format
= qeth_get_qdio_q_format(card
);
3196 init_data
.qib_param_field_format
= 0;
3197 init_data
.qib_param_field
= qib_param_field
;
3198 init_data
.min_input_threshold
= QETH_MIN_INPUT_THRESHOLD
;
3199 init_data
.max_input_threshold
= QETH_MAX_INPUT_THRESHOLD
;
3200 init_data
.min_output_threshold
= QETH_MIN_OUTPUT_THRESHOLD
;
3201 init_data
.max_output_threshold
= QETH_MAX_OUTPUT_THRESHOLD
;
3202 init_data
.no_input_qs
= 1;
3203 init_data
.no_output_qs
= card
->qdio
.no_out_queues
;
3204 init_data
.input_handler
= (qdio_handler_t
*)
3205 qeth_qdio_input_handler
;
3206 init_data
.output_handler
= (qdio_handler_t
*)
3207 qeth_qdio_output_handler
;
3208 init_data
.int_parm
= (unsigned long) card
;
3209 init_data
.flags
= QDIO_INBOUND_0COPY_SBALS
|
3210 QDIO_OUTBOUND_0COPY_SBALS
|
3211 QDIO_USE_OUTBOUND_PCIS
;
3212 init_data
.input_sbal_addr_array
= (void **) in_sbal_ptrs
;
3213 init_data
.output_sbal_addr_array
= (void **) out_sbal_ptrs
;
3215 if (!(rc
= qdio_initialize(&init_data
)))
3216 card
->qdio
.state
= QETH_QDIO_ESTABLISHED
;
3218 kfree(out_sbal_ptrs
);
3219 kfree(in_sbal_ptrs
);
3220 kfree(qib_param_field
);
3225 qeth_qdio_activate(struct qeth_card
*card
)
3227 QETH_DBF_TEXT(setup
,3,"qdioact");
3228 return qdio_activate(CARD_DDEV(card
), 0);
3232 qeth_clear_channel(struct qeth_channel
*channel
)
3234 unsigned long flags
;
3235 struct qeth_card
*card
;
3238 QETH_DBF_TEXT(trace
,3,"clearch");
3239 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3240 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3241 rc
= ccw_device_clear(channel
->ccwdev
, QETH_CLEAR_CHANNEL_PARM
);
3242 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3246 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3247 channel
->state
==CH_STATE_STOPPED
, QETH_TIMEOUT
);
3248 if (rc
== -ERESTARTSYS
)
3250 if (channel
->state
!= CH_STATE_STOPPED
)
3252 channel
->state
= CH_STATE_DOWN
;
3257 qeth_halt_channel(struct qeth_channel
*channel
)
3259 unsigned long flags
;
3260 struct qeth_card
*card
;
3263 QETH_DBF_TEXT(trace
,3,"haltch");
3264 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3265 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3266 rc
= ccw_device_halt(channel
->ccwdev
, QETH_HALT_CHANNEL_PARM
);
3267 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3271 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3272 channel
->state
==CH_STATE_HALTED
, QETH_TIMEOUT
);
3273 if (rc
== -ERESTARTSYS
)
3275 if (channel
->state
!= CH_STATE_HALTED
)
3281 qeth_halt_channels(struct qeth_card
*card
)
3285 QETH_DBF_TEXT(trace
,3,"haltchs");
3286 if ((rc
= qeth_halt_channel(&card
->read
)))
3288 if ((rc
= qeth_halt_channel(&card
->write
)))
3290 return qeth_halt_channel(&card
->data
);
3293 qeth_clear_channels(struct qeth_card
*card
)
3297 QETH_DBF_TEXT(trace
,3,"clearchs");
3298 if ((rc
= qeth_clear_channel(&card
->read
)))
3300 if ((rc
= qeth_clear_channel(&card
->write
)))
3302 return qeth_clear_channel(&card
->data
);
3306 qeth_clear_halt_card(struct qeth_card
*card
, int halt
)
3310 QETH_DBF_TEXT(trace
,3,"clhacrd");
3311 QETH_DBF_HEX(trace
, 3, &card
, sizeof(void *));
3314 rc
= qeth_halt_channels(card
);
3317 return qeth_clear_channels(card
);
3321 qeth_qdio_clear_card(struct qeth_card
*card
, int use_halt
)
3325 QETH_DBF_TEXT(trace
,3,"qdioclr");
3326 if (card
->qdio
.state
== QETH_QDIO_ESTABLISHED
){
3327 if ((rc
= qdio_cleanup(CARD_DDEV(card
),
3328 (card
->info
.type
== QETH_CARD_TYPE_IQD
) ?
3329 QDIO_FLAG_CLEANUP_USING_HALT
:
3330 QDIO_FLAG_CLEANUP_USING_CLEAR
)))
3331 QETH_DBF_TEXT_(trace
, 3, "1err%d", rc
);
3332 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3334 if ((rc
= qeth_clear_halt_card(card
, use_halt
)))
3335 QETH_DBF_TEXT_(trace
, 3, "2err%d", rc
);
3336 card
->state
= CARD_STATE_DOWN
;
3341 qeth_dm_act(struct qeth_card
*card
)
3344 struct qeth_cmd_buffer
*iob
;
3346 QETH_DBF_TEXT(setup
,2,"dmact");
3348 iob
= qeth_wait_for_buffer(&card
->write
);
3349 memcpy(iob
->data
, DM_ACT
, DM_ACT_SIZE
);
3351 memcpy(QETH_DM_ACT_DEST_ADDR(iob
->data
),
3352 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3353 memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob
->data
),
3354 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3355 rc
= qeth_send_control_data(card
, DM_ACT_SIZE
, iob
, NULL
, NULL
);
3360 qeth_mpc_initialize(struct qeth_card
*card
)
3364 QETH_DBF_TEXT(setup
,2,"mpcinit");
3366 if ((rc
= qeth_issue_next_read(card
))){
3367 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3370 if ((rc
= qeth_cm_enable(card
))){
3371 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3374 if ((rc
= qeth_cm_setup(card
))){
3375 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
3378 if ((rc
= qeth_ulp_enable(card
))){
3379 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
3382 if ((rc
= qeth_ulp_setup(card
))){
3383 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3386 if ((rc
= qeth_alloc_qdio_buffers(card
))){
3387 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3390 if ((rc
= qeth_qdio_establish(card
))){
3391 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
3392 qeth_free_qdio_buffers(card
);
3395 if ((rc
= qeth_qdio_activate(card
))){
3396 QETH_DBF_TEXT_(setup
, 2, "7err%d", rc
);
3399 if ((rc
= qeth_dm_act(card
))){
3400 QETH_DBF_TEXT_(setup
, 2, "8err%d", rc
);
3406 qeth_qdio_clear_card(card
, card
->info
.type
==QETH_CARD_TYPE_OSAE
);
3410 static struct net_device
*
3411 qeth_get_netdevice(enum qeth_card_types type
, enum qeth_link_types linktype
)
3413 struct net_device
*dev
= NULL
;
3416 case QETH_CARD_TYPE_OSAE
:
3418 case QETH_LINK_TYPE_LANE_TR
:
3419 case QETH_LINK_TYPE_HSTR
:
3421 dev
= alloc_trdev(0);
3422 #endif /* CONFIG_TR */
3425 dev
= alloc_etherdev(0);
3428 case QETH_CARD_TYPE_IQD
:
3429 dev
= alloc_netdev(0, "hsi%d", ether_setup
);
3432 dev
= alloc_etherdev(0);
3437 /*hard_header fake function; used in case fake_ll is set */
3439 qeth_fake_header(struct sk_buff
*skb
, struct net_device
*dev
,
3440 unsigned short type
, void *daddr
, void *saddr
,
3445 hdr
= (struct ethhdr
*)skb_push(skb
, QETH_FAKE_LL_LEN
);
3446 memcpy(hdr
->h_source
, dev
->dev_addr
, ETH_ALEN
);
3447 memcpy(hdr
->h_dest
, "FAKELL", ETH_ALEN
);
3448 if (type
!= ETH_P_802_3
)
3449 hdr
->h_proto
= htons(type
);
3451 hdr
->h_proto
= htons(len
);
3452 return QETH_FAKE_LL_LEN
;
3456 qeth_send_packet(struct qeth_card
*, struct sk_buff
*);
3459 qeth_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
3462 struct qeth_card
*card
;
3464 QETH_DBF_TEXT(trace
, 6, "hrdstxmi");
3465 card
= (struct qeth_card
*)dev
->priv
;
3467 card
->stats
.tx_dropped
++;
3468 card
->stats
.tx_errors
++;
3469 /* return OK; otherwise ksoftirqd goes to 100% */
3470 return NETDEV_TX_OK
;
3472 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
3473 card
->stats
.tx_dropped
++;
3474 card
->stats
.tx_errors
++;
3475 card
->stats
.tx_carrier_errors
++;
3476 dev_kfree_skb_any(skb
);
3477 /* return OK; otherwise ksoftirqd goes to 100% */
3478 return NETDEV_TX_OK
;
3480 #ifdef CONFIG_QETH_PERF_STATS
3481 card
->perf_stats
.outbound_cnt
++;
3482 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
3484 netif_stop_queue(dev
);
3485 if ((rc
= qeth_send_packet(card
, skb
))) {
3487 return NETDEV_TX_BUSY
;
3489 card
->stats
.tx_errors
++;
3490 card
->stats
.tx_dropped
++;
3491 dev_kfree_skb_any(skb
);
3492 /*set to OK; otherwise ksoftirqd goes to 100% */
3496 netif_wake_queue(dev
);
3497 #ifdef CONFIG_QETH_PERF_STATS
3498 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
3499 card
->perf_stats
.outbound_start_time
;
3505 qeth_verify_vlan_dev(struct net_device
*dev
, struct qeth_card
*card
)
3508 #ifdef CONFIG_QETH_VLAN
3509 struct vlan_group
*vg
;
3512 if (!(vg
= card
->vlangrp
))
3515 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++){
3516 if (vg
->vlan_devices
[i
] == dev
){
3517 rc
= QETH_VLAN_CARD
;
3526 qeth_verify_dev(struct net_device
*dev
)
3528 struct qeth_card
*card
;
3529 unsigned long flags
;
3532 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
3533 list_for_each_entry(card
, &qeth_card_list
.list
, list
){
3534 if (card
->dev
== dev
){
3535 rc
= QETH_REAL_CARD
;
3538 rc
= qeth_verify_vlan_dev(dev
, card
);
3542 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
3547 static struct qeth_card
*
3548 qeth_get_card_from_dev(struct net_device
*dev
)
3550 struct qeth_card
*card
= NULL
;
3553 rc
= qeth_verify_dev(dev
);
3554 if (rc
== QETH_REAL_CARD
)
3555 card
= (struct qeth_card
*)dev
->priv
;
3556 else if (rc
== QETH_VLAN_CARD
)
3557 card
= (struct qeth_card
*)
3558 VLAN_DEV_INFO(dev
)->real_dev
->priv
;
3560 QETH_DBF_TEXT_(trace
, 4, "%d", rc
);
3565 qeth_tx_timeout(struct net_device
*dev
)
3567 struct qeth_card
*card
;
3569 card
= (struct qeth_card
*) dev
->priv
;
3570 card
->stats
.tx_errors
++;
3571 qeth_schedule_recovery(card
);
3575 qeth_open(struct net_device
*dev
)
3577 struct qeth_card
*card
;
3579 QETH_DBF_TEXT(trace
, 4, "qethopen");
3581 card
= (struct qeth_card
*) dev
->priv
;
3583 if (card
->state
!= CARD_STATE_SOFTSETUP
)
3586 if ( (card
->options
.layer2
) &&
3587 (!card
->info
.layer2_mac_registered
)) {
3588 QETH_DBF_TEXT(trace
,4,"nomacadr");
3591 card
->dev
->flags
|= IFF_UP
;
3592 netif_start_queue(dev
);
3593 card
->data
.state
= CH_STATE_UP
;
3594 card
->state
= CARD_STATE_UP
;
3596 if (!card
->lan_online
){
3597 if (netif_carrier_ok(dev
))
3598 netif_carrier_off(dev
);
3604 qeth_stop(struct net_device
*dev
)
3606 struct qeth_card
*card
;
3608 QETH_DBF_TEXT(trace
, 4, "qethstop");
3610 card
= (struct qeth_card
*) dev
->priv
;
3612 netif_stop_queue(dev
);
3613 card
->dev
->flags
&= ~IFF_UP
;
3614 if (card
->state
== CARD_STATE_UP
)
3615 card
->state
= CARD_STATE_SOFTSETUP
;
3620 qeth_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
3622 int cast_type
= RTN_UNSPEC
;
3624 if (skb
->dst
&& skb
->dst
->neighbour
){
3625 cast_type
= skb
->dst
->neighbour
->type
;
3626 if ((cast_type
== RTN_BROADCAST
) ||
3627 (cast_type
== RTN_MULTICAST
) ||
3628 (cast_type
== RTN_ANYCAST
))
3633 /* try something else */
3634 if (skb
->protocol
== ETH_P_IPV6
)
3635 return (skb
->nh
.raw
[24] == 0xff) ? RTN_MULTICAST
: 0;
3636 else if (skb
->protocol
== ETH_P_IP
)
3637 return ((skb
->nh
.raw
[16] & 0xf0) == 0xe0) ? RTN_MULTICAST
: 0;
3639 if (!memcmp(skb
->data
, skb
->dev
->broadcast
, 6))
3640 return RTN_BROADCAST
;
3644 hdr_mac
= *((u16
*)skb
->data
);
3646 switch (card
->info
.link_type
) {
3647 case QETH_LINK_TYPE_HSTR
:
3648 case QETH_LINK_TYPE_LANE_TR
:
3649 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
3650 (hdr_mac
== QETH_TR_MAC_C
))
3651 return RTN_MULTICAST
;
3652 /* eth or so multicast? */
3654 if ((hdr_mac
== QETH_ETH_MAC_V4
) ||
3655 (hdr_mac
== QETH_ETH_MAC_V6
))
3656 return RTN_MULTICAST
;
3663 qeth_get_priority_queue(struct qeth_card
*card
, struct sk_buff
*skb
,
3664 int ipv
, int cast_type
)
3666 if (!ipv
&& (card
->info
.type
== QETH_CARD_TYPE_OSAE
))
3667 return card
->qdio
.default_out_queue
;
3668 switch (card
->qdio
.no_out_queues
) {
3670 if (cast_type
&& card
->info
.is_multicast_different
)
3671 return card
->info
.is_multicast_different
&
3672 (card
->qdio
.no_out_queues
- 1);
3673 if (card
->qdio
.do_prio_queueing
&& (ipv
== 4)) {
3674 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_TOS
){
3675 if (skb
->nh
.iph
->tos
& IP_TOS_NOTIMPORTANT
)
3677 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHRELIABILITY
)
3679 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHTHROUGHPUT
)
3681 if (skb
->nh
.iph
->tos
& IP_TOS_LOWDELAY
)
3684 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_PREC
)
3685 return 3 - (skb
->nh
.iph
->tos
>> 6);
3686 } else if (card
->qdio
.do_prio_queueing
&& (ipv
== 6)) {
3689 return card
->qdio
.default_out_queue
;
3690 case 1: /* fallthrough for single-out-queue 1920-device */
3692 return card
->qdio
.default_out_queue
;
3697 qeth_get_ip_version(struct sk_buff
*skb
)
3699 switch (skb
->protocol
) {
3710 qeth_prepare_skb(struct qeth_card
*card
, struct sk_buff
**skb
,
3711 struct qeth_hdr
**hdr
, int ipv
)
3714 #ifdef CONFIG_QETH_VLAN
3718 QETH_DBF_TEXT(trace
, 6, "prepskb");
3720 rc
= qeth_realloc_headroom(card
, skb
, sizeof(struct qeth_hdr
));
3723 #ifdef CONFIG_QETH_VLAN
3724 if (card
->vlangrp
&& vlan_tx_tag_present(*skb
) &&
3725 ((ipv
== 6) || card
->options
.layer2
) ) {
3727 * Move the mac addresses (6 bytes src, 6 bytes dest)
3728 * to the beginning of the new header. We are using three
3729 * memcpys instead of one memmove to save cycles.
3731 skb_push(*skb
, VLAN_HLEN
);
3732 memcpy((*skb
)->data
, (*skb
)->data
+ 4, 4);
3733 memcpy((*skb
)->data
+ 4, (*skb
)->data
+ 8, 4);
3734 memcpy((*skb
)->data
+ 8, (*skb
)->data
+ 12, 4);
3735 tag
= (u16
*)((*skb
)->data
+ 12);
3737 * first two bytes = ETH_P_8021Q (0x8100)
3738 * second two bytes = VLANID
3740 *tag
= __constant_htons(ETH_P_8021Q
);
3741 *(tag
+ 1) = htons(vlan_tx_tag_get(*skb
));
3744 *hdr
= (struct qeth_hdr
*)
3745 qeth_push_skb(card
, skb
, sizeof(struct qeth_hdr
));
3752 qeth_get_qeth_hdr_flags4(int cast_type
)
3754 if (cast_type
== RTN_MULTICAST
)
3755 return QETH_CAST_MULTICAST
;
3756 if (cast_type
== RTN_BROADCAST
)
3757 return QETH_CAST_BROADCAST
;
3758 return QETH_CAST_UNICAST
;
3762 qeth_get_qeth_hdr_flags6(int cast_type
)
3764 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
3765 if (cast_type
== RTN_MULTICAST
)
3766 return ct
| QETH_CAST_MULTICAST
;
3767 if (cast_type
== RTN_ANYCAST
)
3768 return ct
| QETH_CAST_ANYCAST
;
3769 if (cast_type
== RTN_BROADCAST
)
3770 return ct
| QETH_CAST_BROADCAST
;
3771 return ct
| QETH_CAST_UNICAST
;
3775 qeth_layer2_get_packet_type(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
3776 struct sk_buff
*skb
)
3780 if (!memcmp(skb
->data
+QETH_HEADER_SIZE
,
3781 skb
->dev
->broadcast
,6)) { /* broadcast? */
3782 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3783 QETH_LAYER2_FLAG_BROADCAST
<< 8;
3786 hdr_mac
=*((__u16
*)skb
->data
);
3788 switch (card
->info
.link_type
) {
3789 case QETH_LINK_TYPE_HSTR
:
3790 case QETH_LINK_TYPE_LANE_TR
:
3791 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
3792 (hdr_mac
== QETH_TR_MAC_C
) )
3793 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3794 QETH_LAYER2_FLAG_MULTICAST
<< 8;
3796 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3797 QETH_LAYER2_FLAG_UNICAST
<< 8;
3799 /* eth or so multicast? */
3801 if ( (hdr_mac
==QETH_ETH_MAC_V4
) ||
3802 (hdr_mac
==QETH_ETH_MAC_V6
) )
3803 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3804 QETH_LAYER2_FLAG_MULTICAST
<< 8;
3806 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3807 QETH_LAYER2_FLAG_UNICAST
<< 8;
3812 qeth_layer2_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
3813 struct sk_buff
*skb
, int cast_type
)
3815 memset(hdr
, 0, sizeof(struct qeth_hdr
));
3816 hdr
->hdr
.l2
.id
= QETH_HEADER_TYPE_LAYER2
;
3818 /* set byte 0 to "0x02" and byte 3 to casting flags */
3819 if (cast_type
==RTN_MULTICAST
)
3820 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_MULTICAST
<< 8;
3821 else if (cast_type
==RTN_BROADCAST
)
3822 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_BROADCAST
<< 8;
3824 qeth_layer2_get_packet_type(card
, hdr
, skb
);
3826 hdr
->hdr
.l2
.pkt_length
= skb
->len
-QETH_HEADER_SIZE
;
3827 #ifdef CONFIG_QETH_VLAN
3828 /* VSWITCH relies on the VLAN
3829 * information to be present in
3830 * the QDIO header */
3831 if ((card
->vlangrp
!= NULL
) &&
3832 vlan_tx_tag_present(skb
)) {
3833 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_VLAN
<< 8;
3834 hdr
->hdr
.l2
.vlan_id
= vlan_tx_tag_get(skb
);
3840 qeth_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
3841 struct sk_buff
*skb
, int ipv
, int cast_type
)
3843 QETH_DBF_TEXT(trace
, 6, "fillhdr");
3845 memset(hdr
, 0, sizeof(struct qeth_hdr
));
3846 if (card
->options
.layer2
) {
3847 qeth_layer2_fill_header(card
, hdr
, skb
, cast_type
);
3850 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
3851 hdr
->hdr
.l3
.ext_flags
= 0;
3852 #ifdef CONFIG_QETH_VLAN
3854 * before we're going to overwrite this location with next hop ip.
3855 * v6 uses passthrough, v4 sets the tag in the QDIO header.
3857 if (card
->vlangrp
&& vlan_tx_tag_present(skb
)) {
3858 hdr
->hdr
.l3
.ext_flags
= (ipv
== 4) ?
3859 QETH_HDR_EXT_VLAN_FRAME
:
3860 QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
3861 hdr
->hdr
.l3
.vlan_id
= vlan_tx_tag_get(skb
);
3863 #endif /* CONFIG_QETH_VLAN */
3864 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
3865 if (ipv
== 4) { /* IPv4 */
3866 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags4(cast_type
);
3867 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
3868 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
3869 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
3870 *((u32
*) skb
->dst
->neighbour
->primary_key
);
3872 /* fill in destination address used in ip header */
3873 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) = skb
->nh
.iph
->daddr
;
3875 } else if (ipv
== 6) { /* IPv6 or passthru */
3876 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags6(cast_type
);
3877 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
3878 memcpy(hdr
->hdr
.l3
.dest_addr
,
3879 skb
->dst
->neighbour
->primary_key
, 16);
3881 /* fill in destination address used in ip header */
3882 memcpy(hdr
->hdr
.l3
.dest_addr
, &skb
->nh
.ipv6h
->daddr
, 16);
3884 } else { /* passthrough */
3885 if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
3886 skb
->dev
->broadcast
, 6)) { /* broadcast? */
3887 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
| QETH_HDR_PASSTHRU
;
3889 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
3890 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
3891 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
3897 __qeth_fill_buffer_frag(struct sk_buff
*skb
, struct qdio_buffer
*buffer
,
3898 int *next_element_to_fill
)
3900 int length
= skb
->len
;
3901 struct skb_frag_struct
*frag
;
3907 fragno
= skb_shinfo(skb
)->nr_frags
; /* start with last frag */
3908 element
= *next_element_to_fill
+ fragno
;
3909 while (length
> 0) {
3911 frag
= &skb_shinfo(skb
)->frags
[fragno
- 1];
3912 addr
= (page_to_pfn(frag
->page
) << PAGE_SHIFT
) +
3914 buffer
->element
[element
].addr
= (char *)addr
;
3915 buffer
->element
[element
].length
= frag
->size
;
3916 length
-= frag
->size
;
3918 buffer
->element
[element
].flags
=
3919 SBAL_FLAGS_LAST_FRAG
;
3921 buffer
->element
[element
].flags
=
3922 SBAL_FLAGS_MIDDLE_FRAG
;
3924 buffer
->element
[element
].addr
= skb
->data
;
3925 buffer
->element
[element
].length
= length
;
3927 buffer
->element
[element
].flags
=
3928 SBAL_FLAGS_FIRST_FRAG
;
3934 *next_element_to_fill
+= skb_shinfo(skb
)->nr_frags
+ 1;
3938 __qeth_fill_buffer(struct sk_buff
*skb
, struct qdio_buffer
*buffer
,
3939 int *next_element_to_fill
)
3941 int length
= skb
->len
;
3947 element
= *next_element_to_fill
;
3949 while (length
> 0) {
3950 /* length_here is the remaining amount of data in this page */
3951 length_here
= PAGE_SIZE
- ((unsigned long) data
% PAGE_SIZE
);
3952 if (length
< length_here
)
3953 length_here
= length
;
3954 buffer
->element
[element
].addr
= data
;
3955 buffer
->element
[element
].length
= length_here
;
3956 length
-= length_here
;
3959 buffer
->element
[element
].flags
= 0;
3961 buffer
->element
[element
].flags
=
3962 SBAL_FLAGS_LAST_FRAG
;
3965 buffer
->element
[element
].flags
=
3966 SBAL_FLAGS_FIRST_FRAG
;
3968 buffer
->element
[element
].flags
=
3969 SBAL_FLAGS_MIDDLE_FRAG
;
3971 data
+= length_here
;
3975 *next_element_to_fill
= element
;
3979 qeth_fill_buffer(struct qeth_qdio_out_q
*queue
,
3980 struct qeth_qdio_out_buffer
*buf
,
3981 struct sk_buff
*skb
)
3983 struct qdio_buffer
*buffer
;
3986 QETH_DBF_TEXT(trace
, 6, "qdfillbf");
3987 buffer
= buf
->buffer
;
3988 atomic_inc(&skb
->users
);
3989 skb_queue_tail(&buf
->skb_list
, skb
);
3990 if (skb_shinfo(skb
)->nr_frags
== 0)
3991 __qeth_fill_buffer(skb
, buffer
,
3992 (int *)&buf
->next_element_to_fill
);
3994 __qeth_fill_buffer_frag(skb
, buffer
,
3995 (int *)&buf
->next_element_to_fill
);
3997 if (!queue
->do_pack
) {
3998 QETH_DBF_TEXT(trace
, 6, "fillbfnp");
3999 /* set state to PRIMED -> will be flushed */
4000 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4003 QETH_DBF_TEXT(trace
, 6, "fillbfpa");
4004 #ifdef CONFIG_QETH_PERF_STATS
4005 queue
->card
->perf_stats
.skbs_sent_pack
++;
4007 if (buf
->next_element_to_fill
>=
4008 QETH_MAX_BUFFER_ELEMENTS(queue
->card
)) {
4010 * packed buffer if full -> set state PRIMED
4011 * -> will be flushed
4013 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4021 qeth_do_send_packet_fast(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4022 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4023 int elements_needed
,
4024 struct qeth_eddp_context
*ctx
)
4026 struct qeth_qdio_out_buffer
*buffer
;
4027 int buffers_needed
= 0;
4031 QETH_DBF_TEXT(trace
, 6, "dosndpfa");
4033 /* spin until we get the queue ... */
4034 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED
,
4037 /* ... now we've got the queue */
4038 index
= queue
->next_buf_to_fill
;
4039 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4041 * check if buffer is empty to make sure that we do not 'overtake'
4042 * ourselves and try to fill a buffer that is already primed
4044 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
) {
4045 card
->stats
.tx_dropped
++;
4046 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4050 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ 1) %
4051 QDIO_MAX_BUFFERS_PER_Q
;
4053 buffers_needed
= qeth_eddp_check_buffers_for_context(queue
,ctx
);
4054 if (buffers_needed
< 0) {
4055 card
->stats
.tx_dropped
++;
4056 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4059 queue
->next_buf_to_fill
=
4060 (queue
->next_buf_to_fill
+ buffers_needed
) %
4061 QDIO_MAX_BUFFERS_PER_Q
;
4063 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4065 qeth_fill_buffer(queue
, buffer
, skb
);
4066 qeth_flush_buffers(queue
, 0, index
, 1);
4068 flush_cnt
= qeth_eddp_fill_buffer(queue
, ctx
, index
);
4069 WARN_ON(buffers_needed
!= flush_cnt
);
4070 qeth_flush_buffers(queue
, 0, index
, flush_cnt
);
4076 qeth_do_send_packet(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4077 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4078 int elements_needed
, struct qeth_eddp_context
*ctx
)
4080 struct qeth_qdio_out_buffer
*buffer
;
4082 int flush_count
= 0;
4087 QETH_DBF_TEXT(trace
, 6, "dosndpkt");
4089 /* spin until we get the queue ... */
4090 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED
,
4093 start_index
= queue
->next_buf_to_fill
;
4094 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4096 * check if buffer is empty to make sure that we do not 'overtake'
4097 * ourselves and try to fill a buffer that is already primed
4099 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
){
4100 card
->stats
.tx_dropped
++;
4101 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4104 /* check if we need to switch packing state of this queue */
4105 qeth_switch_to_packing_if_needed(queue
);
4106 if (queue
->do_pack
){
4109 /* does packet fit in current buffer? */
4110 if((QETH_MAX_BUFFER_ELEMENTS(card
) -
4111 buffer
->next_element_to_fill
) < elements_needed
){
4112 /* ... no -> set state PRIMED */
4113 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
4115 queue
->next_buf_to_fill
=
4116 (queue
->next_buf_to_fill
+ 1) %
4117 QDIO_MAX_BUFFERS_PER_Q
;
4118 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4119 /* we did a step forward, so check buffer state
4121 if (atomic_read(&buffer
->state
) !=
4122 QETH_QDIO_BUF_EMPTY
){
4123 card
->stats
.tx_dropped
++;
4124 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4125 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4130 /* check if we have enough elements (including following
4131 * free buffers) to handle eddp context */
4132 if (qeth_eddp_check_buffers_for_context(queue
,ctx
) < 0){
4133 printk("eddp tx_dropped 1\n");
4134 card
->stats
.tx_dropped
++;
4141 tmp
= qeth_fill_buffer(queue
, buffer
, skb
);
4143 tmp
= qeth_eddp_fill_buffer(queue
,ctx
,queue
->next_buf_to_fill
);
4145 printk("eddp tx_dropped 2\n");
4146 card
->stats
.tx_dropped
++;
4151 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ tmp
) %
4152 QDIO_MAX_BUFFERS_PER_Q
;
4156 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4158 * queue->state will go from LOCKED -> UNLOCKED or from
4159 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
4160 * (switch packing state or flush buffer to get another pci flag out).
4161 * In that case we will enter this loop
4163 while (atomic_dec_return(&queue
->state
)){
4165 start_index
= queue
->next_buf_to_fill
;
4166 /* check if we can go back to non-packing state */
4167 flush_count
+= qeth_switch_to_nonpacking_if_needed(queue
);
4169 * check if we need to flush a packing buffer to get a pci
4170 * flag out on the queue
4172 if (!flush_count
&& !atomic_read(&queue
->set_pci_flags_count
))
4173 flush_count
+= qeth_flush_buffers_on_no_pci(queue
);
4175 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4177 /* at this point the queue is UNLOCKED again */
4178 #ifdef CONFIG_QETH_PERF_STATS
4180 queue
->card
->perf_stats
.bufs_sent_pack
+= flush_count
;
4181 #endif /* CONFIG_QETH_PERF_STATS */
4187 qeth_send_packet(struct qeth_card
*card
, struct sk_buff
*skb
)
4191 struct qeth_qdio_out_q
*queue
;
4192 struct qeth_hdr
*hdr
;
4193 int elements_needed
= 0;
4194 enum qeth_large_send_types large_send
= QETH_LARGE_SEND_NO
;
4195 struct qeth_eddp_context
*ctx
= NULL
;
4198 QETH_DBF_TEXT(trace
, 6, "sendpkt");
4200 if (!card
->options
.layer2
) {
4201 ipv
= qeth_get_ip_version(skb
);
4202 if ((card
->dev
->hard_header
== qeth_fake_header
) && ipv
) {
4203 if ((skb
= qeth_pskb_unshare(skb
,GFP_ATOMIC
)) == NULL
) {
4204 card
->stats
.tx_dropped
++;
4205 dev_kfree_skb_irq(skb
);
4208 skb_pull(skb
, QETH_FAKE_LL_LEN
);
4211 cast_type
= qeth_get_cast_type(card
, skb
);
4212 if ((cast_type
== RTN_BROADCAST
) && (card
->info
.broadcast_capable
== 0)){
4213 card
->stats
.tx_dropped
++;
4214 card
->stats
.tx_errors
++;
4215 dev_kfree_skb_any(skb
);
4216 return NETDEV_TX_OK
;
4218 queue
= card
->qdio
.out_qs
4219 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
4221 if (skb_shinfo(skb
)->tso_size
)
4222 large_send
= card
->options
.large_send
;
4224 if ((rc
= qeth_prepare_skb(card
, &skb
, &hdr
, ipv
))){
4225 QETH_DBF_TEXT_(trace
, 4, "pskbe%d", rc
);
4228 /*are we able to do TSO ? If so ,prepare and send it from here */
4229 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
4230 (cast_type
== RTN_UNSPEC
)) {
4231 rc
= qeth_tso_send_packet(card
, skb
, queue
,
4236 qeth_fill_header(card
, hdr
, skb
, ipv
, cast_type
);
4237 if (large_send
== QETH_LARGE_SEND_EDDP
) {
4238 ctx
= qeth_eddp_create_context(card
, skb
, hdr
);
4240 PRINT_WARN("could not create eddp context\n");
4244 elements_needed
= qeth_get_elements_no(card
,(void*) hdr
, skb
);
4245 if (!elements_needed
)
4249 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
4250 rc
= qeth_do_send_packet(card
, queue
, skb
, hdr
,
4251 elements_needed
, ctx
);
4253 rc
= qeth_do_send_packet_fast(card
, queue
, skb
, hdr
,
4254 elements_needed
, ctx
);
4257 card
->stats
.tx_packets
++;
4258 card
->stats
.tx_bytes
+= skb
->len
;
4259 #ifdef CONFIG_QETH_PERF_STATS
4260 if (skb_shinfo(skb
)->tso_size
) {
4261 card
->perf_stats
.large_send_bytes
+= skb
->len
;
4262 card
->perf_stats
.large_send_cnt
++;
4264 if (skb_shinfo(skb
)->nr_frags
> 0){
4265 card
->perf_stats
.sg_skbs_sent
++;
4266 /* nr_frags + skb->data */
4267 card
->perf_stats
.sg_frags_sent
+=
4268 skb_shinfo(skb
)->nr_frags
+ 1;
4270 #endif /* CONFIG_QETH_PERF_STATS */
4273 /* drop creator's reference */
4274 qeth_eddp_put_context(ctx
);
4275 /* free skb; it's not referenced by a buffer */
4277 dev_kfree_skb_any(skb
);
4284 qeth_mdio_read(struct net_device
*dev
, int phy_id
, int regnum
)
4286 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
4290 case MII_BMCR
: /* Basic mode control register */
4292 if ((card
->info
.link_type
!= QETH_LINK_TYPE_GBIT_ETH
)&&
4293 (card
->info
.link_type
!= QETH_LINK_TYPE_10GBIT_ETH
))
4294 rc
|= BMCR_SPEED100
;
4296 case MII_BMSR
: /* Basic mode status register */
4297 rc
= BMSR_ERCAP
| BMSR_ANEGCOMPLETE
| BMSR_LSTATUS
|
4298 BMSR_10HALF
| BMSR_10FULL
| BMSR_100HALF
| BMSR_100FULL
|
4301 case MII_PHYSID1
: /* PHYS ID 1 */
4302 rc
= (dev
->dev_addr
[0] << 16) | (dev
->dev_addr
[1] << 8) |
4304 rc
= (rc
>> 5) & 0xFFFF;
4306 case MII_PHYSID2
: /* PHYS ID 2 */
4307 rc
= (dev
->dev_addr
[2] << 10) & 0xFFFF;
4309 case MII_ADVERTISE
: /* Advertisement control reg */
4312 case MII_LPA
: /* Link partner ability reg */
4313 rc
= LPA_10HALF
| LPA_10FULL
| LPA_100HALF
| LPA_100FULL
|
4314 LPA_100BASE4
| LPA_LPACK
;
4316 case MII_EXPANSION
: /* Expansion register */
4318 case MII_DCOUNTER
: /* disconnect counter */
4320 case MII_FCSCOUNTER
: /* false carrier counter */
4322 case MII_NWAYTEST
: /* N-way auto-neg test register */
4324 case MII_RERRCOUNTER
: /* rx error counter */
4325 rc
= card
->stats
.rx_errors
;
4327 case MII_SREVISION
: /* silicon revision */
4329 case MII_RESV1
: /* reserved 1 */
4331 case MII_LBRERROR
: /* loopback, rx, bypass error */
4333 case MII_PHYADDR
: /* physical address */
4335 case MII_RESV2
: /* reserved 2 */
4337 case MII_TPISTATUS
: /* TPI status for 10mbps */
4339 case MII_NCONFIG
: /* network interface config */
4349 qeth_mdio_write(struct net_device
*dev
, int phy_id
, int regnum
, int value
)
4352 case MII_BMCR
: /* Basic mode control register */
4353 case MII_BMSR
: /* Basic mode status register */
4354 case MII_PHYSID1
: /* PHYS ID 1 */
4355 case MII_PHYSID2
: /* PHYS ID 2 */
4356 case MII_ADVERTISE
: /* Advertisement control reg */
4357 case MII_LPA
: /* Link partner ability reg */
4358 case MII_EXPANSION
: /* Expansion register */
4359 case MII_DCOUNTER
: /* disconnect counter */
4360 case MII_FCSCOUNTER
: /* false carrier counter */
4361 case MII_NWAYTEST
: /* N-way auto-neg test register */
4362 case MII_RERRCOUNTER
: /* rx error counter */
4363 case MII_SREVISION
: /* silicon revision */
4364 case MII_RESV1
: /* reserved 1 */
4365 case MII_LBRERROR
: /* loopback, rx, bypass error */
4366 case MII_PHYADDR
: /* physical address */
4367 case MII_RESV2
: /* reserved 2 */
4368 case MII_TPISTATUS
: /* TPI status for 10mbps */
4369 case MII_NCONFIG
: /* network interface config */
4375 static inline const char *
4376 qeth_arp_get_error_cause(int *rc
)
4379 case QETH_IPA_ARP_RC_FAILED
:
4381 return "operation failed";
4382 case QETH_IPA_ARP_RC_NOTSUPP
:
4384 return "operation not supported";
4385 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
4387 return "argument out of range";
4388 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
4390 return "query operation not supported";
4391 case QETH_IPA_ARP_RC_Q_NO_DATA
:
4393 return "no query data available";
4395 return "unknown error";
4400 qeth_send_simple_setassparms(struct qeth_card
*, enum qeth_ipa_funcs
,
4404 qeth_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
4409 QETH_DBF_TEXT(trace
,3,"arpstnoe");
4411 /* TODO: really not supported by GuestLAN? */
4412 if (card
->info
.guestlan
)
4414 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4415 PRINT_WARN("ARP processing not supported "
4416 "on %s!\n", QETH_CARD_IFNAME(card
));
4419 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
4420 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
4424 PRINT_WARN("Could not set number of ARP entries on %s: "
4426 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4433 qeth_copy_arp_entries_stripped(struct qeth_arp_query_info
*qinfo
,
4434 struct qeth_arp_query_data
*qdata
,
4435 int entry_size
, int uentry_size
)
4441 entry_ptr
= (char *)&qdata
->data
;
4442 uentry_ptr
= (char *)(qinfo
->udata
+ qinfo
->udata_offset
);
4443 for (i
= 0; i
< qdata
->no_entries
; ++i
){
4444 /* strip off 32 bytes "media specific information" */
4445 memcpy(uentry_ptr
, (entry_ptr
+ 32), entry_size
- 32);
4446 entry_ptr
+= entry_size
;
4447 uentry_ptr
+= uentry_size
;
4452 qeth_arp_query_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4455 struct qeth_ipa_cmd
*cmd
;
4456 struct qeth_arp_query_data
*qdata
;
4457 struct qeth_arp_query_info
*qinfo
;
4462 QETH_DBF_TEXT(trace
,4,"arpquecb");
4464 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4465 cmd
= (struct qeth_ipa_cmd
*) data
;
4466 if (cmd
->hdr
.return_code
) {
4467 QETH_DBF_TEXT_(trace
,4,"qaer1%i", cmd
->hdr
.return_code
);
4470 if (cmd
->data
.setassparms
.hdr
.return_code
) {
4471 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
4472 QETH_DBF_TEXT_(trace
,4,"qaer2%i", cmd
->hdr
.return_code
);
4475 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
4476 switch(qdata
->reply_bits
){
4478 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry5
);
4479 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4480 uentry_size
= sizeof(struct qeth_arp_qi_entry5_short
);
4483 /* fall through to default */
4485 /* tr is the same as eth -> entry7 */
4486 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry7
);
4487 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4488 uentry_size
= sizeof(struct qeth_arp_qi_entry7_short
);
4491 /* check if there is enough room in userspace */
4492 if ((qinfo
->udata_len
- qinfo
->udata_offset
) <
4493 qdata
->no_entries
* uentry_size
){
4494 QETH_DBF_TEXT_(trace
, 4, "qaer3%i", -ENOMEM
);
4495 cmd
->hdr
.return_code
= -ENOMEM
;
4496 PRINT_WARN("query ARP user space buffer is too small for "
4497 "the returned number of ARP entries. "
4498 "Aborting query!\n");
4501 QETH_DBF_TEXT_(trace
, 4, "anore%i",
4502 cmd
->data
.setassparms
.hdr
.number_of_replies
);
4503 QETH_DBF_TEXT_(trace
, 4, "aseqn%i", cmd
->data
.setassparms
.hdr
.seq_no
);
4504 QETH_DBF_TEXT_(trace
, 4, "anoen%i", qdata
->no_entries
);
4506 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) {
4507 /* strip off "media specific information" */
4508 qeth_copy_arp_entries_stripped(qinfo
, qdata
, entry_size
,
4511 /*copy entries to user buffer*/
4512 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4513 (char *)&qdata
->data
, qdata
->no_entries
*uentry_size
);
4515 qinfo
->no_entries
+= qdata
->no_entries
;
4516 qinfo
->udata_offset
+= (qdata
->no_entries
*uentry_size
);
4517 /* check if all replies received ... */
4518 if (cmd
->data
.setassparms
.hdr
.seq_no
<
4519 cmd
->data
.setassparms
.hdr
.number_of_replies
)
4521 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
4522 /* keep STRIP_ENTRIES flag so the user program can distinguish
4523 * stripped entries from normal ones */
4524 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4525 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
4526 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
,&qdata
->reply_bits
,2);
4530 memcpy(qinfo
->udata
, &i
, 4);
4535 qeth_send_ipa_arp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4536 int len
, int (*reply_cb
)(struct qeth_card
*,
4537 struct qeth_reply
*,
4541 QETH_DBF_TEXT(trace
,4,"sendarp");
4543 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4544 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4545 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4546 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4547 reply_cb
, reply_param
);
4551 qeth_send_ipa_snmp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4552 int len
, int (*reply_cb
)(struct qeth_card
*,
4553 struct qeth_reply
*,
4559 QETH_DBF_TEXT(trace
,4,"sendsnmp");
4561 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4562 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4563 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4564 /* adjust PDU length fields in IPA_PDU_HEADER */
4565 s1
= (u32
) IPA_PDU_HEADER_SIZE
+ len
;
4567 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
4568 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
4569 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
4570 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
4571 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4572 reply_cb
, reply_param
);
4575 static struct qeth_cmd_buffer
*
4576 qeth_get_setassparms_cmd(struct qeth_card
*, enum qeth_ipa_funcs
,
4577 __u16
, __u16
, enum qeth_prot_versions
);
4579 qeth_arp_query(struct qeth_card
*card
, char *udata
)
4581 struct qeth_cmd_buffer
*iob
;
4582 struct qeth_arp_query_info qinfo
= {0, };
4586 QETH_DBF_TEXT(trace
,3,"arpquery");
4589 * currently GuestLAN does only deliver all zeros on query arp,
4590 * even though arp processing is supported (according to IPA supp.
4591 * funcs flags); since all zeros is no valueable information,
4592 * we say EOPNOTSUPP for all ARP functions
4594 /*if (card->info.guestlan)
4595 return -EOPNOTSUPP; */
4596 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
4597 IPA_ARP_PROCESSING
)) {
4598 PRINT_WARN("ARP processing not supported "
4599 "on %s!\n", QETH_CARD_IFNAME(card
));
4602 /* get size of userspace buffer and mask_bits -> 6 bytes */
4603 if (copy_from_user(&qinfo
, udata
, 6))
4605 if (!(qinfo
.udata
= kmalloc(qinfo
.udata_len
, GFP_KERNEL
)))
4607 memset(qinfo
.udata
, 0, qinfo
.udata_len
);
4608 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
4609 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
4610 IPA_CMD_ASS_ARP_QUERY_INFO
,
4611 sizeof(int),QETH_PROT_IPV4
);
4613 rc
= qeth_send_ipa_arp_cmd(card
, iob
,
4614 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
4615 qeth_arp_query_cb
, (void *)&qinfo
);
4618 PRINT_WARN("Error while querying ARP cache on %s: %s "
4620 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4622 copy_to_user(udata
, qinfo
.udata
, 4);
4624 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4631 * SNMP command callback
4634 qeth_snmp_command_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4635 unsigned long sdata
)
4637 struct qeth_ipa_cmd
*cmd
;
4638 struct qeth_arp_query_info
*qinfo
;
4639 struct qeth_snmp_cmd
*snmp
;
4640 unsigned char *data
;
4643 QETH_DBF_TEXT(trace
,3,"snpcmdcb");
4645 cmd
= (struct qeth_ipa_cmd
*) sdata
;
4646 data
= (unsigned char *)((char *)cmd
- reply
->offset
);
4647 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4648 snmp
= &cmd
->data
.setadapterparms
.data
.snmp
;
4650 if (cmd
->hdr
.return_code
) {
4651 QETH_DBF_TEXT_(trace
,4,"scer1%i", cmd
->hdr
.return_code
);
4654 if (cmd
->data
.setadapterparms
.hdr
.return_code
) {
4655 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
4656 QETH_DBF_TEXT_(trace
,4,"scer2%i", cmd
->hdr
.return_code
);
4659 data_len
= *((__u16
*)QETH_IPA_PDU_LEN_PDU1(data
));
4660 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1)
4661 data_len
-= (__u16
)((char *)&snmp
->data
- (char *)cmd
);
4663 data_len
-= (__u16
)((char*)&snmp
->request
- (char *)cmd
);
4665 /* check if there is enough room in userspace */
4666 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < data_len
) {
4667 QETH_DBF_TEXT_(trace
, 4, "scer3%i", -ENOMEM
);
4668 cmd
->hdr
.return_code
= -ENOMEM
;
4671 QETH_DBF_TEXT_(trace
, 4, "snore%i",
4672 cmd
->data
.setadapterparms
.hdr
.used_total
);
4673 QETH_DBF_TEXT_(trace
, 4, "sseqn%i", cmd
->data
.setadapterparms
.hdr
.seq_no
);
4674 /*copy entries to user buffer*/
4675 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1) {
4676 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4678 data_len
+ offsetof(struct qeth_snmp_cmd
,data
));
4679 qinfo
->udata_offset
+= offsetof(struct qeth_snmp_cmd
, data
);
4681 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4682 (char *)&snmp
->request
, data_len
);
4684 qinfo
->udata_offset
+= data_len
;
4685 /* check if all replies received ... */
4686 QETH_DBF_TEXT_(trace
, 4, "srtot%i",
4687 cmd
->data
.setadapterparms
.hdr
.used_total
);
4688 QETH_DBF_TEXT_(trace
, 4, "srseq%i",
4689 cmd
->data
.setadapterparms
.hdr
.seq_no
);
4690 if (cmd
->data
.setadapterparms
.hdr
.seq_no
<
4691 cmd
->data
.setadapterparms
.hdr
.used_total
)
4696 static struct qeth_cmd_buffer
*
4697 qeth_get_ipacmd_buffer(struct qeth_card
*, enum qeth_ipa_cmds
,
4698 enum qeth_prot_versions
);
4700 static struct qeth_cmd_buffer
*
4701 qeth_get_adapter_cmd(struct qeth_card
*card
, __u32 command
, __u32 cmdlen
)
4703 struct qeth_cmd_buffer
*iob
;
4704 struct qeth_ipa_cmd
*cmd
;
4706 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETADAPTERPARMS
,
4708 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4709 cmd
->data
.setadapterparms
.hdr
.cmdlength
= cmdlen
;
4710 cmd
->data
.setadapterparms
.hdr
.command_code
= command
;
4711 cmd
->data
.setadapterparms
.hdr
.used_total
= 1;
4712 cmd
->data
.setadapterparms
.hdr
.seq_no
= 1;
4718 * function to send SNMP commands to OSA-E card
4721 qeth_snmp_command(struct qeth_card
*card
, char *udata
)
4723 struct qeth_cmd_buffer
*iob
;
4724 struct qeth_ipa_cmd
*cmd
;
4725 struct qeth_snmp_ureq
*ureq
;
4727 struct qeth_arp_query_info qinfo
= {0, };
4730 QETH_DBF_TEXT(trace
,3,"snmpcmd");
4732 if (card
->info
.guestlan
)
4735 if ((!qeth_adp_supported(card
,IPA_SETADP_SET_SNMP_CONTROL
)) &&
4736 (!card
->options
.layer2
) ) {
4737 PRINT_WARN("SNMP Query MIBS not supported "
4738 "on %s!\n", QETH_CARD_IFNAME(card
));
4741 /* skip 4 bytes (data_len struct member) to get req_len */
4742 if (copy_from_user(&req_len
, udata
+ sizeof(int), sizeof(int)))
4744 ureq
= kmalloc(req_len
+sizeof(struct qeth_snmp_ureq_hdr
), GFP_KERNEL
);
4746 QETH_DBF_TEXT(trace
, 2, "snmpnome");
4749 if (copy_from_user(ureq
, udata
,
4750 req_len
+sizeof(struct qeth_snmp_ureq_hdr
))){
4754 qinfo
.udata_len
= ureq
->hdr
.data_len
;
4755 if (!(qinfo
.udata
= kmalloc(qinfo
.udata_len
, GFP_KERNEL
))){
4759 memset(qinfo
.udata
, 0, qinfo
.udata_len
);
4760 qinfo
.udata_offset
= sizeof(struct qeth_snmp_ureq_hdr
);
4762 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_SNMP_CONTROL
,
4763 QETH_SNMP_SETADP_CMDLENGTH
+ req_len
);
4764 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4765 memcpy(&cmd
->data
.setadapterparms
.data
.snmp
, &ureq
->cmd
, req_len
);
4766 rc
= qeth_send_ipa_snmp_cmd(card
, iob
, QETH_SETADP_BASE_LEN
+ req_len
,
4767 qeth_snmp_command_cb
, (void *)&qinfo
);
4769 PRINT_WARN("SNMP command failed on %s: (0x%x)\n",
4770 QETH_CARD_IFNAME(card
), rc
);
4772 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4780 qeth_default_setassparms_cb(struct qeth_card
*, struct qeth_reply
*,
4784 qeth_send_setassparms(struct qeth_card
*, struct qeth_cmd_buffer
*,
4787 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
4791 qeth_arp_add_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
4793 struct qeth_cmd_buffer
*iob
;
4798 QETH_DBF_TEXT(trace
,3,"arpadent");
4801 * currently GuestLAN does only deliver all zeros on query arp,
4802 * even though arp processing is supported (according to IPA supp.
4803 * funcs flags); since all zeros is no valueable information,
4804 * we say EOPNOTSUPP for all ARP functions
4806 if (card
->info
.guestlan
)
4808 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4809 PRINT_WARN("ARP processing not supported "
4810 "on %s!\n", QETH_CARD_IFNAME(card
));
4814 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
4815 IPA_CMD_ASS_ARP_ADD_ENTRY
,
4816 sizeof(struct qeth_arp_cache_entry
),
4818 rc
= qeth_send_setassparms(card
, iob
,
4819 sizeof(struct qeth_arp_cache_entry
),
4820 (unsigned long) entry
,
4821 qeth_default_setassparms_cb
, NULL
);
4824 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
4825 PRINT_WARN("Could not add ARP entry for address %s on %s: "
4827 buf
, QETH_CARD_IFNAME(card
),
4828 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
4834 qeth_arp_remove_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
4836 struct qeth_cmd_buffer
*iob
;
4837 char buf
[16] = {0, };
4841 QETH_DBF_TEXT(trace
,3,"arprment");
4844 * currently GuestLAN does only deliver all zeros on query arp,
4845 * even though arp processing is supported (according to IPA supp.
4846 * funcs flags); since all zeros is no valueable information,
4847 * we say EOPNOTSUPP for all ARP functions
4849 if (card
->info
.guestlan
)
4851 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4852 PRINT_WARN("ARP processing not supported "
4853 "on %s!\n", QETH_CARD_IFNAME(card
));
4856 memcpy(buf
, entry
, 12);
4857 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
4858 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
4861 rc
= qeth_send_setassparms(card
, iob
,
4862 12, (unsigned long)buf
,
4863 qeth_default_setassparms_cb
, NULL
);
4867 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
4868 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
4870 buf
, QETH_CARD_IFNAME(card
),
4871 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
4877 qeth_arp_flush_cache(struct qeth_card
*card
)
4882 QETH_DBF_TEXT(trace
,3,"arpflush");
4885 * currently GuestLAN does only deliver all zeros on query arp,
4886 * even though arp processing is supported (according to IPA supp.
4887 * funcs flags); since all zeros is no valueable information,
4888 * we say EOPNOTSUPP for all ARP functions
4890 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
4892 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4893 PRINT_WARN("ARP processing not supported "
4894 "on %s!\n", QETH_CARD_IFNAME(card
));
4897 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
4898 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
4901 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
4902 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4909 qeth_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
4911 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
4912 struct qeth_arp_cache_entry arp_entry
;
4913 struct mii_ioctl_data
*mii_data
;
4919 if ((card
->state
!= CARD_STATE_UP
) &&
4920 (card
->state
!= CARD_STATE_SOFTSETUP
))
4924 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
4925 if ( !capable(CAP_NET_ADMIN
) ||
4926 (card
->options
.layer2
) ) {
4930 rc
= qeth_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
4932 case SIOC_QETH_ARP_QUERY_INFO
:
4933 if ( !capable(CAP_NET_ADMIN
) ||
4934 (card
->options
.layer2
) ) {
4938 rc
= qeth_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
4940 case SIOC_QETH_ARP_ADD_ENTRY
:
4941 if ( !capable(CAP_NET_ADMIN
) ||
4942 (card
->options
.layer2
) ) {
4946 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
4947 sizeof(struct qeth_arp_cache_entry
)))
4950 rc
= qeth_arp_add_entry(card
, &arp_entry
);
4952 case SIOC_QETH_ARP_REMOVE_ENTRY
:
4953 if ( !capable(CAP_NET_ADMIN
) ||
4954 (card
->options
.layer2
) ) {
4958 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
4959 sizeof(struct qeth_arp_cache_entry
)))
4962 rc
= qeth_arp_remove_entry(card
, &arp_entry
);
4964 case SIOC_QETH_ARP_FLUSH_CACHE
:
4965 if ( !capable(CAP_NET_ADMIN
) ||
4966 (card
->options
.layer2
) ) {
4970 rc
= qeth_arp_flush_cache(card
);
4972 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
4973 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
4975 case SIOC_QETH_GET_CARD_TYPE
:
4976 if ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
4977 !card
->info
.guestlan
)
4982 mii_data
= if_mii(rq
);
4983 mii_data
->phy_id
= 0;
4986 mii_data
= if_mii(rq
);
4987 if (mii_data
->phy_id
!= 0)
4990 mii_data
->val_out
= qeth_mdio_read(dev
,mii_data
->phy_id
,
4996 /* TODO: remove return if qeth_mdio_write does something */
4997 if (!capable(CAP_NET_ADMIN
)){
5001 mii_data
= if_mii(rq
);
5002 if (mii_data
->phy_id
!= 0)
5005 qeth_mdio_write(dev
, mii_data
->phy_id
, mii_data
->reg_num
,
5012 QETH_DBF_TEXT_(trace
, 2, "ioce%d", rc
);
5016 static struct net_device_stats
*
5017 qeth_get_stats(struct net_device
*dev
)
5019 struct qeth_card
*card
;
5021 card
= (struct qeth_card
*) (dev
->priv
);
5023 QETH_DBF_TEXT(trace
,5,"getstat");
5025 return &card
->stats
;
5029 qeth_change_mtu(struct net_device
*dev
, int new_mtu
)
5031 struct qeth_card
*card
;
5034 card
= (struct qeth_card
*) (dev
->priv
);
5036 QETH_DBF_TEXT(trace
,4,"chgmtu");
5037 sprintf(dbf_text
, "%8x", new_mtu
);
5038 QETH_DBF_TEXT(trace
,4,dbf_text
);
5042 if (new_mtu
> 65535)
5044 if ((!qeth_is_supported(card
,IPA_IP_FRAGMENTATION
)) &&
5045 (!qeth_mtu_is_valid(card
, new_mtu
)))
5051 #ifdef CONFIG_QETH_VLAN
5053 qeth_vlan_rx_register(struct net_device
*dev
, struct vlan_group
*grp
)
5055 struct qeth_card
*card
;
5056 unsigned long flags
;
5058 QETH_DBF_TEXT(trace
,4,"vlanreg");
5060 card
= (struct qeth_card
*) dev
->priv
;
5061 spin_lock_irqsave(&card
->vlanlock
, flags
);
5062 card
->vlangrp
= grp
;
5063 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5067 qeth_free_vlan_buffer(struct qeth_card
*card
, struct qeth_qdio_out_buffer
*buf
,
5071 struct sk_buff
*skb
;
5072 struct sk_buff_head tmp_list
;
5074 skb_queue_head_init(&tmp_list
);
5075 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
5076 while ((skb
= skb_dequeue(&buf
->skb_list
))){
5077 if (vlan_tx_tag_present(skb
) &&
5078 (vlan_tx_tag_get(skb
) == vid
)) {
5079 atomic_dec(&skb
->users
);
5082 skb_queue_tail(&tmp_list
, skb
);
5085 while ((skb
= skb_dequeue(&tmp_list
)))
5086 skb_queue_tail(&buf
->skb_list
, skb
);
5090 qeth_free_vlan_skbs(struct qeth_card
*card
, unsigned short vid
)
5094 QETH_DBF_TEXT(trace
, 4, "frvlskbs");
5095 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
5096 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
5097 qeth_free_vlan_buffer(card
, &card
->qdio
.
5098 out_qs
[i
]->bufs
[j
], vid
);
5103 qeth_free_vlan_addresses4(struct qeth_card
*card
, unsigned short vid
)
5105 struct in_device
*in_dev
;
5106 struct in_ifaddr
*ifa
;
5107 struct qeth_ipaddr
*addr
;
5109 QETH_DBF_TEXT(trace
, 4, "frvaddr4");
5113 in_dev
= __in_dev_get(card
->vlangrp
->vlan_devices
[vid
]);
5116 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
5117 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5119 addr
->u
.a4
.addr
= ifa
->ifa_address
;
5120 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
5121 addr
->type
= QETH_IP_TYPE_NORMAL
;
5122 if (!qeth_delete_ip(card
, addr
))
5131 qeth_free_vlan_addresses6(struct qeth_card
*card
, unsigned short vid
)
5133 #ifdef CONFIG_QETH_IPV6
5134 struct inet6_dev
*in6_dev
;
5135 struct inet6_ifaddr
*ifa
;
5136 struct qeth_ipaddr
*addr
;
5138 QETH_DBF_TEXT(trace
, 4, "frvaddr6");
5141 in6_dev
= in6_dev_get(card
->vlangrp
->vlan_devices
[vid
]);
5144 for (ifa
= in6_dev
->addr_list
; ifa
; ifa
= ifa
->lst_next
){
5145 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5147 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
5148 sizeof(struct in6_addr
));
5149 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
5150 addr
->type
= QETH_IP_TYPE_NORMAL
;
5151 if (!qeth_delete_ip(card
, addr
))
5155 in6_dev_put(in6_dev
);
5156 #endif /* CONFIG_QETH_IPV6 */
5160 qeth_layer2_send_setdelvlan(struct qeth_card
*card
, __u16 i
,
5161 enum qeth_ipa_cmds ipacmd
)
5164 struct qeth_ipa_cmd
*cmd
;
5165 struct qeth_cmd_buffer
*iob
;
5167 QETH_DBF_TEXT_(trace
, 4, "L2sdv%x",ipacmd
);
5168 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5169 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5170 cmd
->data
.setdelvlan
.vlan_id
= i
;
5172 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
5174 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5175 "Continuing\n",i
, QETH_CARD_IFNAME(card
), rc
);
5176 QETH_DBF_TEXT_(trace
, 2, "L2VL%4x", ipacmd
);
5177 QETH_DBF_TEXT_(trace
, 2, "L2%s", CARD_BUS_ID(card
));
5178 QETH_DBF_TEXT_(trace
, 2, "err%d", rc
);
5183 qeth_layer2_process_vlans(struct qeth_card
*card
, int clear
)
5187 QETH_DBF_TEXT(trace
, 3, "L2prcvln");
5191 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5192 if (card
->vlangrp
->vlan_devices
[i
] == NULL
)
5195 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_DELVLAN
);
5197 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_SETVLAN
);
5201 /*add_vid is layer 2 used only ....*/
5203 qeth_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
5205 struct qeth_card
*card
;
5207 QETH_DBF_TEXT_(trace
, 4, "aid:%d", vid
);
5209 card
= (struct qeth_card
*) dev
->priv
;
5210 if (!card
->options
.layer2
)
5212 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_SETVLAN
);
5215 /*... kill_vid used for both modes*/
5217 qeth_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
5219 struct qeth_card
*card
;
5220 unsigned long flags
;
5222 QETH_DBF_TEXT_(trace
, 4, "kid:%d", vid
);
5224 card
= (struct qeth_card
*) dev
->priv
;
5225 /* free all skbs for the vlan device */
5226 qeth_free_vlan_skbs(card
, vid
);
5227 spin_lock_irqsave(&card
->vlanlock
, flags
);
5228 /* unregister IP addresses of vlan device */
5229 qeth_free_vlan_addresses4(card
, vid
);
5230 qeth_free_vlan_addresses6(card
, vid
);
5232 card
->vlangrp
->vlan_devices
[vid
] = NULL
;
5233 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5234 if (card
->options
.layer2
)
5235 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_DELVLAN
);
5236 qeth_set_multicast_list(card
->dev
);
5241 * set multicast address on card
5244 qeth_set_multicast_list(struct net_device
*dev
)
5246 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
5248 QETH_DBF_TEXT(trace
,3,"setmulti");
5249 qeth_delete_mc_addresses(card
);
5250 qeth_add_multicast_ipv4(card
);
5251 #ifdef CONFIG_QETH_IPV6
5252 qeth_add_multicast_ipv6(card
);
5254 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
5255 schedule_work(&card
->kernel_thread_starter
);
5259 qeth_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
5265 qeth_get_mac_for_ipm(__u32 ipm
, char *mac
, struct net_device
*dev
)
5267 if (dev
->type
== ARPHRD_IEEE802_TR
)
5268 ip_tr_mc_map(ipm
, mac
);
5270 ip_eth_mc_map(ipm
, mac
);
5273 static struct qeth_ipaddr
*
5274 qeth_get_addr_buffer(enum qeth_prot_versions prot
)
5276 struct qeth_ipaddr
*addr
;
5278 addr
= kmalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
5280 PRINT_WARN("Not enough memory to add address\n");
5283 memset(addr
,0,sizeof(struct qeth_ipaddr
));
5284 addr
->type
= QETH_IP_TYPE_NORMAL
;
5290 qeth_delete_mc_addresses(struct qeth_card
*card
)
5292 struct qeth_ipaddr
*iptodo
;
5293 unsigned long flags
;
5295 QETH_DBF_TEXT(trace
,4,"delmc");
5296 iptodo
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5298 QETH_DBF_TEXT(trace
, 2, "dmcnomem");
5301 iptodo
->type
= QETH_IP_TYPE_DEL_ALL_MC
;
5302 spin_lock_irqsave(&card
->ip_lock
, flags
);
5303 if (!__qeth_insert_ip_todo(card
, iptodo
, 0))
5305 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
5309 qeth_add_mc(struct qeth_card
*card
, struct in_device
*in4_dev
)
5311 struct qeth_ipaddr
*ipm
;
5312 struct ip_mc_list
*im4
;
5313 char buf
[MAX_ADDR_LEN
];
5315 QETH_DBF_TEXT(trace
,4,"addmc");
5316 for (im4
= in4_dev
->mc_list
; im4
; im4
= im4
->next
) {
5317 qeth_get_mac_for_ipm(im4
->multiaddr
, buf
, in4_dev
->dev
);
5318 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5321 ipm
->u
.a4
.addr
= im4
->multiaddr
;
5322 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5323 ipm
->is_multicast
= 1;
5324 if (!qeth_add_ip(card
,ipm
))
5330 qeth_add_vlan_mc(struct qeth_card
*card
)
5332 #ifdef CONFIG_QETH_VLAN
5333 struct in_device
*in_dev
;
5334 struct vlan_group
*vg
;
5337 QETH_DBF_TEXT(trace
,4,"addmcvl");
5338 if ( ((card
->options
.layer2
== 0) &&
5339 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5340 (card
->vlangrp
== NULL
) )
5344 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5345 if (vg
->vlan_devices
[i
] == NULL
||
5346 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5348 in_dev
= in_dev_get(vg
->vlan_devices
[i
]);
5351 read_lock(&in_dev
->mc_list_lock
);
5352 qeth_add_mc(card
,in_dev
);
5353 read_unlock(&in_dev
->mc_list_lock
);
5360 qeth_add_multicast_ipv4(struct qeth_card
*card
)
5362 struct in_device
*in4_dev
;
5364 QETH_DBF_TEXT(trace
,4,"chkmcv4");
5365 in4_dev
= in_dev_get(card
->dev
);
5366 if (in4_dev
== NULL
)
5368 read_lock(&in4_dev
->mc_list_lock
);
5369 qeth_add_mc(card
, in4_dev
);
5370 qeth_add_vlan_mc(card
);
5371 read_unlock(&in4_dev
->mc_list_lock
);
5372 in_dev_put(in4_dev
);
5375 #ifdef CONFIG_QETH_IPV6
5377 qeth_add_mc6(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
5379 struct qeth_ipaddr
*ipm
;
5380 struct ifmcaddr6
*im6
;
5381 char buf
[MAX_ADDR_LEN
];
5383 QETH_DBF_TEXT(trace
,4,"addmc6");
5384 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
5385 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
5386 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5389 ipm
->is_multicast
= 1;
5390 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5391 memcpy(&ipm
->u
.a6
.addr
,&im6
->mca_addr
.s6_addr
,
5392 sizeof(struct in6_addr
));
5393 if (!qeth_add_ip(card
,ipm
))
5399 qeth_add_vlan_mc6(struct qeth_card
*card
)
5401 #ifdef CONFIG_QETH_VLAN
5402 struct inet6_dev
*in_dev
;
5403 struct vlan_group
*vg
;
5406 QETH_DBF_TEXT(trace
,4,"admc6vl");
5407 if ( ((card
->options
.layer2
== 0) &&
5408 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5409 (card
->vlangrp
== NULL
))
5413 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5414 if (vg
->vlan_devices
[i
] == NULL
||
5415 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5417 in_dev
= in6_dev_get(vg
->vlan_devices
[i
]);
5420 read_lock(&in_dev
->lock
);
5421 qeth_add_mc6(card
,in_dev
);
5422 read_unlock(&in_dev
->lock
);
5423 in6_dev_put(in_dev
);
5425 #endif /* CONFIG_QETH_VLAN */
5429 qeth_add_multicast_ipv6(struct qeth_card
*card
)
5431 struct inet6_dev
*in6_dev
;
5433 QETH_DBF_TEXT(trace
,4,"chkmcv6");
5434 if ((card
->options
.layer2
== 0) &&
5435 (!qeth_is_supported(card
, IPA_IPV6
)) )
5438 in6_dev
= in6_dev_get(card
->dev
);
5439 if (in6_dev
== NULL
)
5441 read_lock(&in6_dev
->lock
);
5442 qeth_add_mc6(card
, in6_dev
);
5443 qeth_add_vlan_mc6(card
);
5444 read_unlock(&in6_dev
->lock
);
5445 in6_dev_put(in6_dev
);
5447 #endif /* CONFIG_QETH_IPV6 */
5450 qeth_layer2_send_setdelmac(struct qeth_card
*card
, __u8
*mac
,
5451 enum qeth_ipa_cmds ipacmd
,
5452 int (*reply_cb
) (struct qeth_card
*,
5456 struct qeth_ipa_cmd
*cmd
;
5457 struct qeth_cmd_buffer
*iob
;
5459 QETH_DBF_TEXT(trace
, 2, "L2sdmac");
5460 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5461 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5462 cmd
->data
.setdelmac
.mac_length
= OSA_ADDR_LEN
;
5463 memcpy(&cmd
->data
.setdelmac
.mac
, mac
, OSA_ADDR_LEN
);
5464 return qeth_send_ipa_cmd(card
, iob
, reply_cb
, NULL
);
5468 qeth_layer2_send_setgroupmac_cb(struct qeth_card
*card
,
5469 struct qeth_reply
*reply
,
5472 struct qeth_ipa_cmd
*cmd
;
5475 QETH_DBF_TEXT(trace
, 2, "L2Sgmacb");
5476 cmd
= (struct qeth_ipa_cmd
*) data
;
5477 mac
= &cmd
->data
.setdelmac
.mac
[0];
5478 /* MAC already registered, needed in couple/uncouple case */
5479 if (cmd
->hdr
.return_code
== 0x2005) {
5480 PRINT_WARN("Group MAC %02x:%02x:%02x:%02x:%02x:%02x " \
5481 "already existing on %s \n",
5482 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5483 QETH_CARD_IFNAME(card
));
5484 cmd
->hdr
.return_code
= 0;
5486 if (cmd
->hdr
.return_code
)
5487 PRINT_ERR("Could not set group MAC " \
5488 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5489 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5490 QETH_CARD_IFNAME(card
),cmd
->hdr
.return_code
);
5495 qeth_layer2_send_setgroupmac(struct qeth_card
*card
, __u8
*mac
)
5497 QETH_DBF_TEXT(trace
, 2, "L2Sgmac");
5498 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETGMAC
,
5499 qeth_layer2_send_setgroupmac_cb
);
5503 qeth_layer2_send_delgroupmac_cb(struct qeth_card
*card
,
5504 struct qeth_reply
*reply
,
5507 struct qeth_ipa_cmd
*cmd
;
5510 QETH_DBF_TEXT(trace
, 2, "L2Dgmacb");
5511 cmd
= (struct qeth_ipa_cmd
*) data
;
5512 mac
= &cmd
->data
.setdelmac
.mac
[0];
5513 if (cmd
->hdr
.return_code
)
5514 PRINT_ERR("Could not delete group MAC " \
5515 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5516 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5517 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
5522 qeth_layer2_send_delgroupmac(struct qeth_card
*card
, __u8
*mac
)
5524 QETH_DBF_TEXT(trace
, 2, "L2Dgmac");
5525 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELGMAC
,
5526 qeth_layer2_send_delgroupmac_cb
);
5530 qeth_layer2_send_setmac_cb(struct qeth_card
*card
,
5531 struct qeth_reply
*reply
,
5534 struct qeth_ipa_cmd
*cmd
;
5536 QETH_DBF_TEXT(trace
, 2, "L2Smaccb");
5537 cmd
= (struct qeth_ipa_cmd
*) data
;
5538 if (cmd
->hdr
.return_code
) {
5539 QETH_DBF_TEXT_(trace
, 2, "L2er%x", cmd
->hdr
.return_code
);
5540 PRINT_WARN("Error in registering MAC address on " \
5541 "device %s: x%x\n", CARD_BUS_ID(card
),
5542 cmd
->hdr
.return_code
);
5543 card
->info
.layer2_mac_registered
= 0;
5544 cmd
->hdr
.return_code
= -EIO
;
5546 card
->info
.layer2_mac_registered
= 1;
5547 memcpy(card
->dev
->dev_addr
,cmd
->data
.setdelmac
.mac
,
5549 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
5550 "successfully registered on device %s\n",
5551 card
->dev
->dev_addr
[0], card
->dev
->dev_addr
[1],
5552 card
->dev
->dev_addr
[2], card
->dev
->dev_addr
[3],
5553 card
->dev
->dev_addr
[4], card
->dev
->dev_addr
[5],
5560 qeth_layer2_send_setmac(struct qeth_card
*card
, __u8
*mac
)
5562 QETH_DBF_TEXT(trace
, 2, "L2Setmac");
5563 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
,
5564 qeth_layer2_send_setmac_cb
);
5568 qeth_layer2_send_delmac_cb(struct qeth_card
*card
,
5569 struct qeth_reply
*reply
,
5572 struct qeth_ipa_cmd
*cmd
;
5574 QETH_DBF_TEXT(trace
, 2, "L2Dmaccb");
5575 cmd
= (struct qeth_ipa_cmd
*) data
;
5576 if (cmd
->hdr
.return_code
) {
5577 PRINT_WARN("Error in deregistering MAC address on " \
5578 "device %s: x%x\n", CARD_BUS_ID(card
),
5579 cmd
->hdr
.return_code
);
5580 QETH_DBF_TEXT_(trace
, 2, "err%d", cmd
->hdr
.return_code
);
5581 cmd
->hdr
.return_code
= -EIO
;
5584 card
->info
.layer2_mac_registered
= 0;
5589 qeth_layer2_send_delmac(struct qeth_card
*card
, __u8
*mac
)
5591 QETH_DBF_TEXT(trace
, 2, "L2Delmac");
5592 if (!card
->info
.layer2_mac_registered
)
5594 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELVMAC
,
5595 qeth_layer2_send_delmac_cb
);
5599 qeth_layer2_set_mac_address(struct net_device
*dev
, void *p
)
5601 struct sockaddr
*addr
= p
;
5602 struct qeth_card
*card
;
5605 QETH_DBF_TEXT(trace
, 3, "setmac");
5607 if (qeth_verify_dev(dev
) != QETH_REAL_CARD
) {
5608 QETH_DBF_TEXT(trace
, 3, "setmcINV");
5611 card
= (struct qeth_card
*) dev
->priv
;
5613 if (!card
->options
.layer2
) {
5614 PRINT_WARN("Setting MAC address on %s is not supported"
5615 "in Layer 3 mode.\n", dev
->name
);
5616 QETH_DBF_TEXT(trace
, 3, "setmcLY3");
5619 QETH_DBF_TEXT_(trace
, 3, "%s", CARD_BUS_ID(card
));
5620 QETH_DBF_HEX(trace
, 3, addr
->sa_data
, OSA_ADDR_LEN
);
5621 rc
= qeth_layer2_send_delmac(card
, &card
->dev
->dev_addr
[0]);
5623 rc
= qeth_layer2_send_setmac(card
, addr
->sa_data
);
5628 qeth_fill_ipacmd_header(struct qeth_card
*card
, struct qeth_ipa_cmd
*cmd
,
5629 __u8 command
, enum qeth_prot_versions prot
)
5631 memset(cmd
, 0, sizeof (struct qeth_ipa_cmd
));
5632 cmd
->hdr
.command
= command
;
5633 cmd
->hdr
.initiator
= IPA_CMD_INITIATOR_HOST
;
5634 cmd
->hdr
.seqno
= card
->seqno
.ipa
;
5635 cmd
->hdr
.adapter_type
= qeth_get_ipa_adp_type(card
->info
.link_type
);
5636 cmd
->hdr
.rel_adapter_no
= (__u8
) card
->info
.portno
;
5637 if (card
->options
.layer2
)
5638 cmd
->hdr
.prim_version_no
= 2;
5640 cmd
->hdr
.prim_version_no
= 1;
5641 cmd
->hdr
.param_count
= 1;
5642 cmd
->hdr
.prot_version
= prot
;
5643 cmd
->hdr
.ipa_supported
= 0;
5644 cmd
->hdr
.ipa_enabled
= 0;
5647 static struct qeth_cmd_buffer
*
5648 qeth_get_ipacmd_buffer(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
5649 enum qeth_prot_versions prot
)
5651 struct qeth_cmd_buffer
*iob
;
5652 struct qeth_ipa_cmd
*cmd
;
5654 iob
= qeth_wait_for_buffer(&card
->write
);
5655 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5656 qeth_fill_ipacmd_header(card
, cmd
, ipacmd
, prot
);
5662 qeth_send_setdelmc(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int ipacmd
)
5665 struct qeth_cmd_buffer
*iob
;
5666 struct qeth_ipa_cmd
*cmd
;
5668 QETH_DBF_TEXT(trace
,4,"setdelmc");
5670 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
5671 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5672 memcpy(&cmd
->data
.setdelipm
.mac
,addr
->mac
, OSA_ADDR_LEN
);
5673 if (addr
->proto
== QETH_PROT_IPV6
)
5674 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
5675 sizeof(struct in6_addr
));
5677 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
,4);
5679 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
5684 qeth_fill_netmask(u8
*netmask
, unsigned int len
)
5687 for (i
=0;i
<16;i
++) {
5692 netmask
[i
] = (u8
)(0xFF00>>j
);
5699 qeth_send_setdelip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
,
5700 int ipacmd
, unsigned int flags
)
5703 struct qeth_cmd_buffer
*iob
;
5704 struct qeth_ipa_cmd
*cmd
;
5707 QETH_DBF_TEXT(trace
,4,"setdelip");
5708 QETH_DBF_TEXT_(trace
,4,"flags%02X", flags
);
5710 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
5711 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5712 if (addr
->proto
== QETH_PROT_IPV6
) {
5713 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
5714 sizeof(struct in6_addr
));
5715 qeth_fill_netmask(netmask
,addr
->u
.a6
.pfxlen
);
5716 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
5717 sizeof(struct in6_addr
));
5718 cmd
->data
.setdelip6
.flags
= flags
;
5720 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
5721 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
5722 cmd
->data
.setdelip4
.flags
= flags
;
5725 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
5731 qeth_layer2_register_addr_entry(struct qeth_card
*card
,
5732 struct qeth_ipaddr
*addr
)
5734 if (!addr
->is_multicast
)
5736 QETH_DBF_TEXT(trace
, 2, "setgmac");
5737 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
5738 return qeth_layer2_send_setgroupmac(card
, &addr
->mac
[0]);
5742 qeth_layer2_deregister_addr_entry(struct qeth_card
*card
,
5743 struct qeth_ipaddr
*addr
)
5745 if (!addr
->is_multicast
)
5747 QETH_DBF_TEXT(trace
, 2, "delgmac");
5748 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
5749 return qeth_layer2_send_delgroupmac(card
, &addr
->mac
[0]);
5753 qeth_layer3_register_addr_entry(struct qeth_card
*card
,
5754 struct qeth_ipaddr
*addr
)
5760 if (addr
->proto
== QETH_PROT_IPV4
) {
5761 QETH_DBF_TEXT(trace
, 2,"setaddr4");
5762 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
5763 } else if (addr
->proto
== QETH_PROT_IPV6
) {
5764 QETH_DBF_TEXT(trace
, 2, "setaddr6");
5765 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
5766 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
5768 QETH_DBF_TEXT(trace
, 2, "setaddr?");
5769 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
5772 if (addr
->is_multicast
)
5773 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
5775 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
5778 QETH_DBF_TEXT(trace
, 2, "failed");
5779 } while ((--cnt
> 0) && rc
);
5781 QETH_DBF_TEXT(trace
, 2, "FAILED");
5782 qeth_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
5783 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
5790 qeth_layer3_deregister_addr_entry(struct qeth_card
*card
,
5791 struct qeth_ipaddr
*addr
)
5796 if (addr
->proto
== QETH_PROT_IPV4
) {
5797 QETH_DBF_TEXT(trace
, 2,"deladdr4");
5798 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
5799 } else if (addr
->proto
== QETH_PROT_IPV6
) {
5800 QETH_DBF_TEXT(trace
, 2, "deladdr6");
5801 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
5802 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
5804 QETH_DBF_TEXT(trace
, 2, "deladdr?");
5805 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
5807 if (addr
->is_multicast
)
5808 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
5810 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
5813 QETH_DBF_TEXT(trace
, 2, "failed");
5814 /* TODO: re-activate this warning as soon as we have a
5816 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
5817 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
5825 qeth_register_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
5827 if (card
->options
.layer2
)
5828 return qeth_layer2_register_addr_entry(card
, addr
);
5830 return qeth_layer3_register_addr_entry(card
, addr
);
5834 qeth_deregister_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
5836 if (card
->options
.layer2
)
5837 return qeth_layer2_deregister_addr_entry(card
, addr
);
5839 return qeth_layer3_deregister_addr_entry(card
, addr
);
5843 qeth_ethtool_get_tx_csum(struct net_device
*dev
)
5845 /* We may need to say that we support tx csum offload if
5846 * we do EDDP or TSO. There are discussions going on to
5847 * enforce rules in the stack and in ethtool that make
5848 * SG and TSO depend on HW_CSUM. At the moment there are
5850 * If we say yes here, we have to checksum outbound packets
5856 qeth_ethtool_set_tx_csum(struct net_device
*dev
, u32 data
)
5862 qeth_ethtool_get_rx_csum(struct net_device
*dev
)
5864 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5866 return (card
->options
.checksum_type
== HW_CHECKSUMMING
);
5870 qeth_ethtool_set_rx_csum(struct net_device
*dev
, u32 data
)
5872 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5874 if ((card
->state
!= CARD_STATE_DOWN
) &&
5875 (card
->state
!= CARD_STATE_RECOVER
))
5878 card
->options
.checksum_type
= HW_CHECKSUMMING
;
5880 card
->options
.checksum_type
= SW_CHECKSUMMING
;
5885 qeth_ethtool_get_sg(struct net_device
*dev
)
5887 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5889 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
5890 (dev
->features
& NETIF_F_SG
));
5894 qeth_ethtool_set_sg(struct net_device
*dev
, u32 data
)
5896 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5899 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
5900 dev
->features
|= NETIF_F_SG
;
5902 dev
->features
&= ~NETIF_F_SG
;
5906 dev
->features
&= ~NETIF_F_SG
;
5911 qeth_ethtool_get_tso(struct net_device
*dev
)
5913 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5915 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
5916 (dev
->features
& NETIF_F_TSO
));
5920 qeth_ethtool_set_tso(struct net_device
*dev
, u32 data
)
5922 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5925 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
5926 dev
->features
|= NETIF_F_TSO
;
5928 dev
->features
&= ~NETIF_F_TSO
;
5932 dev
->features
&= ~NETIF_F_TSO
;
5936 static struct ethtool_ops qeth_ethtool_ops
= {
5937 .get_tx_csum
= qeth_ethtool_get_tx_csum
,
5938 .set_tx_csum
= qeth_ethtool_set_tx_csum
,
5939 .get_rx_csum
= qeth_ethtool_get_rx_csum
,
5940 .set_rx_csum
= qeth_ethtool_set_rx_csum
,
5941 .get_sg
= qeth_ethtool_get_sg
,
5942 .set_sg
= qeth_ethtool_set_sg
,
5943 .get_tso
= qeth_ethtool_get_tso
,
5944 .set_tso
= qeth_ethtool_set_tso
,
5948 qeth_netdev_init(struct net_device
*dev
)
5950 struct qeth_card
*card
;
5952 card
= (struct qeth_card
*) dev
->priv
;
5954 QETH_DBF_TEXT(trace
,3,"initdev");
5956 dev
->tx_timeout
= &qeth_tx_timeout
;
5957 dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
5958 dev
->open
= qeth_open
;
5959 dev
->stop
= qeth_stop
;
5960 dev
->hard_start_xmit
= qeth_hard_start_xmit
;
5961 dev
->do_ioctl
= qeth_do_ioctl
;
5962 dev
->get_stats
= qeth_get_stats
;
5963 dev
->change_mtu
= qeth_change_mtu
;
5964 dev
->neigh_setup
= qeth_neigh_setup
;
5965 dev
->set_multicast_list
= qeth_set_multicast_list
;
5966 #ifdef CONFIG_QETH_VLAN
5967 dev
->vlan_rx_register
= qeth_vlan_rx_register
;
5968 dev
->vlan_rx_kill_vid
= qeth_vlan_rx_kill_vid
;
5969 dev
->vlan_rx_add_vid
= qeth_vlan_rx_add_vid
;
5971 dev
->hard_header
= card
->orig_hard_header
;
5972 if (qeth_get_netdev_flags(card
) & IFF_NOARP
) {
5973 dev
->rebuild_header
= NULL
;
5974 dev
->hard_header
= NULL
;
5975 if (card
->options
.fake_ll
)
5976 dev
->hard_header
= qeth_fake_header
;
5977 dev
->header_cache_update
= NULL
;
5978 dev
->hard_header_cache
= NULL
;
5980 #ifdef CONFIG_QETH_IPV6
5981 /*IPv6 address autoconfiguration stuff*/
5982 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
5983 card
->dev
->dev_id
= card
->info
.unique_id
& 0xffff;
5985 dev
->hard_header_parse
= NULL
;
5986 dev
->set_mac_address
= qeth_layer2_set_mac_address
;
5987 dev
->flags
|= qeth_get_netdev_flags(card
);
5988 if ((card
->options
.fake_broadcast
) ||
5989 (card
->info
.broadcast_capable
))
5990 dev
->flags
|= IFF_BROADCAST
;
5991 dev
->hard_header_len
=
5992 qeth_get_hlen(card
->info
.link_type
) + card
->options
.add_hhlen
;
5993 dev
->addr_len
= OSA_ADDR_LEN
;
5994 dev
->mtu
= card
->info
.initial_mtu
;
5996 SET_ETHTOOL_OPS(dev
, &qeth_ethtool_ops
);
5998 SET_MODULE_OWNER(dev
);
6003 qeth_init_func_level(struct qeth_card
*card
)
6005 if (card
->ipato
.enabled
) {
6006 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6007 card
->info
.func_level
=
6008 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT
;
6010 card
->info
.func_level
=
6011 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT
;
6013 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6014 card
->info
.func_level
=
6015 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT
;
6017 card
->info
.func_level
=
6018 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT
;
6023 * hardsetup card, initialize MPC and QDIO stuff
6026 qeth_hardsetup_card(struct qeth_card
*card
)
6031 QETH_DBF_TEXT(setup
, 2, "hrdsetup");
6035 PRINT_WARN("Retrying to do IDX activates.\n");
6036 ccw_device_set_offline(CARD_DDEV(card
));
6037 ccw_device_set_offline(CARD_WDEV(card
));
6038 ccw_device_set_offline(CARD_RDEV(card
));
6039 ccw_device_set_online(CARD_RDEV(card
));
6040 ccw_device_set_online(CARD_WDEV(card
));
6041 ccw_device_set_online(CARD_DDEV(card
));
6043 rc
= qeth_qdio_clear_card(card
,card
->info
.type
==QETH_CARD_TYPE_OSAE
);
6044 if (rc
== -ERESTARTSYS
) {
6045 QETH_DBF_TEXT(setup
, 2, "break1");
6048 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
6054 if ((rc
= qeth_get_unitaddr(card
))){
6055 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
6058 qeth_init_tokens(card
);
6059 qeth_init_func_level(card
);
6060 rc
= qeth_idx_activate_channel(&card
->read
, qeth_idx_read_cb
);
6061 if (rc
== -ERESTARTSYS
) {
6062 QETH_DBF_TEXT(setup
, 2, "break2");
6065 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
6071 rc
= qeth_idx_activate_channel(&card
->write
, qeth_idx_write_cb
);
6072 if (rc
== -ERESTARTSYS
) {
6073 QETH_DBF_TEXT(setup
, 2, "break3");
6076 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
6082 if ((rc
= qeth_mpc_initialize(card
))){
6083 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
6086 /*network device will be recovered*/
6088 card
->dev
->hard_header
= card
->orig_hard_header
;
6091 /* at first set_online allocate netdev */
6092 card
->dev
= qeth_get_netdevice(card
->info
.type
,
6093 card
->info
.link_type
);
6095 qeth_qdio_clear_card(card
, card
->info
.type
==
6096 QETH_CARD_TYPE_OSAE
);
6098 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
6101 card
->dev
->priv
= card
;
6102 card
->orig_hard_header
= card
->dev
->hard_header
;
6103 card
->dev
->type
= qeth_get_arphdr_type(card
->info
.type
,
6104 card
->info
.link_type
);
6105 card
->dev
->init
= qeth_netdev_init
;
6108 PRINT_ERR("Initialization in hardsetup failed! rc=%d\n", rc
);
6113 qeth_default_setassparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6116 struct qeth_ipa_cmd
*cmd
;
6118 QETH_DBF_TEXT(trace
,4,"defadpcb");
6120 cmd
= (struct qeth_ipa_cmd
*) data
;
6121 if (cmd
->hdr
.return_code
== 0){
6122 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
6123 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
6124 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6125 #ifdef CONFIG_QETH_IPV6
6126 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
6127 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6130 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
6131 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
6132 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
6133 QETH_DBF_TEXT_(trace
, 3, "csum:%d", card
->info
.csum_mask
);
6139 qeth_default_setadapterparms_cb(struct qeth_card
*card
,
6140 struct qeth_reply
*reply
,
6143 struct qeth_ipa_cmd
*cmd
;
6145 QETH_DBF_TEXT(trace
,4,"defadpcb");
6147 cmd
= (struct qeth_ipa_cmd
*) data
;
6148 if (cmd
->hdr
.return_code
== 0)
6149 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
6154 qeth_query_setadapterparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6157 struct qeth_ipa_cmd
*cmd
;
6159 QETH_DBF_TEXT(trace
,3,"quyadpcb");
6161 cmd
= (struct qeth_ipa_cmd
*) data
;
6162 if (cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
& 0x7f)
6163 card
->info
.link_type
=
6164 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
;
6165 card
->options
.adp
.supported_funcs
=
6166 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.supported_cmds
;
6167 return qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
6171 qeth_query_setadapterparms(struct qeth_card
*card
)
6174 struct qeth_cmd_buffer
*iob
;
6176 QETH_DBF_TEXT(trace
,3,"queryadp");
6177 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_COMMANDS_SUPPORTED
,
6178 sizeof(struct qeth_ipacmd_setadpparms
));
6179 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_setadapterparms_cb
, NULL
);
6184 qeth_setadpparms_change_macaddr_cb(struct qeth_card
*card
,
6185 struct qeth_reply
*reply
,
6188 struct qeth_ipa_cmd
*cmd
;
6190 QETH_DBF_TEXT(trace
,4,"chgmaccb");
6192 cmd
= (struct qeth_ipa_cmd
*) data
;
6193 memcpy(card
->dev
->dev_addr
,
6194 &cmd
->data
.setadapterparms
.data
.change_addr
.addr
,OSA_ADDR_LEN
);
6195 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
6200 qeth_setadpparms_change_macaddr(struct qeth_card
*card
)
6203 struct qeth_cmd_buffer
*iob
;
6204 struct qeth_ipa_cmd
*cmd
;
6206 QETH_DBF_TEXT(trace
,4,"chgmac");
6208 iob
= qeth_get_adapter_cmd(card
,IPA_SETADP_ALTER_MAC_ADDRESS
,
6209 sizeof(struct qeth_ipacmd_setadpparms
));
6210 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6211 cmd
->data
.setadapterparms
.data
.change_addr
.cmd
= CHANGE_ADDR_READ_MAC
;
6212 cmd
->data
.setadapterparms
.data
.change_addr
.addr_size
= OSA_ADDR_LEN
;
6213 memcpy(&cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
6214 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6215 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_change_macaddr_cb
,
6221 qeth_send_setadp_mode(struct qeth_card
*card
, __u32 command
, __u32 mode
)
6224 struct qeth_cmd_buffer
*iob
;
6225 struct qeth_ipa_cmd
*cmd
;
6227 QETH_DBF_TEXT(trace
,4,"adpmode");
6229 iob
= qeth_get_adapter_cmd(card
, command
,
6230 sizeof(struct qeth_ipacmd_setadpparms
));
6231 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6232 cmd
->data
.setadapterparms
.data
.mode
= mode
;
6233 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_default_setadapterparms_cb
,
6239 qeth_setadapter_hstr(struct qeth_card
*card
)
6243 QETH_DBF_TEXT(trace
,4,"adphstr");
6245 if (qeth_adp_supported(card
,IPA_SETADP_SET_BROADCAST_MODE
)) {
6246 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_SET_BROADCAST_MODE
,
6247 card
->options
.broadcast_mode
);
6249 PRINT_WARN("couldn't set broadcast mode on "
6251 CARD_BUS_ID(card
), rc
);
6252 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_ALTER_MAC_ADDRESS
,
6253 card
->options
.macaddr_mode
);
6255 PRINT_WARN("couldn't set macaddr mode on "
6256 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
6259 if (card
->options
.broadcast_mode
== QETH_TR_BROADCAST_LOCAL
)
6260 PRINT_WARN("set adapter parameters not available "
6261 "to set broadcast mode, using ALLRINGS "
6262 "on device %s:\n", CARD_BUS_ID(card
));
6263 if (card
->options
.macaddr_mode
== QETH_TR_MACADDR_CANONICAL
)
6264 PRINT_WARN("set adapter parameters not available "
6265 "to set macaddr mode, using NONCANONICAL "
6266 "on device %s:\n", CARD_BUS_ID(card
));
6271 qeth_setadapter_parms(struct qeth_card
*card
)
6275 QETH_DBF_TEXT(setup
, 2, "setadprm");
6277 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)){
6278 PRINT_WARN("set adapter parameters not supported "
6281 QETH_DBF_TEXT(setup
, 2, " notsupp");
6284 rc
= qeth_query_setadapterparms(card
);
6286 PRINT_WARN("couldn't set adapter parameters on device %s: "
6287 "x%x\n", CARD_BUS_ID(card
), rc
);
6290 if (qeth_adp_supported(card
,IPA_SETADP_ALTER_MAC_ADDRESS
)) {
6291 rc
= qeth_setadpparms_change_macaddr(card
);
6293 PRINT_WARN("couldn't get MAC address on "
6295 CARD_BUS_ID(card
), rc
);
6298 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
6299 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
6300 rc
= qeth_setadapter_hstr(card
);
6306 qeth_layer2_initialize(struct qeth_card
*card
)
6311 QETH_DBF_TEXT(setup
, 2, "doL2init");
6312 QETH_DBF_TEXT_(setup
, 2, "doL2%s", CARD_BUS_ID(card
));
6314 rc
= qeth_setadpparms_change_macaddr(card
);
6316 PRINT_WARN("couldn't get MAC address on "
6318 CARD_BUS_ID(card
), rc
);
6319 QETH_DBF_TEXT_(setup
, 2,"1err%d",rc
);
6322 QETH_DBF_HEX(setup
,2, card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6324 rc
= qeth_layer2_send_setmac(card
, &card
->dev
->dev_addr
[0]);
6326 QETH_DBF_TEXT_(setup
, 2,"2err%d",rc
);
6332 qeth_send_startstoplan(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
6333 enum qeth_prot_versions prot
)
6336 struct qeth_cmd_buffer
*iob
;
6338 iob
= qeth_get_ipacmd_buffer(card
,ipacmd
,prot
);
6339 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6345 qeth_send_startlan(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6349 QETH_DBF_TEXT_(setup
, 2, "strtlan%i", prot
);
6351 rc
= qeth_send_startstoplan(card
, IPA_CMD_STARTLAN
, prot
);
6356 qeth_send_stoplan(struct qeth_card
*card
)
6361 * TODO: according to the IPA format document page 14,
6362 * TCP/IP (we!) never issue a STOPLAN
6365 QETH_DBF_TEXT(trace
, 2, "stoplan");
6367 rc
= qeth_send_startstoplan(card
, IPA_CMD_STOPLAN
, QETH_PROT_IPV4
);
6372 qeth_query_ipassists_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6375 struct qeth_ipa_cmd
*cmd
;
6377 QETH_DBF_TEXT(setup
, 2, "qipasscb");
6379 cmd
= (struct qeth_ipa_cmd
*) data
;
6380 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
6381 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6382 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6384 #ifdef CONFIG_QETH_IPV6
6385 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6386 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6389 QETH_DBF_TEXT(setup
, 2, "suppenbl");
6390 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_supported
);
6391 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_enabled
);
6396 qeth_query_ipassists(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6399 struct qeth_cmd_buffer
*iob
;
6401 QETH_DBF_TEXT_(setup
, 2, "qipassi%i", prot
);
6402 if (card
->options
.layer2
) {
6403 QETH_DBF_TEXT(setup
, 2, "noprmly2");
6407 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_QIPASSIST
,prot
);
6408 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_ipassists_cb
, NULL
);
6412 static struct qeth_cmd_buffer
*
6413 qeth_get_setassparms_cmd(struct qeth_card
*card
, enum qeth_ipa_funcs ipa_func
,
6414 __u16 cmd_code
, __u16 len
,
6415 enum qeth_prot_versions prot
)
6417 struct qeth_cmd_buffer
*iob
;
6418 struct qeth_ipa_cmd
*cmd
;
6420 QETH_DBF_TEXT(trace
,4,"getasscm");
6421 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETASSPARMS
,prot
);
6423 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6424 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
6425 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
6426 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
6427 cmd
->data
.setassparms
.hdr
.return_code
= 0;
6428 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
6434 qeth_send_setassparms(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
6435 __u16 len
, long data
,
6437 (struct qeth_card
*,struct qeth_reply
*,unsigned long),
6441 struct qeth_ipa_cmd
*cmd
;
6443 QETH_DBF_TEXT(trace
,4,"sendassp");
6445 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6446 if (len
<= sizeof(__u32
))
6447 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
6448 else if (len
> sizeof(__u32
))
6449 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
6451 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
6455 #ifdef CONFIG_QETH_IPV6
6457 qeth_send_simple_setassparms_ipv6(struct qeth_card
*card
,
6458 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
6462 struct qeth_cmd_buffer
*iob
;
6464 QETH_DBF_TEXT(trace
,4,"simassp6");
6465 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6467 rc
= qeth_send_setassparms(card
, iob
, 0, 0,
6468 qeth_default_setassparms_cb
, NULL
);
6474 qeth_send_simple_setassparms(struct qeth_card
*card
,
6475 enum qeth_ipa_funcs ipa_func
,
6476 __u16 cmd_code
, long data
)
6480 struct qeth_cmd_buffer
*iob
;
6482 QETH_DBF_TEXT(trace
,4,"simassp4");
6484 length
= sizeof(__u32
);
6485 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6486 length
, QETH_PROT_IPV4
);
6487 rc
= qeth_send_setassparms(card
, iob
, length
, data
,
6488 qeth_default_setassparms_cb
, NULL
);
6493 qeth_start_ipa_arp_processing(struct qeth_card
*card
)
6497 QETH_DBF_TEXT(trace
,3,"ipaarp");
6499 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
6500 PRINT_WARN("ARP processing not supported "
6501 "on %s!\n", QETH_CARD_IFNAME(card
));
6504 rc
= qeth_send_simple_setassparms(card
,IPA_ARP_PROCESSING
,
6505 IPA_CMD_ASS_START
, 0);
6507 PRINT_WARN("Could not start ARP processing "
6508 "assist on %s: 0x%x\n",
6509 QETH_CARD_IFNAME(card
), rc
);
6515 qeth_start_ipa_ip_fragmentation(struct qeth_card
*card
)
6519 QETH_DBF_TEXT(trace
,3,"ipaipfrg");
6521 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
6522 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
6523 QETH_CARD_IFNAME(card
));
6527 rc
= qeth_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
6528 IPA_CMD_ASS_START
, 0);
6530 PRINT_WARN("Could not start Hardware IP fragmentation "
6531 "assist on %s: 0x%x\n",
6532 QETH_CARD_IFNAME(card
), rc
);
6534 PRINT_INFO("Hardware IP fragmentation enabled \n");
6539 qeth_start_ipa_source_mac(struct qeth_card
*card
)
6543 QETH_DBF_TEXT(trace
,3,"stsrcmac");
6545 if (!card
->options
.fake_ll
)
6548 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
6549 PRINT_INFO("Inbound source address not "
6550 "supported on %s\n", QETH_CARD_IFNAME(card
));
6554 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
6555 IPA_CMD_ASS_START
, 0);
6557 PRINT_WARN("Could not start inbound source "
6558 "assist on %s: 0x%x\n",
6559 QETH_CARD_IFNAME(card
), rc
);
6564 qeth_start_ipa_vlan(struct qeth_card
*card
)
6568 QETH_DBF_TEXT(trace
,3,"strtvlan");
6570 #ifdef CONFIG_QETH_VLAN
6571 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
6572 PRINT_WARN("VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
6576 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
6577 IPA_CMD_ASS_START
,0);
6579 PRINT_WARN("Could not start vlan "
6580 "assist on %s: 0x%x\n",
6581 QETH_CARD_IFNAME(card
), rc
);
6583 PRINT_INFO("VLAN enabled \n");
6584 card
->dev
->features
|=
6585 NETIF_F_HW_VLAN_FILTER
|
6586 NETIF_F_HW_VLAN_TX
|
6589 #endif /* QETH_VLAN */
6594 qeth_start_ipa_multicast(struct qeth_card
*card
)
6598 QETH_DBF_TEXT(trace
,3,"stmcast");
6600 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
6601 PRINT_WARN("Multicast not supported on %s\n",
6602 QETH_CARD_IFNAME(card
));
6606 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
6607 IPA_CMD_ASS_START
,0);
6609 PRINT_WARN("Could not start multicast "
6610 "assist on %s: rc=%i\n",
6611 QETH_CARD_IFNAME(card
), rc
);
6613 PRINT_INFO("Multicast enabled\n");
6614 card
->dev
->flags
|= IFF_MULTICAST
;
6619 #ifdef CONFIG_QETH_IPV6
6621 qeth_softsetup_ipv6(struct qeth_card
*card
)
6625 QETH_DBF_TEXT(trace
,3,"softipv6");
6627 netif_stop_queue(card
->dev
);
6628 rc
= qeth_send_startlan(card
, QETH_PROT_IPV6
);
6630 PRINT_ERR("IPv6 startlan failed on %s\n",
6631 QETH_CARD_IFNAME(card
));
6634 netif_wake_queue(card
->dev
);
6635 rc
= qeth_query_ipassists(card
,QETH_PROT_IPV6
);
6637 PRINT_ERR("IPv6 query ipassist failed on %s\n",
6638 QETH_CARD_IFNAME(card
));
6641 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
6642 IPA_CMD_ASS_START
, 3);
6644 PRINT_WARN("IPv6 start assist (version 4) failed "
6646 QETH_CARD_IFNAME(card
), rc
);
6649 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
6652 PRINT_WARN("IPV6 start assist (version 6) failed "
6654 QETH_CARD_IFNAME(card
), rc
);
6657 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
6660 PRINT_WARN("Could not enable passthrough "
6662 QETH_CARD_IFNAME(card
), rc
);
6665 PRINT_INFO("IPV6 enabled \n");
6672 qeth_start_ipa_ipv6(struct qeth_card
*card
)
6675 #ifdef CONFIG_QETH_IPV6
6676 QETH_DBF_TEXT(trace
,3,"strtipv6");
6678 if (!qeth_is_supported(card
, IPA_IPV6
)) {
6679 PRINT_WARN("IPv6 not supported on %s\n",
6680 QETH_CARD_IFNAME(card
));
6683 rc
= qeth_softsetup_ipv6(card
);
6689 qeth_start_ipa_broadcast(struct qeth_card
*card
)
6693 QETH_DBF_TEXT(trace
,3,"stbrdcst");
6694 card
->info
.broadcast_capable
= 0;
6695 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
6696 PRINT_WARN("Broadcast not supported on %s\n",
6697 QETH_CARD_IFNAME(card
));
6701 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
6702 IPA_CMD_ASS_START
, 0);
6704 PRINT_WARN("Could not enable broadcasting filtering "
6706 QETH_CARD_IFNAME(card
), rc
);
6710 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
6711 IPA_CMD_ASS_CONFIGURE
, 1);
6713 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
6714 QETH_CARD_IFNAME(card
), rc
);
6717 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
6718 PRINT_INFO("Broadcast enabled \n");
6719 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
6720 IPA_CMD_ASS_ENABLE
, 1);
6722 PRINT_WARN("Could not set up broadcast echo filtering on "
6723 "%s: 0x%x\n", QETH_CARD_IFNAME(card
), rc
);
6726 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
6728 if (card
->info
.broadcast_capable
)
6729 card
->dev
->flags
|= IFF_BROADCAST
;
6731 card
->dev
->flags
&= ~IFF_BROADCAST
;
6736 qeth_send_checksum_command(struct qeth_card
*card
)
6740 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
6741 IPA_CMD_ASS_START
, 0);
6743 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
6744 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
6745 QETH_CARD_IFNAME(card
), rc
);
6748 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
6750 card
->info
.csum_mask
);
6752 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
6753 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
6754 QETH_CARD_IFNAME(card
), rc
);
6761 qeth_start_ipa_checksum(struct qeth_card
*card
)
6765 QETH_DBF_TEXT(trace
,3,"strtcsum");
6767 if (card
->options
.checksum_type
== NO_CHECKSUMMING
) {
6768 PRINT_WARN("Using no checksumming on %s.\n",
6769 QETH_CARD_IFNAME(card
));
6772 if (card
->options
.checksum_type
== SW_CHECKSUMMING
) {
6773 PRINT_WARN("Using SW checksumming on %s.\n",
6774 QETH_CARD_IFNAME(card
));
6777 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
6778 PRINT_WARN("Inbound HW Checksumming not "
6779 "supported on %s,\ncontinuing "
6780 "using Inbound SW Checksumming\n",
6781 QETH_CARD_IFNAME(card
));
6782 card
->options
.checksum_type
= SW_CHECKSUMMING
;
6785 rc
= qeth_send_checksum_command(card
);
6787 PRINT_INFO("HW Checksumming (inbound) enabled \n");
6793 qeth_start_ipa_tso(struct qeth_card
*card
)
6797 QETH_DBF_TEXT(trace
,3,"sttso");
6799 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
6800 PRINT_WARN("Outbound TSO not supported on %s\n",
6801 QETH_CARD_IFNAME(card
));
6804 rc
= qeth_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
6805 IPA_CMD_ASS_START
,0);
6807 PRINT_WARN("Could not start outbound TSO "
6808 "assist on %s: rc=%i\n",
6809 QETH_CARD_IFNAME(card
), rc
);
6811 PRINT_INFO("Outbound TSO enabled\n");
6813 if (rc
&& (card
->options
.large_send
== QETH_LARGE_SEND_TSO
)){
6814 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
6815 card
->dev
->features
&= ~ (NETIF_F_TSO
| NETIF_F_SG
);
6821 qeth_start_ipassists(struct qeth_card
*card
)
6823 QETH_DBF_TEXT(trace
,3,"strtipas");
6824 qeth_start_ipa_arp_processing(card
); /* go on*/
6825 qeth_start_ipa_ip_fragmentation(card
); /* go on*/
6826 qeth_start_ipa_source_mac(card
); /* go on*/
6827 qeth_start_ipa_vlan(card
); /* go on*/
6828 qeth_start_ipa_multicast(card
); /* go on*/
6829 qeth_start_ipa_ipv6(card
); /* go on*/
6830 qeth_start_ipa_broadcast(card
); /* go on*/
6831 qeth_start_ipa_checksum(card
); /* go on*/
6832 qeth_start_ipa_tso(card
); /* go on*/
6837 qeth_send_setrouting(struct qeth_card
*card
, enum qeth_routing_types type
,
6838 enum qeth_prot_versions prot
)
6841 struct qeth_ipa_cmd
*cmd
;
6842 struct qeth_cmd_buffer
*iob
;
6844 QETH_DBF_TEXT(trace
,4,"setroutg");
6845 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
6846 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6847 cmd
->data
.setrtg
.type
= (type
);
6848 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6855 qeth_correct_routing_type(struct qeth_card
*card
, enum qeth_routing_types
*type
,
6856 enum qeth_prot_versions prot
)
6858 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
6861 case PRIMARY_CONNECTOR
:
6862 case SECONDARY_CONNECTOR
:
6863 case MULTICAST_ROUTER
:
6871 case PRIMARY_ROUTER
:
6872 case SECONDARY_ROUTER
:
6874 case MULTICAST_ROUTER
:
6875 if (qeth_is_ipafunc_supported(card
, prot
,
6883 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
6884 "Router status set to 'no router'.\n",
6885 ((*type
== PRIMARY_ROUTER
)? "primary router" :
6886 (*type
== SECONDARY_ROUTER
)? "secondary router" :
6887 (*type
== PRIMARY_CONNECTOR
)? "primary connector" :
6888 (*type
== SECONDARY_CONNECTOR
)? "secondary connector" :
6889 (*type
== MULTICAST_ROUTER
)? "multicast router" :
6896 qeth_setrouting_v4(struct qeth_card
*card
)
6900 QETH_DBF_TEXT(trace
,3,"setrtg4");
6902 qeth_correct_routing_type(card
, &card
->options
.route4
.type
,
6905 rc
= qeth_send_setrouting(card
, card
->options
.route4
.type
,
6908 card
->options
.route4
.type
= NO_ROUTER
;
6909 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
6910 "Type set to 'no router'.\n",
6911 rc
, QETH_CARD_IFNAME(card
));
6917 qeth_setrouting_v6(struct qeth_card
*card
)
6921 QETH_DBF_TEXT(trace
,3,"setrtg6");
6922 #ifdef CONFIG_QETH_IPV6
6924 qeth_correct_routing_type(card
, &card
->options
.route6
.type
,
6927 if ((card
->options
.route6
.type
== NO_ROUTER
) ||
6928 ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
6929 (card
->options
.route6
.type
== MULTICAST_ROUTER
) &&
6930 !qeth_is_supported6(card
,IPA_OSA_MC_ROUTER
)))
6932 rc
= qeth_send_setrouting(card
, card
->options
.route6
.type
,
6935 card
->options
.route6
.type
= NO_ROUTER
;
6936 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
6937 "Type set to 'no router'.\n",
6938 rc
, QETH_CARD_IFNAME(card
));
6945 qeth_set_large_send(struct qeth_card
*card
)
6949 if (card
->dev
== NULL
)
6952 netif_stop_queue(card
->dev
);
6953 switch (card
->options
.large_send
) {
6954 case QETH_LARGE_SEND_EDDP
:
6955 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
6957 case QETH_LARGE_SEND_TSO
:
6958 if (qeth_is_supported(card
, IPA_OUTBOUND_TSO
)){
6959 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
6961 PRINT_WARN("TSO not supported on %s. "
6962 "large_send set to 'no'.\n",
6964 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
6965 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
6969 default: /* includes QETH_LARGE_SEND_NO */
6970 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
6974 netif_wake_queue(card
->dev
);
6979 * softsetup card: init IPA stuff
6982 qeth_softsetup_card(struct qeth_card
*card
)
6986 QETH_DBF_TEXT(setup
, 2, "softsetp");
6988 if ((rc
= qeth_send_startlan(card
, QETH_PROT_IPV4
))){
6989 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
6991 PRINT_WARN("LAN on card %s if offline! "
6992 "Continuing softsetup.\n",
6994 card
->lan_online
= 0;
6998 card
->lan_online
= 1;
6999 if (card
->options
.layer2
) {
7000 card
->dev
->features
|=
7001 NETIF_F_HW_VLAN_FILTER
|
7002 NETIF_F_HW_VLAN_TX
|
7004 card
->dev
->flags
|=IFF_MULTICAST
|IFF_BROADCAST
;
7005 card
->info
.broadcast_capable
=1;
7006 if ((rc
= qeth_layer2_initialize(card
))) {
7007 QETH_DBF_TEXT_(setup
, 2, "L2err%d", rc
);
7010 #ifdef CONFIG_QETH_VLAN
7011 qeth_layer2_process_vlans(card
, 0);
7015 if ((card
->options
.large_send
== QETH_LARGE_SEND_EDDP
) ||
7016 (card
->options
.large_send
== QETH_LARGE_SEND_TSO
))
7017 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
7019 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
7021 if ((rc
= qeth_setadapter_parms(card
)))
7022 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7023 if ((rc
= qeth_start_ipassists(card
)))
7024 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7025 if ((rc
= qeth_setrouting_v4(card
)))
7026 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7027 if ((rc
= qeth_setrouting_v6(card
)))
7028 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7030 netif_stop_queue(card
->dev
);
7034 #ifdef CONFIG_QETH_IPV6
7036 qeth_get_unique_id_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
7039 struct qeth_ipa_cmd
*cmd
;
7041 cmd
= (struct qeth_ipa_cmd
*) data
;
7042 if (cmd
->hdr
.return_code
== 0)
7043 card
->info
.unique_id
= *((__u16
*)
7044 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
7046 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7047 UNIQUE_ID_NOT_BY_CARD
;
7048 PRINT_WARN("couldn't get a unique id from the card on device "
7049 "%s (result=x%x), using default id. ipv6 "
7050 "autoconfig on other lpars may lead to duplicate "
7051 "ip addresses. please use manually "
7052 "configured ones.\n",
7053 CARD_BUS_ID(card
), cmd
->hdr
.return_code
);
7060 qeth_put_unique_id(struct qeth_card
*card
)
7064 #ifdef CONFIG_QETH_IPV6
7065 struct qeth_cmd_buffer
*iob
;
7066 struct qeth_ipa_cmd
*cmd
;
7068 QETH_DBF_TEXT(trace
,2,"puniqeid");
7070 if ((card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
) ==
7071 UNIQUE_ID_NOT_BY_CARD
)
7073 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_DESTROY_ADDR
,
7075 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7076 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7077 card
->info
.unique_id
;
7078 memcpy(&cmd
->data
.create_destroy_addr
.unique_id
[0],
7079 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
7080 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
7082 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7083 UNIQUE_ID_NOT_BY_CARD
;
7092 qeth_clear_ip_list(struct qeth_card
*card
, int clean
, int recover
)
7094 struct qeth_ipaddr
*addr
, *tmp
;
7095 unsigned long flags
;
7097 QETH_DBF_TEXT(trace
,4,"clearip");
7098 spin_lock_irqsave(&card
->ip_lock
, flags
);
7099 /* clear todo list */
7100 list_for_each_entry_safe(addr
, tmp
, card
->ip_tbd_list
, entry
){
7101 list_del(&addr
->entry
);
7105 while (!list_empty(&card
->ip_list
)) {
7106 addr
= list_entry(card
->ip_list
.next
,
7107 struct qeth_ipaddr
, entry
);
7108 list_del_init(&addr
->entry
);
7110 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7111 qeth_deregister_addr_entry(card
, addr
);
7112 spin_lock_irqsave(&card
->ip_lock
, flags
);
7114 if (!recover
|| addr
->is_multicast
) {
7118 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
7120 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7124 qeth_set_allowed_threads(struct qeth_card
*card
, unsigned long threads
,
7125 int clear_start_mask
)
7127 unsigned long flags
;
7129 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7130 card
->thread_allowed_mask
= threads
;
7131 if (clear_start_mask
)
7132 card
->thread_start_mask
&= threads
;
7133 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7134 wake_up(&card
->wait_q
);
7138 qeth_threads_running(struct qeth_card
*card
, unsigned long threads
)
7140 unsigned long flags
;
7143 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7144 rc
= (card
->thread_running_mask
& threads
);
7145 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7150 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
)
7152 return wait_event_interruptible(card
->wait_q
,
7153 qeth_threads_running(card
, threads
) == 0);
7157 qeth_stop_card(struct qeth_card
*card
)
7161 QETH_DBF_TEXT(setup
,2,"stopcard");
7162 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7164 qeth_set_allowed_threads(card
, 0, 1);
7165 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
))
7166 return -ERESTARTSYS
;
7167 if (card
->read
.state
== CH_STATE_UP
&&
7168 card
->write
.state
== CH_STATE_UP
&&
7169 (card
->state
== CARD_STATE_UP
)) {
7171 dev_close(card
->dev
);
7173 if (!card
->use_hard_stop
) {
7174 __u8
*mac
= &card
->dev
->dev_addr
[0];
7175 rc
= qeth_layer2_send_delmac(card
, mac
);
7176 QETH_DBF_TEXT_(setup
, 2, "Lerr%d", rc
);
7177 if ((rc
= qeth_send_stoplan(card
)))
7178 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7180 card
->state
= CARD_STATE_SOFTSETUP
;
7182 if (card
->state
== CARD_STATE_SOFTSETUP
) {
7183 #ifdef CONFIG_QETH_VLAN
7184 if (card
->options
.layer2
)
7185 qeth_layer2_process_vlans(card
, 1);
7187 qeth_clear_ip_list(card
, !card
->use_hard_stop
, 1);
7188 qeth_clear_ipacmd_list(card
);
7189 card
->state
= CARD_STATE_HARDSETUP
;
7191 if (card
->state
== CARD_STATE_HARDSETUP
) {
7192 if ((!card
->use_hard_stop
) &&
7193 (!card
->options
.layer2
))
7194 if ((rc
= qeth_put_unique_id(card
)))
7195 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7196 qeth_qdio_clear_card(card
, 0);
7197 qeth_clear_qdio_buffers(card
);
7198 qeth_clear_working_pool_list(card
);
7199 card
->state
= CARD_STATE_DOWN
;
7201 if (card
->state
== CARD_STATE_DOWN
) {
7202 qeth_clear_cmd_buffers(&card
->read
);
7203 qeth_clear_cmd_buffers(&card
->write
);
7205 card
->use_hard_stop
= 0;
7211 qeth_get_unique_id(struct qeth_card
*card
)
7214 #ifdef CONFIG_QETH_IPV6
7215 struct qeth_cmd_buffer
*iob
;
7216 struct qeth_ipa_cmd
*cmd
;
7218 QETH_DBF_TEXT(setup
, 2, "guniqeid");
7220 if (!qeth_is_supported(card
,IPA_IPV6
)) {
7221 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7222 UNIQUE_ID_NOT_BY_CARD
;
7226 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
7228 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7229 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7230 card
->info
.unique_id
;
7232 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_get_unique_id_cb
, NULL
);
7234 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7235 UNIQUE_ID_NOT_BY_CARD
;
7240 qeth_print_status_with_portname(struct qeth_card
*card
)
7245 sprintf(dbf_text
, "%s", card
->info
.portname
+ 1);
7246 for (i
= 0; i
< 8; i
++)
7248 (char) _ebcasc
[(__u8
) dbf_text
[i
]];
7250 printk("qeth: Device %s/%s/%s is a%s card%s%s%s\n"
7251 "with link type %s (portname: %s)\n",
7255 qeth_get_cardname(card
),
7256 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7257 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7258 (card
->info
.mcl_level
[0]) ? ")" : "",
7259 qeth_get_cardname_short(card
),
7265 qeth_print_status_no_portname(struct qeth_card
*card
)
7267 if (card
->info
.portname
[0])
7268 printk("qeth: Device %s/%s/%s is a%s "
7269 "card%s%s%s\nwith link type %s "
7270 "(no portname needed by interface).\n",
7274 qeth_get_cardname(card
),
7275 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7276 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7277 (card
->info
.mcl_level
[0]) ? ")" : "",
7278 qeth_get_cardname_short(card
));
7280 printk("qeth: Device %s/%s/%s is a%s "
7281 "card%s%s%s\nwith link type %s.\n",
7285 qeth_get_cardname(card
),
7286 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7287 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7288 (card
->info
.mcl_level
[0]) ? ")" : "",
7289 qeth_get_cardname_short(card
));
7293 qeth_print_status_message(struct qeth_card
*card
)
7295 switch (card
->info
.type
) {
7296 case QETH_CARD_TYPE_OSAE
:
7297 /* VM will use a non-zero first character
7298 * to indicate a HiperSockets like reporting
7299 * of the level OSA sets the first character to zero
7301 if (!card
->info
.mcl_level
[0]) {
7302 sprintf(card
->info
.mcl_level
,"%02x%02x",
7303 card
->info
.mcl_level
[2],
7304 card
->info
.mcl_level
[3]);
7306 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7310 case QETH_CARD_TYPE_IQD
:
7311 card
->info
.mcl_level
[0] = (char) _ebcasc
[(__u8
)
7312 card
->info
.mcl_level
[0]];
7313 card
->info
.mcl_level
[1] = (char) _ebcasc
[(__u8
)
7314 card
->info
.mcl_level
[1]];
7315 card
->info
.mcl_level
[2] = (char) _ebcasc
[(__u8
)
7316 card
->info
.mcl_level
[2]];
7317 card
->info
.mcl_level
[3] = (char) _ebcasc
[(__u8
)
7318 card
->info
.mcl_level
[3]];
7319 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7322 memset(&card
->info
.mcl_level
[0], 0, QETH_MCL_LENGTH
+ 1);
7324 if (card
->info
.portname_required
)
7325 qeth_print_status_with_portname(card
);
7327 qeth_print_status_no_portname(card
);
7331 qeth_register_netdev(struct qeth_card
*card
)
7333 QETH_DBF_TEXT(setup
, 3, "regnetd");
7334 if (card
->dev
->reg_state
!= NETREG_UNINITIALIZED
) {
7335 qeth_netdev_init(card
->dev
);
7339 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
7340 return register_netdev(card
->dev
);
7344 qeth_start_again(struct qeth_card
*card
)
7346 QETH_DBF_TEXT(setup
,2, "startag");
7349 dev_open(card
->dev
);
7351 /* this also sets saved unicast addresses */
7352 qeth_set_multicast_list(card
->dev
);
7356 /* Layer 2 specific stuff */
7357 #define IGNORE_PARAM_EQ(option,value,reset_value,msg) \
7358 if (card->options.option == value) { \
7359 PRINT_ERR("%s not supported with layer 2 " \
7360 "functionality, ignoring option on read" \
7361 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7362 card->options.option = reset_value; \
7364 #define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \
7365 if (card->options.option != value) { \
7366 PRINT_ERR("%s not supported with layer 2 " \
7367 "functionality, ignoring option on read" \
7368 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7369 card->options.option = reset_value; \
7373 static void qeth_make_parameters_consistent(struct qeth_card
*card
)
7376 if (card
->options
.layer2
) {
7377 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
7378 PRINT_ERR("Device %s does not support " \
7379 "layer 2 functionality. " \
7380 "Ignoring layer2 option.\n",CARD_BUS_ID(card
));
7382 IGNORE_PARAM_NEQ(route4
.type
, NO_ROUTER
, NO_ROUTER
,
7383 "Routing options are");
7384 #ifdef CONFIG_QETH_IPV6
7385 IGNORE_PARAM_NEQ(route6
.type
, NO_ROUTER
, NO_ROUTER
,
7386 "Routing options are");
7388 IGNORE_PARAM_EQ(checksum_type
, HW_CHECKSUMMING
,
7389 QETH_CHECKSUM_DEFAULT
,
7390 "Checksumming options are");
7391 IGNORE_PARAM_NEQ(broadcast_mode
, QETH_TR_BROADCAST_ALLRINGS
,
7392 QETH_TR_BROADCAST_ALLRINGS
,
7393 "Broadcast mode options are");
7394 IGNORE_PARAM_NEQ(macaddr_mode
, QETH_TR_MACADDR_NONCANONICAL
,
7395 QETH_TR_MACADDR_NONCANONICAL
,
7396 "Canonical MAC addr options are");
7397 IGNORE_PARAM_NEQ(fake_broadcast
, 0, 0,
7398 "Broadcast faking options are");
7399 IGNORE_PARAM_NEQ(add_hhlen
, DEFAULT_ADD_HHLEN
,
7400 DEFAULT_ADD_HHLEN
,"Option add_hhlen is");
7401 IGNORE_PARAM_NEQ(fake_ll
, 0, 0,"Option fake_ll is");
7407 qeth_set_online(struct ccwgroup_device
*gdev
)
7409 struct qeth_card
*card
= gdev
->dev
.driver_data
;
7411 enum qeth_card_states recover_flag
;
7414 QETH_DBF_TEXT(setup
,2, "setonlin");
7415 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7417 qeth_set_allowed_threads(card
, QETH_RECOVER_THREAD
, 1);
7418 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
)){
7419 PRINT_WARN("set_online of card %s interrupted by user!\n",
7421 return -ERESTARTSYS
;
7424 recover_flag
= card
->state
;
7425 if ((rc
= ccw_device_set_online(CARD_RDEV(card
))) ||
7426 (rc
= ccw_device_set_online(CARD_WDEV(card
))) ||
7427 (rc
= ccw_device_set_online(CARD_DDEV(card
)))){
7428 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7432 if (card
->options
.layer2
)
7433 qeth_make_parameters_consistent(card
);
7435 if ((rc
= qeth_hardsetup_card(card
))){
7436 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7439 card
->state
= CARD_STATE_HARDSETUP
;
7441 if (!(rc
= qeth_query_ipassists(card
,QETH_PROT_IPV4
)))
7442 rc
= qeth_get_unique_id(card
);
7444 if (rc
&& card
->options
.layer2
== 0) {
7445 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7448 qeth_print_status_message(card
);
7449 if ((rc
= qeth_register_netdev(card
))){
7450 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7453 if ((rc
= qeth_softsetup_card(card
))){
7454 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7457 card
->state
= CARD_STATE_SOFTSETUP
;
7459 if ((rc
= qeth_init_qdio_queues(card
))){
7460 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
7463 /*maybe it was set offline without ifconfig down
7464 * we can also use this state for recovery purposes*/
7465 qeth_set_allowed_threads(card
, 0xffffffff, 0);
7466 if (recover_flag
== CARD_STATE_RECOVER
)
7467 qeth_start_again(card
);
7468 qeth_notify_processes();
7471 card
->use_hard_stop
= 1;
7472 qeth_stop_card(card
);
7473 ccw_device_set_offline(CARD_DDEV(card
));
7474 ccw_device_set_offline(CARD_WDEV(card
));
7475 ccw_device_set_offline(CARD_RDEV(card
));
7476 if (recover_flag
== CARD_STATE_RECOVER
)
7477 card
->state
= CARD_STATE_RECOVER
;
7479 card
->state
= CARD_STATE_DOWN
;
7483 static struct ccw_device_id qeth_ids
[] = {
7484 {CCW_DEVICE(0x1731, 0x01), driver_info
:QETH_CARD_TYPE_OSAE
},
7485 {CCW_DEVICE(0x1731, 0x05), driver_info
:QETH_CARD_TYPE_IQD
},
7488 MODULE_DEVICE_TABLE(ccw
, qeth_ids
);
7490 struct device
*qeth_root_dev
= NULL
;
7492 struct ccwgroup_driver qeth_ccwgroup_driver
= {
7493 .owner
= THIS_MODULE
,
7495 .driver_id
= 0xD8C5E3C8,
7496 .probe
= qeth_probe_device
,
7497 .remove
= qeth_remove_device
,
7498 .set_online
= qeth_set_online
,
7499 .set_offline
= qeth_set_offline
,
7502 struct ccw_driver qeth_ccw_driver
= {
7505 .probe
= ccwgroup_probe_ccwdev
,
7506 .remove
= ccwgroup_remove_ccwdev
,
7511 qeth_unregister_dbf_views(void)
7514 debug_unregister(qeth_dbf_setup
);
7516 debug_unregister(qeth_dbf_qerr
);
7518 debug_unregister(qeth_dbf_sense
);
7520 debug_unregister(qeth_dbf_misc
);
7522 debug_unregister(qeth_dbf_data
);
7523 if (qeth_dbf_control
)
7524 debug_unregister(qeth_dbf_control
);
7526 debug_unregister(qeth_dbf_trace
);
7529 qeth_register_dbf_views(void)
7531 qeth_dbf_setup
= debug_register(QETH_DBF_SETUP_NAME
,
7532 QETH_DBF_SETUP_INDEX
,
7533 QETH_DBF_SETUP_NR_AREAS
,
7534 QETH_DBF_SETUP_LEN
);
7535 qeth_dbf_misc
= debug_register(QETH_DBF_MISC_NAME
,
7536 QETH_DBF_MISC_INDEX
,
7537 QETH_DBF_MISC_NR_AREAS
,
7539 qeth_dbf_data
= debug_register(QETH_DBF_DATA_NAME
,
7540 QETH_DBF_DATA_INDEX
,
7541 QETH_DBF_DATA_NR_AREAS
,
7543 qeth_dbf_control
= debug_register(QETH_DBF_CONTROL_NAME
,
7544 QETH_DBF_CONTROL_INDEX
,
7545 QETH_DBF_CONTROL_NR_AREAS
,
7546 QETH_DBF_CONTROL_LEN
);
7547 qeth_dbf_sense
= debug_register(QETH_DBF_SENSE_NAME
,
7548 QETH_DBF_SENSE_INDEX
,
7549 QETH_DBF_SENSE_NR_AREAS
,
7550 QETH_DBF_SENSE_LEN
);
7551 qeth_dbf_qerr
= debug_register(QETH_DBF_QERR_NAME
,
7552 QETH_DBF_QERR_INDEX
,
7553 QETH_DBF_QERR_NR_AREAS
,
7555 qeth_dbf_trace
= debug_register(QETH_DBF_TRACE_NAME
,
7556 QETH_DBF_TRACE_INDEX
,
7557 QETH_DBF_TRACE_NR_AREAS
,
7558 QETH_DBF_TRACE_LEN
);
7560 if ((qeth_dbf_setup
== NULL
) || (qeth_dbf_misc
== NULL
) ||
7561 (qeth_dbf_data
== NULL
) || (qeth_dbf_control
== NULL
) ||
7562 (qeth_dbf_sense
== NULL
) || (qeth_dbf_qerr
== NULL
) ||
7563 (qeth_dbf_trace
== NULL
)) {
7564 qeth_unregister_dbf_views();
7567 debug_register_view(qeth_dbf_setup
, &debug_hex_ascii_view
);
7568 debug_set_level(qeth_dbf_setup
, QETH_DBF_SETUP_LEVEL
);
7570 debug_register_view(qeth_dbf_misc
, &debug_hex_ascii_view
);
7571 debug_set_level(qeth_dbf_misc
, QETH_DBF_MISC_LEVEL
);
7573 debug_register_view(qeth_dbf_data
, &debug_hex_ascii_view
);
7574 debug_set_level(qeth_dbf_data
, QETH_DBF_DATA_LEVEL
);
7576 debug_register_view(qeth_dbf_control
, &debug_hex_ascii_view
);
7577 debug_set_level(qeth_dbf_control
, QETH_DBF_CONTROL_LEVEL
);
7579 debug_register_view(qeth_dbf_sense
, &debug_hex_ascii_view
);
7580 debug_set_level(qeth_dbf_sense
, QETH_DBF_SENSE_LEVEL
);
7582 debug_register_view(qeth_dbf_qerr
, &debug_hex_ascii_view
);
7583 debug_set_level(qeth_dbf_qerr
, QETH_DBF_QERR_LEVEL
);
7585 debug_register_view(qeth_dbf_trace
, &debug_hex_ascii_view
);
7586 debug_set_level(qeth_dbf_trace
, QETH_DBF_TRACE_LEVEL
);
7591 #ifdef CONFIG_QETH_IPV6
7592 extern struct neigh_table arp_tbl
;
7593 static struct neigh_ops
*arp_direct_ops
;
7594 static int (*qeth_old_arp_constructor
) (struct neighbour
*);
7596 static struct neigh_ops arp_direct_ops_template
= {
7600 .error_report
= NULL
,
7601 .output
= dev_queue_xmit
,
7602 .connected_output
= dev_queue_xmit
,
7603 .hh_output
= dev_queue_xmit
,
7604 .queue_xmit
= dev_queue_xmit
7608 qeth_arp_constructor(struct neighbour
*neigh
)
7610 struct net_device
*dev
= neigh
->dev
;
7611 struct in_device
*in_dev
;
7612 struct neigh_parms
*parms
;
7613 struct qeth_card
*card
;
7615 card
= qeth_get_card_from_dev(dev
);
7618 if((card
->options
.layer2
) ||
7619 (card
->dev
->hard_header
== qeth_fake_header
))
7623 in_dev
= rcu_dereference(__in_dev_get(dev
));
7624 if (in_dev
== NULL
) {
7629 parms
= in_dev
->arp_parms
;
7630 __neigh_parms_put(neigh
->parms
);
7631 neigh
->parms
= neigh_parms_clone(parms
);
7634 neigh
->type
= inet_addr_type(*(u32
*) neigh
->primary_key
);
7635 neigh
->nud_state
= NUD_NOARP
;
7636 neigh
->ops
= arp_direct_ops
;
7637 neigh
->output
= neigh
->ops
->queue_xmit
;
7640 return qeth_old_arp_constructor(neigh
);
7642 #endif /*CONFIG_QETH_IPV6*/
7645 * IP address takeover related functions
7648 qeth_clear_ipato_list(struct qeth_card
*card
)
7650 struct qeth_ipato_entry
*ipatoe
, *tmp
;
7651 unsigned long flags
;
7653 spin_lock_irqsave(&card
->ip_lock
, flags
);
7654 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
7655 list_del(&ipatoe
->entry
);
7658 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7662 qeth_add_ipato_entry(struct qeth_card
*card
, struct qeth_ipato_entry
*new)
7664 struct qeth_ipato_entry
*ipatoe
;
7665 unsigned long flags
;
7668 QETH_DBF_TEXT(trace
, 2, "addipato");
7669 spin_lock_irqsave(&card
->ip_lock
, flags
);
7670 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
7671 if (ipatoe
->proto
!= new->proto
)
7673 if (!memcmp(ipatoe
->addr
, new->addr
,
7674 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
7675 (ipatoe
->mask_bits
== new->mask_bits
)){
7676 PRINT_WARN("ipato entry already exists!\n");
7682 list_add_tail(&new->entry
, &card
->ipato
.entries
);
7684 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7689 qeth_del_ipato_entry(struct qeth_card
*card
, enum qeth_prot_versions proto
,
7690 u8
*addr
, int mask_bits
)
7692 struct qeth_ipato_entry
*ipatoe
, *tmp
;
7693 unsigned long flags
;
7695 QETH_DBF_TEXT(trace
, 2, "delipato");
7696 spin_lock_irqsave(&card
->ip_lock
, flags
);
7697 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
){
7698 if (ipatoe
->proto
!= proto
)
7700 if (!memcmp(ipatoe
->addr
, addr
,
7701 (proto
== QETH_PROT_IPV4
)? 4:16) &&
7702 (ipatoe
->mask_bits
== mask_bits
)){
7703 list_del(&ipatoe
->entry
);
7707 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7711 qeth_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
7716 for (i
= 0; i
< len
; ++i
){
7718 for (j
= 7; j
>= 0; --j
){
7719 bits
[i
*8 + j
] = octet
& 1;
7726 qeth_is_addr_covered_by_ipato(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
7728 struct qeth_ipato_entry
*ipatoe
;
7729 u8 addr_bits
[128] = {0, };
7730 u8 ipatoe_bits
[128] = {0, };
7733 if (!card
->ipato
.enabled
)
7736 qeth_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
7737 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
7738 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
7739 if (addr
->proto
!= ipatoe
->proto
)
7741 qeth_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
7742 (ipatoe
->proto
==QETH_PROT_IPV4
) ?
7744 if (addr
->proto
== QETH_PROT_IPV4
)
7745 rc
= !memcmp(addr_bits
, ipatoe_bits
,
7746 min(32, ipatoe
->mask_bits
));
7748 rc
= !memcmp(addr_bits
, ipatoe_bits
,
7749 min(128, ipatoe
->mask_bits
));
7754 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
7756 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
7763 * VIPA related functions
7766 qeth_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
7769 struct qeth_ipaddr
*ipaddr
;
7770 unsigned long flags
;
7773 ipaddr
= qeth_get_addr_buffer(proto
);
7775 if (proto
== QETH_PROT_IPV4
){
7776 QETH_DBF_TEXT(trace
, 2, "addvipa4");
7777 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
7778 ipaddr
->u
.a4
.mask
= 0;
7779 #ifdef CONFIG_QETH_IPV6
7780 } else if (proto
== QETH_PROT_IPV6
){
7781 QETH_DBF_TEXT(trace
, 2, "addvipa6");
7782 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
7783 ipaddr
->u
.a6
.pfxlen
= 0;
7786 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
7787 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
7788 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
7791 spin_lock_irqsave(&card
->ip_lock
, flags
);
7792 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
7793 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
7795 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7797 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
7800 if (!qeth_add_ip(card
, ipaddr
))
7802 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
7803 schedule_work(&card
->kernel_thread_starter
);
7808 qeth_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
7811 struct qeth_ipaddr
*ipaddr
;
7813 ipaddr
= qeth_get_addr_buffer(proto
);
7815 if (proto
== QETH_PROT_IPV4
){
7816 QETH_DBF_TEXT(trace
, 2, "delvipa4");
7817 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
7818 ipaddr
->u
.a4
.mask
= 0;
7819 #ifdef CONFIG_QETH_IPV6
7820 } else if (proto
== QETH_PROT_IPV6
){
7821 QETH_DBF_TEXT(trace
, 2, "delvipa6");
7822 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
7823 ipaddr
->u
.a6
.pfxlen
= 0;
7826 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
7829 if (!qeth_delete_ip(card
, ipaddr
))
7831 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
7832 schedule_work(&card
->kernel_thread_starter
);
7836 * proxy ARP related functions
7839 qeth_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
7842 struct qeth_ipaddr
*ipaddr
;
7843 unsigned long flags
;
7846 ipaddr
= qeth_get_addr_buffer(proto
);
7848 if (proto
== QETH_PROT_IPV4
){
7849 QETH_DBF_TEXT(trace
, 2, "addrxip4");
7850 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
7851 ipaddr
->u
.a4
.mask
= 0;
7852 #ifdef CONFIG_QETH_IPV6
7853 } else if (proto
== QETH_PROT_IPV6
){
7854 QETH_DBF_TEXT(trace
, 2, "addrxip6");
7855 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
7856 ipaddr
->u
.a6
.pfxlen
= 0;
7859 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
7860 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
7861 ipaddr
->del_flags
= 0;
7864 spin_lock_irqsave(&card
->ip_lock
, flags
);
7865 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
7866 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
7868 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7870 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
7873 if (!qeth_add_ip(card
, ipaddr
))
7875 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
7876 schedule_work(&card
->kernel_thread_starter
);
7881 qeth_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
7884 struct qeth_ipaddr
*ipaddr
;
7886 ipaddr
= qeth_get_addr_buffer(proto
);
7888 if (proto
== QETH_PROT_IPV4
){
7889 QETH_DBF_TEXT(trace
, 2, "addrxip4");
7890 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
7891 ipaddr
->u
.a4
.mask
= 0;
7892 #ifdef CONFIG_QETH_IPV6
7893 } else if (proto
== QETH_PROT_IPV6
){
7894 QETH_DBF_TEXT(trace
, 2, "addrxip6");
7895 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
7896 ipaddr
->u
.a6
.pfxlen
= 0;
7899 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
7902 if (!qeth_delete_ip(card
, ipaddr
))
7904 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
7905 schedule_work(&card
->kernel_thread_starter
);
7912 qeth_ip_event(struct notifier_block
*this,
7913 unsigned long event
,void *ptr
)
7915 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
7916 struct net_device
*dev
=(struct net_device
*) ifa
->ifa_dev
->dev
;
7917 struct qeth_ipaddr
*addr
;
7918 struct qeth_card
*card
;
7920 QETH_DBF_TEXT(trace
,3,"ipevent");
7921 card
= qeth_get_card_from_dev(dev
);
7924 if (card
->options
.layer2
)
7927 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
7929 addr
->u
.a4
.addr
= ifa
->ifa_address
;
7930 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
7931 addr
->type
= QETH_IP_TYPE_NORMAL
;
7937 if (!qeth_add_ip(card
, addr
))
7941 if (!qeth_delete_ip(card
, addr
))
7947 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
7948 schedule_work(&card
->kernel_thread_starter
);
7953 static struct notifier_block qeth_ip_notifier
= {
7958 #ifdef CONFIG_QETH_IPV6
7960 * IPv6 event handler
7963 qeth_ip6_event(struct notifier_block
*this,
7964 unsigned long event
,void *ptr
)
7967 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
7968 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
7969 struct qeth_ipaddr
*addr
;
7970 struct qeth_card
*card
;
7972 QETH_DBF_TEXT(trace
,3,"ip6event");
7974 card
= qeth_get_card_from_dev(dev
);
7977 if (!qeth_is_supported(card
, IPA_IPV6
))
7980 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
7982 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
7983 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
7984 addr
->type
= QETH_IP_TYPE_NORMAL
;
7990 if (!qeth_add_ip(card
, addr
))
7994 if (!qeth_delete_ip(card
, addr
))
8000 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8001 schedule_work(&card
->kernel_thread_starter
);
8006 static struct notifier_block qeth_ip6_notifier
= {
8013 qeth_reboot_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
8016 struct device
*entry
;
8017 struct qeth_card
*card
;
8019 down_read(&qeth_ccwgroup_driver
.driver
.bus
->subsys
.rwsem
);
8020 list_for_each_entry(entry
, &qeth_ccwgroup_driver
.driver
.devices
,
8022 card
= (struct qeth_card
*) entry
->driver_data
;
8023 qeth_clear_ip_list(card
, 0, 0);
8024 qeth_qdio_clear_card(card
, 0);
8026 up_read(&qeth_ccwgroup_driver
.driver
.bus
->subsys
.rwsem
);
8031 static struct notifier_block qeth_reboot_notifier
= {
8037 qeth_register_notifiers(void)
8041 QETH_DBF_TEXT(trace
,5,"regnotif");
8042 if ((r
= register_reboot_notifier(&qeth_reboot_notifier
)))
8044 if ((r
= register_inetaddr_notifier(&qeth_ip_notifier
)))
8046 #ifdef CONFIG_QETH_IPV6
8047 if ((r
= register_inet6addr_notifier(&qeth_ip6_notifier
)))
8052 #ifdef CONFIG_QETH_IPV6
8054 unregister_inetaddr_notifier(&qeth_ip_notifier
);
8057 unregister_reboot_notifier(&qeth_reboot_notifier
);
8062 * unregister all event notifiers
8065 qeth_unregister_notifiers(void)
8068 QETH_DBF_TEXT(trace
,5,"unregnot");
8069 BUG_ON(unregister_reboot_notifier(&qeth_reboot_notifier
));
8070 BUG_ON(unregister_inetaddr_notifier(&qeth_ip_notifier
));
8071 #ifdef CONFIG_QETH_IPV6
8072 BUG_ON(unregister_inet6addr_notifier(&qeth_ip6_notifier
));
8073 #endif /* QETH_IPV6 */
8077 #ifdef CONFIG_QETH_IPV6
8079 qeth_ipv6_init(void)
8081 qeth_old_arp_constructor
= arp_tbl
.constructor
;
8082 write_lock(&arp_tbl
.lock
);
8083 arp_tbl
.constructor
= qeth_arp_constructor
;
8084 write_unlock(&arp_tbl
.lock
);
8086 arp_direct_ops
= (struct neigh_ops
*)
8087 kmalloc(sizeof(struct neigh_ops
), GFP_KERNEL
);
8088 if (!arp_direct_ops
)
8091 memcpy(arp_direct_ops
, &arp_direct_ops_template
,
8092 sizeof(struct neigh_ops
));
8098 qeth_ipv6_uninit(void)
8100 write_lock(&arp_tbl
.lock
);
8101 arp_tbl
.constructor
= qeth_old_arp_constructor
;
8102 write_unlock(&arp_tbl
.lock
);
8103 kfree(arp_direct_ops
);
8105 #endif /* CONFIG_QETH_IPV6 */
8108 qeth_sysfs_unregister(void)
8110 qeth_remove_driver_attributes();
8111 ccw_driver_unregister(&qeth_ccw_driver
);
8112 ccwgroup_driver_unregister(&qeth_ccwgroup_driver
);
8113 s390_root_dev_unregister(qeth_root_dev
);
8116 * register qeth at sysfs
8119 qeth_sysfs_register(void)
8123 rc
= ccwgroup_driver_register(&qeth_ccwgroup_driver
);
8126 rc
= ccw_driver_register(&qeth_ccw_driver
);
8129 rc
= qeth_create_driver_attributes();
8132 qeth_root_dev
= s390_root_dev_register("qeth");
8133 if (IS_ERR(qeth_root_dev
)) {
8134 rc
= PTR_ERR(qeth_root_dev
);
8149 PRINT_INFO("loading %s (%s/%s/%s/%s/%s/%s/%s %s %s)\n",
8150 version
, VERSION_QETH_C
, VERSION_QETH_H
,
8151 VERSION_QETH_MPC_H
, VERSION_QETH_MPC_C
,
8152 VERSION_QETH_FS_H
, VERSION_QETH_PROC_C
,
8153 VERSION_QETH_SYS_C
, QETH_VERSION_IPV6
,
8156 INIT_LIST_HEAD(&qeth_card_list
.list
);
8157 INIT_LIST_HEAD(&qeth_notify_list
);
8158 spin_lock_init(&qeth_notify_lock
);
8159 rwlock_init(&qeth_card_list
.rwlock
);
8161 if (qeth_register_dbf_views())
8163 if (qeth_sysfs_register())
8166 #ifdef CONFIG_QETH_IPV6
8167 if (qeth_ipv6_init()) {
8168 PRINT_ERR("Out of memory during ipv6 init.\n");
8171 #endif /* QETH_IPV6 */
8172 if (qeth_register_notifiers())
8174 if (qeth_create_procfs_entries())
8180 qeth_unregister_notifiers();
8182 #ifdef CONFIG_QETH_IPV6
8184 #endif /* QETH_IPV6 */
8186 qeth_sysfs_unregister();
8187 qeth_unregister_dbf_views();
8189 PRINT_ERR("Initialization failed");
8194 __exit
qeth_exit(void)
8196 struct qeth_card
*card
, *tmp
;
8197 unsigned long flags
;
8199 QETH_DBF_TEXT(trace
,1, "cleanup.");
8202 * Weed would not need to clean up our devices here, because the
8203 * common device layer calls qeth_remove_device for each device
8204 * as soon as we unregister our driver (done in qeth_sysfs_unregister).
8205 * But we do cleanup here so we can do a "soft" shutdown of our cards.
8206 * qeth_remove_device called by the common device layer would otherwise
8207 * do a "hard" shutdown (card->use_hard_stop is set to one in
8208 * qeth_remove_device).
8211 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
8212 list_for_each_entry_safe(card
, tmp
, &qeth_card_list
.list
, list
){
8213 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8214 qeth_set_offline(card
->gdev
);
8215 qeth_remove_device(card
->gdev
);
8218 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8219 #ifdef CONFIG_QETH_IPV6
8222 qeth_unregister_notifiers();
8223 qeth_remove_procfs_entries();
8224 qeth_sysfs_unregister();
8225 qeth_unregister_dbf_views();
8226 printk("qeth: removed\n");
8229 EXPORT_SYMBOL(qeth_eyecatcher
);
8230 module_init(qeth_init
);
8231 module_exit(qeth_exit
);
8232 MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>");
8233 MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \
8234 "Copyright 2000,2003 IBM Corporation\n");
8236 MODULE_LICENSE("GPL");