3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.224 $)
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.224 $ $Date: 2005/05/04 20:19: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 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
36 #include <linux/string.h>
37 #include <linux/errno.h>
40 #include <linux/inetdevice.h>
41 #include <linux/netdevice.h>
42 #include <linux/sched.h>
43 #include <linux/workqueue.h>
44 #include <linux/kernel.h>
45 #include <linux/slab.h>
46 #include <linux/interrupt.h>
47 #include <linux/tcp.h>
48 #include <linux/icmp.h>
49 #include <linux/skbuff.h>
51 #include <linux/igmp.h>
52 #include <linux/init.h>
53 #include <linux/reboot.h>
54 #include <linux/mii.h>
55 #include <linux/rcupdate.h>
56 #include <linux/ethtool.h>
60 #include <net/route.h>
62 #include <asm/ebcdic.h>
65 #include <asm/timex.h>
66 #include <asm/semaphore.h>
67 #include <asm/uaccess.h>
72 #include "qeth_eddp.h"
75 #define VERSION_QETH_C "$Revision: 1.224 $"
76 static const char *version = "qeth S/390 OSA-Express driver";
79 * Debug Facility Stuff
81 static debug_info_t *qeth_dbf_setup = NULL;
82 static debug_info_t *qeth_dbf_data = NULL;
83 static debug_info_t *qeth_dbf_misc = NULL;
84 static debug_info_t *qeth_dbf_control = NULL;
85 debug_info_t *qeth_dbf_trace = NULL;
86 static debug_info_t *qeth_dbf_sense = NULL;
87 static debug_info_t *qeth_dbf_qerr = NULL;
89 DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf);
92 * some more definitions and declarations
94 static unsigned int known_devices[][10] = QETH_MODELLIST_ARRAY;
96 /* list of our cards */
97 struct qeth_card_list_struct qeth_card_list;
98 /*process list want to be notified*/
99 spinlock_t qeth_notify_lock;
100 struct list_head qeth_notify_list;
102 static void qeth_send_control_data_cb(struct qeth_channel *,
103 struct qeth_cmd_buffer *);
106 * here we go with function implementation
109 qeth_init_qdio_info(struct qeth_card *card);
112 qeth_init_qdio_queues(struct qeth_card *card);
115 qeth_alloc_qdio_buffers(struct qeth_card *card);
118 qeth_free_qdio_buffers(struct qeth_card *);
121 qeth_clear_qdio_buffers(struct qeth_card *);
124 qeth_clear_ip_list(struct qeth_card *, int, int);
127 qeth_clear_ipacmd_list(struct qeth_card *);
130 qeth_qdio_clear_card(struct qeth_card *, int);
133 qeth_clear_working_pool_list(struct qeth_card *);
136 qeth_clear_cmd_buffers(struct qeth_channel *);
139 qeth_stop(struct net_device *);
142 qeth_clear_ipato_list(struct qeth_card *);
145 qeth_is_addr_covered_by_ipato(struct qeth_card *, struct qeth_ipaddr *);
148 qeth_irq_tasklet(unsigned long);
151 qeth_set_online(struct ccwgroup_device *);
154 __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode);
156 static struct qeth_ipaddr *
157 qeth_get_addr_buffer(enum qeth_prot_versions);
160 qeth_set_multicast_list(struct net_device *);
163 qeth_notify_processes(void)
165 /*notify all registered processes */
166 struct qeth_notify_list_struct *n_entry;
168 QETH_DBF_TEXT(trace,3,"procnoti");
169 spin_lock(&qeth_notify_lock);
170 list_for_each_entry(n_entry, &qeth_notify_list, list) {
171 send_sig(n_entry->signum, n_entry->task, 1);
173 spin_unlock(&qeth_notify_lock);
177 qeth_notifier_unregister(struct task_struct *p)
179 struct qeth_notify_list_struct *n_entry, *tmp;
181 QETH_DBF_TEXT(trace, 2, "notunreg");
182 spin_lock(&qeth_notify_lock);
183 list_for_each_entry_safe(n_entry, tmp, &qeth_notify_list, list) {
184 if (n_entry->task == p) {
185 list_del(&n_entry->list);
191 spin_unlock(&qeth_notify_lock);
195 qeth_notifier_register(struct task_struct *p, int signum)
197 struct qeth_notify_list_struct *n_entry;
199 /*check first if entry already exists*/
200 spin_lock(&qeth_notify_lock);
201 list_for_each_entry(n_entry, &qeth_notify_list, list) {
202 if (n_entry->task == p) {
203 n_entry->signum = signum;
204 spin_unlock(&qeth_notify_lock);
208 spin_unlock(&qeth_notify_lock);
210 n_entry = (struct qeth_notify_list_struct *)
211 kmalloc(sizeof(struct qeth_notify_list_struct),GFP_KERNEL);
215 n_entry->signum = signum;
216 spin_lock(&qeth_notify_lock);
217 list_add(&n_entry->list,&qeth_notify_list);
218 spin_unlock(&qeth_notify_lock);
224 * free channel command buffers
227 qeth_clean_channel(struct qeth_channel *channel)
231 QETH_DBF_TEXT(setup, 2, "freech");
232 for (cnt = 0; cnt < QETH_CMD_BUFFER_NO; cnt++)
233 kfree(channel->iob[cnt].data);
240 qeth_free_card(struct qeth_card *card)
243 QETH_DBF_TEXT(setup, 2, "freecrd");
244 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
245 qeth_clean_channel(&card->read);
246 qeth_clean_channel(&card->write);
248 free_netdev(card->dev);
249 qeth_clear_ip_list(card, 0, 0);
250 qeth_clear_ipato_list(card);
251 kfree(card->ip_tbd_list);
252 qeth_free_qdio_buffers(card);
257 * alloc memory for command buffer per channel
260 qeth_setup_channel(struct qeth_channel *channel)
264 QETH_DBF_TEXT(setup, 2, "setupch");
265 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++) {
266 channel->iob[cnt].data = (char *)
267 kmalloc(QETH_BUFSIZE, GFP_DMA|GFP_KERNEL);
268 if (channel->iob[cnt].data == NULL)
270 channel->iob[cnt].state = BUF_STATE_FREE;
271 channel->iob[cnt].channel = channel;
272 channel->iob[cnt].callback = qeth_send_control_data_cb;
273 channel->iob[cnt].rc = 0;
275 if (cnt < QETH_CMD_BUFFER_NO) {
277 kfree(channel->iob[cnt].data);
281 channel->io_buf_no = 0;
282 atomic_set(&channel->irq_pending, 0);
283 spin_lock_init(&channel->iob_lock);
285 init_waitqueue_head(&channel->wait_q);
286 channel->irq_tasklet.data = (unsigned long) channel;
287 channel->irq_tasklet.func = qeth_irq_tasklet;
292 * alloc memory for card structure
294 static struct qeth_card *
295 qeth_alloc_card(void)
297 struct qeth_card *card;
299 QETH_DBF_TEXT(setup, 2, "alloccrd");
300 card = (struct qeth_card *) kmalloc(sizeof(struct qeth_card),
304 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
305 memset(card, 0, sizeof(struct qeth_card));
306 if (qeth_setup_channel(&card->read)) {
310 if (qeth_setup_channel(&card->write)) {
311 qeth_clean_channel(&card->read);
319 __qeth_check_irb_error(struct ccw_device *cdev, struct irb *irb)
324 switch (PTR_ERR(irb)) {
326 PRINT_WARN("i/o-error on device %s\n", cdev->dev.bus_id);
327 QETH_DBF_TEXT(trace, 2, "ckirberr");
328 QETH_DBF_TEXT_(trace, 2, " rc%d", -EIO);
331 PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id);
332 QETH_DBF_TEXT(trace, 2, "ckirberr");
333 QETH_DBF_TEXT_(trace, 2, " rc%d", -ETIMEDOUT);
336 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
338 QETH_DBF_TEXT(trace, 2, "ckirberr");
339 QETH_DBF_TEXT(trace, 2, " rc???");
345 qeth_get_problem(struct ccw_device *cdev, struct irb *irb)
350 sense = (char *) irb->ecw;
351 cstat = irb->scsw.cstat;
352 dstat = irb->scsw.dstat;
354 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
355 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
356 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
357 QETH_DBF_TEXT(trace,2, "CGENCHK");
358 PRINT_WARN("check on device %s, dstat=x%x, cstat=x%x ",
359 cdev->dev.bus_id, dstat, cstat);
360 HEXDUMP16(WARN, "irb: ", irb);
361 HEXDUMP16(WARN, "irb: ", ((char *) irb) + 32);
365 if (dstat & DEV_STAT_UNIT_CHECK) {
366 if (sense[SENSE_RESETTING_EVENT_BYTE] &
367 SENSE_RESETTING_EVENT_FLAG) {
368 QETH_DBF_TEXT(trace,2,"REVIND");
371 if (sense[SENSE_COMMAND_REJECT_BYTE] &
372 SENSE_COMMAND_REJECT_FLAG) {
373 QETH_DBF_TEXT(trace,2,"CMDREJi");
376 if ((sense[2] == 0xaf) && (sense[3] == 0xfe)) {
377 QETH_DBF_TEXT(trace,2,"AFFE");
380 if ((!sense[0]) && (!sense[1]) && (!sense[2]) && (!sense[3])) {
381 QETH_DBF_TEXT(trace,2,"ZEROSEN");
384 QETH_DBF_TEXT(trace,2,"DGENCHK");
389 static int qeth_issue_next_read(struct qeth_card *);
395 qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
399 struct qeth_cmd_buffer *buffer;
400 struct qeth_channel *channel;
401 struct qeth_card *card;
403 QETH_DBF_TEXT(trace,5,"irq");
405 if (__qeth_check_irb_error(cdev, irb))
407 cstat = irb->scsw.cstat;
408 dstat = irb->scsw.dstat;
410 card = CARD_FROM_CDEV(cdev);
414 if (card->read.ccwdev == cdev){
415 channel = &card->read;
416 QETH_DBF_TEXT(trace,5,"read");
417 } else if (card->write.ccwdev == cdev) {
418 channel = &card->write;
419 QETH_DBF_TEXT(trace,5,"write");
421 channel = &card->data;
422 QETH_DBF_TEXT(trace,5,"data");
424 atomic_set(&channel->irq_pending, 0);
426 if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC))
427 channel->state = CH_STATE_STOPPED;
429 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC))
430 channel->state = CH_STATE_HALTED;
432 /*let's wake up immediately on data channel*/
433 if ((channel == &card->data) && (intparm != 0))
436 if (intparm == QETH_CLEAR_CHANNEL_PARM) {
437 QETH_DBF_TEXT(trace, 6, "clrchpar");
438 /* we don't have to handle this further */
441 if (intparm == QETH_HALT_CHANNEL_PARM) {
442 QETH_DBF_TEXT(trace, 6, "hltchpar");
443 /* we don't have to handle this further */
446 if ((dstat & DEV_STAT_UNIT_EXCEP) ||
447 (dstat & DEV_STAT_UNIT_CHECK) ||
449 if (irb->esw.esw0.erw.cons) {
450 /* TODO: we should make this s390dbf */
451 PRINT_WARN("sense data available on channel %s.\n",
452 CHANNEL_ID(channel));
453 PRINT_WARN(" cstat 0x%X\n dstat 0x%X\n", cstat, dstat);
454 HEXDUMP16(WARN,"irb: ",irb);
455 HEXDUMP16(WARN,"sense data: ",irb->ecw);
457 rc = qeth_get_problem(cdev,irb);
459 qeth_schedule_recovery(card);
465 buffer = (struct qeth_cmd_buffer *) __va((addr_t)intparm);
466 buffer->state = BUF_STATE_PROCESSED;
468 if (channel == &card->data)
471 if (channel == &card->read &&
472 channel->state == CH_STATE_UP)
473 qeth_issue_next_read(card);
475 tasklet_schedule(&channel->irq_tasklet);
478 wake_up(&card->wait_q);
482 * tasklet function scheduled from irq handler
485 qeth_irq_tasklet(unsigned long data)
487 struct qeth_card *card;
488 struct qeth_channel *channel;
489 struct qeth_cmd_buffer *iob;
492 QETH_DBF_TEXT(trace,5,"irqtlet");
493 channel = (struct qeth_channel *) data;
495 index = channel->buf_no;
496 card = CARD_FROM_CDEV(channel->ccwdev);
497 while (iob[index].state == BUF_STATE_PROCESSED) {
498 if (iob[index].callback !=NULL) {
499 iob[index].callback(channel,iob + index);
501 index = (index + 1) % QETH_CMD_BUFFER_NO;
503 channel->buf_no = index;
504 wake_up(&card->wait_q);
507 static int qeth_stop_card(struct qeth_card *, int);
510 __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
512 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
513 int rc = 0, rc2 = 0, rc3 = 0;
514 enum qeth_card_states recover_flag;
516 QETH_DBF_TEXT(setup, 3, "setoffl");
517 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
519 recover_flag = card->state;
520 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){
521 PRINT_WARN("Stopping card %s interrupted by user!\n",
525 rc = ccw_device_set_offline(CARD_DDEV(card));
526 rc2 = ccw_device_set_offline(CARD_WDEV(card));
527 rc3 = ccw_device_set_offline(CARD_RDEV(card));
529 rc = (rc2) ? rc2 : rc3;
531 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
532 if (recover_flag == CARD_STATE_UP)
533 card->state = CARD_STATE_RECOVER;
534 qeth_notify_processes();
539 qeth_set_offline(struct ccwgroup_device *cgdev)
541 return __qeth_set_offline(cgdev, 0);
545 qeth_wait_for_threads(struct qeth_card *card, unsigned long threads);
549 qeth_remove_device(struct ccwgroup_device *cgdev)
551 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
554 QETH_DBF_TEXT(setup, 3, "rmdev");
555 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
560 if (qeth_wait_for_threads(card, 0xffffffff))
563 if (cgdev->state == CCWGROUP_ONLINE){
564 card->use_hard_stop = 1;
565 qeth_set_offline(cgdev);
567 /* remove form our internal list */
568 write_lock_irqsave(&qeth_card_list.rwlock, flags);
569 list_del(&card->list);
570 write_unlock_irqrestore(&qeth_card_list.rwlock, flags);
572 unregister_netdev(card->dev);
573 qeth_remove_device_attributes(&cgdev->dev);
574 qeth_free_card(card);
575 cgdev->dev.driver_data = NULL;
576 put_device(&cgdev->dev);
580 qeth_register_addr_entry(struct qeth_card *, struct qeth_ipaddr *);
582 qeth_deregister_addr_entry(struct qeth_card *, struct qeth_ipaddr *);
585 * Add/remove address to/from card's ip list, i.e. try to add or remove
586 * reference to/from an IP address that is already registered on the card.
588 * 0 address was on card and its reference count has been adjusted,
589 * but is still > 0, so nothing has to be done
590 * also returns 0 if card was not on card and the todo was to delete
591 * the address -> there is also nothing to be done
592 * 1 address was not on card and the todo is to add it to the card's ip
594 * -1 address was on card and its reference count has been decremented
595 * to <= 0 by the todo -> address must be removed from card
598 __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo,
599 struct qeth_ipaddr **__addr)
601 struct qeth_ipaddr *addr;
604 list_for_each_entry(addr, &card->ip_list, entry) {
605 if ((addr->proto == QETH_PROT_IPV4) &&
606 (todo->proto == QETH_PROT_IPV4) &&
607 (addr->type == todo->type) &&
608 (addr->u.a4.addr == todo->u.a4.addr) &&
609 (addr->u.a4.mask == todo->u.a4.mask) ){
613 if ((addr->proto == QETH_PROT_IPV6) &&
614 (todo->proto == QETH_PROT_IPV6) &&
615 (addr->type == todo->type) &&
616 (addr->u.a6.pfxlen == todo->u.a6.pfxlen) &&
617 (memcmp(&addr->u.a6.addr, &todo->u.a6.addr,
618 sizeof(struct in6_addr)) == 0)) {
624 addr->users += todo->users;
625 if (addr->users <= 0){
629 /* for VIPA and RXIP limit refcount to 1 */
630 if (addr->type != QETH_IP_TYPE_NORMAL)
635 if (todo->users > 0){
636 /* for VIPA and RXIP limit refcount to 1 */
637 if (todo->type != QETH_IP_TYPE_NORMAL)
645 __qeth_address_exists_in_list(struct list_head *list, struct qeth_ipaddr *addr,
648 struct qeth_ipaddr *tmp;
650 list_for_each_entry(tmp, list, entry) {
651 if ((tmp->proto == QETH_PROT_IPV4) &&
652 (addr->proto == QETH_PROT_IPV4) &&
653 ((same_type && (tmp->type == addr->type)) ||
654 (!same_type && (tmp->type != addr->type)) ) &&
655 (tmp->u.a4.addr == addr->u.a4.addr) ){
658 if ((tmp->proto == QETH_PROT_IPV6) &&
659 (addr->proto == QETH_PROT_IPV6) &&
660 ((same_type && (tmp->type == addr->type)) ||
661 (!same_type && (tmp->type != addr->type)) ) &&
662 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr,
663 sizeof(struct in6_addr)) == 0) ) {
671 * Add IP to be added to todo list. If there is already an "add todo"
672 * in this list we just incremenent the reference count.
673 * Returns 0 if we just incremented reference count.
676 __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add)
678 struct qeth_ipaddr *tmp, *t;
681 list_for_each_entry_safe(tmp, t, card->ip_tbd_list, entry) {
682 if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) &&
683 (tmp->type == QETH_IP_TYPE_DEL_ALL_MC))
685 if ((tmp->proto == QETH_PROT_IPV4) &&
686 (addr->proto == QETH_PROT_IPV4) &&
687 (tmp->type == addr->type) &&
688 (tmp->is_multicast == addr->is_multicast) &&
689 (tmp->u.a4.addr == addr->u.a4.addr) &&
690 (tmp->u.a4.mask == addr->u.a4.mask) ){
694 if ((tmp->proto == QETH_PROT_IPV6) &&
695 (addr->proto == QETH_PROT_IPV6) &&
696 (tmp->type == addr->type) &&
697 (tmp->is_multicast == addr->is_multicast) &&
698 (tmp->u.a6.pfxlen == addr->u.a6.pfxlen) &&
699 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr,
700 sizeof(struct in6_addr)) == 0) ){
706 if (addr->users != 0)
707 tmp->users += addr->users;
709 tmp->users += add? 1:-1;
710 if (tmp->users == 0){
711 list_del(&tmp->entry);
716 if (addr->type == QETH_IP_TYPE_DEL_ALL_MC)
717 list_add(&addr->entry, card->ip_tbd_list);
719 if (addr->users == 0)
720 addr->users += add? 1:-1;
721 if (add && (addr->type == QETH_IP_TYPE_NORMAL) &&
722 qeth_is_addr_covered_by_ipato(card, addr)){
723 QETH_DBF_TEXT(trace, 2, "tkovaddr");
724 addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
726 list_add_tail(&addr->entry, card->ip_tbd_list);
733 * Remove IP address from list
736 qeth_delete_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
741 QETH_DBF_TEXT(trace,4,"delip");
742 if (addr->proto == QETH_PROT_IPV4)
743 QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4);
745 QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8);
746 QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8);
748 spin_lock_irqsave(&card->ip_lock, flags);
749 rc = __qeth_insert_ip_todo(card, addr, 0);
750 spin_unlock_irqrestore(&card->ip_lock, flags);
755 qeth_add_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
760 QETH_DBF_TEXT(trace,4,"addip");
761 if (addr->proto == QETH_PROT_IPV4)
762 QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4);
764 QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8);
765 QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8);
767 spin_lock_irqsave(&card->ip_lock, flags);
768 rc = __qeth_insert_ip_todo(card, addr, 1);
769 spin_unlock_irqrestore(&card->ip_lock, flags);
774 __qeth_delete_all_mc(struct qeth_card *card, unsigned long *flags)
776 struct qeth_ipaddr *addr, *tmp;
779 list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) {
780 if (addr->is_multicast) {
781 spin_unlock_irqrestore(&card->ip_lock, *flags);
782 rc = qeth_deregister_addr_entry(card, addr);
783 spin_lock_irqsave(&card->ip_lock, *flags);
785 list_del(&addr->entry);
793 qeth_set_ip_addr_list(struct qeth_card *card)
795 struct list_head *tbd_list;
796 struct qeth_ipaddr *todo, *addr;
800 QETH_DBF_TEXT(trace, 2, "sdiplist");
801 QETH_DBF_HEX(trace, 2, &card, sizeof(void *));
803 spin_lock_irqsave(&card->ip_lock, flags);
804 tbd_list = card->ip_tbd_list;
805 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC);
806 if (!card->ip_tbd_list) {
807 QETH_DBF_TEXT(trace, 0, "silnomem");
808 card->ip_tbd_list = tbd_list;
809 spin_unlock_irqrestore(&card->ip_lock, flags);
812 INIT_LIST_HEAD(card->ip_tbd_list);
814 while (!list_empty(tbd_list)){
815 todo = list_entry(tbd_list->next, struct qeth_ipaddr, entry);
816 list_del(&todo->entry);
817 if (todo->type == QETH_IP_TYPE_DEL_ALL_MC){
818 __qeth_delete_all_mc(card, &flags);
822 rc = __qeth_ref_ip_on_card(card, todo, &addr);
824 /* nothing to be done; only adjusted refcount */
826 } else if (rc == 1) {
827 /* new entry to be added to on-card list */
828 spin_unlock_irqrestore(&card->ip_lock, flags);
829 rc = qeth_register_addr_entry(card, todo);
830 spin_lock_irqsave(&card->ip_lock, flags);
832 list_add_tail(&todo->entry, &card->ip_list);
835 } else if (rc == -1) {
836 /* on-card entry to be removed */
837 list_del_init(&addr->entry);
838 spin_unlock_irqrestore(&card->ip_lock, flags);
839 rc = qeth_deregister_addr_entry(card, addr);
840 spin_lock_irqsave(&card->ip_lock, flags);
844 list_add_tail(&addr->entry, &card->ip_list);
848 spin_unlock_irqrestore(&card->ip_lock, flags);
852 static void qeth_delete_mc_addresses(struct qeth_card *);
853 static void qeth_add_multicast_ipv4(struct qeth_card *);
854 #ifdef CONFIG_QETH_IPV6
855 static void qeth_add_multicast_ipv6(struct qeth_card *);
859 qeth_set_thread_start_bit(struct qeth_card *card, unsigned long thread)
863 spin_lock_irqsave(&card->thread_mask_lock, flags);
864 if ( !(card->thread_allowed_mask & thread) ||
865 (card->thread_start_mask & thread) ) {
866 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
869 card->thread_start_mask |= thread;
870 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
875 qeth_clear_thread_start_bit(struct qeth_card *card, unsigned long thread)
879 spin_lock_irqsave(&card->thread_mask_lock, flags);
880 card->thread_start_mask &= ~thread;
881 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
882 wake_up(&card->wait_q);
886 qeth_clear_thread_running_bit(struct qeth_card *card, unsigned long thread)
890 spin_lock_irqsave(&card->thread_mask_lock, flags);
891 card->thread_running_mask &= ~thread;
892 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
893 wake_up(&card->wait_q);
897 __qeth_do_run_thread(struct qeth_card *card, unsigned long thread)
902 spin_lock_irqsave(&card->thread_mask_lock, flags);
903 if (card->thread_start_mask & thread){
904 if ((card->thread_allowed_mask & thread) &&
905 !(card->thread_running_mask & thread)){
907 card->thread_start_mask &= ~thread;
908 card->thread_running_mask |= thread;
912 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
917 qeth_do_run_thread(struct qeth_card *card, unsigned long thread)
921 wait_event(card->wait_q,
922 (rc = __qeth_do_run_thread(card, thread)) >= 0);
927 qeth_register_ip_addresses(void *ptr)
929 struct qeth_card *card;
931 card = (struct qeth_card *) ptr;
932 daemonize("qeth_reg_ip");
933 QETH_DBF_TEXT(trace,4,"regipth1");
934 if (!qeth_do_run_thread(card, QETH_SET_IP_THREAD))
936 QETH_DBF_TEXT(trace,4,"regipth2");
937 qeth_set_ip_addr_list(card);
938 qeth_clear_thread_running_bit(card, QETH_SET_IP_THREAD);
943 qeth_recover(void *ptr)
945 struct qeth_card *card;
948 card = (struct qeth_card *) ptr;
949 daemonize("qeth_recover");
950 QETH_DBF_TEXT(trace,2,"recover1");
951 QETH_DBF_HEX(trace, 2, &card, sizeof(void *));
952 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD))
954 QETH_DBF_TEXT(trace,2,"recover2");
955 PRINT_WARN("Recovery of device %s started ...\n",
957 card->use_hard_stop = 1;
958 __qeth_set_offline(card->gdev,1);
959 rc = __qeth_set_online(card->gdev,1);
961 PRINT_INFO("Device %s successfully recovered!\n",
964 PRINT_INFO("Device %s could not be recovered!\n",
966 /* don't run another scheduled recovery */
967 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
968 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
973 qeth_schedule_recovery(struct qeth_card *card)
975 QETH_DBF_TEXT(trace,2,"startrec");
977 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0)
978 schedule_work(&card->kernel_thread_starter);
982 qeth_do_start_thread(struct qeth_card *card, unsigned long thread)
987 spin_lock_irqsave(&card->thread_mask_lock, flags);
988 QETH_DBF_TEXT_(trace, 4, " %02x%02x%02x",
989 (u8) card->thread_start_mask,
990 (u8) card->thread_allowed_mask,
991 (u8) card->thread_running_mask);
992 rc = (card->thread_start_mask & thread);
993 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
998 qeth_start_kernel_thread(struct qeth_card *card)
1000 QETH_DBF_TEXT(trace , 2, "strthrd");
1002 if (card->read.state != CH_STATE_UP &&
1003 card->write.state != CH_STATE_UP)
1006 if (qeth_do_start_thread(card, QETH_SET_IP_THREAD))
1007 kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD);
1008 if (qeth_do_start_thread(card, QETH_RECOVER_THREAD))
1009 kernel_thread(qeth_recover, (void *) card, SIGCHLD);
1014 qeth_set_intial_options(struct qeth_card *card)
1016 card->options.route4.type = NO_ROUTER;
1017 #ifdef CONFIG_QETH_IPV6
1018 card->options.route6.type = NO_ROUTER;
1019 #endif /* QETH_IPV6 */
1020 card->options.checksum_type = QETH_CHECKSUM_DEFAULT;
1021 card->options.broadcast_mode = QETH_TR_BROADCAST_ALLRINGS;
1022 card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL;
1023 card->options.fake_broadcast = 0;
1024 card->options.add_hhlen = DEFAULT_ADD_HHLEN;
1025 card->options.fake_ll = 0;
1026 if (card->info.type == QETH_CARD_TYPE_OSN)
1027 card->options.layer2 = 1;
1029 card->options.layer2 = 0;
1033 * initialize channels ,card and all state machines
1036 qeth_setup_card(struct qeth_card *card)
1039 QETH_DBF_TEXT(setup, 2, "setupcrd");
1040 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
1042 card->read.state = CH_STATE_DOWN;
1043 card->write.state = CH_STATE_DOWN;
1044 card->data.state = CH_STATE_DOWN;
1045 card->state = CARD_STATE_DOWN;
1046 card->lan_online = 0;
1047 card->use_hard_stop = 0;
1049 #ifdef CONFIG_QETH_VLAN
1050 spin_lock_init(&card->vlanlock);
1051 card->vlangrp = NULL;
1053 spin_lock_init(&card->lock);
1054 spin_lock_init(&card->ip_lock);
1055 spin_lock_init(&card->thread_mask_lock);
1056 card->thread_start_mask = 0;
1057 card->thread_allowed_mask = 0;
1058 card->thread_running_mask = 0;
1059 INIT_WORK(&card->kernel_thread_starter,
1060 (void *)qeth_start_kernel_thread,card);
1061 INIT_LIST_HEAD(&card->ip_list);
1062 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
1063 if (!card->ip_tbd_list) {
1064 QETH_DBF_TEXT(setup, 0, "iptbdnom");
1067 INIT_LIST_HEAD(card->ip_tbd_list);
1068 INIT_LIST_HEAD(&card->cmd_waiter_list);
1069 init_waitqueue_head(&card->wait_q);
1070 /* intial options */
1071 qeth_set_intial_options(card);
1072 /* IP address takeover */
1073 INIT_LIST_HEAD(&card->ipato.entries);
1074 card->ipato.enabled = 0;
1075 card->ipato.invert4 = 0;
1076 card->ipato.invert6 = 0;
1077 /* init QDIO stuff */
1078 qeth_init_qdio_info(card);
1083 is_1920_device (struct qeth_card *card)
1085 int single_queue = 0;
1086 struct ccw_device *ccwdev;
1087 struct channelPath_dsc {
1098 QETH_DBF_TEXT(setup, 2, "chk_1920");
1100 ccwdev = card->data.ccwdev;
1101 chp_dsc = (struct channelPath_dsc *)ccw_device_get_chp_desc(ccwdev, 0);
1102 if (chp_dsc != NULL) {
1103 /* CHPP field bit 6 == 1 -> single queue */
1104 single_queue = ((chp_dsc->chpp & 0x02) == 0x02);
1107 QETH_DBF_TEXT_(setup, 2, "rc:%x", single_queue);
1108 return single_queue;
1112 qeth_determine_card_type(struct qeth_card *card)
1116 QETH_DBF_TEXT(setup, 2, "detcdtyp");
1118 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT;
1119 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
1120 while (known_devices[i][4]) {
1121 if ((CARD_RDEV(card)->id.dev_type == known_devices[i][2]) &&
1122 (CARD_RDEV(card)->id.dev_model == known_devices[i][3])) {
1123 card->info.type = known_devices[i][4];
1124 card->qdio.no_out_queues = known_devices[i][8];
1125 card->info.is_multicast_different = known_devices[i][9];
1126 if (is_1920_device(card)) {
1127 PRINT_INFO("Priority Queueing not able "
1128 "due to hardware limitations!\n");
1129 card->qdio.no_out_queues = 1;
1130 card->qdio.default_out_queue = 0;
1136 card->info.type = QETH_CARD_TYPE_UNKNOWN;
1137 PRINT_ERR("unknown card type on device %s\n", CARD_BUS_ID(card));
1142 qeth_probe_device(struct ccwgroup_device *gdev)
1144 struct qeth_card *card;
1146 unsigned long flags;
1149 QETH_DBF_TEXT(setup, 2, "probedev");
1152 if (!get_device(dev))
1155 QETH_DBF_TEXT_(setup, 2, "%s", gdev->dev.bus_id);
1157 card = qeth_alloc_card();
1160 QETH_DBF_TEXT_(setup, 2, "1err%d", -ENOMEM);
1163 card->read.ccwdev = gdev->cdev[0];
1164 card->write.ccwdev = gdev->cdev[1];
1165 card->data.ccwdev = gdev->cdev[2];
1166 gdev->dev.driver_data = card;
1168 gdev->cdev[0]->handler = qeth_irq;
1169 gdev->cdev[1]->handler = qeth_irq;
1170 gdev->cdev[2]->handler = qeth_irq;
1172 if ((rc = qeth_determine_card_type(card))){
1173 PRINT_WARN("%s: not a valid card type\n", __func__);
1174 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
1176 qeth_free_card(card);
1179 if ((rc = qeth_setup_card(card))){
1180 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
1182 qeth_free_card(card);
1185 rc = qeth_create_device_attributes(dev);
1188 qeth_free_card(card);
1191 /* insert into our internal list */
1192 write_lock_irqsave(&qeth_card_list.rwlock, flags);
1193 list_add_tail(&card->list, &qeth_card_list.list);
1194 write_unlock_irqrestore(&qeth_card_list.rwlock, flags);
1200 qeth_get_unitaddr(struct qeth_card *card)
1206 QETH_DBF_TEXT(setup, 2, "getunit");
1207 rc = read_conf_data(CARD_DDEV(card), (void **) &prcd, &length);
1209 PRINT_ERR("read_conf_data for device %s returned %i\n",
1210 CARD_DDEV_ID(card), rc);
1213 card->info.chpid = prcd[30];
1214 card->info.unit_addr2 = prcd[31];
1215 card->info.cula = prcd[63];
1216 card->info.guestlan = ((prcd[0x10] == _ascebc['V']) &&
1217 (prcd[0x11] == _ascebc['M']));
1222 qeth_init_tokens(struct qeth_card *card)
1224 card->token.issuer_rm_w = 0x00010103UL;
1225 card->token.cm_filter_w = 0x00010108UL;
1226 card->token.cm_connection_w = 0x0001010aUL;
1227 card->token.ulp_filter_w = 0x0001010bUL;
1228 card->token.ulp_connection_w = 0x0001010dUL;
1232 raw_devno_from_bus_id(char *id)
1234 id += (strlen(id) - 4);
1235 return (__u16) simple_strtoul(id, &id, 16);
1241 qeth_setup_ccw(struct qeth_channel *channel,unsigned char *iob, __u32 len)
1243 struct qeth_card *card;
1245 QETH_DBF_TEXT(trace, 4, "setupccw");
1246 card = CARD_FROM_CDEV(channel->ccwdev);
1247 if (channel == &card->read)
1248 memcpy(&channel->ccw, READ_CCW, sizeof(struct ccw1));
1250 memcpy(&channel->ccw, WRITE_CCW, sizeof(struct ccw1));
1251 channel->ccw.count = len;
1252 channel->ccw.cda = (__u32) __pa(iob);
1256 * get free buffer for ccws (IDX activation, lancmds,ipassists...)
1258 static struct qeth_cmd_buffer *
1259 __qeth_get_buffer(struct qeth_channel *channel)
1263 QETH_DBF_TEXT(trace, 6, "getbuff");
1264 index = channel->io_buf_no;
1266 if (channel->iob[index].state == BUF_STATE_FREE) {
1267 channel->iob[index].state = BUF_STATE_LOCKED;
1268 channel->io_buf_no = (channel->io_buf_no + 1) %
1270 memset(channel->iob[index].data, 0, QETH_BUFSIZE);
1271 return channel->iob + index;
1273 index = (index + 1) % QETH_CMD_BUFFER_NO;
1274 } while(index != channel->io_buf_no);
1280 * release command buffer
1283 qeth_release_buffer(struct qeth_channel *channel, struct qeth_cmd_buffer *iob)
1285 unsigned long flags;
1287 QETH_DBF_TEXT(trace, 6, "relbuff");
1288 spin_lock_irqsave(&channel->iob_lock, flags);
1289 memset(iob->data, 0, QETH_BUFSIZE);
1290 iob->state = BUF_STATE_FREE;
1291 iob->callback = qeth_send_control_data_cb;
1293 spin_unlock_irqrestore(&channel->iob_lock, flags);
1296 static struct qeth_cmd_buffer *
1297 qeth_get_buffer(struct qeth_channel *channel)
1299 struct qeth_cmd_buffer *buffer = NULL;
1300 unsigned long flags;
1302 spin_lock_irqsave(&channel->iob_lock, flags);
1303 buffer = __qeth_get_buffer(channel);
1304 spin_unlock_irqrestore(&channel->iob_lock, flags);
1308 static struct qeth_cmd_buffer *
1309 qeth_wait_for_buffer(struct qeth_channel *channel)
1311 struct qeth_cmd_buffer *buffer;
1312 wait_event(channel->wait_q,
1313 ((buffer = qeth_get_buffer(channel)) != NULL));
1318 qeth_clear_cmd_buffers(struct qeth_channel *channel)
1322 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++)
1323 qeth_release_buffer(channel,&channel->iob[cnt]);
1324 channel->buf_no = 0;
1325 channel->io_buf_no = 0;
1329 * start IDX for read and write channel
1332 qeth_idx_activate_get_answer(struct qeth_channel *channel,
1333 void (*idx_reply_cb)(struct qeth_channel *,
1334 struct qeth_cmd_buffer *))
1336 struct qeth_cmd_buffer *iob;
1337 unsigned long flags;
1339 struct qeth_card *card;
1341 QETH_DBF_TEXT(setup, 2, "idxanswr");
1342 card = CARD_FROM_CDEV(channel->ccwdev);
1343 iob = qeth_get_buffer(channel);
1344 iob->callback = idx_reply_cb;
1345 memcpy(&channel->ccw, READ_CCW, sizeof(struct ccw1));
1346 channel->ccw.count = QETH_BUFSIZE;
1347 channel->ccw.cda = (__u32) __pa(iob->data);
1349 wait_event(card->wait_q,
1350 atomic_compare_and_swap(0,1,&channel->irq_pending) == 0);
1351 QETH_DBF_TEXT(setup, 6, "noirqpnd");
1352 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1353 rc = ccw_device_start(channel->ccwdev,
1354 &channel->ccw,(addr_t) iob, 0, 0);
1355 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1358 PRINT_ERR("qeth: Error2 in activating channel rc=%d\n",rc);
1359 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
1360 atomic_set(&channel->irq_pending, 0);
1361 wake_up(&card->wait_q);
1364 rc = wait_event_interruptible_timeout(card->wait_q,
1365 channel->state == CH_STATE_UP, QETH_TIMEOUT);
1366 if (rc == -ERESTARTSYS)
1368 if (channel->state != CH_STATE_UP){
1370 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
1371 qeth_clear_cmd_buffers(channel);
1378 qeth_idx_activate_channel(struct qeth_channel *channel,
1379 void (*idx_reply_cb)(struct qeth_channel *,
1380 struct qeth_cmd_buffer *))
1382 struct qeth_card *card;
1383 struct qeth_cmd_buffer *iob;
1384 unsigned long flags;
1388 card = CARD_FROM_CDEV(channel->ccwdev);
1390 QETH_DBF_TEXT(setup, 2, "idxactch");
1392 iob = qeth_get_buffer(channel);
1393 iob->callback = idx_reply_cb;
1394 memcpy(&channel->ccw, WRITE_CCW, sizeof(struct ccw1));
1395 channel->ccw.count = IDX_ACTIVATE_SIZE;
1396 channel->ccw.cda = (__u32) __pa(iob->data);
1397 if (channel == &card->write) {
1398 memcpy(iob->data, IDX_ACTIVATE_WRITE, IDX_ACTIVATE_SIZE);
1399 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data),
1400 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH);
1401 card->seqno.trans_hdr++;
1403 memcpy(iob->data, IDX_ACTIVATE_READ, IDX_ACTIVATE_SIZE);
1404 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data),
1405 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH);
1407 memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob->data),
1408 &card->token.issuer_rm_w,QETH_MPC_TOKEN_LENGTH);
1409 memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob->data),
1410 &card->info.func_level,sizeof(__u16));
1411 temp = raw_devno_from_bus_id(CARD_DDEV_ID(card));
1412 memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob->data), &temp, 2);
1413 temp = (card->info.cula << 8) + card->info.unit_addr2;
1414 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob->data), &temp, 2);
1416 wait_event(card->wait_q,
1417 atomic_compare_and_swap(0,1,&channel->irq_pending) == 0);
1418 QETH_DBF_TEXT(setup, 6, "noirqpnd");
1419 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1420 rc = ccw_device_start(channel->ccwdev,
1421 &channel->ccw,(addr_t) iob, 0, 0);
1422 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1425 PRINT_ERR("qeth: Error1 in activating channel. rc=%d\n",rc);
1426 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
1427 atomic_set(&channel->irq_pending, 0);
1428 wake_up(&card->wait_q);
1431 rc = wait_event_interruptible_timeout(card->wait_q,
1432 channel->state == CH_STATE_ACTIVATING, QETH_TIMEOUT);
1433 if (rc == -ERESTARTSYS)
1435 if (channel->state != CH_STATE_ACTIVATING) {
1436 PRINT_WARN("qeth: IDX activate timed out!\n");
1437 QETH_DBF_TEXT_(setup, 2, "2err%d", -ETIME);
1438 qeth_clear_cmd_buffers(channel);
1441 return qeth_idx_activate_get_answer(channel,idx_reply_cb);
1445 qeth_peer_func_level(int level)
1447 if ((level & 0xff) == 8)
1448 return (level & 0xff) + 0x400;
1449 if (((level >> 8) & 3) == 1)
1450 return (level & 0xff) + 0x200;
1455 qeth_idx_write_cb(struct qeth_channel *channel, struct qeth_cmd_buffer *iob)
1457 struct qeth_card *card;
1460 QETH_DBF_TEXT(setup ,2, "idxwrcb");
1462 if (channel->state == CH_STATE_DOWN) {
1463 channel->state = CH_STATE_ACTIVATING;
1466 card = CARD_FROM_CDEV(channel->ccwdev);
1468 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob->data))) {
1469 PRINT_ERR("IDX_ACTIVATE on write channel device %s: negative "
1470 "reply\n", CARD_WDEV_ID(card));
1473 memcpy(&temp, QETH_IDX_ACT_FUNC_LEVEL(iob->data), 2);
1474 if ((temp & ~0x0100) != qeth_peer_func_level(card->info.func_level)) {
1475 PRINT_WARN("IDX_ACTIVATE on write channel device %s: "
1476 "function level mismatch "
1477 "(sent: 0x%x, received: 0x%x)\n",
1478 CARD_WDEV_ID(card), card->info.func_level, temp);
1481 channel->state = CH_STATE_UP;
1483 qeth_release_buffer(channel, iob);
1487 qeth_check_idx_response(unsigned char *buffer)
1492 QETH_DBF_HEX(control, 2, buffer, QETH_DBF_CONTROL_LEN);
1493 if ((buffer[2] & 0xc0) == 0xc0) {
1494 PRINT_WARN("received an IDX TERMINATE "
1495 "with cause code 0x%02x%s\n",
1497 ((buffer[4] == 0x22) ?
1498 " -- try another portname" : ""));
1499 QETH_DBF_TEXT(trace, 2, "ckidxres");
1500 QETH_DBF_TEXT(trace, 2, " idxterm");
1501 QETH_DBF_TEXT_(trace, 2, " rc%d", -EIO);
1508 qeth_idx_read_cb(struct qeth_channel *channel, struct qeth_cmd_buffer *iob)
1510 struct qeth_card *card;
1513 QETH_DBF_TEXT(setup , 2, "idxrdcb");
1514 if (channel->state == CH_STATE_DOWN) {
1515 channel->state = CH_STATE_ACTIVATING;
1519 card = CARD_FROM_CDEV(channel->ccwdev);
1520 if (qeth_check_idx_response(iob->data)) {
1523 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob->data))) {
1524 PRINT_ERR("IDX_ACTIVATE on read channel device %s: negative "
1525 "reply\n", CARD_RDEV_ID(card));
1530 * temporary fix for microcode bug
1531 * to revert it,replace OR by AND
1533 if ( (!QETH_IDX_NO_PORTNAME_REQUIRED(iob->data)) ||
1534 (card->info.type == QETH_CARD_TYPE_OSAE) )
1535 card->info.portname_required = 1;
1537 memcpy(&temp, QETH_IDX_ACT_FUNC_LEVEL(iob->data), 2);
1538 if (temp != qeth_peer_func_level(card->info.func_level)) {
1539 PRINT_WARN("IDX_ACTIVATE on read channel device %s: function "
1540 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1541 CARD_RDEV_ID(card), card->info.func_level, temp);
1544 memcpy(&card->token.issuer_rm_r,
1545 QETH_IDX_ACT_ISSUER_RM_TOKEN(iob->data),
1546 QETH_MPC_TOKEN_LENGTH);
1547 memcpy(&card->info.mcl_level[0],
1548 QETH_IDX_REPLY_LEVEL(iob->data), QETH_MCL_LENGTH);
1549 channel->state = CH_STATE_UP;
1551 qeth_release_buffer(channel,iob);
1555 qeth_issue_next_read(struct qeth_card *card)
1558 struct qeth_cmd_buffer *iob;
1560 QETH_DBF_TEXT(trace,5,"issnxrd");
1561 if (card->read.state != CH_STATE_UP)
1563 iob = qeth_get_buffer(&card->read);
1565 PRINT_WARN("issue_next_read failed: no iob available!\n");
1568 qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE);
1569 wait_event(card->wait_q,
1570 atomic_compare_and_swap(0,1,&card->read.irq_pending) == 0);
1571 QETH_DBF_TEXT(trace, 6, "noirqpnd");
1572 rc = ccw_device_start(card->read.ccwdev, &card->read.ccw,
1573 (addr_t) iob, 0, 0);
1575 PRINT_ERR("Error in starting next read ccw! rc=%i\n", rc);
1576 atomic_set(&card->read.irq_pending, 0);
1577 qeth_schedule_recovery(card);
1578 wake_up(&card->wait_q);
1583 static struct qeth_reply *
1584 qeth_alloc_reply(struct qeth_card *card)
1586 struct qeth_reply *reply;
1588 reply = kmalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
1590 memset(reply, 0, sizeof(struct qeth_reply));
1591 atomic_set(&reply->refcnt, 1);
1598 qeth_get_reply(struct qeth_reply *reply)
1600 WARN_ON(atomic_read(&reply->refcnt) <= 0);
1601 atomic_inc(&reply->refcnt);
1605 qeth_put_reply(struct qeth_reply *reply)
1607 WARN_ON(atomic_read(&reply->refcnt) <= 0);
1608 if (atomic_dec_and_test(&reply->refcnt))
1613 qeth_cmd_timeout(unsigned long data)
1615 struct qeth_reply *reply, *list_reply, *r;
1616 unsigned long flags;
1618 reply = (struct qeth_reply *) data;
1619 spin_lock_irqsave(&reply->card->lock, flags);
1620 list_for_each_entry_safe(list_reply, r,
1621 &reply->card->cmd_waiter_list, list) {
1622 if (reply == list_reply){
1623 qeth_get_reply(reply);
1624 list_del_init(&reply->list);
1625 spin_unlock_irqrestore(&reply->card->lock, flags);
1627 reply->received = 1;
1628 wake_up(&reply->wait_q);
1629 qeth_put_reply(reply);
1633 spin_unlock_irqrestore(&reply->card->lock, flags);
1636 static struct qeth_ipa_cmd *
1637 qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1639 struct qeth_ipa_cmd *cmd = NULL;
1641 QETH_DBF_TEXT(trace,5,"chkipad");
1642 if (IS_IPA(iob->data)){
1643 cmd = (struct qeth_ipa_cmd *) PDU_ENCAPSULATION(iob->data);
1644 if (IS_IPA_REPLY(cmd))
1647 switch (cmd->hdr.command) {
1648 case IPA_CMD_STOPLAN:
1649 PRINT_WARN("Link failure on %s (CHPID 0x%X) - "
1650 "there is a network problem or "
1651 "someone pulled the cable or "
1652 "disabled the port.\n",
1653 QETH_CARD_IFNAME(card),
1655 card->lan_online = 0;
1656 netif_carrier_off(card->dev);
1658 case IPA_CMD_STARTLAN:
1659 PRINT_INFO("Link reestablished on %s "
1660 "(CHPID 0x%X). Scheduling "
1661 "IP address reset.\n",
1662 QETH_CARD_IFNAME(card),
1664 netif_carrier_on(card->dev);
1665 qeth_schedule_recovery(card);
1667 case IPA_CMD_MODCCID:
1669 case IPA_CMD_REGISTER_LOCAL_ADDR:
1670 QETH_DBF_TEXT(trace,3, "irla");
1672 case IPA_CMD_UNREGISTER_LOCAL_ADDR:
1673 QETH_DBF_TEXT(trace,3, "urla");
1676 PRINT_WARN("Received data is IPA "
1677 "but not a reply!\n");
1686 * wake all waiting ipa commands
1689 qeth_clear_ipacmd_list(struct qeth_card *card)
1691 struct qeth_reply *reply, *r;
1692 unsigned long flags;
1694 QETH_DBF_TEXT(trace, 4, "clipalst");
1696 spin_lock_irqsave(&card->lock, flags);
1697 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) {
1698 qeth_get_reply(reply);
1700 reply->received = 1;
1701 list_del_init(&reply->list);
1702 wake_up(&reply->wait_q);
1703 qeth_put_reply(reply);
1705 spin_unlock_irqrestore(&card->lock, flags);
1709 qeth_send_control_data_cb(struct qeth_channel *channel,
1710 struct qeth_cmd_buffer *iob)
1712 struct qeth_card *card;
1713 struct qeth_reply *reply, *r;
1714 struct qeth_ipa_cmd *cmd;
1715 unsigned long flags;
1718 QETH_DBF_TEXT(trace,4,"sndctlcb");
1720 card = CARD_FROM_CDEV(channel->ccwdev);
1721 if (qeth_check_idx_response(iob->data)) {
1722 qeth_clear_ipacmd_list(card);
1723 qeth_schedule_recovery(card);
1727 cmd = qeth_check_ipa_data(card, iob);
1728 if ((cmd == NULL) && (card->state != CARD_STATE_DOWN))
1730 /*in case of OSN : check if cmd is set */
1731 if (card->info.type == QETH_CARD_TYPE_OSN &&
1733 cmd->hdr.command != IPA_CMD_STARTLAN &&
1734 card->osn_info.assist_cb != NULL) {
1735 card->osn_info.assist_cb(card->dev, cmd);
1739 spin_lock_irqsave(&card->lock, flags);
1740 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) {
1741 if ((reply->seqno == QETH_IDX_COMMAND_SEQNO) ||
1742 ((cmd) && (reply->seqno == cmd->hdr.seqno))) {
1743 qeth_get_reply(reply);
1744 list_del_init(&reply->list);
1745 spin_unlock_irqrestore(&card->lock, flags);
1747 if (reply->callback != NULL) {
1749 reply->offset = (__u16)((char*)cmd -
1751 keep_reply = reply->callback(card,
1753 (unsigned long)cmd);
1755 keep_reply = reply->callback(card,
1757 (unsigned long)iob);
1760 reply->rc = (u16) cmd->hdr.return_code;
1762 reply->rc = iob->rc;
1764 spin_lock_irqsave(&card->lock, flags);
1765 list_add_tail(&reply->list,
1766 &card->cmd_waiter_list);
1767 spin_unlock_irqrestore(&card->lock, flags);
1769 reply->received = 1;
1770 wake_up(&reply->wait_q);
1772 qeth_put_reply(reply);
1776 spin_unlock_irqrestore(&card->lock, flags);
1778 memcpy(&card->seqno.pdu_hdr_ack,
1779 QETH_PDU_HEADER_SEQ_NO(iob->data),
1780 QETH_SEQ_NO_LENGTH);
1781 qeth_release_buffer(channel,iob);
1785 qeth_prepare_control_data(struct qeth_card *card, int len,
1786 struct qeth_cmd_buffer *iob)
1788 qeth_setup_ccw(&card->write,iob->data,len);
1789 iob->callback = qeth_release_buffer;
1791 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data),
1792 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH);
1793 card->seqno.trans_hdr++;
1794 memcpy(QETH_PDU_HEADER_SEQ_NO(iob->data),
1795 &card->seqno.pdu_hdr, QETH_SEQ_NO_LENGTH);
1796 card->seqno.pdu_hdr++;
1797 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob->data),
1798 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH);
1799 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1803 qeth_send_control_data(struct qeth_card *card, int len,
1804 struct qeth_cmd_buffer *iob,
1806 (struct qeth_card *, struct qeth_reply*, unsigned long),
1811 unsigned long flags;
1812 struct qeth_reply *reply = NULL;
1813 struct timer_list timer;
1815 QETH_DBF_TEXT(trace, 2, "sendctl");
1817 reply = qeth_alloc_reply(card);
1819 PRINT_WARN("Could no alloc qeth_reply!\n");
1822 reply->callback = reply_cb;
1823 reply->param = reply_param;
1824 if (card->state == CARD_STATE_DOWN)
1825 reply->seqno = QETH_IDX_COMMAND_SEQNO;
1827 reply->seqno = card->seqno.ipa++;
1829 timer.function = qeth_cmd_timeout;
1830 timer.data = (unsigned long) reply;
1831 init_waitqueue_head(&reply->wait_q);
1832 spin_lock_irqsave(&card->lock, flags);
1833 list_add_tail(&reply->list, &card->cmd_waiter_list);
1834 spin_unlock_irqrestore(&card->lock, flags);
1835 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1836 wait_event(card->wait_q,
1837 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0);
1838 qeth_prepare_control_data(card, len, iob);
1839 if (IS_IPA(iob->data))
1840 timer.expires = jiffies + QETH_IPA_TIMEOUT;
1842 timer.expires = jiffies + QETH_TIMEOUT;
1843 QETH_DBF_TEXT(trace, 6, "noirqpnd");
1844 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
1845 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
1846 (addr_t) iob, 0, 0);
1847 spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags);
1849 PRINT_WARN("qeth_send_control_data: "
1850 "ccw_device_start rc = %i\n", rc);
1851 QETH_DBF_TEXT_(trace, 2, " err%d", rc);
1852 spin_lock_irqsave(&card->lock, flags);
1853 list_del_init(&reply->list);
1854 qeth_put_reply(reply);
1855 spin_unlock_irqrestore(&card->lock, flags);
1856 qeth_release_buffer(iob->channel, iob);
1857 atomic_set(&card->write.irq_pending, 0);
1858 wake_up(&card->wait_q);
1862 wait_event(reply->wait_q, reply->received);
1863 del_timer_sync(&timer);
1865 qeth_put_reply(reply);
1870 qeth_osn_send_control_data(struct qeth_card *card, int len,
1871 struct qeth_cmd_buffer *iob)
1873 unsigned long flags;
1876 QETH_DBF_TEXT(trace, 5, "osndctrd");
1878 wait_event(card->wait_q,
1879 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0);
1880 qeth_prepare_control_data(card, len, iob);
1881 QETH_DBF_TEXT(trace, 6, "osnoirqp");
1882 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
1883 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
1884 (addr_t) iob, 0, 0);
1885 spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags);
1887 PRINT_WARN("qeth_osn_send_control_data: "
1888 "ccw_device_start rc = %i\n", rc);
1889 QETH_DBF_TEXT_(trace, 2, " err%d", rc);
1890 qeth_release_buffer(iob->channel, iob);
1891 atomic_set(&card->write.irq_pending, 0);
1892 wake_up(&card->wait_q);
1898 qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1901 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
1902 memcpy(QETH_IPA_CMD_PROT_TYPE(iob->data),&prot_type,1);
1903 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
1904 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
1908 qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1913 QETH_DBF_TEXT(trace,4,"osndipa");
1915 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
1916 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
1918 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2);
1919 memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2);
1920 memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2);
1921 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
1922 return qeth_osn_send_control_data(card, s1, iob);
1926 qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1928 (struct qeth_card *,struct qeth_reply*, unsigned long),
1934 QETH_DBF_TEXT(trace,4,"sendipa");
1936 if (card->options.layer2)
1937 if (card->info.type == QETH_CARD_TYPE_OSN)
1938 prot_type = QETH_PROT_OSN2;
1940 prot_type = QETH_PROT_LAYER2;
1942 prot_type = QETH_PROT_TCPIP;
1943 qeth_prepare_ipa_cmd(card,iob,prot_type);
1944 rc = qeth_send_control_data(card, IPA_CMD_LENGTH, iob,
1945 reply_cb, reply_param);
1951 qeth_cm_enable_cb(struct qeth_card *card, struct qeth_reply *reply,
1954 struct qeth_cmd_buffer *iob;
1956 QETH_DBF_TEXT(setup, 2, "cmenblcb");
1958 iob = (struct qeth_cmd_buffer *) data;
1959 memcpy(&card->token.cm_filter_r,
1960 QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob->data),
1961 QETH_MPC_TOKEN_LENGTH);
1962 QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc);
1967 qeth_cm_enable(struct qeth_card *card)
1970 struct qeth_cmd_buffer *iob;
1972 QETH_DBF_TEXT(setup,2,"cmenable");
1974 iob = qeth_wait_for_buffer(&card->write);
1975 memcpy(iob->data, CM_ENABLE, CM_ENABLE_SIZE);
1976 memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob->data),
1977 &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH);
1978 memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob->data),
1979 &card->token.cm_filter_w, QETH_MPC_TOKEN_LENGTH);
1981 rc = qeth_send_control_data(card, CM_ENABLE_SIZE, iob,
1982 qeth_cm_enable_cb, NULL);
1987 qeth_cm_setup_cb(struct qeth_card *card, struct qeth_reply *reply,
1991 struct qeth_cmd_buffer *iob;
1993 QETH_DBF_TEXT(setup, 2, "cmsetpcb");
1995 iob = (struct qeth_cmd_buffer *) data;
1996 memcpy(&card->token.cm_connection_r,
1997 QETH_CM_SETUP_RESP_DEST_ADDR(iob->data),
1998 QETH_MPC_TOKEN_LENGTH);
1999 QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc);
2004 qeth_cm_setup(struct qeth_card *card)
2007 struct qeth_cmd_buffer *iob;
2009 QETH_DBF_TEXT(setup,2,"cmsetup");
2011 iob = qeth_wait_for_buffer(&card->write);
2012 memcpy(iob->data, CM_SETUP, CM_SETUP_SIZE);
2013 memcpy(QETH_CM_SETUP_DEST_ADDR(iob->data),
2014 &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH);
2015 memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob->data),
2016 &card->token.cm_connection_w, QETH_MPC_TOKEN_LENGTH);
2017 memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob->data),
2018 &card->token.cm_filter_r, QETH_MPC_TOKEN_LENGTH);
2019 rc = qeth_send_control_data(card, CM_SETUP_SIZE, iob,
2020 qeth_cm_setup_cb, NULL);
2026 qeth_ulp_enable_cb(struct qeth_card *card, struct qeth_reply *reply,
2030 __u16 mtu, framesize;
2033 struct qeth_cmd_buffer *iob;
2035 QETH_DBF_TEXT(setup, 2, "ulpenacb");
2037 iob = (struct qeth_cmd_buffer *) data;
2038 memcpy(&card->token.ulp_filter_r,
2039 QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob->data),
2040 QETH_MPC_TOKEN_LENGTH);
2041 if (qeth_get_mtu_out_of_mpc(card->info.type)) {
2042 memcpy(&framesize, QETH_ULP_ENABLE_RESP_MAX_MTU(iob->data), 2);
2043 mtu = qeth_get_mtu_outof_framesize(framesize);
2046 QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc);
2049 card->info.max_mtu = mtu;
2050 card->info.initial_mtu = mtu;
2051 card->qdio.in_buf_size = mtu + 2 * PAGE_SIZE;
2053 card->info.initial_mtu = qeth_get_initial_mtu_for_card(card);
2054 card->info.max_mtu = qeth_get_max_mtu_for_card(card->info.type);
2055 card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT;
2058 memcpy(&len, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob->data), 2);
2059 if (len >= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE) {
2061 QETH_ULP_ENABLE_RESP_LINK_TYPE(iob->data), 1);
2062 card->info.link_type = link_type;
2064 card->info.link_type = 0;
2065 QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc);
2070 qeth_ulp_enable(struct qeth_card *card)
2074 struct qeth_cmd_buffer *iob;
2076 /*FIXME: trace view callbacks*/
2077 QETH_DBF_TEXT(setup,2,"ulpenabl");
2079 iob = qeth_wait_for_buffer(&card->write);
2080 memcpy(iob->data, ULP_ENABLE, ULP_ENABLE_SIZE);
2082 *(QETH_ULP_ENABLE_LINKNUM(iob->data)) =
2083 (__u8) card->info.portno;
2084 if (card->options.layer2)
2085 if (card->info.type == QETH_CARD_TYPE_OSN)
2086 prot_type = QETH_PROT_OSN2;
2088 prot_type = QETH_PROT_LAYER2;
2090 prot_type = QETH_PROT_TCPIP;
2092 memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob->data),&prot_type,1);
2093 memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob->data),
2094 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
2095 memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob->data),
2096 &card->token.ulp_filter_w, QETH_MPC_TOKEN_LENGTH);
2097 memcpy(QETH_ULP_ENABLE_PORTNAME_AND_LL(iob->data),
2098 card->info.portname, 9);
2099 rc = qeth_send_control_data(card, ULP_ENABLE_SIZE, iob,
2100 qeth_ulp_enable_cb, NULL);
2106 __raw_devno_from_bus_id(char *id)
2108 id += (strlen(id) - 4);
2109 return (__u16) simple_strtoul(id, &id, 16);
2113 qeth_ulp_setup_cb(struct qeth_card *card, struct qeth_reply *reply,
2116 struct qeth_cmd_buffer *iob;
2118 QETH_DBF_TEXT(setup, 2, "ulpstpcb");
2120 iob = (struct qeth_cmd_buffer *) data;
2121 memcpy(&card->token.ulp_connection_r,
2122 QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob->data),
2123 QETH_MPC_TOKEN_LENGTH);
2124 QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc);
2129 qeth_ulp_setup(struct qeth_card *card)
2133 struct qeth_cmd_buffer *iob;
2135 QETH_DBF_TEXT(setup,2,"ulpsetup");
2137 iob = qeth_wait_for_buffer(&card->write);
2138 memcpy(iob->data, ULP_SETUP, ULP_SETUP_SIZE);
2140 memcpy(QETH_ULP_SETUP_DEST_ADDR(iob->data),
2141 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
2142 memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob->data),
2143 &card->token.ulp_connection_w, QETH_MPC_TOKEN_LENGTH);
2144 memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob->data),
2145 &card->token.ulp_filter_r, QETH_MPC_TOKEN_LENGTH);
2147 temp = __raw_devno_from_bus_id(CARD_DDEV_ID(card));
2148 memcpy(QETH_ULP_SETUP_CUA(iob->data), &temp, 2);
2149 temp = (card->info.cula << 8) + card->info.unit_addr2;
2150 memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob->data), &temp, 2);
2151 rc = qeth_send_control_data(card, ULP_SETUP_SIZE, iob,
2152 qeth_ulp_setup_cb, NULL);
2157 qeth_check_for_inbound_error(struct qeth_qdio_buffer *buf,
2158 unsigned int qdio_error,
2159 unsigned int siga_error)
2163 if (qdio_error || siga_error) {
2164 QETH_DBF_TEXT(trace, 2, "qdinerr");
2165 QETH_DBF_TEXT(qerr, 2, "qdinerr");
2166 QETH_DBF_TEXT_(qerr, 2, " F15=%02X",
2167 buf->buffer->element[15].flags & 0xff);
2168 QETH_DBF_TEXT_(qerr, 2, " F14=%02X",
2169 buf->buffer->element[14].flags & 0xff);
2170 QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error);
2171 QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error);
2177 static inline struct sk_buff *
2178 qeth_get_skb(unsigned int length, struct qeth_hdr *hdr)
2180 struct sk_buff* skb;
2184 if (hdr->hdr.osn.id == QETH_HEADER_TYPE_OSN)
2185 add_len = sizeof(struct qeth_hdr);
2186 #ifdef CONFIG_QETH_VLAN
2188 add_len = VLAN_HLEN;
2190 skb = dev_alloc_skb(length + add_len);
2192 skb_reserve(skb, add_len);
2196 static inline struct sk_buff *
2197 qeth_get_next_skb(struct qeth_card *card, struct qdio_buffer *buffer,
2198 struct qdio_buffer_element **__element, int *__offset,
2199 struct qeth_hdr **hdr)
2201 struct qdio_buffer_element *element = *__element;
2202 int offset = *__offset;
2203 struct sk_buff *skb = NULL;
2208 QETH_DBF_TEXT(trace,6,"nextskb");
2209 /* qeth_hdr must not cross element boundaries */
2210 if (element->length < offset + sizeof(struct qeth_hdr)){
2211 if (qeth_is_last_sbale(element))
2215 if (element->length < sizeof(struct qeth_hdr))
2218 *hdr = element->addr + offset;
2220 offset += sizeof(struct qeth_hdr);
2221 if (card->options.layer2)
2222 if (card->info.type == QETH_CARD_TYPE_OSN)
2223 skb_len = (*hdr)->hdr.osn.pdu_length;
2225 skb_len = (*hdr)->hdr.l2.pkt_length;
2227 skb_len = (*hdr)->hdr.l3.length;
2231 if (card->options.fake_ll){
2232 if(card->dev->type == ARPHRD_IEEE802_TR){
2233 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_TR, *hdr)))
2235 skb_reserve(skb,QETH_FAKE_LL_LEN_TR);
2237 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_ETH, *hdr)))
2239 skb_reserve(skb,QETH_FAKE_LL_LEN_ETH);
2241 } else if (!(skb = qeth_get_skb(skb_len, *hdr)))
2243 data_ptr = element->addr + offset;
2245 data_len = min(skb_len, (int)(element->length - offset));
2247 memcpy(skb_put(skb, data_len), data_ptr, data_len);
2248 skb_len -= data_len;
2250 if (qeth_is_last_sbale(element)){
2251 QETH_DBF_TEXT(trace,4,"unexeob");
2252 QETH_DBF_TEXT_(trace,4,"%s",CARD_BUS_ID(card));
2253 QETH_DBF_TEXT(qerr,2,"unexeob");
2254 QETH_DBF_TEXT_(qerr,2,"%s",CARD_BUS_ID(card));
2255 QETH_DBF_HEX(misc,4,buffer,sizeof(*buffer));
2256 dev_kfree_skb_any(skb);
2257 card->stats.rx_errors++;
2262 data_ptr = element->addr;
2267 *__element = element;
2271 if (net_ratelimit()){
2272 PRINT_WARN("No memory for packet received on %s.\n",
2273 QETH_CARD_IFNAME(card));
2274 QETH_DBF_TEXT(trace,2,"noskbmem");
2275 QETH_DBF_TEXT_(trace,2,"%s",CARD_BUS_ID(card));
2277 card->stats.rx_dropped++;
2281 static inline __be16
2282 qeth_type_trans(struct sk_buff *skb, struct net_device *dev)
2284 struct qeth_card *card;
2287 QETH_DBF_TEXT(trace,6,"typtrans");
2289 card = (struct qeth_card *)dev->priv;
2291 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) ||
2292 (card->info.link_type == QETH_LINK_TYPE_LANE_TR))
2293 return tr_type_trans(skb,dev);
2294 #endif /* CONFIG_TR */
2295 skb->mac.raw = skb->data;
2296 skb_pull(skb, ETH_HLEN );
2299 if (*eth->h_dest & 1) {
2300 if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0)
2301 skb->pkt_type = PACKET_BROADCAST;
2303 skb->pkt_type = PACKET_MULTICAST;
2304 } else if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN))
2305 skb->pkt_type = PACKET_OTHERHOST;
2307 if (ntohs(eth->h_proto) >= 1536)
2308 return eth->h_proto;
2309 if (*(unsigned short *) (skb->data) == 0xFFFF)
2310 return htons(ETH_P_802_3);
2311 return htons(ETH_P_802_2);
2315 qeth_rebuild_skb_fake_ll_tr(struct qeth_card *card, struct sk_buff *skb,
2316 struct qeth_hdr *hdr)
2318 struct trh_hdr *fake_hdr;
2319 struct trllc *fake_llc;
2320 struct iphdr *ip_hdr;
2322 QETH_DBF_TEXT(trace,5,"skbfktr");
2323 skb->mac.raw = skb->data - QETH_FAKE_LL_LEN_TR;
2324 /* this is a fake ethernet header */
2325 fake_hdr = (struct trh_hdr *) skb->mac.raw;
2327 /* the destination MAC address */
2328 switch (skb->pkt_type){
2329 case PACKET_MULTICAST:
2330 switch (skb->protocol){
2331 #ifdef CONFIG_QETH_IPV6
2332 case __constant_htons(ETH_P_IPV6):
2333 ndisc_mc_map((struct in6_addr *)
2334 skb->data + QETH_FAKE_LL_V6_ADDR_POS,
2335 fake_hdr->daddr, card->dev, 0);
2337 #endif /* CONFIG_QETH_IPV6 */
2338 case __constant_htons(ETH_P_IP):
2339 ip_hdr = (struct iphdr *)skb->data;
2340 ip_tr_mc_map(ip_hdr->daddr, fake_hdr->daddr);
2343 memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN);
2346 case PACKET_BROADCAST:
2347 memset(fake_hdr->daddr, 0xff, TR_ALEN);
2350 memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN);
2352 /* the source MAC address */
2353 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
2354 memcpy(fake_hdr->saddr, &hdr->hdr.l3.dest_addr[2], TR_ALEN);
2356 memset(fake_hdr->saddr, 0, TR_ALEN);
2358 fake_llc = (struct trllc*)&(fake_hdr->rcf);
2359 fake_llc->dsap = EXTENDED_SAP;
2360 fake_llc->ssap = EXTENDED_SAP;
2361 fake_llc->llc = UI_CMD;
2362 fake_llc->protid[0] = 0;
2363 fake_llc->protid[1] = 0;
2364 fake_llc->protid[2] = 0;
2365 fake_llc->ethertype = ETH_P_IP;
2369 qeth_rebuild_skb_fake_ll_eth(struct qeth_card *card, struct sk_buff *skb,
2370 struct qeth_hdr *hdr)
2372 struct ethhdr *fake_hdr;
2373 struct iphdr *ip_hdr;
2375 QETH_DBF_TEXT(trace,5,"skbfketh");
2376 skb->mac.raw = skb->data - QETH_FAKE_LL_LEN_ETH;
2377 /* this is a fake ethernet header */
2378 fake_hdr = (struct ethhdr *) skb->mac.raw;
2380 /* the destination MAC address */
2381 switch (skb->pkt_type){
2382 case PACKET_MULTICAST:
2383 switch (skb->protocol){
2384 #ifdef CONFIG_QETH_IPV6
2385 case __constant_htons(ETH_P_IPV6):
2386 ndisc_mc_map((struct in6_addr *)
2387 skb->data + QETH_FAKE_LL_V6_ADDR_POS,
2388 fake_hdr->h_dest, card->dev, 0);
2390 #endif /* CONFIG_QETH_IPV6 */
2391 case __constant_htons(ETH_P_IP):
2392 ip_hdr = (struct iphdr *)skb->data;
2393 ip_eth_mc_map(ip_hdr->daddr, fake_hdr->h_dest);
2396 memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN);
2399 case PACKET_BROADCAST:
2400 memset(fake_hdr->h_dest, 0xff, ETH_ALEN);
2403 memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN);
2405 /* the source MAC address */
2406 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
2407 memcpy(fake_hdr->h_source, &hdr->hdr.l3.dest_addr[2], ETH_ALEN);
2409 memset(fake_hdr->h_source, 0, ETH_ALEN);
2411 fake_hdr->h_proto = skb->protocol;
2415 qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb,
2416 struct qeth_hdr *hdr)
2418 if (card->dev->type == ARPHRD_IEEE802_TR)
2419 qeth_rebuild_skb_fake_ll_tr(card, skb, hdr);
2421 qeth_rebuild_skb_fake_ll_eth(card, skb, hdr);
2425 qeth_rebuild_skb_vlan(struct qeth_card *card, struct sk_buff *skb,
2426 struct qeth_hdr *hdr)
2428 #ifdef CONFIG_QETH_VLAN
2431 if (hdr->hdr.l3.ext_flags &
2432 (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) {
2433 vlan_tag = (u16 *) skb_push(skb, VLAN_HLEN);
2434 *vlan_tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)?
2435 hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]);
2436 *(vlan_tag + 1) = skb->protocol;
2437 skb->protocol = __constant_htons(ETH_P_8021Q);
2439 #endif /* CONFIG_QETH_VLAN */
2443 qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
2444 struct qeth_hdr *hdr)
2446 unsigned short vlan_id = 0;
2447 #ifdef CONFIG_QETH_VLAN
2448 struct vlan_hdr *vhdr;
2451 skb->pkt_type = PACKET_HOST;
2452 skb->protocol = qeth_type_trans(skb, skb->dev);
2453 if (card->options.checksum_type == NO_CHECKSUMMING)
2454 skb->ip_summed = CHECKSUM_UNNECESSARY;
2456 skb->ip_summed = CHECKSUM_NONE;
2457 #ifdef CONFIG_QETH_VLAN
2458 if (hdr->hdr.l2.flags[2] & (QETH_LAYER2_FLAG_VLAN)) {
2459 vhdr = (struct vlan_hdr *) skb->data;
2461 __constant_htons(vhdr->h_vlan_encapsulated_proto);
2462 vlan_id = hdr->hdr.l2.vlan_id;
2463 skb_pull(skb, VLAN_HLEN);
2466 *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
2471 qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
2472 struct qeth_hdr *hdr)
2474 #ifdef CONFIG_QETH_IPV6
2475 if (hdr->hdr.l3.flags & QETH_HDR_PASSTHRU) {
2476 skb->pkt_type = PACKET_HOST;
2477 skb->protocol = qeth_type_trans(skb, card->dev);
2480 #endif /* CONFIG_QETH_IPV6 */
2481 skb->protocol = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 :
2483 switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK){
2484 case QETH_CAST_UNICAST:
2485 skb->pkt_type = PACKET_HOST;
2487 case QETH_CAST_MULTICAST:
2488 skb->pkt_type = PACKET_MULTICAST;
2489 card->stats.multicast++;
2491 case QETH_CAST_BROADCAST:
2492 skb->pkt_type = PACKET_BROADCAST;
2493 card->stats.multicast++;
2495 case QETH_CAST_ANYCAST:
2496 case QETH_CAST_NOCAST:
2498 skb->pkt_type = PACKET_HOST;
2500 qeth_rebuild_skb_vlan(card, skb, hdr);
2501 if (card->options.fake_ll)
2502 qeth_rebuild_skb_fake_ll(card, skb, hdr);
2504 skb->mac.raw = skb->data;
2505 skb->ip_summed = card->options.checksum_type;
2506 if (card->options.checksum_type == HW_CHECKSUMMING){
2507 if ( (hdr->hdr.l3.ext_flags &
2508 (QETH_HDR_EXT_CSUM_HDR_REQ |
2509 QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
2510 (QETH_HDR_EXT_CSUM_HDR_REQ |
2511 QETH_HDR_EXT_CSUM_TRANSP_REQ) )
2512 skb->ip_summed = CHECKSUM_UNNECESSARY;
2514 skb->ip_summed = SW_CHECKSUMMING;
2519 qeth_process_inbound_buffer(struct qeth_card *card,
2520 struct qeth_qdio_buffer *buf, int index)
2522 struct qdio_buffer_element *element;
2523 struct sk_buff *skb;
2524 struct qeth_hdr *hdr;
2529 /* get first element of current buffer */
2530 element = (struct qdio_buffer_element *)&buf->buffer->element[0];
2532 #ifdef CONFIG_QETH_PERF_STATS
2533 card->perf_stats.bufs_rec++;
2535 while((skb = qeth_get_next_skb(card, buf->buffer, &element,
2537 skb->dev = card->dev;
2538 if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
2539 vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr);
2540 else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3)
2541 qeth_rebuild_skb(card, skb, hdr);
2542 else { /*in case of OSN*/
2543 skb_push(skb, sizeof(struct qeth_hdr));
2544 memcpy(skb->data, hdr, sizeof(struct qeth_hdr));
2546 /* is device UP ? */
2547 if (!(card->dev->flags & IFF_UP)){
2548 dev_kfree_skb_any(skb);
2551 #ifdef CONFIG_QETH_VLAN
2553 vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag);
2556 if (card->info.type == QETH_CARD_TYPE_OSN)
2557 rxrc = card->osn_info.data_cb(skb);
2559 rxrc = netif_rx(skb);
2560 card->dev->last_rx = jiffies;
2561 card->stats.rx_packets++;
2562 card->stats.rx_bytes += skb->len;
2566 static inline struct qeth_buffer_pool_entry *
2567 qeth_get_buffer_pool_entry(struct qeth_card *card)
2569 struct qeth_buffer_pool_entry *entry;
2571 QETH_DBF_TEXT(trace, 6, "gtbfplen");
2572 if (!list_empty(&card->qdio.in_buf_pool.entry_list)) {
2573 entry = list_entry(card->qdio.in_buf_pool.entry_list.next,
2574 struct qeth_buffer_pool_entry, list);
2575 list_del_init(&entry->list);
2582 qeth_init_input_buffer(struct qeth_card *card, struct qeth_qdio_buffer *buf)
2584 struct qeth_buffer_pool_entry *pool_entry;
2587 pool_entry = qeth_get_buffer_pool_entry(card);
2589 * since the buffer is accessed only from the input_tasklet
2590 * there shouldn't be a need to synchronize; also, since we use
2591 * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off
2594 BUG_ON(!pool_entry);
2596 buf->pool_entry = pool_entry;
2597 for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i){
2598 buf->buffer->element[i].length = PAGE_SIZE;
2599 buf->buffer->element[i].addr = pool_entry->elements[i];
2600 if (i == QETH_MAX_BUFFER_ELEMENTS(card) - 1)
2601 buf->buffer->element[i].flags = SBAL_FLAGS_LAST_ENTRY;
2603 buf->buffer->element[i].flags = 0;
2605 buf->state = QETH_QDIO_BUF_EMPTY;
2609 qeth_clear_output_buffer(struct qeth_qdio_out_q *queue,
2610 struct qeth_qdio_out_buffer *buf)
2613 struct sk_buff *skb;
2615 /* is PCI flag set on buffer? */
2616 if (buf->buffer->element[0].flags & 0x40)
2617 atomic_dec(&queue->set_pci_flags_count);
2619 while ((skb = skb_dequeue(&buf->skb_list))){
2620 atomic_dec(&skb->users);
2621 dev_kfree_skb_any(skb);
2623 qeth_eddp_buf_release_contexts(buf);
2624 for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(queue->card); ++i){
2625 buf->buffer->element[i].length = 0;
2626 buf->buffer->element[i].addr = NULL;
2627 buf->buffer->element[i].flags = 0;
2629 buf->next_element_to_fill = 0;
2630 atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY);
2634 qeth_queue_input_buffer(struct qeth_card *card, int index)
2636 struct qeth_qdio_q *queue = card->qdio.in_q;
2641 QETH_DBF_TEXT(trace,6,"queinbuf");
2642 count = (index < queue->next_buf_to_init)?
2643 card->qdio.in_buf_pool.buf_count -
2644 (queue->next_buf_to_init - index) :
2645 card->qdio.in_buf_pool.buf_count -
2646 (queue->next_buf_to_init + QDIO_MAX_BUFFERS_PER_Q - index);
2647 /* only requeue at a certain threshold to avoid SIGAs */
2648 if (count >= QETH_IN_BUF_REQUEUE_THRESHOLD(card)){
2649 for (i = queue->next_buf_to_init;
2650 i < queue->next_buf_to_init + count; ++i)
2651 qeth_init_input_buffer(card,
2652 &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]);
2654 * according to old code it should be avoided to requeue all
2655 * 128 buffers in order to benefit from PCI avoidance.
2656 * this function keeps at least one buffer (the buffer at
2657 * 'index') un-requeued -> this buffer is the first buffer that
2658 * will be requeued the next time
2660 #ifdef CONFIG_QETH_PERF_STATS
2661 card->perf_stats.inbound_do_qdio_cnt++;
2662 card->perf_stats.inbound_do_qdio_start_time = qeth_get_micros();
2664 rc = do_QDIO(CARD_DDEV(card),
2665 QDIO_FLAG_SYNC_INPUT | QDIO_FLAG_UNDER_INTERRUPT,
2666 0, queue->next_buf_to_init, count, NULL);
2667 #ifdef CONFIG_QETH_PERF_STATS
2668 card->perf_stats.inbound_do_qdio_time += qeth_get_micros() -
2669 card->perf_stats.inbound_do_qdio_start_time;
2672 PRINT_WARN("qeth_queue_input_buffer's do_QDIO "
2673 "return %i (device %s).\n",
2674 rc, CARD_DDEV_ID(card));
2675 QETH_DBF_TEXT(trace,2,"qinberr");
2676 QETH_DBF_TEXT_(trace,2,"%s",CARD_BUS_ID(card));
2678 queue->next_buf_to_init = (queue->next_buf_to_init + count) %
2679 QDIO_MAX_BUFFERS_PER_Q;
2684 qeth_put_buffer_pool_entry(struct qeth_card *card,
2685 struct qeth_buffer_pool_entry *entry)
2687 QETH_DBF_TEXT(trace, 6, "ptbfplen");
2688 list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
2692 qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2693 unsigned int qdio_err, unsigned int siga_err,
2694 unsigned int queue, int first_element, int count,
2695 unsigned long card_ptr)
2697 struct net_device *net_dev;
2698 struct qeth_card *card;
2699 struct qeth_qdio_buffer *buffer;
2703 QETH_DBF_TEXT(trace, 6, "qdinput");
2704 card = (struct qeth_card *) card_ptr;
2705 net_dev = card->dev;
2706 #ifdef CONFIG_QETH_PERF_STATS
2707 card->perf_stats.inbound_cnt++;
2708 card->perf_stats.inbound_start_time = qeth_get_micros();
2710 if (status & QDIO_STATUS_LOOK_FOR_ERROR) {
2711 if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){
2712 QETH_DBF_TEXT(trace, 1,"qdinchk");
2713 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2714 QETH_DBF_TEXT_(trace,1,"%04X%04X",first_element,count);
2715 QETH_DBF_TEXT_(trace,1,"%04X%04X", queue, status);
2716 qeth_schedule_recovery(card);
2720 for (i = first_element; i < (first_element + count); ++i) {
2721 index = i % QDIO_MAX_BUFFERS_PER_Q;
2722 buffer = &card->qdio.in_q->bufs[index];
2723 if (!((status == QDIO_STATUS_LOOK_FOR_ERROR) &&
2724 qeth_check_for_inbound_error(buffer, qdio_err, siga_err)))
2725 qeth_process_inbound_buffer(card, buffer, index);
2726 /* clear buffer and give back to hardware */
2727 qeth_put_buffer_pool_entry(card, buffer->pool_entry);
2728 qeth_queue_input_buffer(card, index);
2730 #ifdef CONFIG_QETH_PERF_STATS
2731 card->perf_stats.inbound_time += qeth_get_micros() -
2732 card->perf_stats.inbound_start_time;
2737 qeth_handle_send_error(struct qeth_card *card,
2738 struct qeth_qdio_out_buffer *buffer,
2739 int qdio_err, int siga_err)
2741 int sbalf15 = buffer->buffer->element[15].flags & 0xff;
2742 int cc = siga_err & 3;
2744 QETH_DBF_TEXT(trace, 6, "hdsnderr");
2748 QETH_DBF_TEXT(trace, 1,"lnkfail");
2749 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2750 QETH_DBF_TEXT_(trace,1,"%04x %02x",
2751 (u16)qdio_err, (u8)sbalf15);
2752 return QETH_SEND_ERROR_LINK_FAILURE;
2754 return QETH_SEND_ERROR_NONE;
2756 if (siga_err & QDIO_SIGA_ERROR_B_BIT_SET) {
2757 QETH_DBF_TEXT(trace, 1, "SIGAcc2B");
2758 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2759 return QETH_SEND_ERROR_KICK_IT;
2761 if ((sbalf15 >= 15) && (sbalf15 <= 31))
2762 return QETH_SEND_ERROR_RETRY;
2763 return QETH_SEND_ERROR_LINK_FAILURE;
2764 /* look at qdio_error and sbalf 15 */
2766 QETH_DBF_TEXT(trace, 1, "SIGAcc1");
2767 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2768 return QETH_SEND_ERROR_LINK_FAILURE;
2770 QETH_DBF_TEXT(trace, 1, "SIGAcc3");
2771 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2772 return QETH_SEND_ERROR_KICK_IT;
2774 return QETH_SEND_ERROR_LINK_FAILURE;
2778 qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int,
2779 int index, int count)
2781 struct qeth_qdio_out_buffer *buf;
2785 QETH_DBF_TEXT(trace, 6, "flushbuf");
2787 for (i = index; i < index + count; ++i) {
2788 buf = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q];
2789 buf->buffer->element[buf->next_element_to_fill - 1].flags |=
2790 SBAL_FLAGS_LAST_ENTRY;
2792 if (queue->card->info.type == QETH_CARD_TYPE_IQD)
2795 if (!queue->do_pack){
2796 if ((atomic_read(&queue->used_buffers) >=
2797 (QETH_HIGH_WATERMARK_PACK -
2798 QETH_WATERMARK_PACK_FUZZ)) &&
2799 !atomic_read(&queue->set_pci_flags_count)){
2800 /* it's likely that we'll go to packing
2802 atomic_inc(&queue->set_pci_flags_count);
2803 buf->buffer->element[0].flags |= 0x40;
2806 if (!atomic_read(&queue->set_pci_flags_count)){
2808 * there's no outstanding PCI any more, so we
2809 * have to request a PCI to be sure the the PCI
2810 * will wake at some time in the future then we
2811 * can flush packed buffers that might still be
2812 * hanging around, which can happen if no
2813 * further send was requested by the stack
2815 atomic_inc(&queue->set_pci_flags_count);
2816 buf->buffer->element[0].flags |= 0x40;
2821 queue->card->dev->trans_start = jiffies;
2822 #ifdef CONFIG_QETH_PERF_STATS
2823 queue->card->perf_stats.outbound_do_qdio_cnt++;
2824 queue->card->perf_stats.outbound_do_qdio_start_time = qeth_get_micros();
2827 rc = do_QDIO(CARD_DDEV(queue->card),
2828 QDIO_FLAG_SYNC_OUTPUT | QDIO_FLAG_UNDER_INTERRUPT,
2829 queue->queue_no, index, count, NULL);
2831 rc = do_QDIO(CARD_DDEV(queue->card), QDIO_FLAG_SYNC_OUTPUT,
2832 queue->queue_no, index, count, NULL);
2833 #ifdef CONFIG_QETH_PERF_STATS
2834 queue->card->perf_stats.outbound_do_qdio_time += qeth_get_micros() -
2835 queue->card->perf_stats.outbound_do_qdio_start_time;
2838 QETH_DBF_TEXT(trace, 2, "flushbuf");
2839 QETH_DBF_TEXT_(trace, 2, " err%d", rc);
2840 QETH_DBF_TEXT_(trace, 2, "%s", CARD_DDEV_ID(queue->card));
2841 queue->card->stats.tx_errors += count;
2842 /* this must not happen under normal circumstances. if it
2843 * happens something is really wrong -> recover */
2844 qeth_schedule_recovery(queue->card);
2847 atomic_add(count, &queue->used_buffers);
2848 #ifdef CONFIG_QETH_PERF_STATS
2849 queue->card->perf_stats.bufs_sent += count;
2854 * Switched to packing state if the number of used buffers on a queue
2855 * reaches a certain limit.
2858 qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue)
2860 if (!queue->do_pack) {
2861 if (atomic_read(&queue->used_buffers)
2862 >= QETH_HIGH_WATERMARK_PACK){
2863 /* switch non-PACKING -> PACKING */
2864 QETH_DBF_TEXT(trace, 6, "np->pack");
2865 #ifdef CONFIG_QETH_PERF_STATS
2866 queue->card->perf_stats.sc_dp_p++;
2874 * Switches from packing to non-packing mode. If there is a packing
2875 * buffer on the queue this buffer will be prepared to be flushed.
2876 * In that case 1 is returned to inform the caller. If no buffer
2877 * has to be flushed, zero is returned.
2880 qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue)
2882 struct qeth_qdio_out_buffer *buffer;
2883 int flush_count = 0;
2885 if (queue->do_pack) {
2886 if (atomic_read(&queue->used_buffers)
2887 <= QETH_LOW_WATERMARK_PACK) {
2888 /* switch PACKING -> non-PACKING */
2889 QETH_DBF_TEXT(trace, 6, "pack->np");
2890 #ifdef CONFIG_QETH_PERF_STATS
2891 queue->card->perf_stats.sc_p_dp++;
2894 /* flush packing buffers */
2895 buffer = &queue->bufs[queue->next_buf_to_fill];
2896 if ((atomic_read(&buffer->state) ==
2897 QETH_QDIO_BUF_EMPTY) &&
2898 (buffer->next_element_to_fill > 0)) {
2899 atomic_set(&buffer->state,QETH_QDIO_BUF_PRIMED);
2901 queue->next_buf_to_fill =
2902 (queue->next_buf_to_fill + 1) %
2903 QDIO_MAX_BUFFERS_PER_Q;
2911 * Called to flush a packing buffer if no more pci flags are on the queue.
2912 * Checks if there is a packing buffer and prepares it to be flushed.
2913 * In that case returns 1, otherwise zero.
2916 qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q *queue)
2918 struct qeth_qdio_out_buffer *buffer;
2920 buffer = &queue->bufs[queue->next_buf_to_fill];
2921 if((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) &&
2922 (buffer->next_element_to_fill > 0)){
2923 /* it's a packing buffer */
2924 atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED);
2925 queue->next_buf_to_fill =
2926 (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q;
2933 qeth_check_outbound_queue(struct qeth_qdio_out_q *queue)
2937 int q_was_packing = 0;
2940 * check if weed have to switch to non-packing mode or if
2941 * we have to get a pci flag out on the queue
2943 if ((atomic_read(&queue->used_buffers) <= QETH_LOW_WATERMARK_PACK) ||
2944 !atomic_read(&queue->set_pci_flags_count)){
2945 if (atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) ==
2946 QETH_OUT_Q_UNLOCKED) {
2948 * If we get in here, there was no action in
2949 * do_send_packet. So, we check if there is a
2950 * packing buffer to be flushed here.
2952 netif_stop_queue(queue->card->dev);
2953 index = queue->next_buf_to_fill;
2954 q_was_packing = queue->do_pack;
2955 flush_cnt += qeth_switch_to_nonpacking_if_needed(queue);
2957 !atomic_read(&queue->set_pci_flags_count))
2959 qeth_flush_buffers_on_no_pci(queue);
2960 #ifdef CONFIG_QETH_PERF_STATS
2962 queue->card->perf_stats.bufs_sent_pack +=
2966 qeth_flush_buffers(queue, 1, index, flush_cnt);
2967 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
2973 qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status,
2974 unsigned int qdio_error, unsigned int siga_error,
2975 unsigned int __queue, int first_element, int count,
2976 unsigned long card_ptr)
2978 struct qeth_card *card = (struct qeth_card *) card_ptr;
2979 struct qeth_qdio_out_q *queue = card->qdio.out_qs[__queue];
2980 struct qeth_qdio_out_buffer *buffer;
2983 QETH_DBF_TEXT(trace, 6, "qdouhdl");
2984 if (status & QDIO_STATUS_LOOK_FOR_ERROR) {
2985 if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){
2986 QETH_DBF_TEXT(trace, 2, "achkcond");
2987 QETH_DBF_TEXT_(trace, 2, "%s", CARD_BUS_ID(card));
2988 QETH_DBF_TEXT_(trace, 2, "%08x", status);
2989 netif_stop_queue(card->dev);
2990 qeth_schedule_recovery(card);
2994 #ifdef CONFIG_QETH_PERF_STATS
2995 card->perf_stats.outbound_handler_cnt++;
2996 card->perf_stats.outbound_handler_start_time = qeth_get_micros();
2998 for(i = first_element; i < (first_element + count); ++i){
2999 buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q];
3000 /*we only handle the KICK_IT error by doing a recovery */
3001 if (qeth_handle_send_error(card, buffer, qdio_error, siga_error)
3002 == QETH_SEND_ERROR_KICK_IT){
3003 netif_stop_queue(card->dev);
3004 qeth_schedule_recovery(card);
3007 qeth_clear_output_buffer(queue, buffer);
3009 atomic_sub(count, &queue->used_buffers);
3010 /* check if we need to do something on this outbound queue */
3011 if (card->info.type != QETH_CARD_TYPE_IQD)
3012 qeth_check_outbound_queue(queue);
3014 netif_wake_queue(queue->card->dev);
3015 #ifdef CONFIG_QETH_PERF_STATS
3016 card->perf_stats.outbound_handler_time += qeth_get_micros() -
3017 card->perf_stats.outbound_handler_start_time;
3022 qeth_create_qib_param_field(struct qeth_card *card, char *param_field)
3025 param_field[0] = _ascebc['P'];
3026 param_field[1] = _ascebc['C'];
3027 param_field[2] = _ascebc['I'];
3028 param_field[3] = _ascebc['T'];
3029 *((unsigned int *) (¶m_field[4])) = QETH_PCI_THRESHOLD_A(card);
3030 *((unsigned int *) (¶m_field[8])) = QETH_PCI_THRESHOLD_B(card);
3031 *((unsigned int *) (¶m_field[12])) = QETH_PCI_TIMER_VALUE(card);
3035 qeth_create_qib_param_field_blkt(struct qeth_card *card, char *param_field)
3037 param_field[16] = _ascebc['B'];
3038 param_field[17] = _ascebc['L'];
3039 param_field[18] = _ascebc['K'];
3040 param_field[19] = _ascebc['T'];
3041 *((unsigned int *) (¶m_field[20])) = card->info.blkt.time_total;
3042 *((unsigned int *) (¶m_field[24])) = card->info.blkt.inter_packet;
3043 *((unsigned int *) (¶m_field[28])) = card->info.blkt.inter_packet_jumbo;
3047 qeth_initialize_working_pool_list(struct qeth_card *card)
3049 struct qeth_buffer_pool_entry *entry;
3051 QETH_DBF_TEXT(trace,5,"inwrklst");
3053 list_for_each_entry(entry,
3054 &card->qdio.init_pool.entry_list, init_list) {
3055 qeth_put_buffer_pool_entry(card,entry);
3060 qeth_clear_working_pool_list(struct qeth_card *card)
3062 struct qeth_buffer_pool_entry *pool_entry, *tmp;
3064 QETH_DBF_TEXT(trace,5,"clwrklst");
3065 list_for_each_entry_safe(pool_entry, tmp,
3066 &card->qdio.in_buf_pool.entry_list, list){
3067 list_del(&pool_entry->list);
3072 qeth_free_buffer_pool(struct qeth_card *card)
3074 struct qeth_buffer_pool_entry *pool_entry, *tmp;
3076 QETH_DBF_TEXT(trace,5,"freepool");
3077 list_for_each_entry_safe(pool_entry, tmp,
3078 &card->qdio.init_pool.entry_list, init_list){
3079 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i)
3080 free_page((unsigned long)pool_entry->elements[i]);
3081 list_del(&pool_entry->init_list);
3087 qeth_alloc_buffer_pool(struct qeth_card *card)
3089 struct qeth_buffer_pool_entry *pool_entry;
3093 QETH_DBF_TEXT(trace,5,"alocpool");
3094 for (i = 0; i < card->qdio.init_pool.buf_count; ++i){
3095 pool_entry = kmalloc(sizeof(*pool_entry), GFP_KERNEL);
3097 qeth_free_buffer_pool(card);
3100 for(j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j){
3101 ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA);
3104 free_page((unsigned long)
3105 pool_entry->elements[--j]);
3107 qeth_free_buffer_pool(card);
3110 pool_entry->elements[j] = ptr;
3112 list_add(&pool_entry->init_list,
3113 &card->qdio.init_pool.entry_list);
3119 qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt)
3121 QETH_DBF_TEXT(trace, 2, "realcbp");
3123 if ((card->state != CARD_STATE_DOWN) &&
3124 (card->state != CARD_STATE_RECOVER))
3127 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
3128 qeth_clear_working_pool_list(card);
3129 qeth_free_buffer_pool(card);
3130 card->qdio.in_buf_pool.buf_count = bufcnt;
3131 card->qdio.init_pool.buf_count = bufcnt;
3132 return qeth_alloc_buffer_pool(card);
3136 qeth_alloc_qdio_buffers(struct qeth_card *card)
3140 QETH_DBF_TEXT(setup, 2, "allcqdbf");
3142 if (card->qdio.state == QETH_QDIO_ALLOCATED)
3145 card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q),
3146 GFP_KERNEL|GFP_DMA);
3147 if (!card->qdio.in_q)
3149 QETH_DBF_TEXT(setup, 2, "inq");
3150 QETH_DBF_HEX(setup, 2, &card->qdio.in_q, sizeof(void *));
3151 memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q));
3152 /* give inbound qeth_qdio_buffers their qdio_buffers */
3153 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i)
3154 card->qdio.in_q->bufs[i].buffer =
3155 &card->qdio.in_q->qdio_bufs[i];
3156 /* inbound buffer pool */
3157 if (qeth_alloc_buffer_pool(card)){
3158 kfree(card->qdio.in_q);
3163 kmalloc(card->qdio.no_out_queues *
3164 sizeof(struct qeth_qdio_out_q *), GFP_KERNEL);
3165 if (!card->qdio.out_qs){
3166 qeth_free_buffer_pool(card);
3169 for (i = 0; i < card->qdio.no_out_queues; ++i){
3170 card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q),
3171 GFP_KERNEL|GFP_DMA);
3172 if (!card->qdio.out_qs[i]){
3174 kfree(card->qdio.out_qs[--i]);
3175 kfree(card->qdio.out_qs);
3178 QETH_DBF_TEXT_(setup, 2, "outq %i", i);
3179 QETH_DBF_HEX(setup, 2, &card->qdio.out_qs[i], sizeof(void *));
3180 memset(card->qdio.out_qs[i], 0, sizeof(struct qeth_qdio_out_q));
3181 card->qdio.out_qs[i]->queue_no = i;
3182 /* give outbound qeth_qdio_buffers their qdio_buffers */
3183 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j){
3184 card->qdio.out_qs[i]->bufs[j].buffer =
3185 &card->qdio.out_qs[i]->qdio_bufs[j];
3186 skb_queue_head_init(&card->qdio.out_qs[i]->bufs[j].
3188 INIT_LIST_HEAD(&card->qdio.out_qs[i]->bufs[j].ctx_list);
3191 card->qdio.state = QETH_QDIO_ALLOCATED;
3196 qeth_free_qdio_buffers(struct qeth_card *card)
3200 QETH_DBF_TEXT(trace, 2, "freeqdbf");
3201 if (card->qdio.state == QETH_QDIO_UNINITIALIZED)
3203 kfree(card->qdio.in_q);
3204 /* inbound buffer pool */
3205 qeth_free_buffer_pool(card);
3206 /* free outbound qdio_qs */
3207 for (i = 0; i < card->qdio.no_out_queues; ++i){
3208 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j)
3209 qeth_clear_output_buffer(card->qdio.out_qs[i],
3210 &card->qdio.out_qs[i]->bufs[j]);
3211 kfree(card->qdio.out_qs[i]);
3213 kfree(card->qdio.out_qs);
3214 card->qdio.state = QETH_QDIO_UNINITIALIZED;
3218 qeth_clear_qdio_buffers(struct qeth_card *card)
3222 QETH_DBF_TEXT(trace, 2, "clearqdbf");
3223 /* clear outbound buffers to free skbs */
3224 for (i = 0; i < card->qdio.no_out_queues; ++i)
3225 if (card->qdio.out_qs[i]){
3226 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j)
3227 qeth_clear_output_buffer(card->qdio.out_qs[i],
3228 &card->qdio.out_qs[i]->bufs[j]);
3233 qeth_init_qdio_info(struct qeth_card *card)
3235 QETH_DBF_TEXT(setup, 4, "intqdinf");
3236 card->qdio.state = QETH_QDIO_UNINITIALIZED;
3238 card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT;
3239 card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_DEFAULT;
3240 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count;
3241 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list);
3242 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list);
3247 qeth_init_qdio_queues(struct qeth_card *card)
3252 QETH_DBF_TEXT(setup, 2, "initqdqs");
3255 memset(card->qdio.in_q->qdio_bufs, 0,
3256 QDIO_MAX_BUFFERS_PER_Q * sizeof(struct qdio_buffer));
3257 qeth_initialize_working_pool_list(card);
3258 /*give only as many buffers to hardware as we have buffer pool entries*/
3259 for (i = 0; i < card->qdio.in_buf_pool.buf_count - 1; ++i)
3260 qeth_init_input_buffer(card, &card->qdio.in_q->bufs[i]);
3261 card->qdio.in_q->next_buf_to_init = card->qdio.in_buf_pool.buf_count - 1;
3262 rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0, 0,
3263 card->qdio.in_buf_pool.buf_count - 1, NULL);
3265 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
3268 rc = qdio_synchronize(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0);
3270 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
3273 /* outbound queue */
3274 for (i = 0; i < card->qdio.no_out_queues; ++i){
3275 memset(card->qdio.out_qs[i]->qdio_bufs, 0,
3276 QDIO_MAX_BUFFERS_PER_Q * sizeof(struct qdio_buffer));
3277 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j){
3278 qeth_clear_output_buffer(card->qdio.out_qs[i],
3279 &card->qdio.out_qs[i]->bufs[j]);
3281 card->qdio.out_qs[i]->card = card;
3282 card->qdio.out_qs[i]->next_buf_to_fill = 0;
3283 card->qdio.out_qs[i]->do_pack = 0;
3284 atomic_set(&card->qdio.out_qs[i]->used_buffers,0);
3285 atomic_set(&card->qdio.out_qs[i]->set_pci_flags_count, 0);
3286 atomic_set(&card->qdio.out_qs[i]->state,
3287 QETH_OUT_Q_UNLOCKED);
3293 qeth_qdio_establish(struct qeth_card *card)
3295 struct qdio_initialize init_data;
3296 char *qib_param_field;
3297 struct qdio_buffer **in_sbal_ptrs;
3298 struct qdio_buffer **out_sbal_ptrs;
3302 QETH_DBF_TEXT(setup, 2, "qdioest");
3304 qib_param_field = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
3306 if (!qib_param_field)
3309 memset(qib_param_field, 0, QDIO_MAX_BUFFERS_PER_Q * sizeof(char));
3311 qeth_create_qib_param_field(card, qib_param_field);
3312 qeth_create_qib_param_field_blkt(card, qib_param_field);
3314 in_sbal_ptrs = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(void *),
3316 if (!in_sbal_ptrs) {
3317 kfree(qib_param_field);
3320 for(i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i)
3321 in_sbal_ptrs[i] = (struct qdio_buffer *)
3322 virt_to_phys(card->qdio.in_q->bufs[i].buffer);
3325 kmalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q *
3326 sizeof(void *), GFP_KERNEL);
3327 if (!out_sbal_ptrs) {
3328 kfree(in_sbal_ptrs);
3329 kfree(qib_param_field);
3332 for(i = 0, k = 0; i < card->qdio.no_out_queues; ++i)
3333 for(j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j, ++k){
3334 out_sbal_ptrs[k] = (struct qdio_buffer *)
3335 virt_to_phys(card->qdio.out_qs[i]->
3339 memset(&init_data, 0, sizeof(struct qdio_initialize));
3340 init_data.cdev = CARD_DDEV(card);
3341 init_data.q_format = qeth_get_qdio_q_format(card);
3342 init_data.qib_param_field_format = 0;
3343 init_data.qib_param_field = qib_param_field;
3344 init_data.min_input_threshold = QETH_MIN_INPUT_THRESHOLD;
3345 init_data.max_input_threshold = QETH_MAX_INPUT_THRESHOLD;
3346 init_data.min_output_threshold = QETH_MIN_OUTPUT_THRESHOLD;
3347 init_data.max_output_threshold = QETH_MAX_OUTPUT_THRESHOLD;
3348 init_data.no_input_qs = 1;
3349 init_data.no_output_qs = card->qdio.no_out_queues;
3350 init_data.input_handler = (qdio_handler_t *)
3351 qeth_qdio_input_handler;
3352 init_data.output_handler = (qdio_handler_t *)
3353 qeth_qdio_output_handler;
3354 init_data.int_parm = (unsigned long) card;
3355 init_data.flags = QDIO_INBOUND_0COPY_SBALS |
3356 QDIO_OUTBOUND_0COPY_SBALS |
3357 QDIO_USE_OUTBOUND_PCIS;
3358 init_data.input_sbal_addr_array = (void **) in_sbal_ptrs;
3359 init_data.output_sbal_addr_array = (void **) out_sbal_ptrs;
3361 if (!(rc = qdio_initialize(&init_data)))
3362 card->qdio.state = QETH_QDIO_ESTABLISHED;
3364 kfree(out_sbal_ptrs);
3365 kfree(in_sbal_ptrs);
3366 kfree(qib_param_field);
3371 qeth_qdio_activate(struct qeth_card *card)
3373 QETH_DBF_TEXT(setup,3,"qdioact");
3374 return qdio_activate(CARD_DDEV(card), 0);
3378 qeth_clear_channel(struct qeth_channel *channel)
3380 unsigned long flags;
3381 struct qeth_card *card;
3384 QETH_DBF_TEXT(trace,3,"clearch");
3385 card = CARD_FROM_CDEV(channel->ccwdev);
3386 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
3387 rc = ccw_device_clear(channel->ccwdev, QETH_CLEAR_CHANNEL_PARM);
3388 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
3392 rc = wait_event_interruptible_timeout(card->wait_q,
3393 channel->state==CH_STATE_STOPPED, QETH_TIMEOUT);
3394 if (rc == -ERESTARTSYS)
3396 if (channel->state != CH_STATE_STOPPED)
3398 channel->state = CH_STATE_DOWN;
3403 qeth_halt_channel(struct qeth_channel *channel)
3405 unsigned long flags;
3406 struct qeth_card *card;
3409 QETH_DBF_TEXT(trace,3,"haltch");
3410 card = CARD_FROM_CDEV(channel->ccwdev);
3411 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
3412 rc = ccw_device_halt(channel->ccwdev, QETH_HALT_CHANNEL_PARM);
3413 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
3417 rc = wait_event_interruptible_timeout(card->wait_q,
3418 channel->state==CH_STATE_HALTED, QETH_TIMEOUT);
3419 if (rc == -ERESTARTSYS)
3421 if (channel->state != CH_STATE_HALTED)
3427 qeth_halt_channels(struct qeth_card *card)
3429 int rc1 = 0, rc2=0, rc3 = 0;
3431 QETH_DBF_TEXT(trace,3,"haltchs");
3432 rc1 = qeth_halt_channel(&card->read);
3433 rc2 = qeth_halt_channel(&card->write);
3434 rc3 = qeth_halt_channel(&card->data);
3442 qeth_clear_channels(struct qeth_card *card)
3444 int rc1 = 0, rc2=0, rc3 = 0;
3446 QETH_DBF_TEXT(trace,3,"clearchs");
3447 rc1 = qeth_clear_channel(&card->read);
3448 rc2 = qeth_clear_channel(&card->write);
3449 rc3 = qeth_clear_channel(&card->data);
3458 qeth_clear_halt_card(struct qeth_card *card, int halt)
3462 QETH_DBF_TEXT(trace,3,"clhacrd");
3463 QETH_DBF_HEX(trace, 3, &card, sizeof(void *));
3466 rc = qeth_halt_channels(card);
3469 return qeth_clear_channels(card);
3473 qeth_qdio_clear_card(struct qeth_card *card, int use_halt)
3477 QETH_DBF_TEXT(trace,3,"qdioclr");
3478 if (card->qdio.state == QETH_QDIO_ESTABLISHED){
3479 if ((rc = qdio_cleanup(CARD_DDEV(card),
3480 (card->info.type == QETH_CARD_TYPE_IQD) ?
3481 QDIO_FLAG_CLEANUP_USING_HALT :
3482 QDIO_FLAG_CLEANUP_USING_CLEAR)))
3483 QETH_DBF_TEXT_(trace, 3, "1err%d", rc);
3484 card->qdio.state = QETH_QDIO_ALLOCATED;
3486 if ((rc = qeth_clear_halt_card(card, use_halt)))
3487 QETH_DBF_TEXT_(trace, 3, "2err%d", rc);
3488 card->state = CARD_STATE_DOWN;
3493 qeth_dm_act(struct qeth_card *card)
3496 struct qeth_cmd_buffer *iob;
3498 QETH_DBF_TEXT(setup,2,"dmact");
3500 iob = qeth_wait_for_buffer(&card->write);
3501 memcpy(iob->data, DM_ACT, DM_ACT_SIZE);
3503 memcpy(QETH_DM_ACT_DEST_ADDR(iob->data),
3504 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
3505 memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob->data),
3506 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
3507 rc = qeth_send_control_data(card, DM_ACT_SIZE, iob, NULL, NULL);
3512 qeth_mpc_initialize(struct qeth_card *card)
3516 QETH_DBF_TEXT(setup,2,"mpcinit");
3518 if ((rc = qeth_issue_next_read(card))){
3519 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
3522 if ((rc = qeth_cm_enable(card))){
3523 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
3526 if ((rc = qeth_cm_setup(card))){
3527 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
3530 if ((rc = qeth_ulp_enable(card))){
3531 QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
3534 if ((rc = qeth_ulp_setup(card))){
3535 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
3538 if ((rc = qeth_alloc_qdio_buffers(card))){
3539 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
3542 if ((rc = qeth_qdio_establish(card))){
3543 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
3544 qeth_free_qdio_buffers(card);
3547 if ((rc = qeth_qdio_activate(card))){
3548 QETH_DBF_TEXT_(setup, 2, "7err%d", rc);
3551 if ((rc = qeth_dm_act(card))){
3552 QETH_DBF_TEXT_(setup, 2, "8err%d", rc);
3558 qeth_qdio_clear_card(card, card->info.type!=QETH_CARD_TYPE_IQD);
3562 static struct net_device *
3563 qeth_get_netdevice(enum qeth_card_types type, enum qeth_link_types linktype)
3565 struct net_device *dev = NULL;
3568 case QETH_CARD_TYPE_OSAE:
3570 case QETH_LINK_TYPE_LANE_TR:
3571 case QETH_LINK_TYPE_HSTR:
3573 dev = alloc_trdev(0);
3574 #endif /* CONFIG_TR */
3577 dev = alloc_etherdev(0);
3580 case QETH_CARD_TYPE_IQD:
3581 dev = alloc_netdev(0, "hsi%d", ether_setup);
3583 case QETH_CARD_TYPE_OSN:
3584 dev = alloc_netdev(0, "osn%d", ether_setup);
3587 dev = alloc_etherdev(0);
3592 /*hard_header fake function; used in case fake_ll is set */
3594 qeth_fake_header(struct sk_buff *skb, struct net_device *dev,
3595 unsigned short type, void *daddr, void *saddr,
3598 if(dev->type == ARPHRD_IEEE802_TR){
3599 struct trh_hdr *hdr;
3600 hdr = (struct trh_hdr *)skb_push(skb, QETH_FAKE_LL_LEN_TR);
3601 memcpy(hdr->saddr, dev->dev_addr, TR_ALEN);
3602 memcpy(hdr->daddr, "FAKELL", TR_ALEN);
3603 return QETH_FAKE_LL_LEN_TR;
3607 hdr = (struct ethhdr *)skb_push(skb, QETH_FAKE_LL_LEN_ETH);
3608 memcpy(hdr->h_source, dev->dev_addr, ETH_ALEN);
3609 memcpy(hdr->h_dest, "FAKELL", ETH_ALEN);
3610 if (type != ETH_P_802_3)
3611 hdr->h_proto = htons(type);
3613 hdr->h_proto = htons(len);
3614 return QETH_FAKE_LL_LEN_ETH;
3620 qeth_send_packet(struct qeth_card *, struct sk_buff *);
3623 qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
3626 struct qeth_card *card;
3628 QETH_DBF_TEXT(trace, 6, "hrdstxmi");
3629 card = (struct qeth_card *)dev->priv;
3631 card->stats.tx_dropped++;
3632 card->stats.tx_errors++;
3633 /* return OK; otherwise ksoftirqd goes to 100% */
3634 return NETDEV_TX_OK;
3636 if ((card->state != CARD_STATE_UP) || !card->lan_online) {
3637 card->stats.tx_dropped++;
3638 card->stats.tx_errors++;
3639 card->stats.tx_carrier_errors++;
3640 dev_kfree_skb_any(skb);
3641 /* return OK; otherwise ksoftirqd goes to 100% */
3642 return NETDEV_TX_OK;
3644 #ifdef CONFIG_QETH_PERF_STATS
3645 card->perf_stats.outbound_cnt++;
3646 card->perf_stats.outbound_start_time = qeth_get_micros();
3648 netif_stop_queue(dev);
3649 if ((rc = qeth_send_packet(card, skb))) {
3651 return NETDEV_TX_BUSY;
3653 card->stats.tx_errors++;
3654 card->stats.tx_dropped++;
3655 dev_kfree_skb_any(skb);
3656 /*set to OK; otherwise ksoftirqd goes to 100% */
3660 netif_wake_queue(dev);
3661 #ifdef CONFIG_QETH_PERF_STATS
3662 card->perf_stats.outbound_time += qeth_get_micros() -
3663 card->perf_stats.outbound_start_time;
3669 qeth_verify_vlan_dev(struct net_device *dev, struct qeth_card *card)
3672 #ifdef CONFIG_QETH_VLAN
3673 struct vlan_group *vg;
3676 if (!(vg = card->vlangrp))
3679 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++){
3680 if (vg->vlan_devices[i] == dev){
3681 rc = QETH_VLAN_CARD;
3690 qeth_verify_dev(struct net_device *dev)
3692 struct qeth_card *card;
3693 unsigned long flags;
3696 read_lock_irqsave(&qeth_card_list.rwlock, flags);
3697 list_for_each_entry(card, &qeth_card_list.list, list){
3698 if (card->dev == dev){
3699 rc = QETH_REAL_CARD;
3702 rc = qeth_verify_vlan_dev(dev, card);
3706 read_unlock_irqrestore(&qeth_card_list.rwlock, flags);
3711 static struct qeth_card *
3712 qeth_get_card_from_dev(struct net_device *dev)
3714 struct qeth_card *card = NULL;
3717 rc = qeth_verify_dev(dev);
3718 if (rc == QETH_REAL_CARD)
3719 card = (struct qeth_card *)dev->priv;
3720 else if (rc == QETH_VLAN_CARD)
3721 card = (struct qeth_card *)
3722 VLAN_DEV_INFO(dev)->real_dev->priv;
3724 QETH_DBF_TEXT_(trace, 4, "%d", rc);
3729 qeth_tx_timeout(struct net_device *dev)
3731 struct qeth_card *card;
3733 card = (struct qeth_card *) dev->priv;
3734 card->stats.tx_errors++;
3735 qeth_schedule_recovery(card);
3739 qeth_open(struct net_device *dev)
3741 struct qeth_card *card;
3743 QETH_DBF_TEXT(trace, 4, "qethopen");
3745 card = (struct qeth_card *) dev->priv;
3747 if (card->state != CARD_STATE_SOFTSETUP)
3750 if ( (card->info.type != QETH_CARD_TYPE_OSN) &&
3751 (card->options.layer2) &&
3752 (!card->info.layer2_mac_registered)) {
3753 QETH_DBF_TEXT(trace,4,"nomacadr");
3756 card->dev->flags |= IFF_UP;
3757 netif_start_queue(dev);
3758 card->data.state = CH_STATE_UP;
3759 card->state = CARD_STATE_UP;
3761 if (!card->lan_online){
3762 if (netif_carrier_ok(dev))
3763 netif_carrier_off(dev);
3769 qeth_stop(struct net_device *dev)
3771 struct qeth_card *card;
3773 QETH_DBF_TEXT(trace, 4, "qethstop");
3775 card = (struct qeth_card *) dev->priv;
3777 netif_stop_queue(dev);
3778 card->dev->flags &= ~IFF_UP;
3779 if (card->state == CARD_STATE_UP)
3780 card->state = CARD_STATE_SOFTSETUP;
3785 qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
3787 int cast_type = RTN_UNSPEC;
3789 if (card->info.type == QETH_CARD_TYPE_OSN)
3792 if (skb->dst && skb->dst->neighbour){
3793 cast_type = skb->dst->neighbour->type;
3794 if ((cast_type == RTN_BROADCAST) ||
3795 (cast_type == RTN_MULTICAST) ||
3796 (cast_type == RTN_ANYCAST))
3801 /* try something else */
3802 if (skb->protocol == ETH_P_IPV6)
3803 return (skb->nh.raw[24] == 0xff) ? RTN_MULTICAST : 0;
3804 else if (skb->protocol == ETH_P_IP)
3805 return ((skb->nh.raw[16] & 0xf0) == 0xe0) ? RTN_MULTICAST : 0;
3807 if (!memcmp(skb->data, skb->dev->broadcast, 6))
3808 return RTN_BROADCAST;
3812 hdr_mac = *((u16 *)skb->data);
3814 switch (card->info.link_type) {
3815 case QETH_LINK_TYPE_HSTR:
3816 case QETH_LINK_TYPE_LANE_TR:
3817 if ((hdr_mac == QETH_TR_MAC_NC) ||
3818 (hdr_mac == QETH_TR_MAC_C))
3819 return RTN_MULTICAST;
3820 /* eth or so multicast? */
3822 if ((hdr_mac == QETH_ETH_MAC_V4) ||
3823 (hdr_mac == QETH_ETH_MAC_V6))
3824 return RTN_MULTICAST;
3831 qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb,
3832 int ipv, int cast_type)
3834 if (!ipv && (card->info.type == QETH_CARD_TYPE_OSAE))
3835 return card->qdio.default_out_queue;
3836 switch (card->qdio.no_out_queues) {
3838 if (cast_type && card->info.is_multicast_different)
3839 return card->info.is_multicast_different &
3840 (card->qdio.no_out_queues - 1);
3841 if (card->qdio.do_prio_queueing && (ipv == 4)) {
3842 if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_TOS){
3843 if (skb->nh.iph->tos & IP_TOS_NOTIMPORTANT)
3845 if (skb->nh.iph->tos & IP_TOS_HIGHRELIABILITY)
3847 if (skb->nh.iph->tos & IP_TOS_HIGHTHROUGHPUT)
3849 if (skb->nh.iph->tos & IP_TOS_LOWDELAY)
3852 if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_PREC)
3853 return 3 - (skb->nh.iph->tos >> 6);
3854 } else if (card->qdio.do_prio_queueing && (ipv == 6)) {
3857 return card->qdio.default_out_queue;
3858 case 1: /* fallthrough for single-out-queue 1920-device */
3860 return card->qdio.default_out_queue;
3865 qeth_get_ip_version(struct sk_buff *skb)
3867 switch (skb->protocol) {
3878 qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb,
3879 struct qeth_hdr **hdr, int ipv)
3882 #ifdef CONFIG_QETH_VLAN
3886 QETH_DBF_TEXT(trace, 6, "prepskb");
3887 if (card->info.type == QETH_CARD_TYPE_OSN) {
3888 *hdr = (struct qeth_hdr *)(*skb)->data;
3891 rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr));
3894 #ifdef CONFIG_QETH_VLAN
3895 if (card->vlangrp && vlan_tx_tag_present(*skb) &&
3896 ((ipv == 6) || card->options.layer2) ) {
3898 * Move the mac addresses (6 bytes src, 6 bytes dest)
3899 * to the beginning of the new header. We are using three
3900 * memcpys instead of one memmove to save cycles.
3902 skb_push(*skb, VLAN_HLEN);
3903 memcpy((*skb)->data, (*skb)->data + 4, 4);
3904 memcpy((*skb)->data + 4, (*skb)->data + 8, 4);
3905 memcpy((*skb)->data + 8, (*skb)->data + 12, 4);
3906 tag = (u16 *)((*skb)->data + 12);
3908 * first two bytes = ETH_P_8021Q (0x8100)
3909 * second two bytes = VLANID
3911 *tag = __constant_htons(ETH_P_8021Q);
3912 *(tag + 1) = htons(vlan_tx_tag_get(*skb));
3915 *hdr = (struct qeth_hdr *)
3916 qeth_push_skb(card, skb, sizeof(struct qeth_hdr));
3923 qeth_get_qeth_hdr_flags4(int cast_type)
3925 if (cast_type == RTN_MULTICAST)
3926 return QETH_CAST_MULTICAST;
3927 if (cast_type == RTN_BROADCAST)
3928 return QETH_CAST_BROADCAST;
3929 return QETH_CAST_UNICAST;
3933 qeth_get_qeth_hdr_flags6(int cast_type)
3935 u8 ct = QETH_HDR_PASSTHRU | QETH_HDR_IPV6;
3936 if (cast_type == RTN_MULTICAST)
3937 return ct | QETH_CAST_MULTICAST;
3938 if (cast_type == RTN_ANYCAST)
3939 return ct | QETH_CAST_ANYCAST;
3940 if (cast_type == RTN_BROADCAST)
3941 return ct | QETH_CAST_BROADCAST;
3942 return ct | QETH_CAST_UNICAST;
3946 qeth_layer2_get_packet_type(struct qeth_card *card, struct qeth_hdr *hdr,
3947 struct sk_buff *skb)
3951 if (!memcmp(skb->data+QETH_HEADER_SIZE,
3952 skb->dev->broadcast,6)) { /* broadcast? */
3953 *(__u32 *)hdr->hdr.l2.flags |=
3954 QETH_LAYER2_FLAG_BROADCAST << 8;
3957 hdr_mac=*((__u16*)skb->data);
3959 switch (card->info.link_type) {
3960 case QETH_LINK_TYPE_HSTR:
3961 case QETH_LINK_TYPE_LANE_TR:
3962 if ((hdr_mac == QETH_TR_MAC_NC) ||
3963 (hdr_mac == QETH_TR_MAC_C) )
3964 *(__u32 *)hdr->hdr.l2.flags |=
3965 QETH_LAYER2_FLAG_MULTICAST << 8;
3967 *(__u32 *)hdr->hdr.l2.flags |=
3968 QETH_LAYER2_FLAG_UNICAST << 8;
3970 /* eth or so multicast? */
3972 if ( (hdr_mac==QETH_ETH_MAC_V4) ||
3973 (hdr_mac==QETH_ETH_MAC_V6) )
3974 *(__u32 *)hdr->hdr.l2.flags |=
3975 QETH_LAYER2_FLAG_MULTICAST << 8;
3977 *(__u32 *)hdr->hdr.l2.flags |=
3978 QETH_LAYER2_FLAG_UNICAST << 8;
3983 qeth_layer2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
3984 struct sk_buff *skb, int cast_type)
3986 memset(hdr, 0, sizeof(struct qeth_hdr));
3987 hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2;
3989 /* set byte 0 to "0x02" and byte 3 to casting flags */
3990 if (cast_type==RTN_MULTICAST)
3991 *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_MULTICAST << 8;
3992 else if (cast_type==RTN_BROADCAST)
3993 *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_BROADCAST << 8;
3995 qeth_layer2_get_packet_type(card, hdr, skb);
3997 hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE;
3998 #ifdef CONFIG_QETH_VLAN
3999 /* VSWITCH relies on the VLAN
4000 * information to be present in
4001 * the QDIO header */
4002 if ((card->vlangrp != NULL) &&
4003 vlan_tx_tag_present(skb)) {
4004 *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_VLAN << 8;
4005 hdr->hdr.l2.vlan_id = vlan_tx_tag_get(skb);
4011 qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
4012 struct sk_buff *skb, int ipv, int cast_type)
4014 QETH_DBF_TEXT(trace, 6, "fillhdr");
4016 memset(hdr, 0, sizeof(struct qeth_hdr));
4017 if (card->options.layer2) {
4018 qeth_layer2_fill_header(card, hdr, skb, cast_type);
4021 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3;
4022 hdr->hdr.l3.ext_flags = 0;
4023 #ifdef CONFIG_QETH_VLAN
4025 * before we're going to overwrite this location with next hop ip.
4026 * v6 uses passthrough, v4 sets the tag in the QDIO header.
4028 if (card->vlangrp && vlan_tx_tag_present(skb)) {
4029 hdr->hdr.l3.ext_flags = (ipv == 4) ?
4030 QETH_HDR_EXT_VLAN_FRAME :
4031 QETH_HDR_EXT_INCLUDE_VLAN_TAG;
4032 hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb);
4034 #endif /* CONFIG_QETH_VLAN */
4035 hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr);
4036 if (ipv == 4) { /* IPv4 */
4037 hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags4(cast_type);
4038 memset(hdr->hdr.l3.dest_addr, 0, 12);
4039 if ((skb->dst) && (skb->dst->neighbour)) {
4040 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
4041 *((u32 *) skb->dst->neighbour->primary_key);
4043 /* fill in destination address used in ip header */
4044 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = skb->nh.iph->daddr;
4046 } else if (ipv == 6) { /* IPv6 or passthru */
4047 hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags6(cast_type);
4048 if ((skb->dst) && (skb->dst->neighbour)) {
4049 memcpy(hdr->hdr.l3.dest_addr,
4050 skb->dst->neighbour->primary_key, 16);
4052 /* fill in destination address used in ip header */
4053 memcpy(hdr->hdr.l3.dest_addr, &skb->nh.ipv6h->daddr, 16);
4055 } else { /* passthrough */
4056 if((skb->dev->type == ARPHRD_IEEE802_TR) &&
4057 !memcmp(skb->data + sizeof(struct qeth_hdr) +
4058 sizeof(__u16), skb->dev->broadcast, 6)) {
4059 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
4061 } else if (!memcmp(skb->data + sizeof(struct qeth_hdr),
4062 skb->dev->broadcast, 6)) { /* broadcast? */
4063 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
4066 hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ?
4067 QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU :
4068 QETH_CAST_UNICAST | QETH_HDR_PASSTHRU;
4074 __qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer,
4075 int is_tso, int *next_element_to_fill)
4077 int length = skb->len;
4083 element = *next_element_to_fill;
4085 first_lap = (is_tso == 0 ? 1 : 0);
4087 while (length > 0) {
4088 /* length_here is the remaining amount of data in this page */
4089 length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE);
4090 if (length < length_here)
4091 length_here = length;
4093 buffer->element[element].addr = data;
4094 buffer->element[element].length = length_here;
4095 length -= length_here;
4098 buffer->element[element].flags = 0;
4100 buffer->element[element].flags =
4101 SBAL_FLAGS_LAST_FRAG;
4104 buffer->element[element].flags =
4105 SBAL_FLAGS_FIRST_FRAG;
4107 buffer->element[element].flags =
4108 SBAL_FLAGS_MIDDLE_FRAG;
4110 data += length_here;
4114 *next_element_to_fill = element;
4118 qeth_fill_buffer(struct qeth_qdio_out_q *queue,
4119 struct qeth_qdio_out_buffer *buf,
4120 struct sk_buff *skb)
4122 struct qdio_buffer *buffer;
4123 struct qeth_hdr_tso *hdr;
4124 int flush_cnt = 0, hdr_len, large_send = 0;
4126 QETH_DBF_TEXT(trace, 6, "qdfillbf");
4128 buffer = buf->buffer;
4129 atomic_inc(&skb->users);
4130 skb_queue_tail(&buf->skb_list, skb);
4132 hdr = (struct qeth_hdr_tso *) skb->data;
4133 /*check first on TSO ....*/
4134 if (hdr->hdr.hdr.l3.id == QETH_HEADER_TYPE_TSO) {
4135 int element = buf->next_element_to_fill;
4137 hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len;
4138 /*fill first buffer entry only with header information */
4139 buffer->element[element].addr = skb->data;
4140 buffer->element[element].length = hdr_len;
4141 buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG;
4142 buf->next_element_to_fill++;
4143 skb->data += hdr_len;
4144 skb->len -= hdr_len;
4147 if (skb_shinfo(skb)->nr_frags == 0)
4148 __qeth_fill_buffer(skb, buffer, large_send,
4149 (int *)&buf->next_element_to_fill);
4151 __qeth_fill_buffer_frag(skb, buffer, large_send,
4152 (int *)&buf->next_element_to_fill);
4154 if (!queue->do_pack) {
4155 QETH_DBF_TEXT(trace, 6, "fillbfnp");
4156 /* set state to PRIMED -> will be flushed */
4157 atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED);
4160 QETH_DBF_TEXT(trace, 6, "fillbfpa");
4161 #ifdef CONFIG_QETH_PERF_STATS
4162 queue->card->perf_stats.skbs_sent_pack++;
4164 if (buf->next_element_to_fill >=
4165 QETH_MAX_BUFFER_ELEMENTS(queue->card)) {
4167 * packed buffer if full -> set state PRIMED
4168 * -> will be flushed
4170 atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED);
4178 qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue,
4179 struct sk_buff *skb, struct qeth_hdr *hdr,
4180 int elements_needed,
4181 struct qeth_eddp_context *ctx)
4183 struct qeth_qdio_out_buffer *buffer;
4184 int buffers_needed = 0;
4188 QETH_DBF_TEXT(trace, 6, "dosndpfa");
4190 /* spin until we get the queue ... */
4191 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED,
4194 /* ... now we've got the queue */
4195 index = queue->next_buf_to_fill;
4196 buffer = &queue->bufs[queue->next_buf_to_fill];
4198 * check if buffer is empty to make sure that we do not 'overtake'
4199 * ourselves and try to fill a buffer that is already primed
4201 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) {
4202 card->stats.tx_dropped++;
4203 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
4207 queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) %
4208 QDIO_MAX_BUFFERS_PER_Q;
4210 buffers_needed = qeth_eddp_check_buffers_for_context(queue,ctx);
4211 if (buffers_needed < 0) {
4212 card->stats.tx_dropped++;
4213 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
4216 queue->next_buf_to_fill =
4217 (queue->next_buf_to_fill + buffers_needed) %
4218 QDIO_MAX_BUFFERS_PER_Q;
4220 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
4222 qeth_fill_buffer(queue, buffer, skb);
4223 qeth_flush_buffers(queue, 0, index, 1);
4225 flush_cnt = qeth_eddp_fill_buffer(queue, ctx, index);
4226 WARN_ON(buffers_needed != flush_cnt);
4227 qeth_flush_buffers(queue, 0, index, flush_cnt);
4233 qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
4234 struct sk_buff *skb, struct qeth_hdr *hdr,
4235 int elements_needed, struct qeth_eddp_context *ctx)
4237 struct qeth_qdio_out_buffer *buffer;
4239 int flush_count = 0;
4244 QETH_DBF_TEXT(trace, 6, "dosndpkt");
4246 /* spin until we get the queue ... */
4247 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED,
4250 start_index = queue->next_buf_to_fill;
4251 buffer = &queue->bufs[queue->next_buf_to_fill];
4253 * check if buffer is empty to make sure that we do not 'overtake'
4254 * ourselves and try to fill a buffer that is already primed
4256 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){
4257 card->stats.tx_dropped++;
4258 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
4261 /* check if we need to switch packing state of this queue */
4262 qeth_switch_to_packing_if_needed(queue);
4263 if (queue->do_pack){
4266 /* does packet fit in current buffer? */
4267 if((QETH_MAX_BUFFER_ELEMENTS(card) -
4268 buffer->next_element_to_fill) < elements_needed){
4269 /* ... no -> set state PRIMED */
4270 atomic_set(&buffer->state,QETH_QDIO_BUF_PRIMED);
4272 queue->next_buf_to_fill =
4273 (queue->next_buf_to_fill + 1) %
4274 QDIO_MAX_BUFFERS_PER_Q;
4275 buffer = &queue->bufs[queue->next_buf_to_fill];
4276 /* we did a step forward, so check buffer state
4278 if (atomic_read(&buffer->state) !=
4279 QETH_QDIO_BUF_EMPTY){
4280 card->stats.tx_dropped++;
4281 qeth_flush_buffers(queue, 0, start_index, flush_count);
4282 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
4287 /* check if we have enough elements (including following
4288 * free buffers) to handle eddp context */
4289 if (qeth_eddp_check_buffers_for_context(queue,ctx) < 0){
4290 printk("eddp tx_dropped 1\n");
4291 card->stats.tx_dropped++;
4298 tmp = qeth_fill_buffer(queue, buffer, skb);
4300 tmp = qeth_eddp_fill_buffer(queue,ctx,queue->next_buf_to_fill);
4302 printk("eddp tx_dropped 2\n");
4303 card->stats.tx_dropped++;
4308 queue->next_buf_to_fill = (queue->next_buf_to_fill + tmp) %
4309 QDIO_MAX_BUFFERS_PER_Q;
4313 qeth_flush_buffers(queue, 0, start_index, flush_count);
4315 * queue->state will go from LOCKED -> UNLOCKED or from
4316 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
4317 * (switch packing state or flush buffer to get another pci flag out).
4318 * In that case we will enter this loop
4320 while (atomic_dec_return(&queue->state)){
4322 start_index = queue->next_buf_to_fill;
4323 /* check if we can go back to non-packing state */
4324 flush_count += qeth_switch_to_nonpacking_if_needed(queue);
4326 * check if we need to flush a packing buffer to get a pci
4327 * flag out on the queue
4329 if (!flush_count && !atomic_read(&queue->set_pci_flags_count))
4330 flush_count += qeth_flush_buffers_on_no_pci(queue);
4332 qeth_flush_buffers(queue, 0, start_index, flush_count);
4334 /* at this point the queue is UNLOCKED again */
4335 #ifdef CONFIG_QETH_PERF_STATS
4337 queue->card->perf_stats.bufs_sent_pack += flush_count;
4338 #endif /* CONFIG_QETH_PERF_STATS */
4344 qeth_get_elements_no(struct qeth_card *card, void *hdr,
4345 struct sk_buff *skb, int elems)
4347 int elements_needed = 0;
4349 if (skb_shinfo(skb)->nr_frags > 0) {
4350 elements_needed = (skb_shinfo(skb)->nr_frags + 1);
4352 if (elements_needed == 0 )
4353 elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE)
4354 + skb->len) >> PAGE_SHIFT);
4355 if ((elements_needed + elems) > QETH_MAX_BUFFER_ELEMENTS(card)){
4356 PRINT_ERR("qeth_do_send_packet: invalid size of "
4357 "IP packet (Number=%d / Length=%d). Discarded.\n",
4358 (elements_needed+elems), skb->len);
4361 return elements_needed;
4365 qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4369 struct qeth_qdio_out_q *queue;
4370 struct qeth_hdr *hdr = NULL;
4371 int elements_needed = 0;
4372 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
4373 struct qeth_eddp_context *ctx = NULL;
4376 QETH_DBF_TEXT(trace, 6, "sendpkt");
4378 if (!card->options.layer2) {
4379 ipv = qeth_get_ip_version(skb);
4380 if ((card->dev->hard_header == qeth_fake_header) && ipv) {
4381 if ((skb = qeth_pskb_unshare(skb,GFP_ATOMIC)) == NULL) {
4382 card->stats.tx_dropped++;
4383 dev_kfree_skb_irq(skb);
4386 if(card->dev->type == ARPHRD_IEEE802_TR){
4387 skb_pull(skb, QETH_FAKE_LL_LEN_TR);
4389 skb_pull(skb, QETH_FAKE_LL_LEN_ETH);
4393 if ((card->info.type == QETH_CARD_TYPE_OSN) &&
4394 (skb->protocol == htons(ETH_P_IPV6))) {
4395 dev_kfree_skb_any(skb);
4398 cast_type = qeth_get_cast_type(card, skb);
4399 if ((cast_type == RTN_BROADCAST) &&
4400 (card->info.broadcast_capable == 0)){
4401 card->stats.tx_dropped++;
4402 card->stats.tx_errors++;
4403 dev_kfree_skb_any(skb);
4404 return NETDEV_TX_OK;
4406 queue = card->qdio.out_qs
4407 [qeth_get_priority_queue(card, skb, ipv, cast_type)];
4409 if (skb_shinfo(skb)->tso_size)
4410 large_send = card->options.large_send;
4412 /*are we able to do TSO ? If so ,prepare and send it from here */
4413 if ((large_send == QETH_LARGE_SEND_TSO) &&
4414 (cast_type == RTN_UNSPEC)) {
4415 rc = qeth_tso_prepare_packet(card, skb, ipv, cast_type);
4417 card->stats.tx_dropped++;
4418 card->stats.tx_errors++;
4419 dev_kfree_skb_any(skb);
4420 return NETDEV_TX_OK;
4424 if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) {
4425 QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
4428 if (card->info.type != QETH_CARD_TYPE_OSN)
4429 qeth_fill_header(card, hdr, skb, ipv, cast_type);
4432 if (large_send == QETH_LARGE_SEND_EDDP) {
4433 ctx = qeth_eddp_create_context(card, skb, hdr);
4435 PRINT_WARN("could not create eddp context\n");
4439 int elems = qeth_get_elements_no(card,(void*) hdr, skb,
4443 elements_needed += elems;
4446 if (card->info.type != QETH_CARD_TYPE_IQD)
4447 rc = qeth_do_send_packet(card, queue, skb, hdr,
4448 elements_needed, ctx);
4450 rc = qeth_do_send_packet_fast(card, queue, skb, hdr,
4451 elements_needed, ctx);
4453 card->stats.tx_packets++;
4454 card->stats.tx_bytes += skb->len;
4455 #ifdef CONFIG_QETH_PERF_STATS
4456 if (skb_shinfo(skb)->tso_size &&
4457 !(large_send == QETH_LARGE_SEND_NO)) {
4458 card->perf_stats.large_send_bytes += skb->len;
4459 card->perf_stats.large_send_cnt++;
4461 if (skb_shinfo(skb)->nr_frags > 0){
4462 card->perf_stats.sg_skbs_sent++;
4463 /* nr_frags + skb->data */
4464 card->perf_stats.sg_frags_sent +=
4465 skb_shinfo(skb)->nr_frags + 1;
4467 #endif /* CONFIG_QETH_PERF_STATS */
4470 /* drop creator's reference */
4471 qeth_eddp_put_context(ctx);
4472 /* free skb; it's not referenced by a buffer */
4474 dev_kfree_skb_any(skb);
4481 qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
4483 struct qeth_card *card = (struct qeth_card *) dev->priv;
4487 case MII_BMCR: /* Basic mode control register */
4489 if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH)&&
4490 (card->info.link_type != QETH_LINK_TYPE_OSN) &&
4491 (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH))
4492 rc |= BMCR_SPEED100;
4494 case MII_BMSR: /* Basic mode status register */
4495 rc = BMSR_ERCAP | BMSR_ANEGCOMPLETE | BMSR_LSTATUS |
4496 BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | BMSR_100FULL |
4499 case MII_PHYSID1: /* PHYS ID 1 */
4500 rc = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 8) |
4502 rc = (rc >> 5) & 0xFFFF;
4504 case MII_PHYSID2: /* PHYS ID 2 */
4505 rc = (dev->dev_addr[2] << 10) & 0xFFFF;
4507 case MII_ADVERTISE: /* Advertisement control reg */
4510 case MII_LPA: /* Link partner ability reg */
4511 rc = LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL |
4512 LPA_100BASE4 | LPA_LPACK;
4514 case MII_EXPANSION: /* Expansion register */
4516 case MII_DCOUNTER: /* disconnect counter */
4518 case MII_FCSCOUNTER: /* false carrier counter */
4520 case MII_NWAYTEST: /* N-way auto-neg test register */
4522 case MII_RERRCOUNTER: /* rx error counter */
4523 rc = card->stats.rx_errors;
4525 case MII_SREVISION: /* silicon revision */
4527 case MII_RESV1: /* reserved 1 */
4529 case MII_LBRERROR: /* loopback, rx, bypass error */
4531 case MII_PHYADDR: /* physical address */
4533 case MII_RESV2: /* reserved 2 */
4535 case MII_TPISTATUS: /* TPI status for 10mbps */
4537 case MII_NCONFIG: /* network interface config */
4547 qeth_mdio_write(struct net_device *dev, int phy_id, int regnum, int value)
4550 case MII_BMCR: /* Basic mode control register */
4551 case MII_BMSR: /* Basic mode status register */
4552 case MII_PHYSID1: /* PHYS ID 1 */
4553 case MII_PHYSID2: /* PHYS ID 2 */
4554 case MII_ADVERTISE: /* Advertisement control reg */
4555 case MII_LPA: /* Link partner ability reg */
4556 case MII_EXPANSION: /* Expansion register */
4557 case MII_DCOUNTER: /* disconnect counter */
4558 case MII_FCSCOUNTER: /* false carrier counter */
4559 case MII_NWAYTEST: /* N-way auto-neg test register */
4560 case MII_RERRCOUNTER: /* rx error counter */
4561 case MII_SREVISION: /* silicon revision */
4562 case MII_RESV1: /* reserved 1 */
4563 case MII_LBRERROR: /* loopback, rx, bypass error */
4564 case MII_PHYADDR: /* physical address */
4565 case MII_RESV2: /* reserved 2 */
4566 case MII_TPISTATUS: /* TPI status for 10mbps */
4567 case MII_NCONFIG: /* network interface config */
4573 static inline const char *
4574 qeth_arp_get_error_cause(int *rc)
4577 case QETH_IPA_ARP_RC_FAILED:
4579 return "operation failed";
4580 case QETH_IPA_ARP_RC_NOTSUPP:
4582 return "operation not supported";
4583 case QETH_IPA_ARP_RC_OUT_OF_RANGE:
4585 return "argument out of range";
4586 case QETH_IPA_ARP_RC_Q_NOTSUPP:
4588 return "query operation not supported";
4589 case QETH_IPA_ARP_RC_Q_NO_DATA:
4591 return "no query data available";
4593 return "unknown error";
4598 qeth_send_simple_setassparms(struct qeth_card *, enum qeth_ipa_funcs,
4602 qeth_arp_set_no_entries(struct qeth_card *card, int no_entries)
4607 QETH_DBF_TEXT(trace,3,"arpstnoe");
4610 * currently GuestLAN only supports the ARP assist function
4611 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
4612 * thus we say EOPNOTSUPP for this ARP function
4614 if (card->info.guestlan)
4616 if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) {
4617 PRINT_WARN("ARP processing not supported "
4618 "on %s!\n", QETH_CARD_IFNAME(card));
4621 rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING,
4622 IPA_CMD_ASS_ARP_SET_NO_ENTRIES,
4626 PRINT_WARN("Could not set number of ARP entries on %s: "
4628 QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc),
4635 qeth_copy_arp_entries_stripped(struct qeth_arp_query_info *qinfo,
4636 struct qeth_arp_query_data *qdata,
4637 int entry_size, int uentry_size)
4643 entry_ptr = (char *)&qdata->data;
4644 uentry_ptr = (char *)(qinfo->udata + qinfo->udata_offset);
4645 for (i = 0; i < qdata->no_entries; ++i){
4646 /* strip off 32 bytes "media specific information" */
4647 memcpy(uentry_ptr, (entry_ptr + 32), entry_size - 32);
4648 entry_ptr += entry_size;
4649 uentry_ptr += uentry_size;
4654 qeth_arp_query_cb(struct qeth_card *card, struct qeth_reply *reply,
4657 struct qeth_ipa_cmd *cmd;
4658 struct qeth_arp_query_data *qdata;
4659 struct qeth_arp_query_info *qinfo;
4664 QETH_DBF_TEXT(trace,4,"arpquecb");
4666 qinfo = (struct qeth_arp_query_info *) reply->param;
4667 cmd = (struct qeth_ipa_cmd *) data;
4668 if (cmd->hdr.return_code) {
4669 QETH_DBF_TEXT_(trace,4,"qaer1%i", cmd->hdr.return_code);
4672 if (cmd->data.setassparms.hdr.return_code) {
4673 cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code;
4674 QETH_DBF_TEXT_(trace,4,"qaer2%i", cmd->hdr.return_code);
4677 qdata = &cmd->data.setassparms.data.query_arp;
4678 switch(qdata->reply_bits){
4680 uentry_size = entry_size = sizeof(struct qeth_arp_qi_entry5);
4681 if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES)
4682 uentry_size = sizeof(struct qeth_arp_qi_entry5_short);
4685 /* fall through to default */
4687 /* tr is the same as eth -> entry7 */
4688 uentry_size = entry_size = sizeof(struct qeth_arp_qi_entry7);
4689 if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES)
4690 uentry_size = sizeof(struct qeth_arp_qi_entry7_short);
4693 /* check if there is enough room in userspace */
4694 if ((qinfo->udata_len - qinfo->udata_offset) <
4695 qdata->no_entries * uentry_size){
4696 QETH_DBF_TEXT_(trace, 4, "qaer3%i", -ENOMEM);
4697 cmd->hdr.return_code = -ENOMEM;
4698 PRINT_WARN("query ARP user space buffer is too small for "
4699 "the returned number of ARP entries. "
4700 "Aborting query!\n");
4703 QETH_DBF_TEXT_(trace, 4, "anore%i",
4704 cmd->data.setassparms.hdr.number_of_replies);
4705 QETH_DBF_TEXT_(trace, 4, "aseqn%i", cmd->data.setassparms.hdr.seq_no);
4706 QETH_DBF_TEXT_(trace, 4, "anoen%i", qdata->no_entries);
4708 if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) {
4709 /* strip off "media specific information" */
4710 qeth_copy_arp_entries_stripped(qinfo, qdata, entry_size,
4713 /*copy entries to user buffer*/
4714 memcpy(qinfo->udata + qinfo->udata_offset,
4715 (char *)&qdata->data, qdata->no_entries*uentry_size);
4717 qinfo->no_entries += qdata->no_entries;
4718 qinfo->udata_offset += (qdata->no_entries*uentry_size);
4719 /* check if all replies received ... */
4720 if (cmd->data.setassparms.hdr.seq_no <
4721 cmd->data.setassparms.hdr.number_of_replies)
4723 memcpy(qinfo->udata, &qinfo->no_entries, 4);
4724 /* keep STRIP_ENTRIES flag so the user program can distinguish
4725 * stripped entries from normal ones */
4726 if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES)
4727 qdata->reply_bits |= QETH_QARP_STRIP_ENTRIES;
4728 memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET,&qdata->reply_bits,2);
4732 memcpy(qinfo->udata, &i, 4);
4737 qeth_send_ipa_arp_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
4738 int len, int (*reply_cb)(struct qeth_card *,
4739 struct qeth_reply *,
4743 QETH_DBF_TEXT(trace,4,"sendarp");
4745 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
4746 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
4747 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
4748 return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob,
4749 reply_cb, reply_param);
4753 qeth_send_ipa_snmp_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
4754 int len, int (*reply_cb)(struct qeth_card *,
4755 struct qeth_reply *,
4761 QETH_DBF_TEXT(trace,4,"sendsnmp");
4763 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
4764 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
4765 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
4766 /* adjust PDU length fields in IPA_PDU_HEADER */
4767 s1 = (u32) IPA_PDU_HEADER_SIZE + len;
4769 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2);
4770 memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2);
4771 memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2);
4772 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
4773 return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob,
4774 reply_cb, reply_param);
4777 static struct qeth_cmd_buffer *
4778 qeth_get_setassparms_cmd(struct qeth_card *, enum qeth_ipa_funcs,
4779 __u16, __u16, enum qeth_prot_versions);
4781 qeth_arp_query(struct qeth_card *card, char *udata)
4783 struct qeth_cmd_buffer *iob;
4784 struct qeth_arp_query_info qinfo = {0, };
4788 QETH_DBF_TEXT(trace,3,"arpquery");
4790 if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/
4791 IPA_ARP_PROCESSING)) {
4792 PRINT_WARN("ARP processing not supported "
4793 "on %s!\n", QETH_CARD_IFNAME(card));
4796 /* get size of userspace buffer and mask_bits -> 6 bytes */
4797 if (copy_from_user(&qinfo, udata, 6))
4799 if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL)))
4801 memset(qinfo.udata, 0, qinfo.udata_len);
4802 qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET;
4803 iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
4804 IPA_CMD_ASS_ARP_QUERY_INFO,
4805 sizeof(int),QETH_PROT_IPV4);
4807 rc = qeth_send_ipa_arp_cmd(card, iob,
4808 QETH_SETASS_BASE_LEN+QETH_ARP_CMD_LEN,
4809 qeth_arp_query_cb, (void *)&qinfo);
4812 PRINT_WARN("Error while querying ARP cache on %s: %s "
4814 QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc),
4816 copy_to_user(udata, qinfo.udata, 4);
4818 copy_to_user(udata, qinfo.udata, qinfo.udata_len);
4825 * SNMP command callback
4828 qeth_snmp_command_cb(struct qeth_card *card, struct qeth_reply *reply,
4829 unsigned long sdata)
4831 struct qeth_ipa_cmd *cmd;
4832 struct qeth_arp_query_info *qinfo;
4833 struct qeth_snmp_cmd *snmp;
4834 unsigned char *data;
4837 QETH_DBF_TEXT(trace,3,"snpcmdcb");
4839 cmd = (struct qeth_ipa_cmd *) sdata;
4840 data = (unsigned char *)((char *)cmd - reply->offset);
4841 qinfo = (struct qeth_arp_query_info *) reply->param;
4842 snmp = &cmd->data.setadapterparms.data.snmp;
4844 if (cmd->hdr.return_code) {
4845 QETH_DBF_TEXT_(trace,4,"scer1%i", cmd->hdr.return_code);
4848 if (cmd->data.setadapterparms.hdr.return_code) {
4849 cmd->hdr.return_code = cmd->data.setadapterparms.hdr.return_code;
4850 QETH_DBF_TEXT_(trace,4,"scer2%i", cmd->hdr.return_code);
4853 data_len = *((__u16*)QETH_IPA_PDU_LEN_PDU1(data));
4854 if (cmd->data.setadapterparms.hdr.seq_no == 1)
4855 data_len -= (__u16)((char *)&snmp->data - (char *)cmd);
4857 data_len -= (__u16)((char*)&snmp->request - (char *)cmd);
4859 /* check if there is enough room in userspace */
4860 if ((qinfo->udata_len - qinfo->udata_offset) < data_len) {
4861 QETH_DBF_TEXT_(trace, 4, "scer3%i", -ENOMEM);
4862 cmd->hdr.return_code = -ENOMEM;
4865 QETH_DBF_TEXT_(trace, 4, "snore%i",
4866 cmd->data.setadapterparms.hdr.used_total);
4867 QETH_DBF_TEXT_(trace, 4, "sseqn%i", cmd->data.setadapterparms.hdr.seq_no);
4868 /*copy entries to user buffer*/
4869 if (cmd->data.setadapterparms.hdr.seq_no == 1) {
4870 memcpy(qinfo->udata + qinfo->udata_offset,
4872 data_len + offsetof(struct qeth_snmp_cmd,data));
4873 qinfo->udata_offset += offsetof(struct qeth_snmp_cmd, data);
4875 memcpy(qinfo->udata + qinfo->udata_offset,
4876 (char *)&snmp->request, data_len);
4878 qinfo->udata_offset += data_len;
4879 /* check if all replies received ... */
4880 QETH_DBF_TEXT_(trace, 4, "srtot%i",
4881 cmd->data.setadapterparms.hdr.used_total);
4882 QETH_DBF_TEXT_(trace, 4, "srseq%i",
4883 cmd->data.setadapterparms.hdr.seq_no);
4884 if (cmd->data.setadapterparms.hdr.seq_no <
4885 cmd->data.setadapterparms.hdr.used_total)
4890 static struct qeth_cmd_buffer *
4891 qeth_get_ipacmd_buffer(struct qeth_card *, enum qeth_ipa_cmds,
4892 enum qeth_prot_versions );
4894 static struct qeth_cmd_buffer *
4895 qeth_get_adapter_cmd(struct qeth_card *card, __u32 command, __u32 cmdlen)
4897 struct qeth_cmd_buffer *iob;
4898 struct qeth_ipa_cmd *cmd;
4900 iob = qeth_get_ipacmd_buffer(card,IPA_CMD_SETADAPTERPARMS,
4902 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
4903 cmd->data.setadapterparms.hdr.cmdlength = cmdlen;
4904 cmd->data.setadapterparms.hdr.command_code = command;
4905 cmd->data.setadapterparms.hdr.used_total = 1;
4906 cmd->data.setadapterparms.hdr.seq_no = 1;
4912 * function to send SNMP commands to OSA-E card
4915 qeth_snmp_command(struct qeth_card *card, char *udata)
4917 struct qeth_cmd_buffer *iob;
4918 struct qeth_ipa_cmd *cmd;
4919 struct qeth_snmp_ureq *ureq;
4921 struct qeth_arp_query_info qinfo = {0, };
4924 QETH_DBF_TEXT(trace,3,"snmpcmd");
4926 if (card->info.guestlan)
4929 if ((!qeth_adp_supported(card,IPA_SETADP_SET_SNMP_CONTROL)) &&
4930 (!card->options.layer2) ) {
4931 PRINT_WARN("SNMP Query MIBS not supported "
4932 "on %s!\n", QETH_CARD_IFNAME(card));
4935 /* skip 4 bytes (data_len struct member) to get req_len */
4936 if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int)))
4938 ureq = kmalloc(req_len+sizeof(struct qeth_snmp_ureq_hdr), GFP_KERNEL);
4940 QETH_DBF_TEXT(trace, 2, "snmpnome");
4943 if (copy_from_user(ureq, udata,
4944 req_len+sizeof(struct qeth_snmp_ureq_hdr))){
4948 qinfo.udata_len = ureq->hdr.data_len;
4949 if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL))){
4953 memset(qinfo.udata, 0, qinfo.udata_len);
4954 qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
4956 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,
4957 QETH_SNMP_SETADP_CMDLENGTH + req_len);
4958 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
4959 memcpy(&cmd->data.setadapterparms.data.snmp, &ureq->cmd, req_len);
4960 rc = qeth_send_ipa_snmp_cmd(card, iob, QETH_SETADP_BASE_LEN + req_len,
4961 qeth_snmp_command_cb, (void *)&qinfo);
4963 PRINT_WARN("SNMP command failed on %s: (0x%x)\n",
4964 QETH_CARD_IFNAME(card), rc);
4966 copy_to_user(udata, qinfo.udata, qinfo.udata_len);
4974 qeth_default_setassparms_cb(struct qeth_card *, struct qeth_reply *,
4978 qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *,
4981 (struct qeth_card *, struct qeth_reply *, unsigned long),
4985 qeth_arp_add_entry(struct qeth_card *card, struct qeth_arp_cache_entry *entry)
4987 struct qeth_cmd_buffer *iob;
4992 QETH_DBF_TEXT(trace,3,"arpadent");
4995 * currently GuestLAN only supports the ARP assist function
4996 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
4997 * thus we say EOPNOTSUPP for this ARP function
4999 if (card->info.guestlan)
5001 if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) {
5002 PRINT_WARN("ARP processing not supported "
5003 "on %s!\n", QETH_CARD_IFNAME(card));
5007 iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
5008 IPA_CMD_ASS_ARP_ADD_ENTRY,
5009 sizeof(struct qeth_arp_cache_entry),
5011 rc = qeth_send_setassparms(card, iob,
5012 sizeof(struct qeth_arp_cache_entry),
5013 (unsigned long) entry,
5014 qeth_default_setassparms_cb, NULL);
5017 qeth_ipaddr4_to_string((u8 *)entry->ipaddr, buf);
5018 PRINT_WARN("Could not add ARP entry for address %s on %s: "
5020 buf, QETH_CARD_IFNAME(card),
5021 qeth_arp_get_error_cause(&rc), tmp, tmp);
5027 qeth_arp_remove_entry(struct qeth_card *card, struct qeth_arp_cache_entry *entry)
5029 struct qeth_cmd_buffer *iob;
5030 char buf[16] = {0, };
5034 QETH_DBF_TEXT(trace,3,"arprment");
5037 * currently GuestLAN only supports the ARP assist function
5038 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
5039 * thus we say EOPNOTSUPP for this ARP function
5041 if (card->info.guestlan)
5043 if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) {
5044 PRINT_WARN("ARP processing not supported "
5045 "on %s!\n", QETH_CARD_IFNAME(card));
5048 memcpy(buf, entry, 12);
5049 iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
5050 IPA_CMD_ASS_ARP_REMOVE_ENTRY,
5053 rc = qeth_send_setassparms(card, iob,
5054 12, (unsigned long)buf,
5055 qeth_default_setassparms_cb, NULL);
5059 qeth_ipaddr4_to_string((u8 *)entry->ipaddr, buf);
5060 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
5062 buf, QETH_CARD_IFNAME(card),
5063 qeth_arp_get_error_cause(&rc), tmp, tmp);
5069 qeth_arp_flush_cache(struct qeth_card *card)
5074 QETH_DBF_TEXT(trace,3,"arpflush");
5077 * currently GuestLAN only supports the ARP assist function
5078 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
5079 * thus we say EOPNOTSUPP for this ARP function
5081 if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD))
5083 if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) {
5084 PRINT_WARN("ARP processing not supported "
5085 "on %s!\n", QETH_CARD_IFNAME(card));
5088 rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING,
5089 IPA_CMD_ASS_ARP_FLUSH_CACHE, 0);
5092 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
5093 QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc),
5100 qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5102 struct qeth_card *card = (struct qeth_card *)dev->priv;
5103 struct qeth_arp_cache_entry arp_entry;
5104 struct mii_ioctl_data *mii_data;
5110 if ((card->state != CARD_STATE_UP) &&
5111 (card->state != CARD_STATE_SOFTSETUP))
5114 if (card->info.type == QETH_CARD_TYPE_OSN)
5118 case SIOC_QETH_ARP_SET_NO_ENTRIES:
5119 if ( !capable(CAP_NET_ADMIN) ||
5120 (card->options.layer2) ) {
5124 rc = qeth_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue);
5126 case SIOC_QETH_ARP_QUERY_INFO:
5127 if ( !capable(CAP_NET_ADMIN) ||
5128 (card->options.layer2) ) {
5132 rc = qeth_arp_query(card, rq->ifr_ifru.ifru_data);
5134 case SIOC_QETH_ARP_ADD_ENTRY:
5135 if ( !capable(CAP_NET_ADMIN) ||
5136 (card->options.layer2) ) {
5140 if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data,
5141 sizeof(struct qeth_arp_cache_entry)))
5144 rc = qeth_arp_add_entry(card, &arp_entry);
5146 case SIOC_QETH_ARP_REMOVE_ENTRY:
5147 if ( !capable(CAP_NET_ADMIN) ||
5148 (card->options.layer2) ) {
5152 if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data,
5153 sizeof(struct qeth_arp_cache_entry)))
5156 rc = qeth_arp_remove_entry(card, &arp_entry);
5158 case SIOC_QETH_ARP_FLUSH_CACHE:
5159 if ( !capable(CAP_NET_ADMIN) ||
5160 (card->options.layer2) ) {
5164 rc = qeth_arp_flush_cache(card);
5166 case SIOC_QETH_ADP_SET_SNMP_CONTROL:
5167 rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
5169 case SIOC_QETH_GET_CARD_TYPE:
5170 if ((card->info.type == QETH_CARD_TYPE_OSAE) &&
5171 !card->info.guestlan)
5176 mii_data = if_mii(rq);
5177 mii_data->phy_id = 0;
5180 mii_data = if_mii(rq);
5181 if (mii_data->phy_id != 0)
5184 mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id,
5190 /* TODO: remove return if qeth_mdio_write does something */
5191 if (!capable(CAP_NET_ADMIN)){
5195 mii_data = if_mii(rq);
5196 if (mii_data->phy_id != 0)
5199 qeth_mdio_write(dev, mii_data->phy_id, mii_data->reg_num,
5206 QETH_DBF_TEXT_(trace, 2, "ioce%d", rc);
5210 static struct net_device_stats *
5211 qeth_get_stats(struct net_device *dev)
5213 struct qeth_card *card;
5215 card = (struct qeth_card *) (dev->priv);
5217 QETH_DBF_TEXT(trace,5,"getstat");
5219 return &card->stats;
5223 qeth_change_mtu(struct net_device *dev, int new_mtu)
5225 struct qeth_card *card;
5228 card = (struct qeth_card *) (dev->priv);
5230 QETH_DBF_TEXT(trace,4,"chgmtu");
5231 sprintf(dbf_text, "%8x", new_mtu);
5232 QETH_DBF_TEXT(trace,4,dbf_text);
5236 if (new_mtu > 65535)
5238 if ((!qeth_is_supported(card,IPA_IP_FRAGMENTATION)) &&
5239 (!qeth_mtu_is_valid(card, new_mtu)))
5245 #ifdef CONFIG_QETH_VLAN
5247 qeth_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
5249 struct qeth_card *card;
5250 unsigned long flags;
5252 QETH_DBF_TEXT(trace,4,"vlanreg");
5254 card = (struct qeth_card *) dev->priv;
5255 spin_lock_irqsave(&card->vlanlock, flags);
5256 card->vlangrp = grp;
5257 spin_unlock_irqrestore(&card->vlanlock, flags);
5261 qeth_free_vlan_buffer(struct qeth_card *card, struct qeth_qdio_out_buffer *buf,
5265 struct sk_buff *skb;
5266 struct sk_buff_head tmp_list;
5268 skb_queue_head_init(&tmp_list);
5269 for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i){
5270 while ((skb = skb_dequeue(&buf->skb_list))){
5271 if (vlan_tx_tag_present(skb) &&
5272 (vlan_tx_tag_get(skb) == vid)) {
5273 atomic_dec(&skb->users);
5276 skb_queue_tail(&tmp_list, skb);
5279 while ((skb = skb_dequeue(&tmp_list)))
5280 skb_queue_tail(&buf->skb_list, skb);
5284 qeth_free_vlan_skbs(struct qeth_card *card, unsigned short vid)
5288 QETH_DBF_TEXT(trace, 4, "frvlskbs");
5289 for (i = 0; i < card->qdio.no_out_queues; ++i){
5290 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j)
5291 qeth_free_vlan_buffer(card, &card->qdio.
5292 out_qs[i]->bufs[j], vid);
5297 qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid)
5299 struct in_device *in_dev;
5300 struct in_ifaddr *ifa;
5301 struct qeth_ipaddr *addr;
5303 QETH_DBF_TEXT(trace, 4, "frvaddr4");
5307 in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]);
5310 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
5311 addr = qeth_get_addr_buffer(QETH_PROT_IPV4);
5313 addr->u.a4.addr = ifa->ifa_address;
5314 addr->u.a4.mask = ifa->ifa_mask;
5315 addr->type = QETH_IP_TYPE_NORMAL;
5316 if (!qeth_delete_ip(card, addr))
5325 qeth_free_vlan_addresses6(struct qeth_card *card, unsigned short vid)
5327 #ifdef CONFIG_QETH_IPV6
5328 struct inet6_dev *in6_dev;
5329 struct inet6_ifaddr *ifa;
5330 struct qeth_ipaddr *addr;
5332 QETH_DBF_TEXT(trace, 4, "frvaddr6");
5335 in6_dev = in6_dev_get(card->vlangrp->vlan_devices[vid]);
5338 for (ifa = in6_dev->addr_list; ifa; ifa = ifa->lst_next){
5339 addr = qeth_get_addr_buffer(QETH_PROT_IPV6);
5341 memcpy(&addr->u.a6.addr, &ifa->addr,
5342 sizeof(struct in6_addr));
5343 addr->u.a6.pfxlen = ifa->prefix_len;
5344 addr->type = QETH_IP_TYPE_NORMAL;
5345 if (!qeth_delete_ip(card, addr))
5349 in6_dev_put(in6_dev);
5350 #endif /* CONFIG_QETH_IPV6 */
5354 qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i,
5355 enum qeth_ipa_cmds ipacmd)
5358 struct qeth_ipa_cmd *cmd;
5359 struct qeth_cmd_buffer *iob;
5361 QETH_DBF_TEXT_(trace, 4, "L2sdv%x",ipacmd);
5362 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
5363 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5364 cmd->data.setdelvlan.vlan_id = i;
5366 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
5368 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5369 "Continuing\n",i, QETH_CARD_IFNAME(card), rc);
5370 QETH_DBF_TEXT_(trace, 2, "L2VL%4x", ipacmd);
5371 QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card));
5372 QETH_DBF_TEXT_(trace, 2, "err%d", rc);
5377 qeth_layer2_process_vlans(struct qeth_card *card, int clear)
5381 QETH_DBF_TEXT(trace, 3, "L2prcvln");
5385 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
5386 if (card->vlangrp->vlan_devices[i] == NULL)
5389 qeth_layer2_send_setdelvlan(card, i, IPA_CMD_DELVLAN);
5391 qeth_layer2_send_setdelvlan(card, i, IPA_CMD_SETVLAN);
5395 /*add_vid is layer 2 used only ....*/
5397 qeth_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
5399 struct qeth_card *card;
5401 QETH_DBF_TEXT_(trace, 4, "aid:%d", vid);
5403 card = (struct qeth_card *) dev->priv;
5404 if (!card->options.layer2)
5406 qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN);
5409 /*... kill_vid used for both modes*/
5411 qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
5413 struct qeth_card *card;
5414 unsigned long flags;
5416 QETH_DBF_TEXT_(trace, 4, "kid:%d", vid);
5418 card = (struct qeth_card *) dev->priv;
5419 /* free all skbs for the vlan device */
5420 qeth_free_vlan_skbs(card, vid);
5421 spin_lock_irqsave(&card->vlanlock, flags);
5422 /* unregister IP addresses of vlan device */
5423 qeth_free_vlan_addresses4(card, vid);
5424 qeth_free_vlan_addresses6(card, vid);
5426 card->vlangrp->vlan_devices[vid] = NULL;
5427 spin_unlock_irqrestore(&card->vlanlock, flags);
5428 if (card->options.layer2)
5429 qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN);
5430 qeth_set_multicast_list(card->dev);
5435 * set multicast address on card
5438 qeth_set_multicast_list(struct net_device *dev)
5440 struct qeth_card *card = (struct qeth_card *) dev->priv;
5442 if (card->info.type == QETH_CARD_TYPE_OSN)
5445 QETH_DBF_TEXT(trace,3,"setmulti");
5446 qeth_delete_mc_addresses(card);
5447 qeth_add_multicast_ipv4(card);
5448 #ifdef CONFIG_QETH_IPV6
5449 qeth_add_multicast_ipv6(card);
5451 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
5452 schedule_work(&card->kernel_thread_starter);
5456 qeth_neigh_setup(struct net_device *dev, struct neigh_parms *np)
5462 qeth_get_mac_for_ipm(__u32 ipm, char *mac, struct net_device *dev)
5464 if (dev->type == ARPHRD_IEEE802_TR)
5465 ip_tr_mc_map(ipm, mac);
5467 ip_eth_mc_map(ipm, mac);
5470 static struct qeth_ipaddr *
5471 qeth_get_addr_buffer(enum qeth_prot_versions prot)
5473 struct qeth_ipaddr *addr;
5475 addr = kmalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
5477 PRINT_WARN("Not enough memory to add address\n");
5480 memset(addr,0,sizeof(struct qeth_ipaddr));
5481 addr->type = QETH_IP_TYPE_NORMAL;
5487 qeth_osn_assist(struct net_device *dev,
5491 struct qeth_cmd_buffer *iob;
5492 struct qeth_card *card;
5495 QETH_DBF_TEXT(trace, 2, "osnsdmc");
5498 card = (struct qeth_card *)dev->priv;
5501 if ((card->state != CARD_STATE_UP) &&
5502 (card->state != CARD_STATE_SOFTSETUP))
5504 iob = qeth_wait_for_buffer(&card->write);
5505 memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
5506 rc = qeth_osn_send_ipa_cmd(card, iob, data_len);
5510 static struct net_device *
5511 qeth_netdev_by_devno(unsigned char *read_dev_no)
5513 struct qeth_card *card;
5514 struct net_device *ndev;
5515 unsigned char *readno;
5516 __u16 temp_dev_no, card_dev_no;
5518 unsigned long flags;
5521 memcpy(&temp_dev_no, read_dev_no, 2);
5522 read_lock_irqsave(&qeth_card_list.rwlock, flags);
5523 list_for_each_entry(card, &qeth_card_list.list, list) {
5524 readno = CARD_RDEV_ID(card);
5525 readno += (strlen(readno) - 4);
5526 card_dev_no = simple_strtoul(readno, &endp, 16);
5527 if (card_dev_no == temp_dev_no) {
5532 read_unlock_irqrestore(&qeth_card_list.rwlock, flags);
5537 qeth_osn_register(unsigned char *read_dev_no,
5538 struct net_device **dev,
5539 int (*assist_cb)(struct net_device *, void *),
5540 int (*data_cb)(struct sk_buff *))
5542 struct qeth_card * card;
5544 QETH_DBF_TEXT(trace, 2, "osnreg");
5545 *dev = qeth_netdev_by_devno(read_dev_no);
5548 card = (struct qeth_card *)(*dev)->priv;
5551 if ((assist_cb == NULL) || (data_cb == NULL))
5553 card->osn_info.assist_cb = assist_cb;
5554 card->osn_info.data_cb = data_cb;
5559 qeth_osn_deregister(struct net_device * dev)
5561 struct qeth_card *card;
5563 QETH_DBF_TEXT(trace, 2, "osndereg");
5566 card = (struct qeth_card *)dev->priv;
5569 card->osn_info.assist_cb = NULL;
5570 card->osn_info.data_cb = NULL;
5575 qeth_delete_mc_addresses(struct qeth_card *card)
5577 struct qeth_ipaddr *iptodo;
5578 unsigned long flags;
5580 QETH_DBF_TEXT(trace,4,"delmc");
5581 iptodo = qeth_get_addr_buffer(QETH_PROT_IPV4);
5583 QETH_DBF_TEXT(trace, 2, "dmcnomem");
5586 iptodo->type = QETH_IP_TYPE_DEL_ALL_MC;
5587 spin_lock_irqsave(&card->ip_lock, flags);
5588 if (!__qeth_insert_ip_todo(card, iptodo, 0))
5590 spin_unlock_irqrestore(&card->ip_lock, flags);
5594 qeth_add_mc(struct qeth_card *card, struct in_device *in4_dev)
5596 struct qeth_ipaddr *ipm;
5597 struct ip_mc_list *im4;
5598 char buf[MAX_ADDR_LEN];
5600 QETH_DBF_TEXT(trace,4,"addmc");
5601 for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
5602 qeth_get_mac_for_ipm(im4->multiaddr, buf, in4_dev->dev);
5603 ipm = qeth_get_addr_buffer(QETH_PROT_IPV4);
5606 ipm->u.a4.addr = im4->multiaddr;
5607 memcpy(ipm->mac,buf,OSA_ADDR_LEN);
5608 ipm->is_multicast = 1;
5609 if (!qeth_add_ip(card,ipm))
5615 qeth_add_vlan_mc(struct qeth_card *card)
5617 #ifdef CONFIG_QETH_VLAN
5618 struct in_device *in_dev;
5619 struct vlan_group *vg;
5622 QETH_DBF_TEXT(trace,4,"addmcvl");
5623 if ( ((card->options.layer2 == 0) &&
5624 (!qeth_is_supported(card,IPA_FULL_VLAN))) ||
5625 (card->vlangrp == NULL) )
5629 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
5630 if (vg->vlan_devices[i] == NULL ||
5631 !(vg->vlan_devices[i]->flags & IFF_UP))
5633 in_dev = in_dev_get(vg->vlan_devices[i]);
5636 read_lock(&in_dev->mc_list_lock);
5637 qeth_add_mc(card,in_dev);
5638 read_unlock(&in_dev->mc_list_lock);
5645 qeth_add_multicast_ipv4(struct qeth_card *card)
5647 struct in_device *in4_dev;
5649 QETH_DBF_TEXT(trace,4,"chkmcv4");
5650 in4_dev = in_dev_get(card->dev);
5651 if (in4_dev == NULL)
5653 read_lock(&in4_dev->mc_list_lock);
5654 qeth_add_mc(card, in4_dev);
5655 qeth_add_vlan_mc(card);
5656 read_unlock(&in4_dev->mc_list_lock);
5657 in_dev_put(in4_dev);
5660 #ifdef CONFIG_QETH_IPV6
5662 qeth_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev)
5664 struct qeth_ipaddr *ipm;
5665 struct ifmcaddr6 *im6;
5666 char buf[MAX_ADDR_LEN];
5668 QETH_DBF_TEXT(trace,4,"addmc6");
5669 for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) {
5670 ndisc_mc_map(&im6->mca_addr, buf, in6_dev->dev, 0);
5671 ipm = qeth_get_addr_buffer(QETH_PROT_IPV6);
5674 ipm->is_multicast = 1;
5675 memcpy(ipm->mac,buf,OSA_ADDR_LEN);
5676 memcpy(&ipm->u.a6.addr,&im6->mca_addr.s6_addr,
5677 sizeof(struct in6_addr));
5678 if (!qeth_add_ip(card,ipm))
5684 qeth_add_vlan_mc6(struct qeth_card *card)
5686 #ifdef CONFIG_QETH_VLAN
5687 struct inet6_dev *in_dev;
5688 struct vlan_group *vg;
5691 QETH_DBF_TEXT(trace,4,"admc6vl");
5692 if ( ((card->options.layer2 == 0) &&
5693 (!qeth_is_supported(card,IPA_FULL_VLAN))) ||
5694 (card->vlangrp == NULL))
5698 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
5699 if (vg->vlan_devices[i] == NULL ||
5700 !(vg->vlan_devices[i]->flags & IFF_UP))
5702 in_dev = in6_dev_get(vg->vlan_devices[i]);
5705 read_lock(&in_dev->lock);
5706 qeth_add_mc6(card,in_dev);
5707 read_unlock(&in_dev->lock);
5708 in6_dev_put(in_dev);
5710 #endif /* CONFIG_QETH_VLAN */
5714 qeth_add_multicast_ipv6(struct qeth_card *card)
5716 struct inet6_dev *in6_dev;
5718 QETH_DBF_TEXT(trace,4,"chkmcv6");
5719 if ((card->options.layer2 == 0) &&
5720 (!qeth_is_supported(card, IPA_IPV6)) )
5723 in6_dev = in6_dev_get(card->dev);
5724 if (in6_dev == NULL)
5726 read_lock(&in6_dev->lock);
5727 qeth_add_mc6(card, in6_dev);
5728 qeth_add_vlan_mc6(card);
5729 read_unlock(&in6_dev->lock);
5730 in6_dev_put(in6_dev);
5732 #endif /* CONFIG_QETH_IPV6 */
5735 qeth_layer2_send_setdelmac(struct qeth_card *card, __u8 *mac,
5736 enum qeth_ipa_cmds ipacmd,
5737 int (*reply_cb) (struct qeth_card *,
5741 struct qeth_ipa_cmd *cmd;
5742 struct qeth_cmd_buffer *iob;
5744 QETH_DBF_TEXT(trace, 2, "L2sdmac");
5745 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
5746 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5747 cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
5748 memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
5749 return qeth_send_ipa_cmd(card, iob, reply_cb, NULL);
5753 qeth_layer2_send_setgroupmac_cb(struct qeth_card *card,
5754 struct qeth_reply *reply,
5757 struct qeth_ipa_cmd *cmd;
5760 QETH_DBF_TEXT(trace, 2, "L2Sgmacb");
5761 cmd = (struct qeth_ipa_cmd *) data;
5762 mac = &cmd->data.setdelmac.mac[0];
5763 /* MAC already registered, needed in couple/uncouple case */
5764 if (cmd->hdr.return_code == 0x2005) {
5765 PRINT_WARN("Group MAC %02x:%02x:%02x:%02x:%02x:%02x " \
5766 "already existing on %s \n",
5767 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
5768 QETH_CARD_IFNAME(card));
5769 cmd->hdr.return_code = 0;
5771 if (cmd->hdr.return_code)
5772 PRINT_ERR("Could not set group MAC " \
5773 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5774 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
5775 QETH_CARD_IFNAME(card),cmd->hdr.return_code);
5780 qeth_layer2_send_setgroupmac(struct qeth_card *card, __u8 *mac)
5782 QETH_DBF_TEXT(trace, 2, "L2Sgmac");
5783 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_SETGMAC,
5784 qeth_layer2_send_setgroupmac_cb);
5788 qeth_layer2_send_delgroupmac_cb(struct qeth_card *card,
5789 struct qeth_reply *reply,
5792 struct qeth_ipa_cmd *cmd;
5795 QETH_DBF_TEXT(trace, 2, "L2Dgmacb");
5796 cmd = (struct qeth_ipa_cmd *) data;
5797 mac = &cmd->data.setdelmac.mac[0];
5798 if (cmd->hdr.return_code)
5799 PRINT_ERR("Could not delete group MAC " \
5800 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5801 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
5802 QETH_CARD_IFNAME(card), cmd->hdr.return_code);
5807 qeth_layer2_send_delgroupmac(struct qeth_card *card, __u8 *mac)
5809 QETH_DBF_TEXT(trace, 2, "L2Dgmac");
5810 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELGMAC,
5811 qeth_layer2_send_delgroupmac_cb);
5815 qeth_layer2_send_setmac_cb(struct qeth_card *card,
5816 struct qeth_reply *reply,
5819 struct qeth_ipa_cmd *cmd;
5821 QETH_DBF_TEXT(trace, 2, "L2Smaccb");
5822 cmd = (struct qeth_ipa_cmd *) data;
5823 if (cmd->hdr.return_code) {
5824 QETH_DBF_TEXT_(trace, 2, "L2er%x", cmd->hdr.return_code);
5825 PRINT_WARN("Error in registering MAC address on " \
5826 "device %s: x%x\n", CARD_BUS_ID(card),
5827 cmd->hdr.return_code);
5828 card->info.layer2_mac_registered = 0;
5829 cmd->hdr.return_code = -EIO;
5831 card->info.layer2_mac_registered = 1;
5832 memcpy(card->dev->dev_addr,cmd->data.setdelmac.mac,
5834 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
5835 "successfully registered on device %s\n",
5836 card->dev->dev_addr[0], card->dev->dev_addr[1],
5837 card->dev->dev_addr[2], card->dev->dev_addr[3],
5838 card->dev->dev_addr[4], card->dev->dev_addr[5],
5845 qeth_layer2_send_setmac(struct qeth_card *card, __u8 *mac)
5847 QETH_DBF_TEXT(trace, 2, "L2Setmac");
5848 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_SETVMAC,
5849 qeth_layer2_send_setmac_cb);
5853 qeth_layer2_send_delmac_cb(struct qeth_card *card,
5854 struct qeth_reply *reply,
5857 struct qeth_ipa_cmd *cmd;
5859 QETH_DBF_TEXT(trace, 2, "L2Dmaccb");
5860 cmd = (struct qeth_ipa_cmd *) data;
5861 if (cmd->hdr.return_code) {
5862 PRINT_WARN("Error in deregistering MAC address on " \
5863 "device %s: x%x\n", CARD_BUS_ID(card),
5864 cmd->hdr.return_code);
5865 QETH_DBF_TEXT_(trace, 2, "err%d", cmd->hdr.return_code);
5866 cmd->hdr.return_code = -EIO;
5869 card->info.layer2_mac_registered = 0;
5874 qeth_layer2_send_delmac(struct qeth_card *card, __u8 *mac)
5876 QETH_DBF_TEXT(trace, 2, "L2Delmac");
5877 if (!card->info.layer2_mac_registered)
5879 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELVMAC,
5880 qeth_layer2_send_delmac_cb);
5884 qeth_layer2_set_mac_address(struct net_device *dev, void *p)
5886 struct sockaddr *addr = p;
5887 struct qeth_card *card;
5890 QETH_DBF_TEXT(trace, 3, "setmac");
5892 if (qeth_verify_dev(dev) != QETH_REAL_CARD) {
5893 QETH_DBF_TEXT(trace, 3, "setmcINV");
5896 card = (struct qeth_card *) dev->priv;
5898 if (!card->options.layer2) {
5899 PRINT_WARN("Setting MAC address on %s is not supported"
5900 "in Layer 3 mode.\n", dev->name);
5901 QETH_DBF_TEXT(trace, 3, "setmcLY3");
5904 if (card->info.type == QETH_CARD_TYPE_OSN) {
5905 PRINT_WARN("Setting MAC address on %s is not supported.\n",
5907 QETH_DBF_TEXT(trace, 3, "setmcOSN");
5910 QETH_DBF_TEXT_(trace, 3, "%s", CARD_BUS_ID(card));
5911 QETH_DBF_HEX(trace, 3, addr->sa_data, OSA_ADDR_LEN);
5912 rc = qeth_layer2_send_delmac(card, &card->dev->dev_addr[0]);
5914 rc = qeth_layer2_send_setmac(card, addr->sa_data);
5919 qeth_fill_ipacmd_header(struct qeth_card *card, struct qeth_ipa_cmd *cmd,
5920 __u8 command, enum qeth_prot_versions prot)
5922 memset(cmd, 0, sizeof (struct qeth_ipa_cmd));
5923 cmd->hdr.command = command;
5924 cmd->hdr.initiator = IPA_CMD_INITIATOR_HOST;
5925 cmd->hdr.seqno = card->seqno.ipa;
5926 cmd->hdr.adapter_type = qeth_get_ipa_adp_type(card->info.link_type);
5927 cmd->hdr.rel_adapter_no = (__u8) card->info.portno;
5928 if (card->options.layer2)
5929 cmd->hdr.prim_version_no = 2;
5931 cmd->hdr.prim_version_no = 1;
5932 cmd->hdr.param_count = 1;
5933 cmd->hdr.prot_version = prot;
5934 cmd->hdr.ipa_supported = 0;
5935 cmd->hdr.ipa_enabled = 0;
5938 static struct qeth_cmd_buffer *
5939 qeth_get_ipacmd_buffer(struct qeth_card *card, enum qeth_ipa_cmds ipacmd,
5940 enum qeth_prot_versions prot)
5942 struct qeth_cmd_buffer *iob;
5943 struct qeth_ipa_cmd *cmd;
5945 iob = qeth_wait_for_buffer(&card->write);
5946 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5947 qeth_fill_ipacmd_header(card, cmd, ipacmd, prot);
5953 qeth_send_setdelmc(struct qeth_card *card, struct qeth_ipaddr *addr, int ipacmd)
5956 struct qeth_cmd_buffer *iob;
5957 struct qeth_ipa_cmd *cmd;
5959 QETH_DBF_TEXT(trace,4,"setdelmc");
5961 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto);
5962 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5963 memcpy(&cmd->data.setdelipm.mac,addr->mac, OSA_ADDR_LEN);
5964 if (addr->proto == QETH_PROT_IPV6)
5965 memcpy(cmd->data.setdelipm.ip6, &addr->u.a6.addr,
5966 sizeof(struct in6_addr));
5968 memcpy(&cmd->data.setdelipm.ip4, &addr->u.a4.addr,4);
5970 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
5975 qeth_fill_netmask(u8 *netmask, unsigned int len)
5978 for (i=0;i<16;i++) {
5983 netmask[i] = (u8)(0xFF00>>j);
5990 qeth_send_setdelip(struct qeth_card *card, struct qeth_ipaddr *addr,
5991 int ipacmd, unsigned int flags)
5994 struct qeth_cmd_buffer *iob;
5995 struct qeth_ipa_cmd *cmd;
5998 QETH_DBF_TEXT(trace,4,"setdelip");
5999 QETH_DBF_TEXT_(trace,4,"flags%02X", flags);
6001 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto);
6002 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6003 if (addr->proto == QETH_PROT_IPV6) {
6004 memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr,
6005 sizeof(struct in6_addr));
6006 qeth_fill_netmask(netmask,addr->u.a6.pfxlen);
6007 memcpy(cmd->data.setdelip6.mask, netmask,
6008 sizeof(struct in6_addr));
6009 cmd->data.setdelip6.flags = flags;
6011 memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4);
6012 memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4);
6013 cmd->data.setdelip4.flags = flags;
6016 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
6022 qeth_layer2_register_addr_entry(struct qeth_card *card,
6023 struct qeth_ipaddr *addr)
6025 if (!addr->is_multicast)
6027 QETH_DBF_TEXT(trace, 2, "setgmac");
6028 QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN);
6029 return qeth_layer2_send_setgroupmac(card, &addr->mac[0]);
6033 qeth_layer2_deregister_addr_entry(struct qeth_card *card,
6034 struct qeth_ipaddr *addr)
6036 if (!addr->is_multicast)
6038 QETH_DBF_TEXT(trace, 2, "delgmac");
6039 QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN);
6040 return qeth_layer2_send_delgroupmac(card, &addr->mac[0]);
6044 qeth_layer3_register_addr_entry(struct qeth_card *card,
6045 struct qeth_ipaddr *addr)
6051 if (addr->proto == QETH_PROT_IPV4) {
6052 QETH_DBF_TEXT(trace, 2,"setaddr4");
6053 QETH_DBF_HEX(trace, 3, &addr->u.a4.addr, sizeof(int));
6054 } else if (addr->proto == QETH_PROT_IPV6) {
6055 QETH_DBF_TEXT(trace, 2, "setaddr6");
6056 QETH_DBF_HEX(trace,3,&addr->u.a6.addr,8);
6057 QETH_DBF_HEX(trace,3,((char *)&addr->u.a6.addr)+8,8);
6059 QETH_DBF_TEXT(trace, 2, "setaddr?");
6060 QETH_DBF_HEX(trace, 3, addr, sizeof(struct qeth_ipaddr));
6063 if (addr->is_multicast)
6064 rc = qeth_send_setdelmc(card, addr, IPA_CMD_SETIPM);
6066 rc = qeth_send_setdelip(card, addr, IPA_CMD_SETIP,
6069 QETH_DBF_TEXT(trace, 2, "failed");
6070 } while ((--cnt > 0) && rc);
6072 QETH_DBF_TEXT(trace, 2, "FAILED");
6073 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
6074 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
6081 qeth_layer3_deregister_addr_entry(struct qeth_card *card,
6082 struct qeth_ipaddr *addr)
6087 if (addr->proto == QETH_PROT_IPV4) {
6088 QETH_DBF_TEXT(trace, 2,"deladdr4");
6089 QETH_DBF_HEX(trace, 3, &addr->u.a4.addr, sizeof(int));
6090 } else if (addr->proto == QETH_PROT_IPV6) {
6091 QETH_DBF_TEXT(trace, 2, "deladdr6");
6092 QETH_DBF_HEX(trace,3,&addr->u.a6.addr,8);
6093 QETH_DBF_HEX(trace,3,((char *)&addr->u.a6.addr)+8,8);
6095 QETH_DBF_TEXT(trace, 2, "deladdr?");
6096 QETH_DBF_HEX(trace, 3, addr, sizeof(struct qeth_ipaddr));
6098 if (addr->is_multicast)
6099 rc = qeth_send_setdelmc(card, addr, IPA_CMD_DELIPM);
6101 rc = qeth_send_setdelip(card, addr, IPA_CMD_DELIP,
6104 QETH_DBF_TEXT(trace, 2, "failed");
6105 /* TODO: re-activate this warning as soon as we have a
6107 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
6108 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
6116 qeth_register_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
6118 if (card->options.layer2)
6119 return qeth_layer2_register_addr_entry(card, addr);
6121 return qeth_layer3_register_addr_entry(card, addr);
6125 qeth_deregister_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
6127 if (card->options.layer2)
6128 return qeth_layer2_deregister_addr_entry(card, addr);
6130 return qeth_layer3_deregister_addr_entry(card, addr);
6134 qeth_ethtool_get_tx_csum(struct net_device *dev)
6136 /* We may need to say that we support tx csum offload if
6137 * we do EDDP or TSO. There are discussions going on to
6138 * enforce rules in the stack and in ethtool that make
6139 * SG and TSO depend on HW_CSUM. At the moment there are
6141 * If we say yes here, we have to checksum outbound packets
6147 qeth_ethtool_set_tx_csum(struct net_device *dev, u32 data)
6153 qeth_ethtool_get_rx_csum(struct net_device *dev)
6155 struct qeth_card *card = (struct qeth_card *)dev->priv;
6157 return (card->options.checksum_type == HW_CHECKSUMMING);
6161 qeth_ethtool_set_rx_csum(struct net_device *dev, u32 data)
6163 struct qeth_card *card = (struct qeth_card *)dev->priv;
6165 if ((card->state != CARD_STATE_DOWN) &&
6166 (card->state != CARD_STATE_RECOVER))
6169 card->options.checksum_type = HW_CHECKSUMMING;
6171 card->options.checksum_type = SW_CHECKSUMMING;
6176 qeth_ethtool_get_sg(struct net_device *dev)
6178 struct qeth_card *card = (struct qeth_card *)dev->priv;
6180 return ((card->options.large_send != QETH_LARGE_SEND_NO) &&
6181 (dev->features & NETIF_F_SG));
6185 qeth_ethtool_set_sg(struct net_device *dev, u32 data)
6187 struct qeth_card *card = (struct qeth_card *)dev->priv;
6190 if (card->options.large_send != QETH_LARGE_SEND_NO)
6191 dev->features |= NETIF_F_SG;
6193 dev->features &= ~NETIF_F_SG;
6197 dev->features &= ~NETIF_F_SG;
6202 qeth_ethtool_get_tso(struct net_device *dev)
6204 struct qeth_card *card = (struct qeth_card *)dev->priv;
6206 return ((card->options.large_send != QETH_LARGE_SEND_NO) &&
6207 (dev->features & NETIF_F_TSO));
6211 qeth_ethtool_set_tso(struct net_device *dev, u32 data)
6213 struct qeth_card *card = (struct qeth_card *)dev->priv;
6216 if (card->options.large_send != QETH_LARGE_SEND_NO)
6217 dev->features |= NETIF_F_TSO;
6219 dev->features &= ~NETIF_F_TSO;
6223 dev->features &= ~NETIF_F_TSO;
6227 static struct ethtool_ops qeth_ethtool_ops = {
6228 .get_tx_csum = qeth_ethtool_get_tx_csum,
6229 .set_tx_csum = qeth_ethtool_set_tx_csum,
6230 .get_rx_csum = qeth_ethtool_get_rx_csum,
6231 .set_rx_csum = qeth_ethtool_set_rx_csum,
6232 .get_sg = qeth_ethtool_get_sg,
6233 .set_sg = qeth_ethtool_set_sg,
6234 .get_tso = qeth_ethtool_get_tso,
6235 .set_tso = qeth_ethtool_set_tso,
6239 qeth_netdev_init(struct net_device *dev)
6241 struct qeth_card *card;
6243 card = (struct qeth_card *) dev->priv;
6245 QETH_DBF_TEXT(trace,3,"initdev");
6247 dev->tx_timeout = &qeth_tx_timeout;
6248 dev->watchdog_timeo = QETH_TX_TIMEOUT;
6249 dev->open = qeth_open;
6250 dev->stop = qeth_stop;
6251 dev->hard_start_xmit = qeth_hard_start_xmit;
6252 dev->do_ioctl = qeth_do_ioctl;
6253 dev->get_stats = qeth_get_stats;
6254 dev->change_mtu = qeth_change_mtu;
6255 dev->neigh_setup = qeth_neigh_setup;
6256 dev->set_multicast_list = qeth_set_multicast_list;
6257 #ifdef CONFIG_QETH_VLAN
6258 dev->vlan_rx_register = qeth_vlan_rx_register;
6259 dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid;
6260 dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid;
6262 dev->hard_header = card->orig_hard_header;
6263 if (qeth_get_netdev_flags(card) & IFF_NOARP) {
6264 dev->rebuild_header = NULL;
6265 dev->hard_header = NULL;
6266 if (card->options.fake_ll)
6267 dev->hard_header = qeth_fake_header;
6268 dev->header_cache_update = NULL;
6269 dev->hard_header_cache = NULL;
6271 #ifdef CONFIG_QETH_IPV6
6272 /*IPv6 address autoconfiguration stuff*/
6273 if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD))
6274 card->dev->dev_id = card->info.unique_id & 0xffff;
6276 dev->hard_header_parse = NULL;
6277 dev->set_mac_address = qeth_layer2_set_mac_address;
6278 dev->flags |= qeth_get_netdev_flags(card);
6279 if ((card->options.fake_broadcast) ||
6280 (card->info.broadcast_capable))
6281 dev->flags |= IFF_BROADCAST;
6282 dev->hard_header_len =
6283 qeth_get_hlen(card->info.link_type) + card->options.add_hhlen;
6284 dev->addr_len = OSA_ADDR_LEN;
6285 dev->mtu = card->info.initial_mtu;
6286 if (card->info.type != QETH_CARD_TYPE_OSN)
6287 SET_ETHTOOL_OPS(dev, &qeth_ethtool_ops);
6288 SET_MODULE_OWNER(dev);
6293 qeth_init_func_level(struct qeth_card *card)
6295 if (card->ipato.enabled) {
6296 if (card->info.type == QETH_CARD_TYPE_IQD)
6297 card->info.func_level =
6298 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT;
6300 card->info.func_level =
6301 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT;
6303 if (card->info.type == QETH_CARD_TYPE_IQD)
6304 /*FIXME:why do we have same values for dis and ena for osae??? */
6305 card->info.func_level =
6306 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT;
6308 card->info.func_level =
6309 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT;
6314 * hardsetup card, initialize MPC and QDIO stuff
6317 qeth_hardsetup_card(struct qeth_card *card)
6322 QETH_DBF_TEXT(setup, 2, "hrdsetup");
6326 PRINT_WARN("Retrying to do IDX activates.\n");
6327 ccw_device_set_offline(CARD_DDEV(card));
6328 ccw_device_set_offline(CARD_WDEV(card));
6329 ccw_device_set_offline(CARD_RDEV(card));
6330 ccw_device_set_online(CARD_RDEV(card));
6331 ccw_device_set_online(CARD_WDEV(card));
6332 ccw_device_set_online(CARD_DDEV(card));
6334 rc = qeth_qdio_clear_card(card,card->info.type!=QETH_CARD_TYPE_IQD);
6335 if (rc == -ERESTARTSYS) {
6336 QETH_DBF_TEXT(setup, 2, "break1");
6339 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
6345 if ((rc = qeth_get_unitaddr(card))){
6346 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
6349 qeth_init_tokens(card);
6350 qeth_init_func_level(card);
6351 rc = qeth_idx_activate_channel(&card->read, qeth_idx_read_cb);
6352 if (rc == -ERESTARTSYS) {
6353 QETH_DBF_TEXT(setup, 2, "break2");
6356 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
6362 rc = qeth_idx_activate_channel(&card->write, qeth_idx_write_cb);
6363 if (rc == -ERESTARTSYS) {
6364 QETH_DBF_TEXT(setup, 2, "break3");
6367 QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
6373 if ((rc = qeth_mpc_initialize(card))){
6374 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
6377 /*network device will be recovered*/
6379 card->dev->hard_header = card->orig_hard_header;
6382 /* at first set_online allocate netdev */
6383 card->dev = qeth_get_netdevice(card->info.type,
6384 card->info.link_type);
6386 qeth_qdio_clear_card(card, card->info.type !=
6387 QETH_CARD_TYPE_IQD);
6389 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
6392 card->dev->priv = card;
6393 card->orig_hard_header = card->dev->hard_header;
6394 card->dev->type = qeth_get_arphdr_type(card->info.type,
6395 card->info.link_type);
6396 card->dev->init = qeth_netdev_init;
6399 PRINT_ERR("Initialization in hardsetup failed! rc=%d\n", rc);
6404 qeth_default_setassparms_cb(struct qeth_card *card, struct qeth_reply *reply,
6407 struct qeth_ipa_cmd *cmd;
6409 QETH_DBF_TEXT(trace,4,"defadpcb");
6411 cmd = (struct qeth_ipa_cmd *) data;
6412 if (cmd->hdr.return_code == 0){
6413 cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code;
6414 if (cmd->hdr.prot_version == QETH_PROT_IPV4)
6415 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
6416 #ifdef CONFIG_QETH_IPV6
6417 if (cmd->hdr.prot_version == QETH_PROT_IPV6)
6418 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
6421 if (cmd->data.setassparms.hdr.assist_no == IPA_INBOUND_CHECKSUM &&
6422 cmd->data.setassparms.hdr.command_code == IPA_CMD_ASS_START) {
6423 card->info.csum_mask = cmd->data.setassparms.data.flags_32bit;
6424 QETH_DBF_TEXT_(trace, 3, "csum:%d", card->info.csum_mask);
6430 qeth_default_setadapterparms_cb(struct qeth_card *card,
6431 struct qeth_reply *reply,
6434 struct qeth_ipa_cmd *cmd;
6436 QETH_DBF_TEXT(trace,4,"defadpcb");
6438 cmd = (struct qeth_ipa_cmd *) data;
6439 if (cmd->hdr.return_code == 0)
6440 cmd->hdr.return_code = cmd->data.setadapterparms.hdr.return_code;
6445 qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply,
6448 struct qeth_ipa_cmd *cmd;
6450 QETH_DBF_TEXT(trace,3,"quyadpcb");
6452 cmd = (struct qeth_ipa_cmd *) data;
6453 if (cmd->data.setadapterparms.data.query_cmds_supp.lan_type & 0x7f)
6454 card->info.link_type =
6455 cmd->data.setadapterparms.data.query_cmds_supp.lan_type;
6456 card->options.adp.supported_funcs =
6457 cmd->data.setadapterparms.data.query_cmds_supp.supported_cmds;
6458 return qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd);
6462 qeth_query_setadapterparms(struct qeth_card *card)
6465 struct qeth_cmd_buffer *iob;
6467 QETH_DBF_TEXT(trace,3,"queryadp");
6468 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_COMMANDS_SUPPORTED,
6469 sizeof(struct qeth_ipacmd_setadpparms));
6470 rc = qeth_send_ipa_cmd(card, iob, qeth_query_setadapterparms_cb, NULL);
6475 qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
6476 struct qeth_reply *reply,
6479 struct qeth_ipa_cmd *cmd;
6481 QETH_DBF_TEXT(trace,4,"chgmaccb");
6483 cmd = (struct qeth_ipa_cmd *) data;
6484 memcpy(card->dev->dev_addr,
6485 &cmd->data.setadapterparms.data.change_addr.addr,OSA_ADDR_LEN);
6486 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
6491 qeth_setadpparms_change_macaddr(struct qeth_card *card)
6494 struct qeth_cmd_buffer *iob;
6495 struct qeth_ipa_cmd *cmd;
6497 QETH_DBF_TEXT(trace,4,"chgmac");
6499 iob = qeth_get_adapter_cmd(card,IPA_SETADP_ALTER_MAC_ADDRESS,
6500 sizeof(struct qeth_ipacmd_setadpparms));
6501 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6502 cmd->data.setadapterparms.data.change_addr.cmd = CHANGE_ADDR_READ_MAC;
6503 cmd->data.setadapterparms.data.change_addr.addr_size = OSA_ADDR_LEN;
6504 memcpy(&cmd->data.setadapterparms.data.change_addr.addr,
6505 card->dev->dev_addr, OSA_ADDR_LEN);
6506 rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_change_macaddr_cb,
6512 qeth_send_setadp_mode(struct qeth_card *card, __u32 command, __u32 mode)
6515 struct qeth_cmd_buffer *iob;
6516 struct qeth_ipa_cmd *cmd;
6518 QETH_DBF_TEXT(trace,4,"adpmode");
6520 iob = qeth_get_adapter_cmd(card, command,
6521 sizeof(struct qeth_ipacmd_setadpparms));
6522 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6523 cmd->data.setadapterparms.data.mode = mode;
6524 rc = qeth_send_ipa_cmd(card, iob, qeth_default_setadapterparms_cb,
6530 qeth_setadapter_hstr(struct qeth_card *card)
6534 QETH_DBF_TEXT(trace,4,"adphstr");
6536 if (qeth_adp_supported(card,IPA_SETADP_SET_BROADCAST_MODE)) {
6537 rc = qeth_send_setadp_mode(card, IPA_SETADP_SET_BROADCAST_MODE,
6538 card->options.broadcast_mode);
6540 PRINT_WARN("couldn't set broadcast mode on "
6542 CARD_BUS_ID(card), rc);
6543 rc = qeth_send_setadp_mode(card, IPA_SETADP_ALTER_MAC_ADDRESS,
6544 card->options.macaddr_mode);
6546 PRINT_WARN("couldn't set macaddr mode on "
6547 "device %s: x%x\n", CARD_BUS_ID(card), rc);
6550 if (card->options.broadcast_mode == QETH_TR_BROADCAST_LOCAL)
6551 PRINT_WARN("set adapter parameters not available "
6552 "to set broadcast mode, using ALLRINGS "
6553 "on device %s:\n", CARD_BUS_ID(card));
6554 if (card->options.macaddr_mode == QETH_TR_MACADDR_CANONICAL)
6555 PRINT_WARN("set adapter parameters not available "
6556 "to set macaddr mode, using NONCANONICAL "
6557 "on device %s:\n", CARD_BUS_ID(card));
6562 qeth_setadapter_parms(struct qeth_card *card)
6566 QETH_DBF_TEXT(setup, 2, "setadprm");
6568 if (!qeth_is_supported(card, IPA_SETADAPTERPARMS)){
6569 PRINT_WARN("set adapter parameters not supported "
6572 QETH_DBF_TEXT(setup, 2, " notsupp");
6575 rc = qeth_query_setadapterparms(card);
6577 PRINT_WARN("couldn't set adapter parameters on device %s: "
6578 "x%x\n", CARD_BUS_ID(card), rc);
6581 if (qeth_adp_supported(card,IPA_SETADP_ALTER_MAC_ADDRESS)) {
6582 rc = qeth_setadpparms_change_macaddr(card);
6584 PRINT_WARN("couldn't get MAC address on "
6586 CARD_BUS_ID(card), rc);
6589 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) ||
6590 (card->info.link_type == QETH_LINK_TYPE_LANE_TR))
6591 rc = qeth_setadapter_hstr(card);
6597 qeth_layer2_initialize(struct qeth_card *card)
6602 QETH_DBF_TEXT(setup, 2, "doL2init");
6603 QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card));
6605 rc = qeth_setadpparms_change_macaddr(card);
6607 PRINT_WARN("couldn't get MAC address on "
6609 CARD_BUS_ID(card), rc);
6610 QETH_DBF_TEXT_(setup, 2,"1err%d",rc);
6613 QETH_DBF_HEX(setup,2, card->dev->dev_addr, OSA_ADDR_LEN);
6615 rc = qeth_layer2_send_setmac(card, &card->dev->dev_addr[0]);
6617 QETH_DBF_TEXT_(setup, 2,"2err%d",rc);
6623 qeth_send_startstoplan(struct qeth_card *card, enum qeth_ipa_cmds ipacmd,
6624 enum qeth_prot_versions prot)
6627 struct qeth_cmd_buffer *iob;
6629 iob = qeth_get_ipacmd_buffer(card,ipacmd,prot);
6630 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
6636 qeth_send_startlan(struct qeth_card *card, enum qeth_prot_versions prot)
6640 QETH_DBF_TEXT_(setup, 2, "strtlan%i", prot);
6642 rc = qeth_send_startstoplan(card, IPA_CMD_STARTLAN, prot);
6647 qeth_send_stoplan(struct qeth_card *card)
6652 * TODO: according to the IPA format document page 14,
6653 * TCP/IP (we!) never issue a STOPLAN
6656 QETH_DBF_TEXT(trace, 2, "stoplan");
6658 rc = qeth_send_startstoplan(card, IPA_CMD_STOPLAN, QETH_PROT_IPV4);
6663 qeth_query_ipassists_cb(struct qeth_card *card, struct qeth_reply *reply,
6666 struct qeth_ipa_cmd *cmd;
6668 QETH_DBF_TEXT(setup, 2, "qipasscb");
6670 cmd = (struct qeth_ipa_cmd *) data;
6671 if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
6672 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
6673 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
6674 /* Disable IPV6 support hard coded for Hipersockets */
6675 if(card->info.type == QETH_CARD_TYPE_IQD)
6676 card->options.ipa4.supported_funcs &= ~IPA_IPV6;
6678 #ifdef CONFIG_QETH_IPV6
6679 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
6680 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
6683 QETH_DBF_TEXT(setup, 2, "suppenbl");
6684 QETH_DBF_TEXT_(setup, 2, "%x",cmd->hdr.ipa_supported);
6685 QETH_DBF_TEXT_(setup, 2, "%x",cmd->hdr.ipa_enabled);
6690 qeth_query_ipassists(struct qeth_card *card, enum qeth_prot_versions prot)
6693 struct qeth_cmd_buffer *iob;
6695 QETH_DBF_TEXT_(setup, 2, "qipassi%i", prot);
6696 if (card->options.layer2) {
6697 QETH_DBF_TEXT(setup, 2, "noprmly2");
6701 iob = qeth_get_ipacmd_buffer(card,IPA_CMD_QIPASSIST,prot);
6702 rc = qeth_send_ipa_cmd(card, iob, qeth_query_ipassists_cb, NULL);
6706 static struct qeth_cmd_buffer *
6707 qeth_get_setassparms_cmd(struct qeth_card *card, enum qeth_ipa_funcs ipa_func,
6708 __u16 cmd_code, __u16 len,
6709 enum qeth_prot_versions prot)
6711 struct qeth_cmd_buffer *iob;
6712 struct qeth_ipa_cmd *cmd;
6714 QETH_DBF_TEXT(trace,4,"getasscm");
6715 iob = qeth_get_ipacmd_buffer(card,IPA_CMD_SETASSPARMS,prot);
6717 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6718 cmd->data.setassparms.hdr.assist_no = ipa_func;
6719 cmd->data.setassparms.hdr.length = 8 + len;
6720 cmd->data.setassparms.hdr.command_code = cmd_code;
6721 cmd->data.setassparms.hdr.return_code = 0;
6722 cmd->data.setassparms.hdr.seq_no = 0;
6728 qeth_send_setassparms(struct qeth_card *card, struct qeth_cmd_buffer *iob,
6729 __u16 len, long data,
6731 (struct qeth_card *,struct qeth_reply *,unsigned long),
6735 struct qeth_ipa_cmd *cmd;
6737 QETH_DBF_TEXT(trace,4,"sendassp");
6739 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6740 if (len <= sizeof(__u32))
6741 cmd->data.setassparms.data.flags_32bit = (__u32) data;
6742 else if (len > sizeof(__u32))
6743 memcpy(&cmd->data.setassparms.data, (void *) data, len);
6745 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param);
6749 #ifdef CONFIG_QETH_IPV6
6751 qeth_send_simple_setassparms_ipv6(struct qeth_card *card,
6752 enum qeth_ipa_funcs ipa_func, __u16 cmd_code)
6756 struct qeth_cmd_buffer *iob;
6758 QETH_DBF_TEXT(trace,4,"simassp6");
6759 iob = qeth_get_setassparms_cmd(card, ipa_func, cmd_code,
6761 rc = qeth_send_setassparms(card, iob, 0, 0,
6762 qeth_default_setassparms_cb, NULL);
6768 qeth_send_simple_setassparms(struct qeth_card *card,
6769 enum qeth_ipa_funcs ipa_func,
6770 __u16 cmd_code, long data)
6774 struct qeth_cmd_buffer *iob;
6776 QETH_DBF_TEXT(trace,4,"simassp4");
6778 length = sizeof(__u32);
6779 iob = qeth_get_setassparms_cmd(card, ipa_func, cmd_code,
6780 length, QETH_PROT_IPV4);
6781 rc = qeth_send_setassparms(card, iob, length, data,
6782 qeth_default_setassparms_cb, NULL);
6787 qeth_start_ipa_arp_processing(struct qeth_card *card)
6791 QETH_DBF_TEXT(trace,3,"ipaarp");
6793 if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) {
6794 PRINT_WARN("ARP processing not supported "
6795 "on %s!\n", QETH_CARD_IFNAME(card));
6798 rc = qeth_send_simple_setassparms(card,IPA_ARP_PROCESSING,
6799 IPA_CMD_ASS_START, 0);
6801 PRINT_WARN("Could not start ARP processing "
6802 "assist on %s: 0x%x\n",
6803 QETH_CARD_IFNAME(card), rc);
6809 qeth_start_ipa_ip_fragmentation(struct qeth_card *card)
6813 QETH_DBF_TEXT(trace,3,"ipaipfrg");
6815 if (!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) {
6816 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
6817 QETH_CARD_IFNAME(card));
6821 rc = qeth_send_simple_setassparms(card, IPA_IP_FRAGMENTATION,
6822 IPA_CMD_ASS_START, 0);
6824 PRINT_WARN("Could not start Hardware IP fragmentation "
6825 "assist on %s: 0x%x\n",
6826 QETH_CARD_IFNAME(card), rc);
6828 PRINT_INFO("Hardware IP fragmentation enabled \n");
6833 qeth_start_ipa_source_mac(struct qeth_card *card)
6837 QETH_DBF_TEXT(trace,3,"stsrcmac");
6839 if (!card->options.fake_ll)
6842 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) {
6843 PRINT_INFO("Inbound source address not "
6844 "supported on %s\n", QETH_CARD_IFNAME(card));
6848 rc = qeth_send_simple_setassparms(card, IPA_SOURCE_MAC,
6849 IPA_CMD_ASS_START, 0);
6851 PRINT_WARN("Could not start inbound source "
6852 "assist on %s: 0x%x\n",
6853 QETH_CARD_IFNAME(card), rc);
6858 qeth_start_ipa_vlan(struct qeth_card *card)
6862 QETH_DBF_TEXT(trace,3,"strtvlan");
6864 #ifdef CONFIG_QETH_VLAN
6865 if (!qeth_is_supported(card, IPA_FULL_VLAN)) {
6866 PRINT_WARN("VLAN not supported on %s\n", QETH_CARD_IFNAME(card));
6870 rc = qeth_send_simple_setassparms(card, IPA_VLAN_PRIO,
6871 IPA_CMD_ASS_START,0);
6873 PRINT_WARN("Could not start vlan "
6874 "assist on %s: 0x%x\n",
6875 QETH_CARD_IFNAME(card), rc);
6877 PRINT_INFO("VLAN enabled \n");
6878 card->dev->features |=
6879 NETIF_F_HW_VLAN_FILTER |
6880 NETIF_F_HW_VLAN_TX |
6883 #endif /* QETH_VLAN */
6888 qeth_start_ipa_multicast(struct qeth_card *card)
6892 QETH_DBF_TEXT(trace,3,"stmcast");
6894 if (!qeth_is_supported(card, IPA_MULTICASTING)) {
6895 PRINT_WARN("Multicast not supported on %s\n",
6896 QETH_CARD_IFNAME(card));
6900 rc = qeth_send_simple_setassparms(card, IPA_MULTICASTING,
6901 IPA_CMD_ASS_START,0);
6903 PRINT_WARN("Could not start multicast "
6904 "assist on %s: rc=%i\n",
6905 QETH_CARD_IFNAME(card), rc);
6907 PRINT_INFO("Multicast enabled\n");
6908 card->dev->flags |= IFF_MULTICAST;
6913 #ifdef CONFIG_QETH_IPV6
6915 qeth_softsetup_ipv6(struct qeth_card *card)
6919 QETH_DBF_TEXT(trace,3,"softipv6");
6921 netif_stop_queue(card->dev);
6922 rc = qeth_send_startlan(card, QETH_PROT_IPV6);
6924 PRINT_ERR("IPv6 startlan failed on %s\n",
6925 QETH_CARD_IFNAME(card));
6928 netif_wake_queue(card->dev);
6929 rc = qeth_query_ipassists(card,QETH_PROT_IPV6);
6931 PRINT_ERR("IPv6 query ipassist failed on %s\n",
6932 QETH_CARD_IFNAME(card));
6935 rc = qeth_send_simple_setassparms(card, IPA_IPV6,
6936 IPA_CMD_ASS_START, 3);
6938 PRINT_WARN("IPv6 start assist (version 4) failed "
6940 QETH_CARD_IFNAME(card), rc);
6943 rc = qeth_send_simple_setassparms_ipv6(card, IPA_IPV6,
6946 PRINT_WARN("IPV6 start assist (version 6) failed "
6948 QETH_CARD_IFNAME(card), rc);
6951 rc = qeth_send_simple_setassparms_ipv6(card, IPA_PASSTHRU,
6954 PRINT_WARN("Could not enable passthrough "
6956 QETH_CARD_IFNAME(card), rc);
6959 PRINT_INFO("IPV6 enabled \n");
6966 qeth_start_ipa_ipv6(struct qeth_card *card)
6969 #ifdef CONFIG_QETH_IPV6
6970 QETH_DBF_TEXT(trace,3,"strtipv6");
6972 if (!qeth_is_supported(card, IPA_IPV6)) {
6973 PRINT_WARN("IPv6 not supported on %s\n",
6974 QETH_CARD_IFNAME(card));
6977 rc = qeth_softsetup_ipv6(card);
6983 qeth_start_ipa_broadcast(struct qeth_card *card)
6987 QETH_DBF_TEXT(trace,3,"stbrdcst");
6988 card->info.broadcast_capable = 0;
6989 if (!qeth_is_supported(card, IPA_FILTERING)) {
6990 PRINT_WARN("Broadcast not supported on %s\n",
6991 QETH_CARD_IFNAME(card));
6995 rc = qeth_send_simple_setassparms(card, IPA_FILTERING,
6996 IPA_CMD_ASS_START, 0);
6998 PRINT_WARN("Could not enable broadcasting filtering "
7000 QETH_CARD_IFNAME(card), rc);
7004 rc = qeth_send_simple_setassparms(card, IPA_FILTERING,
7005 IPA_CMD_ASS_CONFIGURE, 1);
7007 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
7008 QETH_CARD_IFNAME(card), rc);
7011 card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO;
7012 PRINT_INFO("Broadcast enabled \n");
7013 rc = qeth_send_simple_setassparms(card, IPA_FILTERING,
7014 IPA_CMD_ASS_ENABLE, 1);
7016 PRINT_WARN("Could not set up broadcast echo filtering on "
7017 "%s: 0x%x\n", QETH_CARD_IFNAME(card), rc);
7020 card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO;
7022 if (card->info.broadcast_capable)
7023 card->dev->flags |= IFF_BROADCAST;
7025 card->dev->flags &= ~IFF_BROADCAST;
7030 qeth_send_checksum_command(struct qeth_card *card)
7034 rc = qeth_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM,
7035 IPA_CMD_ASS_START, 0);
7037 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
7038 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7039 QETH_CARD_IFNAME(card), rc);
7042 rc = qeth_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM,
7044 card->info.csum_mask);
7046 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
7047 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7048 QETH_CARD_IFNAME(card), rc);
7055 qeth_start_ipa_checksum(struct qeth_card *card)
7059 QETH_DBF_TEXT(trace,3,"strtcsum");
7061 if (card->options.checksum_type == NO_CHECKSUMMING) {
7062 PRINT_WARN("Using no checksumming on %s.\n",
7063 QETH_CARD_IFNAME(card));
7066 if (card->options.checksum_type == SW_CHECKSUMMING) {
7067 PRINT_WARN("Using SW checksumming on %s.\n",
7068 QETH_CARD_IFNAME(card));
7071 if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM)) {
7072 PRINT_WARN("Inbound HW Checksumming not "
7073 "supported on %s,\ncontinuing "
7074 "using Inbound SW Checksumming\n",
7075 QETH_CARD_IFNAME(card));
7076 card->options.checksum_type = SW_CHECKSUMMING;
7079 rc = qeth_send_checksum_command(card);
7081 PRINT_INFO("HW Checksumming (inbound) enabled \n");
7087 qeth_start_ipa_tso(struct qeth_card *card)
7091 QETH_DBF_TEXT(trace,3,"sttso");
7093 if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
7094 PRINT_WARN("Outbound TSO not supported on %s\n",
7095 QETH_CARD_IFNAME(card));
7098 rc = qeth_send_simple_setassparms(card, IPA_OUTBOUND_TSO,
7099 IPA_CMD_ASS_START,0);
7101 PRINT_WARN("Could not start outbound TSO "
7102 "assist on %s: rc=%i\n",
7103 QETH_CARD_IFNAME(card), rc);
7105 PRINT_INFO("Outbound TSO enabled\n");
7107 if (rc && (card->options.large_send == QETH_LARGE_SEND_TSO)){
7108 card->options.large_send = QETH_LARGE_SEND_NO;
7109 card->dev->features &= ~ (NETIF_F_TSO | NETIF_F_SG);
7115 qeth_start_ipassists(struct qeth_card *card)
7117 QETH_DBF_TEXT(trace,3,"strtipas");
7118 qeth_start_ipa_arp_processing(card); /* go on*/
7119 qeth_start_ipa_ip_fragmentation(card); /* go on*/
7120 qeth_start_ipa_source_mac(card); /* go on*/
7121 qeth_start_ipa_vlan(card); /* go on*/
7122 qeth_start_ipa_multicast(card); /* go on*/
7123 qeth_start_ipa_ipv6(card); /* go on*/
7124 qeth_start_ipa_broadcast(card); /* go on*/
7125 qeth_start_ipa_checksum(card); /* go on*/
7126 qeth_start_ipa_tso(card); /* go on*/
7131 qeth_send_setrouting(struct qeth_card *card, enum qeth_routing_types type,
7132 enum qeth_prot_versions prot)
7135 struct qeth_ipa_cmd *cmd;
7136 struct qeth_cmd_buffer *iob;
7138 QETH_DBF_TEXT(trace,4,"setroutg");
7139 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot);
7140 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
7141 cmd->data.setrtg.type = (type);
7142 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
7149 qeth_correct_routing_type(struct qeth_card *card, enum qeth_routing_types *type,
7150 enum qeth_prot_versions prot)
7152 if (card->info.type == QETH_CARD_TYPE_IQD) {
7155 case PRIMARY_CONNECTOR:
7156 case SECONDARY_CONNECTOR:
7157 case MULTICAST_ROUTER:
7165 case PRIMARY_ROUTER:
7166 case SECONDARY_ROUTER:
7168 case MULTICAST_ROUTER:
7169 if (qeth_is_ipafunc_supported(card, prot,
7177 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
7178 "Router status set to 'no router'.\n",
7179 ((*type == PRIMARY_ROUTER)? "primary router" :
7180 (*type == SECONDARY_ROUTER)? "secondary router" :
7181 (*type == PRIMARY_CONNECTOR)? "primary connector" :
7182 (*type == SECONDARY_CONNECTOR)? "secondary connector" :
7183 (*type == MULTICAST_ROUTER)? "multicast router" :
7190 qeth_setrouting_v4(struct qeth_card *card)
7194 QETH_DBF_TEXT(trace,3,"setrtg4");
7196 qeth_correct_routing_type(card, &card->options.route4.type,
7199 rc = qeth_send_setrouting(card, card->options.route4.type,
7202 card->options.route4.type = NO_ROUTER;
7203 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7204 "Type set to 'no router'.\n",
7205 rc, QETH_CARD_IFNAME(card));
7211 qeth_setrouting_v6(struct qeth_card *card)
7215 QETH_DBF_TEXT(trace,3,"setrtg6");
7216 #ifdef CONFIG_QETH_IPV6
7218 qeth_correct_routing_type(card, &card->options.route6.type,
7221 if ((card->options.route6.type == NO_ROUTER) ||
7222 ((card->info.type == QETH_CARD_TYPE_OSAE) &&
7223 (card->options.route6.type == MULTICAST_ROUTER) &&
7224 !qeth_is_supported6(card,IPA_OSA_MC_ROUTER)))
7226 rc = qeth_send_setrouting(card, card->options.route6.type,
7229 card->options.route6.type = NO_ROUTER;
7230 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7231 "Type set to 'no router'.\n",
7232 rc, QETH_CARD_IFNAME(card));
7239 qeth_set_large_send(struct qeth_card *card, enum qeth_large_send_types type)
7243 if (card->dev == NULL) {
7244 card->options.large_send = type;
7247 netif_stop_queue(card->dev);
7248 card->options.large_send = type;
7249 switch (card->options.large_send) {
7250 case QETH_LARGE_SEND_EDDP:
7251 card->dev->features |= NETIF_F_TSO | NETIF_F_SG;
7253 case QETH_LARGE_SEND_TSO:
7254 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)){
7255 card->dev->features |= NETIF_F_TSO | NETIF_F_SG;
7257 PRINT_WARN("TSO not supported on %s. "
7258 "large_send set to 'no'.\n",
7260 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG);
7261 card->options.large_send = QETH_LARGE_SEND_NO;
7265 default: /* includes QETH_LARGE_SEND_NO */
7266 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG);
7269 netif_wake_queue(card->dev);
7274 * softsetup card: init IPA stuff
7277 qeth_softsetup_card(struct qeth_card *card)
7281 QETH_DBF_TEXT(setup, 2, "softsetp");
7283 if ((rc = qeth_send_startlan(card, QETH_PROT_IPV4))){
7284 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
7286 PRINT_WARN("LAN on card %s if offline! "
7287 "Continuing softsetup.\n",
7289 card->lan_online = 0;
7293 card->lan_online = 1;
7294 if (card->info.type==QETH_CARD_TYPE_OSN)
7296 if (card->options.layer2) {
7297 card->dev->features |=
7298 NETIF_F_HW_VLAN_FILTER |
7299 NETIF_F_HW_VLAN_TX |
7301 card->dev->flags|=IFF_MULTICAST|IFF_BROADCAST;
7302 card->info.broadcast_capable=1;
7303 if ((rc = qeth_layer2_initialize(card))) {
7304 QETH_DBF_TEXT_(setup, 2, "L2err%d", rc);
7307 #ifdef CONFIG_QETH_VLAN
7308 qeth_layer2_process_vlans(card, 0);
7312 if ((card->options.large_send == QETH_LARGE_SEND_EDDP) ||
7313 (card->options.large_send == QETH_LARGE_SEND_TSO))
7314 card->dev->features |= NETIF_F_TSO | NETIF_F_SG;
7316 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG);
7318 if ((rc = qeth_setadapter_parms(card)))
7319 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
7320 if ((rc = qeth_start_ipassists(card)))
7321 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
7322 if ((rc = qeth_setrouting_v4(card)))
7323 QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
7324 if ((rc = qeth_setrouting_v6(card)))
7325 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
7327 netif_stop_queue(card->dev);
7331 #ifdef CONFIG_QETH_IPV6
7333 qeth_get_unique_id_cb(struct qeth_card *card, struct qeth_reply *reply,
7336 struct qeth_ipa_cmd *cmd;
7338 cmd = (struct qeth_ipa_cmd *) data;
7339 if (cmd->hdr.return_code == 0)
7340 card->info.unique_id = *((__u16 *)
7341 &cmd->data.create_destroy_addr.unique_id[6]);
7343 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
7344 UNIQUE_ID_NOT_BY_CARD;
7345 PRINT_WARN("couldn't get a unique id from the card on device "
7346 "%s (result=x%x), using default id. ipv6 "
7347 "autoconfig on other lpars may lead to duplicate "
7348 "ip addresses. please use manually "
7349 "configured ones.\n",
7350 CARD_BUS_ID(card), cmd->hdr.return_code);
7357 qeth_put_unique_id(struct qeth_card *card)
7361 #ifdef CONFIG_QETH_IPV6
7362 struct qeth_cmd_buffer *iob;
7363 struct qeth_ipa_cmd *cmd;
7365 QETH_DBF_TEXT(trace,2,"puniqeid");
7367 if ((card->info.unique_id & UNIQUE_ID_NOT_BY_CARD) ==
7368 UNIQUE_ID_NOT_BY_CARD)
7370 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_DESTROY_ADDR,
7372 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
7373 *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) =
7374 card->info.unique_id;
7375 memcpy(&cmd->data.create_destroy_addr.unique_id[0],
7376 card->dev->dev_addr, OSA_ADDR_LEN);
7377 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
7379 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
7380 UNIQUE_ID_NOT_BY_CARD;
7389 qeth_clear_ip_list(struct qeth_card *card, int clean, int recover)
7391 struct qeth_ipaddr *addr, *tmp;
7392 unsigned long flags;
7394 QETH_DBF_TEXT(trace,4,"clearip");
7395 spin_lock_irqsave(&card->ip_lock, flags);
7396 /* clear todo list */
7397 list_for_each_entry_safe(addr, tmp, card->ip_tbd_list, entry){
7398 list_del(&addr->entry);
7402 while (!list_empty(&card->ip_list)) {
7403 addr = list_entry(card->ip_list.next,
7404 struct qeth_ipaddr, entry);
7405 list_del_init(&addr->entry);
7407 spin_unlock_irqrestore(&card->ip_lock, flags);
7408 qeth_deregister_addr_entry(card, addr);
7409 spin_lock_irqsave(&card->ip_lock, flags);
7411 if (!recover || addr->is_multicast) {
7415 list_add_tail(&addr->entry, card->ip_tbd_list);
7417 spin_unlock_irqrestore(&card->ip_lock, flags);
7421 qeth_set_allowed_threads(struct qeth_card *card, unsigned long threads,
7422 int clear_start_mask)
7424 unsigned long flags;
7426 spin_lock_irqsave(&card->thread_mask_lock, flags);
7427 card->thread_allowed_mask = threads;
7428 if (clear_start_mask)
7429 card->thread_start_mask &= threads;
7430 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
7431 wake_up(&card->wait_q);
7435 qeth_threads_running(struct qeth_card *card, unsigned long threads)
7437 unsigned long flags;
7440 spin_lock_irqsave(&card->thread_mask_lock, flags);
7441 rc = (card->thread_running_mask & threads);
7442 spin_unlock_irqrestore(&card->thread_mask_lock, flags);
7447 qeth_wait_for_threads(struct qeth_card *card, unsigned long threads)
7449 return wait_event_interruptible(card->wait_q,
7450 qeth_threads_running(card, threads) == 0);
7454 qeth_stop_card(struct qeth_card *card, int recovery_mode)
7458 QETH_DBF_TEXT(setup ,2,"stopcard");
7459 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
7461 qeth_set_allowed_threads(card, 0, 1);
7462 if (qeth_wait_for_threads(card, ~QETH_RECOVER_THREAD))
7463 return -ERESTARTSYS;
7464 if (card->read.state == CH_STATE_UP &&
7465 card->write.state == CH_STATE_UP &&
7466 (card->state == CARD_STATE_UP)) {
7467 if (recovery_mode &&
7468 card->info.type != QETH_CARD_TYPE_OSN) {
7469 qeth_stop(card->dev);
7472 dev_close(card->dev);
7475 if (!card->use_hard_stop) {
7476 __u8 *mac = &card->dev->dev_addr[0];
7477 rc = qeth_layer2_send_delmac(card, mac);
7478 QETH_DBF_TEXT_(setup, 2, "Lerr%d", rc);
7479 if ((rc = qeth_send_stoplan(card)))
7480 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
7482 card->state = CARD_STATE_SOFTSETUP;
7484 if (card->state == CARD_STATE_SOFTSETUP) {
7485 #ifdef CONFIG_QETH_VLAN
7486 if (card->options.layer2)
7487 qeth_layer2_process_vlans(card, 1);
7489 qeth_clear_ip_list(card, !card->use_hard_stop, 1);
7490 qeth_clear_ipacmd_list(card);
7491 card->state = CARD_STATE_HARDSETUP;
7493 if (card->state == CARD_STATE_HARDSETUP) {
7494 if ((!card->use_hard_stop) &&
7495 (!card->options.layer2))
7496 if ((rc = qeth_put_unique_id(card)))
7497 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
7498 qeth_qdio_clear_card(card, 0);
7499 qeth_clear_qdio_buffers(card);
7500 qeth_clear_working_pool_list(card);
7501 card->state = CARD_STATE_DOWN;
7503 if (card->state == CARD_STATE_DOWN) {
7504 qeth_clear_cmd_buffers(&card->read);
7505 qeth_clear_cmd_buffers(&card->write);
7507 card->use_hard_stop = 0;
7513 qeth_get_unique_id(struct qeth_card *card)
7516 #ifdef CONFIG_QETH_IPV6
7517 struct qeth_cmd_buffer *iob;
7518 struct qeth_ipa_cmd *cmd;
7520 QETH_DBF_TEXT(setup, 2, "guniqeid");
7522 if (!qeth_is_supported(card,IPA_IPV6)) {
7523 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
7524 UNIQUE_ID_NOT_BY_CARD;
7528 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR,
7530 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
7531 *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) =
7532 card->info.unique_id;
7534 rc = qeth_send_ipa_cmd(card, iob, qeth_get_unique_id_cb, NULL);
7536 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
7537 UNIQUE_ID_NOT_BY_CARD;
7542 qeth_print_status_with_portname(struct qeth_card *card)
7547 sprintf(dbf_text, "%s", card->info.portname + 1);
7548 for (i = 0; i < 8; i++)
7550 (char) _ebcasc[(__u8) dbf_text[i]];
7552 printk("qeth: Device %s/%s/%s is a%s card%s%s%s\n"
7553 "with link type %s (portname: %s)\n",
7557 qeth_get_cardname(card),
7558 (card->info.mcl_level[0]) ? " (level: " : "",
7559 (card->info.mcl_level[0]) ? card->info.mcl_level : "",
7560 (card->info.mcl_level[0]) ? ")" : "",
7561 qeth_get_cardname_short(card),
7567 qeth_print_status_no_portname(struct qeth_card *card)
7569 if (card->info.portname[0])
7570 printk("qeth: Device %s/%s/%s is a%s "
7571 "card%s%s%s\nwith link type %s "
7572 "(no portname needed by interface).\n",
7576 qeth_get_cardname(card),
7577 (card->info.mcl_level[0]) ? " (level: " : "",
7578 (card->info.mcl_level[0]) ? card->info.mcl_level : "",
7579 (card->info.mcl_level[0]) ? ")" : "",
7580 qeth_get_cardname_short(card));
7582 printk("qeth: Device %s/%s/%s is a%s "
7583 "card%s%s%s\nwith link type %s.\n",
7587 qeth_get_cardname(card),
7588 (card->info.mcl_level[0]) ? " (level: " : "",
7589 (card->info.mcl_level[0]) ? card->info.mcl_level : "",
7590 (card->info.mcl_level[0]) ? ")" : "",
7591 qeth_get_cardname_short(card));
7595 qeth_print_status_message(struct qeth_card *card)
7597 switch (card->info.type) {
7598 case QETH_CARD_TYPE_OSAE:
7599 /* VM will use a non-zero first character
7600 * to indicate a HiperSockets like reporting
7601 * of the level OSA sets the first character to zero
7603 if (!card->info.mcl_level[0]) {
7604 sprintf(card->info.mcl_level,"%02x%02x",
7605 card->info.mcl_level[2],
7606 card->info.mcl_level[3]);
7608 card->info.mcl_level[QETH_MCL_LENGTH] = 0;
7612 case QETH_CARD_TYPE_IQD:
7613 card->info.mcl_level[0] = (char) _ebcasc[(__u8)
7614 card->info.mcl_level[0]];
7615 card->info.mcl_level[1] = (char) _ebcasc[(__u8)
7616 card->info.mcl_level[1]];
7617 card->info.mcl_level[2] = (char) _ebcasc[(__u8)
7618 card->info.mcl_level[2]];
7619 card->info.mcl_level[3] = (char) _ebcasc[(__u8)
7620 card->info.mcl_level[3]];
7621 card->info.mcl_level[QETH_MCL_LENGTH] = 0;
7624 memset(&card->info.mcl_level[0], 0, QETH_MCL_LENGTH + 1);
7626 if (card->info.portname_required)
7627 qeth_print_status_with_portname(card);
7629 qeth_print_status_no_portname(card);
7633 qeth_register_netdev(struct qeth_card *card)
7635 QETH_DBF_TEXT(setup, 3, "regnetd");
7636 if (card->dev->reg_state != NETREG_UNINITIALIZED) {
7637 qeth_netdev_init(card->dev);
7641 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
7642 return register_netdev(card->dev);
7646 qeth_start_again(struct qeth_card *card, int recovery_mode)
7648 QETH_DBF_TEXT(setup ,2, "startag");
7650 if (recovery_mode &&
7651 card->info.type != QETH_CARD_TYPE_OSN) {
7652 qeth_open(card->dev);
7655 dev_open(card->dev);
7658 /* this also sets saved unicast addresses */
7659 qeth_set_multicast_list(card->dev);
7663 /* Layer 2 specific stuff */
7664 #define IGNORE_PARAM_EQ(option,value,reset_value,msg) \
7665 if (card->options.option == value) { \
7666 PRINT_ERR("%s not supported with layer 2 " \
7667 "functionality, ignoring option on read" \
7668 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7669 card->options.option = reset_value; \
7671 #define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \
7672 if (card->options.option != value) { \
7673 PRINT_ERR("%s not supported with layer 2 " \
7674 "functionality, ignoring option on read" \
7675 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7676 card->options.option = reset_value; \
7680 static void qeth_make_parameters_consistent(struct qeth_card *card)
7683 if (card->options.layer2 == 0)
7685 if (card->info.type == QETH_CARD_TYPE_OSN)
7687 if (card->info.type == QETH_CARD_TYPE_IQD) {
7688 PRINT_ERR("Device %s does not support layer 2 functionality." \
7689 " Ignoring layer2 option.\n",CARD_BUS_ID(card));
7690 card->options.layer2 = 0;
7693 IGNORE_PARAM_NEQ(route4.type, NO_ROUTER, NO_ROUTER,
7694 "Routing options are");
7695 #ifdef CONFIG_QETH_IPV6
7696 IGNORE_PARAM_NEQ(route6.type, NO_ROUTER, NO_ROUTER,
7697 "Routing options are");
7699 IGNORE_PARAM_EQ(checksum_type, HW_CHECKSUMMING,
7700 QETH_CHECKSUM_DEFAULT,
7701 "Checksumming options are");
7702 IGNORE_PARAM_NEQ(broadcast_mode, QETH_TR_BROADCAST_ALLRINGS,
7703 QETH_TR_BROADCAST_ALLRINGS,
7704 "Broadcast mode options are");
7705 IGNORE_PARAM_NEQ(macaddr_mode, QETH_TR_MACADDR_NONCANONICAL,
7706 QETH_TR_MACADDR_NONCANONICAL,
7707 "Canonical MAC addr options are");
7708 IGNORE_PARAM_NEQ(fake_broadcast, 0, 0,
7709 "Broadcast faking options are");
7710 IGNORE_PARAM_NEQ(add_hhlen, DEFAULT_ADD_HHLEN,
7711 DEFAULT_ADD_HHLEN,"Option add_hhlen is");
7712 IGNORE_PARAM_NEQ(fake_ll, 0, 0,"Option fake_ll is");
7717 __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
7719 struct qeth_card *card = gdev->dev.driver_data;
7721 enum qeth_card_states recover_flag;
7724 QETH_DBF_TEXT(setup ,2, "setonlin");
7725 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
7727 qeth_set_allowed_threads(card, QETH_RECOVER_THREAD, 1);
7728 if (qeth_wait_for_threads(card, ~QETH_RECOVER_THREAD)){
7729 PRINT_WARN("set_online of card %s interrupted by user!\n",
7731 return -ERESTARTSYS;
7734 recover_flag = card->state;
7735 if ((rc = ccw_device_set_online(CARD_RDEV(card))) ||
7736 (rc = ccw_device_set_online(CARD_WDEV(card))) ||
7737 (rc = ccw_device_set_online(CARD_DDEV(card)))){
7738 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
7742 qeth_make_parameters_consistent(card);
7744 if ((rc = qeth_hardsetup_card(card))){
7745 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
7748 card->state = CARD_STATE_HARDSETUP;
7750 if (!(rc = qeth_query_ipassists(card,QETH_PROT_IPV4)))
7751 rc = qeth_get_unique_id(card);
7753 if (rc && card->options.layer2 == 0) {
7754 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
7757 qeth_print_status_message(card);
7758 if ((rc = qeth_register_netdev(card))){
7759 QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
7762 if ((rc = qeth_softsetup_card(card))){
7763 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
7766 card->state = CARD_STATE_SOFTSETUP;
7768 if ((rc = qeth_init_qdio_queues(card))){
7769 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
7772 /*maybe it was set offline without ifconfig down
7773 * we can also use this state for recovery purposes*/
7774 qeth_set_allowed_threads(card, 0xffffffff, 0);
7775 if (recover_flag == CARD_STATE_RECOVER)
7776 qeth_start_again(card, recovery_mode);
7777 qeth_notify_processes();
7780 card->use_hard_stop = 1;
7781 qeth_stop_card(card, 0);
7782 ccw_device_set_offline(CARD_DDEV(card));
7783 ccw_device_set_offline(CARD_WDEV(card));
7784 ccw_device_set_offline(CARD_RDEV(card));
7785 if (recover_flag == CARD_STATE_RECOVER)
7786 card->state = CARD_STATE_RECOVER;
7788 card->state = CARD_STATE_DOWN;
7793 qeth_set_online(struct ccwgroup_device *gdev)
7795 return __qeth_set_online(gdev, 0);
7798 static struct ccw_device_id qeth_ids[] = {
7799 {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE},
7800 {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD},
7801 {CCW_DEVICE(0x1731, 0x06), driver_info:QETH_CARD_TYPE_OSN},
7804 MODULE_DEVICE_TABLE(ccw, qeth_ids);
7806 struct device *qeth_root_dev = NULL;
7808 struct ccwgroup_driver qeth_ccwgroup_driver = {
7809 .owner = THIS_MODULE,
7811 .driver_id = 0xD8C5E3C8,
7812 .probe = qeth_probe_device,
7813 .remove = qeth_remove_device,
7814 .set_online = qeth_set_online,
7815 .set_offline = qeth_set_offline,
7818 struct ccw_driver qeth_ccw_driver = {
7821 .probe = ccwgroup_probe_ccwdev,
7822 .remove = ccwgroup_remove_ccwdev,
7827 qeth_unregister_dbf_views(void)
7830 debug_unregister(qeth_dbf_setup);
7832 debug_unregister(qeth_dbf_qerr);
7834 debug_unregister(qeth_dbf_sense);
7836 debug_unregister(qeth_dbf_misc);
7838 debug_unregister(qeth_dbf_data);
7839 if (qeth_dbf_control)
7840 debug_unregister(qeth_dbf_control);
7842 debug_unregister(qeth_dbf_trace);
7845 qeth_register_dbf_views(void)
7847 qeth_dbf_setup = debug_register(QETH_DBF_SETUP_NAME,
7848 QETH_DBF_SETUP_PAGES,
7849 QETH_DBF_SETUP_NR_AREAS,
7850 QETH_DBF_SETUP_LEN);
7851 qeth_dbf_misc = debug_register(QETH_DBF_MISC_NAME,
7852 QETH_DBF_MISC_PAGES,
7853 QETH_DBF_MISC_NR_AREAS,
7855 qeth_dbf_data = debug_register(QETH_DBF_DATA_NAME,
7856 QETH_DBF_DATA_PAGES,
7857 QETH_DBF_DATA_NR_AREAS,
7859 qeth_dbf_control = debug_register(QETH_DBF_CONTROL_NAME,
7860 QETH_DBF_CONTROL_PAGES,
7861 QETH_DBF_CONTROL_NR_AREAS,
7862 QETH_DBF_CONTROL_LEN);
7863 qeth_dbf_sense = debug_register(QETH_DBF_SENSE_NAME,
7864 QETH_DBF_SENSE_PAGES,
7865 QETH_DBF_SENSE_NR_AREAS,
7866 QETH_DBF_SENSE_LEN);
7867 qeth_dbf_qerr = debug_register(QETH_DBF_QERR_NAME,
7868 QETH_DBF_QERR_PAGES,
7869 QETH_DBF_QERR_NR_AREAS,
7871 qeth_dbf_trace = debug_register(QETH_DBF_TRACE_NAME,
7872 QETH_DBF_TRACE_PAGES,
7873 QETH_DBF_TRACE_NR_AREAS,
7874 QETH_DBF_TRACE_LEN);
7876 if ((qeth_dbf_setup == NULL) || (qeth_dbf_misc == NULL) ||
7877 (qeth_dbf_data == NULL) || (qeth_dbf_control == NULL) ||
7878 (qeth_dbf_sense == NULL) || (qeth_dbf_qerr == NULL) ||
7879 (qeth_dbf_trace == NULL)) {
7880 qeth_unregister_dbf_views();
7883 debug_register_view(qeth_dbf_setup, &debug_hex_ascii_view);
7884 debug_set_level(qeth_dbf_setup, QETH_DBF_SETUP_LEVEL);
7886 debug_register_view(qeth_dbf_misc, &debug_hex_ascii_view);
7887 debug_set_level(qeth_dbf_misc, QETH_DBF_MISC_LEVEL);
7889 debug_register_view(qeth_dbf_data, &debug_hex_ascii_view);
7890 debug_set_level(qeth_dbf_data, QETH_DBF_DATA_LEVEL);
7892 debug_register_view(qeth_dbf_control, &debug_hex_ascii_view);
7893 debug_set_level(qeth_dbf_control, QETH_DBF_CONTROL_LEVEL);
7895 debug_register_view(qeth_dbf_sense, &debug_hex_ascii_view);
7896 debug_set_level(qeth_dbf_sense, QETH_DBF_SENSE_LEVEL);
7898 debug_register_view(qeth_dbf_qerr, &debug_hex_ascii_view);
7899 debug_set_level(qeth_dbf_qerr, QETH_DBF_QERR_LEVEL);
7901 debug_register_view(qeth_dbf_trace, &debug_hex_ascii_view);
7902 debug_set_level(qeth_dbf_trace, QETH_DBF_TRACE_LEVEL);
7907 #ifdef CONFIG_QETH_IPV6
7908 extern struct neigh_table arp_tbl;
7909 static struct neigh_ops *arp_direct_ops;
7910 static int (*qeth_old_arp_constructor) (struct neighbour *);
7912 static struct neigh_ops arp_direct_ops_template = {
7916 .error_report = NULL,
7917 .output = dev_queue_xmit,
7918 .connected_output = dev_queue_xmit,
7919 .hh_output = dev_queue_xmit,
7920 .queue_xmit = dev_queue_xmit
7924 qeth_arp_constructor(struct neighbour *neigh)
7926 struct net_device *dev = neigh->dev;
7927 struct in_device *in_dev;
7928 struct neigh_parms *parms;
7929 struct qeth_card *card;
7931 card = qeth_get_card_from_dev(dev);
7934 if((card->options.layer2) ||
7935 (card->dev->hard_header == qeth_fake_header))
7939 in_dev = __in_dev_get_rcu(dev);
7940 if (in_dev == NULL) {
7945 parms = in_dev->arp_parms;
7946 __neigh_parms_put(neigh->parms);
7947 neigh->parms = neigh_parms_clone(parms);
7950 neigh->type = inet_addr_type(*(u32 *) neigh->primary_key);
7951 neigh->nud_state = NUD_NOARP;
7952 neigh->ops = arp_direct_ops;
7953 neigh->output = neigh->ops->queue_xmit;
7956 return qeth_old_arp_constructor(neigh);
7958 #endif /*CONFIG_QETH_IPV6*/
7961 * IP address takeover related functions
7964 qeth_clear_ipato_list(struct qeth_card *card)
7966 struct qeth_ipato_entry *ipatoe, *tmp;
7967 unsigned long flags;
7969 spin_lock_irqsave(&card->ip_lock, flags);
7970 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) {
7971 list_del(&ipatoe->entry);
7974 spin_unlock_irqrestore(&card->ip_lock, flags);
7978 qeth_add_ipato_entry(struct qeth_card *card, struct qeth_ipato_entry *new)
7980 struct qeth_ipato_entry *ipatoe;
7981 unsigned long flags;
7984 QETH_DBF_TEXT(trace, 2, "addipato");
7985 spin_lock_irqsave(&card->ip_lock, flags);
7986 list_for_each_entry(ipatoe, &card->ipato.entries, entry){
7987 if (ipatoe->proto != new->proto)
7989 if (!memcmp(ipatoe->addr, new->addr,
7990 (ipatoe->proto == QETH_PROT_IPV4)? 4:16) &&
7991 (ipatoe->mask_bits == new->mask_bits)){
7992 PRINT_WARN("ipato entry already exists!\n");
7998 list_add_tail(&new->entry, &card->ipato.entries);
8000 spin_unlock_irqrestore(&card->ip_lock, flags);
8005 qeth_del_ipato_entry(struct qeth_card *card, enum qeth_prot_versions proto,
8006 u8 *addr, int mask_bits)
8008 struct qeth_ipato_entry *ipatoe, *tmp;
8009 unsigned long flags;
8011 QETH_DBF_TEXT(trace, 2, "delipato");
8012 spin_lock_irqsave(&card->ip_lock, flags);
8013 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry){
8014 if (ipatoe->proto != proto)
8016 if (!memcmp(ipatoe->addr, addr,
8017 (proto == QETH_PROT_IPV4)? 4:16) &&
8018 (ipatoe->mask_bits == mask_bits)){
8019 list_del(&ipatoe->entry);
8023 spin_unlock_irqrestore(&card->ip_lock, flags);
8027 qeth_convert_addr_to_bits(u8 *addr, u8 *bits, int len)
8032 for (i = 0; i < len; ++i){
8034 for (j = 7; j >= 0; --j){
8035 bits[i*8 + j] = octet & 1;
8042 qeth_is_addr_covered_by_ipato(struct qeth_card *card, struct qeth_ipaddr *addr)
8044 struct qeth_ipato_entry *ipatoe;
8045 u8 addr_bits[128] = {0, };
8046 u8 ipatoe_bits[128] = {0, };
8049 if (!card->ipato.enabled)
8052 qeth_convert_addr_to_bits((u8 *) &addr->u, addr_bits,
8053 (addr->proto == QETH_PROT_IPV4)? 4:16);
8054 list_for_each_entry(ipatoe, &card->ipato.entries, entry){
8055 if (addr->proto != ipatoe->proto)
8057 qeth_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
8058 (ipatoe->proto==QETH_PROT_IPV4) ?
8060 if (addr->proto == QETH_PROT_IPV4)
8061 rc = !memcmp(addr_bits, ipatoe_bits,
8062 min(32, ipatoe->mask_bits));
8064 rc = !memcmp(addr_bits, ipatoe_bits,
8065 min(128, ipatoe->mask_bits));
8070 if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4)
8072 else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6)
8079 * VIPA related functions
8082 qeth_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
8085 struct qeth_ipaddr *ipaddr;
8086 unsigned long flags;
8089 ipaddr = qeth_get_addr_buffer(proto);
8091 if (proto == QETH_PROT_IPV4){
8092 QETH_DBF_TEXT(trace, 2, "addvipa4");
8093 memcpy(&ipaddr->u.a4.addr, addr, 4);
8094 ipaddr->u.a4.mask = 0;
8095 #ifdef CONFIG_QETH_IPV6
8096 } else if (proto == QETH_PROT_IPV6){
8097 QETH_DBF_TEXT(trace, 2, "addvipa6");
8098 memcpy(&ipaddr->u.a6.addr, addr, 16);
8099 ipaddr->u.a6.pfxlen = 0;
8102 ipaddr->type = QETH_IP_TYPE_VIPA;
8103 ipaddr->set_flags = QETH_IPA_SETIP_VIPA_FLAG;
8104 ipaddr->del_flags = QETH_IPA_DELIP_VIPA_FLAG;
8107 spin_lock_irqsave(&card->ip_lock, flags);
8108 if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
8109 __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
8111 spin_unlock_irqrestore(&card->ip_lock, flags);
8113 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
8116 if (!qeth_add_ip(card, ipaddr))
8118 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8119 schedule_work(&card->kernel_thread_starter);
8124 qeth_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
8127 struct qeth_ipaddr *ipaddr;
8129 ipaddr = qeth_get_addr_buffer(proto);
8131 if (proto == QETH_PROT_IPV4){
8132 QETH_DBF_TEXT(trace, 2, "delvipa4");
8133 memcpy(&ipaddr->u.a4.addr, addr, 4);
8134 ipaddr->u.a4.mask = 0;
8135 #ifdef CONFIG_QETH_IPV6
8136 } else if (proto == QETH_PROT_IPV6){
8137 QETH_DBF_TEXT(trace, 2, "delvipa6");
8138 memcpy(&ipaddr->u.a6.addr, addr, 16);
8139 ipaddr->u.a6.pfxlen = 0;
8142 ipaddr->type = QETH_IP_TYPE_VIPA;
8145 if (!qeth_delete_ip(card, ipaddr))
8147 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8148 schedule_work(&card->kernel_thread_starter);
8152 * proxy ARP related functions
8155 qeth_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto,
8158 struct qeth_ipaddr *ipaddr;
8159 unsigned long flags;
8162 ipaddr = qeth_get_addr_buffer(proto);
8164 if (proto == QETH_PROT_IPV4){
8165 QETH_DBF_TEXT(trace, 2, "addrxip4");
8166 memcpy(&ipaddr->u.a4.addr, addr, 4);
8167 ipaddr->u.a4.mask = 0;
8168 #ifdef CONFIG_QETH_IPV6
8169 } else if (proto == QETH_PROT_IPV6){
8170 QETH_DBF_TEXT(trace, 2, "addrxip6");
8171 memcpy(&ipaddr->u.a6.addr, addr, 16);
8172 ipaddr->u.a6.pfxlen = 0;
8175 ipaddr->type = QETH_IP_TYPE_RXIP;
8176 ipaddr->set_flags = QETH_IPA_SETIP_TAKEOVER_FLAG;
8177 ipaddr->del_flags = 0;
8180 spin_lock_irqsave(&card->ip_lock, flags);
8181 if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
8182 __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
8184 spin_unlock_irqrestore(&card->ip_lock, flags);
8186 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
8189 if (!qeth_add_ip(card, ipaddr))
8191 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8192 schedule_work(&card->kernel_thread_starter);
8197 qeth_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto,
8200 struct qeth_ipaddr *ipaddr;
8202 ipaddr = qeth_get_addr_buffer(proto);
8204 if (proto == QETH_PROT_IPV4){
8205 QETH_DBF_TEXT(trace, 2, "addrxip4");
8206 memcpy(&ipaddr->u.a4.addr, addr, 4);
8207 ipaddr->u.a4.mask = 0;
8208 #ifdef CONFIG_QETH_IPV6
8209 } else if (proto == QETH_PROT_IPV6){
8210 QETH_DBF_TEXT(trace, 2, "addrxip6");
8211 memcpy(&ipaddr->u.a6.addr, addr, 16);
8212 ipaddr->u.a6.pfxlen = 0;
8215 ipaddr->type = QETH_IP_TYPE_RXIP;
8218 if (!qeth_delete_ip(card, ipaddr))
8220 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8221 schedule_work(&card->kernel_thread_starter);
8228 qeth_ip_event(struct notifier_block *this,
8229 unsigned long event,void *ptr)
8231 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
8232 struct net_device *dev =(struct net_device *) ifa->ifa_dev->dev;
8233 struct qeth_ipaddr *addr;
8234 struct qeth_card *card;
8236 QETH_DBF_TEXT(trace,3,"ipevent");
8237 card = qeth_get_card_from_dev(dev);
8240 if (card->options.layer2)
8243 addr = qeth_get_addr_buffer(QETH_PROT_IPV4);
8245 addr->u.a4.addr = ifa->ifa_address;
8246 addr->u.a4.mask = ifa->ifa_mask;
8247 addr->type = QETH_IP_TYPE_NORMAL;
8253 if (!qeth_add_ip(card, addr))
8257 if (!qeth_delete_ip(card, addr))
8263 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8264 schedule_work(&card->kernel_thread_starter);
8269 static struct notifier_block qeth_ip_notifier = {
8274 #ifdef CONFIG_QETH_IPV6
8276 * IPv6 event handler
8279 qeth_ip6_event(struct notifier_block *this,
8280 unsigned long event,void *ptr)
8283 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
8284 struct net_device *dev = (struct net_device *)ifa->idev->dev;
8285 struct qeth_ipaddr *addr;
8286 struct qeth_card *card;
8288 QETH_DBF_TEXT(trace,3,"ip6event");
8290 card = qeth_get_card_from_dev(dev);
8293 if (!qeth_is_supported(card, IPA_IPV6))
8296 addr = qeth_get_addr_buffer(QETH_PROT_IPV6);
8298 memcpy(&addr->u.a6.addr, &ifa->addr, sizeof(struct in6_addr));
8299 addr->u.a6.pfxlen = ifa->prefix_len;
8300 addr->type = QETH_IP_TYPE_NORMAL;
8306 if (!qeth_add_ip(card, addr))
8310 if (!qeth_delete_ip(card, addr))
8316 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
8317 schedule_work(&card->kernel_thread_starter);
8322 static struct notifier_block qeth_ip6_notifier = {
8329 __qeth_reboot_event_card(struct device *dev, void *data)
8331 struct qeth_card *card;
8333 card = (struct qeth_card *) dev->driver_data;
8334 qeth_clear_ip_list(card, 0, 0);
8335 qeth_qdio_clear_card(card, 0);
8340 qeth_reboot_event(struct notifier_block *this, unsigned long event, void *ptr)
8343 driver_for_each_device(&qeth_ccwgroup_driver.driver, NULL, NULL,
8344 __qeth_reboot_event_card);
8349 static struct notifier_block qeth_reboot_notifier = {
8355 qeth_register_notifiers(void)
8359 QETH_DBF_TEXT(trace,5,"regnotif");
8360 if ((r = register_reboot_notifier(&qeth_reboot_notifier)))
8362 if ((r = register_inetaddr_notifier(&qeth_ip_notifier)))
8364 #ifdef CONFIG_QETH_IPV6
8365 if ((r = register_inet6addr_notifier(&qeth_ip6_notifier)))
8370 #ifdef CONFIG_QETH_IPV6
8372 unregister_inetaddr_notifier(&qeth_ip_notifier);
8375 unregister_reboot_notifier(&qeth_reboot_notifier);
8380 * unregister all event notifiers
8383 qeth_unregister_notifiers(void)
8386 QETH_DBF_TEXT(trace,5,"unregnot");
8387 BUG_ON(unregister_reboot_notifier(&qeth_reboot_notifier));
8388 BUG_ON(unregister_inetaddr_notifier(&qeth_ip_notifier));
8389 #ifdef CONFIG_QETH_IPV6
8390 BUG_ON(unregister_inet6addr_notifier(&qeth_ip6_notifier));
8391 #endif /* QETH_IPV6 */
8395 #ifdef CONFIG_QETH_IPV6
8397 qeth_ipv6_init(void)
8399 qeth_old_arp_constructor = arp_tbl.constructor;
8400 write_lock(&arp_tbl.lock);
8401 arp_tbl.constructor = qeth_arp_constructor;
8402 write_unlock(&arp_tbl.lock);
8404 arp_direct_ops = (struct neigh_ops*)
8405 kmalloc(sizeof(struct neigh_ops), GFP_KERNEL);
8406 if (!arp_direct_ops)
8409 memcpy(arp_direct_ops, &arp_direct_ops_template,
8410 sizeof(struct neigh_ops));
8416 qeth_ipv6_uninit(void)
8418 write_lock(&arp_tbl.lock);
8419 arp_tbl.constructor = qeth_old_arp_constructor;
8420 write_unlock(&arp_tbl.lock);
8421 kfree(arp_direct_ops);
8423 #endif /* CONFIG_QETH_IPV6 */
8426 qeth_sysfs_unregister(void)
8428 qeth_remove_driver_attributes();
8429 ccw_driver_unregister(&qeth_ccw_driver);
8430 ccwgroup_driver_unregister(&qeth_ccwgroup_driver);
8431 s390_root_dev_unregister(qeth_root_dev);
8434 * register qeth at sysfs
8437 qeth_sysfs_register(void)
8441 rc = ccwgroup_driver_register(&qeth_ccwgroup_driver);
8444 rc = ccw_driver_register(&qeth_ccw_driver);
8447 rc = qeth_create_driver_attributes();
8450 qeth_root_dev = s390_root_dev_register("qeth");
8451 if (IS_ERR(qeth_root_dev)) {
8452 rc = PTR_ERR(qeth_root_dev);
8466 PRINT_INFO("loading %s (%s/%s/%s/%s/%s/%s/%s %s %s)\n",
8467 version, VERSION_QETH_C, VERSION_QETH_H,
8468 VERSION_QETH_MPC_H, VERSION_QETH_MPC_C,
8469 VERSION_QETH_FS_H, VERSION_QETH_PROC_C,
8470 VERSION_QETH_SYS_C, QETH_VERSION_IPV6,
8473 INIT_LIST_HEAD(&qeth_card_list.list);
8474 INIT_LIST_HEAD(&qeth_notify_list);
8475 spin_lock_init(&qeth_notify_lock);
8476 rwlock_init(&qeth_card_list.rwlock);
8478 if (qeth_register_dbf_views())
8480 if (qeth_sysfs_register())
8483 #ifdef CONFIG_QETH_IPV6
8484 if (qeth_ipv6_init()) {
8485 PRINT_ERR("Out of memory during ipv6 init.\n");
8488 #endif /* QETH_IPV6 */
8489 if (qeth_register_notifiers())
8491 if (qeth_create_procfs_entries())
8497 qeth_unregister_notifiers();
8499 #ifdef CONFIG_QETH_IPV6
8501 #endif /* QETH_IPV6 */
8503 qeth_sysfs_unregister();
8504 qeth_unregister_dbf_views();
8506 PRINT_ERR("Initialization failed");
8511 __exit qeth_exit(void)
8513 struct qeth_card *card, *tmp;
8514 unsigned long flags;
8516 QETH_DBF_TEXT(trace,1, "cleanup.");
8519 * Weed would not need to clean up our devices here, because the
8520 * common device layer calls qeth_remove_device for each device
8521 * as soon as we unregister our driver (done in qeth_sysfs_unregister).
8522 * But we do cleanup here so we can do a "soft" shutdown of our cards.
8523 * qeth_remove_device called by the common device layer would otherwise
8524 * do a "hard" shutdown (card->use_hard_stop is set to one in
8525 * qeth_remove_device).
8528 read_lock_irqsave(&qeth_card_list.rwlock, flags);
8529 list_for_each_entry_safe(card, tmp, &qeth_card_list.list, list){
8530 read_unlock_irqrestore(&qeth_card_list.rwlock, flags);
8531 qeth_set_offline(card->gdev);
8532 qeth_remove_device(card->gdev);
8535 read_unlock_irqrestore(&qeth_card_list.rwlock, flags);
8536 #ifdef CONFIG_QETH_IPV6
8539 qeth_unregister_notifiers();
8540 qeth_remove_procfs_entries();
8541 qeth_sysfs_unregister();
8542 qeth_unregister_dbf_views();
8543 printk("qeth: removed\n");
8546 EXPORT_SYMBOL(qeth_osn_register);
8547 EXPORT_SYMBOL(qeth_osn_deregister);
8548 EXPORT_SYMBOL(qeth_osn_assist);
8549 module_init(qeth_init);
8550 module_exit(qeth_exit);
8551 MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>");
8552 MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \
8553 "Copyright 2000,2003 IBM Corporation\n");
8555 MODULE_LICENSE("GPL");