2 * Copyright IBM Corp. 2007, 2009
3 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
4 * Frank Pavlic <fpavlic@de.ibm.com>,
5 * Thomas Spatzier <tspat@de.ibm.com>,
6 * Frank Blaschka <frank.blaschka@de.ibm.com>
9 #define KMSG_COMPONENT "qeth"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
16 #include <linux/kernel.h>
18 #include <linux/tcp.h>
19 #include <linux/mii.h>
20 #include <linux/kthread.h>
21 #include <linux/slab.h>
22 #include <net/iucv/af_iucv.h>
23 #include <net/dsfield.h>
25 #include <asm/ebcdic.h>
26 #include <asm/chpid.h>
28 #include <asm/sysinfo.h>
29 #include <asm/compat.h>
31 #include "qeth_core.h"
33 struct qeth_dbf_info qeth_dbf
[QETH_DBF_INFOS
] = {
34 /* define dbf - Name, Pages, Areas, Maxlen, Level, View, Handle */
36 [QETH_DBF_SETUP
] = {"qeth_setup",
37 8, 1, 8, 5, &debug_hex_ascii_view
, NULL
},
38 [QETH_DBF_MSG
] = {"qeth_msg", 8, 1, 11 * sizeof(long), 3,
39 &debug_sprintf_view
, NULL
},
40 [QETH_DBF_CTRL
] = {"qeth_control",
41 8, 1, QETH_DBF_CTRL_LEN
, 5, &debug_hex_ascii_view
, NULL
},
43 EXPORT_SYMBOL_GPL(qeth_dbf
);
45 struct qeth_card_list_struct qeth_core_card_list
;
46 EXPORT_SYMBOL_GPL(qeth_core_card_list
);
47 struct kmem_cache
*qeth_core_header_cache
;
48 EXPORT_SYMBOL_GPL(qeth_core_header_cache
);
49 static struct kmem_cache
*qeth_qdio_outbuf_cache
;
51 static struct device
*qeth_core_root_dev
;
52 static unsigned int known_devices
[][6] = QETH_MODELLIST_ARRAY
;
53 static struct lock_class_key qdio_out_skb_queue_key
;
54 static struct mutex qeth_mod_mutex
;
56 static void qeth_send_control_data_cb(struct qeth_channel
*,
57 struct qeth_cmd_buffer
*);
58 static int qeth_issue_next_read(struct qeth_card
*);
59 static struct qeth_cmd_buffer
*qeth_get_buffer(struct qeth_channel
*);
60 static void qeth_setup_ccw(struct qeth_channel
*, unsigned char *, __u32
);
61 static void qeth_free_buffer_pool(struct qeth_card
*);
62 static int qeth_qdio_establish(struct qeth_card
*);
63 static void qeth_free_qdio_buffers(struct qeth_card
*);
64 static void qeth_notify_skbs(struct qeth_qdio_out_q
*queue
,
65 struct qeth_qdio_out_buffer
*buf
,
66 enum iucv_tx_notify notification
);
67 static void qeth_release_skbs(struct qeth_qdio_out_buffer
*buf
);
68 static void qeth_clear_output_buffer(struct qeth_qdio_out_q
*queue
,
69 struct qeth_qdio_out_buffer
*buf
,
70 enum qeth_qdio_buffer_states newbufstate
);
71 static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q
*, int);
73 struct workqueue_struct
*qeth_wq
;
74 EXPORT_SYMBOL_GPL(qeth_wq
);
76 int qeth_card_hw_is_reachable(struct qeth_card
*card
)
78 return (card
->state
== CARD_STATE_SOFTSETUP
) ||
79 (card
->state
== CARD_STATE_UP
);
81 EXPORT_SYMBOL_GPL(qeth_card_hw_is_reachable
);
83 static void qeth_close_dev_handler(struct work_struct
*work
)
85 struct qeth_card
*card
;
87 card
= container_of(work
, struct qeth_card
, close_dev_work
);
88 QETH_CARD_TEXT(card
, 2, "cldevhdl");
92 ccwgroup_set_offline(card
->gdev
);
95 void qeth_close_dev(struct qeth_card
*card
)
97 QETH_CARD_TEXT(card
, 2, "cldevsubm");
98 queue_work(qeth_wq
, &card
->close_dev_work
);
100 EXPORT_SYMBOL_GPL(qeth_close_dev
);
102 static inline const char *qeth_get_cardname(struct qeth_card
*card
)
104 if (card
->info
.guestlan
) {
105 switch (card
->info
.type
) {
106 case QETH_CARD_TYPE_OSD
:
107 return " Virtual NIC QDIO";
108 case QETH_CARD_TYPE_IQD
:
109 return " Virtual NIC Hiper";
110 case QETH_CARD_TYPE_OSM
:
111 return " Virtual NIC QDIO - OSM";
112 case QETH_CARD_TYPE_OSX
:
113 return " Virtual NIC QDIO - OSX";
118 switch (card
->info
.type
) {
119 case QETH_CARD_TYPE_OSD
:
120 return " OSD Express";
121 case QETH_CARD_TYPE_IQD
:
122 return " HiperSockets";
123 case QETH_CARD_TYPE_OSN
:
125 case QETH_CARD_TYPE_OSM
:
127 case QETH_CARD_TYPE_OSX
:
136 /* max length to be returned: 14 */
137 const char *qeth_get_cardname_short(struct qeth_card
*card
)
139 if (card
->info
.guestlan
) {
140 switch (card
->info
.type
) {
141 case QETH_CARD_TYPE_OSD
:
142 return "Virt.NIC QDIO";
143 case QETH_CARD_TYPE_IQD
:
144 return "Virt.NIC Hiper";
145 case QETH_CARD_TYPE_OSM
:
146 return "Virt.NIC OSM";
147 case QETH_CARD_TYPE_OSX
:
148 return "Virt.NIC OSX";
153 switch (card
->info
.type
) {
154 case QETH_CARD_TYPE_OSD
:
155 switch (card
->info
.link_type
) {
156 case QETH_LINK_TYPE_FAST_ETH
:
158 case QETH_LINK_TYPE_HSTR
:
160 case QETH_LINK_TYPE_GBIT_ETH
:
162 case QETH_LINK_TYPE_10GBIT_ETH
:
164 case QETH_LINK_TYPE_LANE_ETH100
:
165 return "OSD_FE_LANE";
166 case QETH_LINK_TYPE_LANE_TR
:
167 return "OSD_TR_LANE";
168 case QETH_LINK_TYPE_LANE_ETH1000
:
169 return "OSD_GbE_LANE";
170 case QETH_LINK_TYPE_LANE
:
171 return "OSD_ATM_LANE";
173 return "OSD_Express";
175 case QETH_CARD_TYPE_IQD
:
176 return "HiperSockets";
177 case QETH_CARD_TYPE_OSN
:
179 case QETH_CARD_TYPE_OSM
:
181 case QETH_CARD_TYPE_OSX
:
190 void qeth_set_recovery_task(struct qeth_card
*card
)
192 card
->recovery_task
= current
;
194 EXPORT_SYMBOL_GPL(qeth_set_recovery_task
);
196 void qeth_clear_recovery_task(struct qeth_card
*card
)
198 card
->recovery_task
= NULL
;
200 EXPORT_SYMBOL_GPL(qeth_clear_recovery_task
);
202 static bool qeth_is_recovery_task(const struct qeth_card
*card
)
204 return card
->recovery_task
== current
;
207 void qeth_set_allowed_threads(struct qeth_card
*card
, unsigned long threads
,
208 int clear_start_mask
)
212 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
213 card
->thread_allowed_mask
= threads
;
214 if (clear_start_mask
)
215 card
->thread_start_mask
&= threads
;
216 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
217 wake_up(&card
->wait_q
);
219 EXPORT_SYMBOL_GPL(qeth_set_allowed_threads
);
221 int qeth_threads_running(struct qeth_card
*card
, unsigned long threads
)
226 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
227 rc
= (card
->thread_running_mask
& threads
);
228 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
231 EXPORT_SYMBOL_GPL(qeth_threads_running
);
233 int qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
)
235 if (qeth_is_recovery_task(card
))
237 return wait_event_interruptible(card
->wait_q
,
238 qeth_threads_running(card
, threads
) == 0);
240 EXPORT_SYMBOL_GPL(qeth_wait_for_threads
);
242 void qeth_clear_working_pool_list(struct qeth_card
*card
)
244 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
246 QETH_CARD_TEXT(card
, 5, "clwrklst");
247 list_for_each_entry_safe(pool_entry
, tmp
,
248 &card
->qdio
.in_buf_pool
.entry_list
, list
){
249 list_del(&pool_entry
->list
);
252 EXPORT_SYMBOL_GPL(qeth_clear_working_pool_list
);
254 static int qeth_alloc_buffer_pool(struct qeth_card
*card
)
256 struct qeth_buffer_pool_entry
*pool_entry
;
260 QETH_CARD_TEXT(card
, 5, "alocpool");
261 for (i
= 0; i
< card
->qdio
.init_pool
.buf_count
; ++i
) {
262 pool_entry
= kzalloc(sizeof(*pool_entry
), GFP_KERNEL
);
264 qeth_free_buffer_pool(card
);
267 for (j
= 0; j
< QETH_MAX_BUFFER_ELEMENTS(card
); ++j
) {
268 ptr
= (void *) __get_free_page(GFP_KERNEL
);
271 free_page((unsigned long)
272 pool_entry
->elements
[--j
]);
274 qeth_free_buffer_pool(card
);
277 pool_entry
->elements
[j
] = ptr
;
279 list_add(&pool_entry
->init_list
,
280 &card
->qdio
.init_pool
.entry_list
);
285 int qeth_realloc_buffer_pool(struct qeth_card
*card
, int bufcnt
)
287 QETH_CARD_TEXT(card
, 2, "realcbp");
289 if ((card
->state
!= CARD_STATE_DOWN
) &&
290 (card
->state
!= CARD_STATE_RECOVER
))
293 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
294 qeth_clear_working_pool_list(card
);
295 qeth_free_buffer_pool(card
);
296 card
->qdio
.in_buf_pool
.buf_count
= bufcnt
;
297 card
->qdio
.init_pool
.buf_count
= bufcnt
;
298 return qeth_alloc_buffer_pool(card
);
300 EXPORT_SYMBOL_GPL(qeth_realloc_buffer_pool
);
302 static void qeth_free_qdio_queue(struct qeth_qdio_q
*q
)
307 qdio_free_buffers(q
->qdio_bufs
, QDIO_MAX_BUFFERS_PER_Q
);
311 static struct qeth_qdio_q
*qeth_alloc_qdio_queue(void)
313 struct qeth_qdio_q
*q
= kzalloc(sizeof(*q
), GFP_KERNEL
);
319 if (qdio_alloc_buffers(q
->qdio_bufs
, QDIO_MAX_BUFFERS_PER_Q
)) {
324 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
325 q
->bufs
[i
].buffer
= q
->qdio_bufs
[i
];
327 QETH_DBF_HEX(SETUP
, 2, &q
, sizeof(void *));
331 static inline int qeth_cq_init(struct qeth_card
*card
)
335 if (card
->options
.cq
== QETH_CQ_ENABLED
) {
336 QETH_DBF_TEXT(SETUP
, 2, "cqinit");
337 qdio_reset_buffers(card
->qdio
.c_q
->qdio_bufs
,
338 QDIO_MAX_BUFFERS_PER_Q
);
339 card
->qdio
.c_q
->next_buf_to_init
= 127;
340 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
,
341 card
->qdio
.no_in_queues
- 1, 0,
344 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
353 static inline int qeth_alloc_cq(struct qeth_card
*card
)
357 if (card
->options
.cq
== QETH_CQ_ENABLED
) {
359 struct qdio_outbuf_state
*outbuf_states
;
361 QETH_DBF_TEXT(SETUP
, 2, "cqon");
362 card
->qdio
.c_q
= qeth_alloc_qdio_queue();
363 if (!card
->qdio
.c_q
) {
367 card
->qdio
.no_in_queues
= 2;
368 card
->qdio
.out_bufstates
=
369 kzalloc(card
->qdio
.no_out_queues
*
370 QDIO_MAX_BUFFERS_PER_Q
*
371 sizeof(struct qdio_outbuf_state
), GFP_KERNEL
);
372 outbuf_states
= card
->qdio
.out_bufstates
;
373 if (outbuf_states
== NULL
) {
377 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
) {
378 card
->qdio
.out_qs
[i
]->bufstates
= outbuf_states
;
379 outbuf_states
+= QDIO_MAX_BUFFERS_PER_Q
;
382 QETH_DBF_TEXT(SETUP
, 2, "nocq");
383 card
->qdio
.c_q
= NULL
;
384 card
->qdio
.no_in_queues
= 1;
386 QETH_DBF_TEXT_(SETUP
, 2, "iqc%d", card
->qdio
.no_in_queues
);
391 qeth_free_qdio_queue(card
->qdio
.c_q
);
392 card
->qdio
.c_q
= NULL
;
394 dev_err(&card
->gdev
->dev
, "Failed to create completion queue\n");
398 static inline void qeth_free_cq(struct qeth_card
*card
)
400 if (card
->qdio
.c_q
) {
401 --card
->qdio
.no_in_queues
;
402 qeth_free_qdio_queue(card
->qdio
.c_q
);
403 card
->qdio
.c_q
= NULL
;
405 kfree(card
->qdio
.out_bufstates
);
406 card
->qdio
.out_bufstates
= NULL
;
409 static inline enum iucv_tx_notify
qeth_compute_cq_notification(int sbalf15
,
411 enum iucv_tx_notify n
;
415 n
= delayed
? TX_NOTIFY_DELAYED_OK
: TX_NOTIFY_OK
;
421 n
= delayed
? TX_NOTIFY_DELAYED_UNREACHABLE
:
422 TX_NOTIFY_UNREACHABLE
;
425 n
= delayed
? TX_NOTIFY_DELAYED_GENERALERROR
:
426 TX_NOTIFY_GENERALERROR
;
433 static inline void qeth_cleanup_handled_pending(struct qeth_qdio_out_q
*q
,
434 int bidx
, int forced_cleanup
)
436 if (q
->card
->options
.cq
!= QETH_CQ_ENABLED
)
439 if (q
->bufs
[bidx
]->next_pending
!= NULL
) {
440 struct qeth_qdio_out_buffer
*head
= q
->bufs
[bidx
];
441 struct qeth_qdio_out_buffer
*c
= q
->bufs
[bidx
]->next_pending
;
444 if (forced_cleanup
||
445 atomic_read(&c
->state
) ==
446 QETH_QDIO_BUF_HANDLED_DELAYED
) {
447 struct qeth_qdio_out_buffer
*f
= c
;
448 QETH_CARD_TEXT(f
->q
->card
, 5, "fp");
449 QETH_CARD_TEXT_(f
->q
->card
, 5, "%lx", (long) f
);
450 /* release here to avoid interleaving between
451 outbound tasklet and inbound tasklet
452 regarding notifications and lifecycle */
453 qeth_release_skbs(c
);
456 WARN_ON_ONCE(head
->next_pending
!= f
);
457 head
->next_pending
= c
;
458 kmem_cache_free(qeth_qdio_outbuf_cache
, f
);
466 if (forced_cleanup
&& (atomic_read(&(q
->bufs
[bidx
]->state
)) ==
467 QETH_QDIO_BUF_HANDLED_DELAYED
)) {
468 /* for recovery situations */
469 q
->bufs
[bidx
]->aob
= q
->bufstates
[bidx
].aob
;
470 qeth_init_qdio_out_buf(q
, bidx
);
471 QETH_CARD_TEXT(q
->card
, 2, "clprecov");
476 static inline void qeth_qdio_handle_aob(struct qeth_card
*card
,
477 unsigned long phys_aob_addr
) {
479 struct qeth_qdio_out_buffer
*buffer
;
480 enum iucv_tx_notify notification
;
482 aob
= (struct qaob
*) phys_to_virt(phys_aob_addr
);
483 QETH_CARD_TEXT(card
, 5, "haob");
484 QETH_CARD_TEXT_(card
, 5, "%lx", phys_aob_addr
);
485 buffer
= (struct qeth_qdio_out_buffer
*) aob
->user1
;
486 QETH_CARD_TEXT_(card
, 5, "%lx", aob
->user1
);
488 if (atomic_cmpxchg(&buffer
->state
, QETH_QDIO_BUF_PRIMED
,
489 QETH_QDIO_BUF_IN_CQ
) == QETH_QDIO_BUF_PRIMED
) {
490 notification
= TX_NOTIFY_OK
;
492 WARN_ON_ONCE(atomic_read(&buffer
->state
) !=
493 QETH_QDIO_BUF_PENDING
);
494 atomic_set(&buffer
->state
, QETH_QDIO_BUF_IN_CQ
);
495 notification
= TX_NOTIFY_DELAYED_OK
;
498 if (aob
->aorc
!= 0) {
499 QETH_CARD_TEXT_(card
, 2, "aorc%02X", aob
->aorc
);
500 notification
= qeth_compute_cq_notification(aob
->aorc
, 1);
502 qeth_notify_skbs(buffer
->q
, buffer
, notification
);
505 qeth_clear_output_buffer(buffer
->q
, buffer
,
506 QETH_QDIO_BUF_HANDLED_DELAYED
);
508 /* from here on: do not touch buffer anymore */
509 qdio_release_aob(aob
);
512 static inline int qeth_is_cq(struct qeth_card
*card
, unsigned int queue
)
514 return card
->options
.cq
== QETH_CQ_ENABLED
&&
515 card
->qdio
.c_q
!= NULL
&&
517 queue
== card
->qdio
.no_in_queues
- 1;
521 static int qeth_issue_next_read(struct qeth_card
*card
)
524 struct qeth_cmd_buffer
*iob
;
526 QETH_CARD_TEXT(card
, 5, "issnxrd");
527 if (card
->read
.state
!= CH_STATE_UP
)
529 iob
= qeth_get_buffer(&card
->read
);
531 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
532 "failed to recover an error on the device\n");
533 QETH_DBF_MESSAGE(2, "%s issue_next_read failed: no iob "
534 "available\n", dev_name(&card
->gdev
->dev
));
537 qeth_setup_ccw(&card
->read
, iob
->data
, QETH_BUFSIZE
);
538 QETH_CARD_TEXT(card
, 6, "noirqpnd");
539 rc
= ccw_device_start(card
->read
.ccwdev
, &card
->read
.ccw
,
542 QETH_DBF_MESSAGE(2, "%s error in starting next read ccw! "
543 "rc=%i\n", dev_name(&card
->gdev
->dev
), rc
);
544 atomic_set(&card
->read
.irq_pending
, 0);
545 card
->read_or_write_problem
= 1;
546 qeth_schedule_recovery(card
);
547 wake_up(&card
->wait_q
);
552 static struct qeth_reply
*qeth_alloc_reply(struct qeth_card
*card
)
554 struct qeth_reply
*reply
;
556 reply
= kzalloc(sizeof(struct qeth_reply
), GFP_ATOMIC
);
558 atomic_set(&reply
->refcnt
, 1);
559 atomic_set(&reply
->received
, 0);
565 static void qeth_get_reply(struct qeth_reply
*reply
)
567 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
568 atomic_inc(&reply
->refcnt
);
571 static void qeth_put_reply(struct qeth_reply
*reply
)
573 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
574 if (atomic_dec_and_test(&reply
->refcnt
))
578 static void qeth_issue_ipa_msg(struct qeth_ipa_cmd
*cmd
, int rc
,
579 struct qeth_card
*card
)
582 int com
= cmd
->hdr
.command
;
583 ipa_name
= qeth_get_ipa_cmd_name(com
);
585 QETH_DBF_MESSAGE(2, "IPA: %s(x%X) for %s/%s returned "
587 ipa_name
, com
, dev_name(&card
->gdev
->dev
),
588 QETH_CARD_IFNAME(card
), rc
,
589 qeth_get_ipa_msg(rc
));
591 QETH_DBF_MESSAGE(5, "IPA: %s(x%X) for %s/%s succeeded\n",
592 ipa_name
, com
, dev_name(&card
->gdev
->dev
),
593 QETH_CARD_IFNAME(card
));
596 static struct qeth_ipa_cmd
*qeth_check_ipa_data(struct qeth_card
*card
,
597 struct qeth_cmd_buffer
*iob
)
599 struct qeth_ipa_cmd
*cmd
= NULL
;
601 QETH_CARD_TEXT(card
, 5, "chkipad");
602 if (IS_IPA(iob
->data
)) {
603 cmd
= (struct qeth_ipa_cmd
*) PDU_ENCAPSULATION(iob
->data
);
604 if (IS_IPA_REPLY(cmd
)) {
605 if (cmd
->hdr
.command
!= IPA_CMD_SETCCID
&&
606 cmd
->hdr
.command
!= IPA_CMD_DELCCID
&&
607 cmd
->hdr
.command
!= IPA_CMD_MODCCID
&&
608 cmd
->hdr
.command
!= IPA_CMD_SET_DIAG_ASS
)
609 qeth_issue_ipa_msg(cmd
,
610 cmd
->hdr
.return_code
, card
);
613 switch (cmd
->hdr
.command
) {
614 case IPA_CMD_STOPLAN
:
615 if (cmd
->hdr
.return_code
==
616 IPA_RC_VEPA_TO_VEB_TRANSITION
) {
617 dev_err(&card
->gdev
->dev
,
618 "Interface %s is down because the "
619 "adjacent port is no longer in "
620 "reflective relay mode\n",
621 QETH_CARD_IFNAME(card
));
622 qeth_close_dev(card
);
624 dev_warn(&card
->gdev
->dev
,
625 "The link for interface %s on CHPID"
627 QETH_CARD_IFNAME(card
),
629 qeth_issue_ipa_msg(cmd
,
630 cmd
->hdr
.return_code
, card
);
632 card
->lan_online
= 0;
633 if (card
->dev
&& netif_carrier_ok(card
->dev
))
634 netif_carrier_off(card
->dev
);
636 case IPA_CMD_STARTLAN
:
637 dev_info(&card
->gdev
->dev
,
638 "The link for %s on CHPID 0x%X has"
640 QETH_CARD_IFNAME(card
),
642 netif_carrier_on(card
->dev
);
643 card
->lan_online
= 1;
644 if (card
->info
.hwtrap
)
645 card
->info
.hwtrap
= 2;
646 qeth_schedule_recovery(card
);
648 case IPA_CMD_SETBRIDGEPORT_IQD
:
649 case IPA_CMD_SETBRIDGEPORT_OSA
:
650 case IPA_CMD_ADDRESS_CHANGE_NOTIF
:
651 if (card
->discipline
->control_event_handler
656 case IPA_CMD_MODCCID
:
658 case IPA_CMD_REGISTER_LOCAL_ADDR
:
659 QETH_CARD_TEXT(card
, 3, "irla");
661 case IPA_CMD_UNREGISTER_LOCAL_ADDR
:
662 QETH_CARD_TEXT(card
, 3, "urla");
665 QETH_DBF_MESSAGE(2, "Received data is IPA "
666 "but not a reply!\n");
674 void qeth_clear_ipacmd_list(struct qeth_card
*card
)
676 struct qeth_reply
*reply
, *r
;
679 QETH_CARD_TEXT(card
, 4, "clipalst");
681 spin_lock_irqsave(&card
->lock
, flags
);
682 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
683 qeth_get_reply(reply
);
685 atomic_inc(&reply
->received
);
686 list_del_init(&reply
->list
);
687 wake_up(&reply
->wait_q
);
688 qeth_put_reply(reply
);
690 spin_unlock_irqrestore(&card
->lock
, flags
);
691 atomic_set(&card
->write
.irq_pending
, 0);
693 EXPORT_SYMBOL_GPL(qeth_clear_ipacmd_list
);
695 static int qeth_check_idx_response(struct qeth_card
*card
,
696 unsigned char *buffer
)
701 QETH_DBF_HEX(CTRL
, 2, buffer
, QETH_DBF_CTRL_LEN
);
702 if ((buffer
[2] & 0xc0) == 0xc0) {
703 QETH_DBF_MESSAGE(2, "received an IDX TERMINATE "
704 "with cause code 0x%02x%s\n",
706 ((buffer
[4] == 0x22) ?
707 " -- try another portname" : ""));
708 QETH_CARD_TEXT(card
, 2, "ckidxres");
709 QETH_CARD_TEXT(card
, 2, " idxterm");
710 QETH_CARD_TEXT_(card
, 2, " rc%d", -EIO
);
711 if (buffer
[4] == 0xf6) {
712 dev_err(&card
->gdev
->dev
,
713 "The qeth device is not configured "
714 "for the OSI layer required by z/VM\n");
722 static struct qeth_card
*CARD_FROM_CDEV(struct ccw_device
*cdev
)
724 struct qeth_card
*card
= dev_get_drvdata(&((struct ccwgroup_device
*)
725 dev_get_drvdata(&cdev
->dev
))->dev
);
729 static void qeth_setup_ccw(struct qeth_channel
*channel
, unsigned char *iob
,
732 struct qeth_card
*card
;
734 card
= CARD_FROM_CDEV(channel
->ccwdev
);
735 QETH_CARD_TEXT(card
, 4, "setupccw");
736 if (channel
== &card
->read
)
737 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
739 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
740 channel
->ccw
.count
= len
;
741 channel
->ccw
.cda
= (__u32
) __pa(iob
);
744 static struct qeth_cmd_buffer
*__qeth_get_buffer(struct qeth_channel
*channel
)
748 QETH_CARD_TEXT(CARD_FROM_CDEV(channel
->ccwdev
), 6, "getbuff");
749 index
= channel
->io_buf_no
;
751 if (channel
->iob
[index
].state
== BUF_STATE_FREE
) {
752 channel
->iob
[index
].state
= BUF_STATE_LOCKED
;
753 channel
->io_buf_no
= (channel
->io_buf_no
+ 1) %
755 memset(channel
->iob
[index
].data
, 0, QETH_BUFSIZE
);
756 return channel
->iob
+ index
;
758 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
759 } while (index
!= channel
->io_buf_no
);
764 void qeth_release_buffer(struct qeth_channel
*channel
,
765 struct qeth_cmd_buffer
*iob
)
769 QETH_CARD_TEXT(CARD_FROM_CDEV(channel
->ccwdev
), 6, "relbuff");
770 spin_lock_irqsave(&channel
->iob_lock
, flags
);
771 memset(iob
->data
, 0, QETH_BUFSIZE
);
772 iob
->state
= BUF_STATE_FREE
;
773 iob
->callback
= qeth_send_control_data_cb
;
775 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
776 wake_up(&channel
->wait_q
);
778 EXPORT_SYMBOL_GPL(qeth_release_buffer
);
780 static struct qeth_cmd_buffer
*qeth_get_buffer(struct qeth_channel
*channel
)
782 struct qeth_cmd_buffer
*buffer
= NULL
;
785 spin_lock_irqsave(&channel
->iob_lock
, flags
);
786 buffer
= __qeth_get_buffer(channel
);
787 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
791 struct qeth_cmd_buffer
*qeth_wait_for_buffer(struct qeth_channel
*channel
)
793 struct qeth_cmd_buffer
*buffer
;
794 wait_event(channel
->wait_q
,
795 ((buffer
= qeth_get_buffer(channel
)) != NULL
));
798 EXPORT_SYMBOL_GPL(qeth_wait_for_buffer
);
800 void qeth_clear_cmd_buffers(struct qeth_channel
*channel
)
804 for (cnt
= 0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
805 qeth_release_buffer(channel
, &channel
->iob
[cnt
]);
807 channel
->io_buf_no
= 0;
809 EXPORT_SYMBOL_GPL(qeth_clear_cmd_buffers
);
811 static void qeth_send_control_data_cb(struct qeth_channel
*channel
,
812 struct qeth_cmd_buffer
*iob
)
814 struct qeth_card
*card
;
815 struct qeth_reply
*reply
, *r
;
816 struct qeth_ipa_cmd
*cmd
;
821 card
= CARD_FROM_CDEV(channel
->ccwdev
);
822 QETH_CARD_TEXT(card
, 4, "sndctlcb");
823 rc
= qeth_check_idx_response(card
, iob
->data
);
828 qeth_clear_ipacmd_list(card
);
829 qeth_schedule_recovery(card
);
835 cmd
= qeth_check_ipa_data(card
, iob
);
836 if ((cmd
== NULL
) && (card
->state
!= CARD_STATE_DOWN
))
838 /*in case of OSN : check if cmd is set */
839 if (card
->info
.type
== QETH_CARD_TYPE_OSN
&&
841 cmd
->hdr
.command
!= IPA_CMD_STARTLAN
&&
842 card
->osn_info
.assist_cb
!= NULL
) {
843 card
->osn_info
.assist_cb(card
->dev
, cmd
);
847 spin_lock_irqsave(&card
->lock
, flags
);
848 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
849 if ((reply
->seqno
== QETH_IDX_COMMAND_SEQNO
) ||
850 ((cmd
) && (reply
->seqno
== cmd
->hdr
.seqno
))) {
851 qeth_get_reply(reply
);
852 list_del_init(&reply
->list
);
853 spin_unlock_irqrestore(&card
->lock
, flags
);
855 if (reply
->callback
!= NULL
) {
857 reply
->offset
= (__u16
)((char *)cmd
-
859 keep_reply
= reply
->callback(card
,
863 keep_reply
= reply
->callback(card
,
868 reply
->rc
= (u16
) cmd
->hdr
.return_code
;
872 spin_lock_irqsave(&card
->lock
, flags
);
873 list_add_tail(&reply
->list
,
874 &card
->cmd_waiter_list
);
875 spin_unlock_irqrestore(&card
->lock
, flags
);
877 atomic_inc(&reply
->received
);
878 wake_up(&reply
->wait_q
);
880 qeth_put_reply(reply
);
884 spin_unlock_irqrestore(&card
->lock
, flags
);
886 memcpy(&card
->seqno
.pdu_hdr_ack
,
887 QETH_PDU_HEADER_SEQ_NO(iob
->data
),
889 qeth_release_buffer(channel
, iob
);
892 static int qeth_setup_channel(struct qeth_channel
*channel
)
896 QETH_DBF_TEXT(SETUP
, 2, "setupch");
897 for (cnt
= 0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++) {
898 channel
->iob
[cnt
].data
=
899 kzalloc(QETH_BUFSIZE
, GFP_DMA
|GFP_KERNEL
);
900 if (channel
->iob
[cnt
].data
== NULL
)
902 channel
->iob
[cnt
].state
= BUF_STATE_FREE
;
903 channel
->iob
[cnt
].channel
= channel
;
904 channel
->iob
[cnt
].callback
= qeth_send_control_data_cb
;
905 channel
->iob
[cnt
].rc
= 0;
907 if (cnt
< QETH_CMD_BUFFER_NO
) {
909 kfree(channel
->iob
[cnt
].data
);
913 channel
->io_buf_no
= 0;
914 atomic_set(&channel
->irq_pending
, 0);
915 spin_lock_init(&channel
->iob_lock
);
917 init_waitqueue_head(&channel
->wait_q
);
921 static int qeth_set_thread_start_bit(struct qeth_card
*card
,
922 unsigned long thread
)
926 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
927 if (!(card
->thread_allowed_mask
& thread
) ||
928 (card
->thread_start_mask
& thread
)) {
929 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
932 card
->thread_start_mask
|= thread
;
933 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
937 void qeth_clear_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
941 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
942 card
->thread_start_mask
&= ~thread
;
943 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
944 wake_up(&card
->wait_q
);
946 EXPORT_SYMBOL_GPL(qeth_clear_thread_start_bit
);
948 void qeth_clear_thread_running_bit(struct qeth_card
*card
, unsigned long thread
)
952 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
953 card
->thread_running_mask
&= ~thread
;
954 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
955 wake_up(&card
->wait_q
);
957 EXPORT_SYMBOL_GPL(qeth_clear_thread_running_bit
);
959 static int __qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
964 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
965 if (card
->thread_start_mask
& thread
) {
966 if ((card
->thread_allowed_mask
& thread
) &&
967 !(card
->thread_running_mask
& thread
)) {
969 card
->thread_start_mask
&= ~thread
;
970 card
->thread_running_mask
|= thread
;
974 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
978 int qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
982 wait_event(card
->wait_q
,
983 (rc
= __qeth_do_run_thread(card
, thread
)) >= 0);
986 EXPORT_SYMBOL_GPL(qeth_do_run_thread
);
988 void qeth_schedule_recovery(struct qeth_card
*card
)
990 QETH_CARD_TEXT(card
, 2, "startrec");
991 if (qeth_set_thread_start_bit(card
, QETH_RECOVER_THREAD
) == 0)
992 schedule_work(&card
->kernel_thread_starter
);
994 EXPORT_SYMBOL_GPL(qeth_schedule_recovery
);
996 static int qeth_get_problem(struct ccw_device
*cdev
, struct irb
*irb
)
1000 struct qeth_card
*card
;
1002 sense
= (char *) irb
->ecw
;
1003 cstat
= irb
->scsw
.cmd
.cstat
;
1004 dstat
= irb
->scsw
.cmd
.dstat
;
1005 card
= CARD_FROM_CDEV(cdev
);
1007 if (cstat
& (SCHN_STAT_CHN_CTRL_CHK
| SCHN_STAT_INTF_CTRL_CHK
|
1008 SCHN_STAT_CHN_DATA_CHK
| SCHN_STAT_CHAIN_CHECK
|
1009 SCHN_STAT_PROT_CHECK
| SCHN_STAT_PROG_CHECK
)) {
1010 QETH_CARD_TEXT(card
, 2, "CGENCHK");
1011 dev_warn(&cdev
->dev
, "The qeth device driver "
1012 "failed to recover an error on the device\n");
1013 QETH_DBF_MESSAGE(2, "%s check on device dstat=x%x, cstat=x%x\n",
1014 dev_name(&cdev
->dev
), dstat
, cstat
);
1015 print_hex_dump(KERN_WARNING
, "qeth: irb ", DUMP_PREFIX_OFFSET
,
1020 if (dstat
& DEV_STAT_UNIT_CHECK
) {
1021 if (sense
[SENSE_RESETTING_EVENT_BYTE
] &
1022 SENSE_RESETTING_EVENT_FLAG
) {
1023 QETH_CARD_TEXT(card
, 2, "REVIND");
1026 if (sense
[SENSE_COMMAND_REJECT_BYTE
] &
1027 SENSE_COMMAND_REJECT_FLAG
) {
1028 QETH_CARD_TEXT(card
, 2, "CMDREJi");
1031 if ((sense
[2] == 0xaf) && (sense
[3] == 0xfe)) {
1032 QETH_CARD_TEXT(card
, 2, "AFFE");
1035 if ((!sense
[0]) && (!sense
[1]) && (!sense
[2]) && (!sense
[3])) {
1036 QETH_CARD_TEXT(card
, 2, "ZEROSEN");
1039 QETH_CARD_TEXT(card
, 2, "DGENCHK");
1045 static long __qeth_check_irb_error(struct ccw_device
*cdev
,
1046 unsigned long intparm
, struct irb
*irb
)
1048 struct qeth_card
*card
;
1050 card
= CARD_FROM_CDEV(cdev
);
1052 if (!card
|| !IS_ERR(irb
))
1055 switch (PTR_ERR(irb
)) {
1057 QETH_DBF_MESSAGE(2, "%s i/o-error on device\n",
1058 dev_name(&cdev
->dev
));
1059 QETH_CARD_TEXT(card
, 2, "ckirberr");
1060 QETH_CARD_TEXT_(card
, 2, " rc%d", -EIO
);
1063 dev_warn(&cdev
->dev
, "A hardware operation timed out"
1064 " on the device\n");
1065 QETH_CARD_TEXT(card
, 2, "ckirberr");
1066 QETH_CARD_TEXT_(card
, 2, " rc%d", -ETIMEDOUT
);
1067 if (intparm
== QETH_RCD_PARM
) {
1068 if (card
->data
.ccwdev
== cdev
) {
1069 card
->data
.state
= CH_STATE_DOWN
;
1070 wake_up(&card
->wait_q
);
1075 QETH_DBF_MESSAGE(2, "%s unknown error %ld on device\n",
1076 dev_name(&cdev
->dev
), PTR_ERR(irb
));
1077 QETH_CARD_TEXT(card
, 2, "ckirberr");
1078 QETH_CARD_TEXT(card
, 2, " rc???");
1080 return PTR_ERR(irb
);
1083 static void qeth_irq(struct ccw_device
*cdev
, unsigned long intparm
,
1088 struct qeth_cmd_buffer
*buffer
;
1089 struct qeth_channel
*channel
;
1090 struct qeth_card
*card
;
1091 struct qeth_cmd_buffer
*iob
;
1094 if (__qeth_check_irb_error(cdev
, intparm
, irb
))
1096 cstat
= irb
->scsw
.cmd
.cstat
;
1097 dstat
= irb
->scsw
.cmd
.dstat
;
1099 card
= CARD_FROM_CDEV(cdev
);
1103 QETH_CARD_TEXT(card
, 5, "irq");
1105 if (card
->read
.ccwdev
== cdev
) {
1106 channel
= &card
->read
;
1107 QETH_CARD_TEXT(card
, 5, "read");
1108 } else if (card
->write
.ccwdev
== cdev
) {
1109 channel
= &card
->write
;
1110 QETH_CARD_TEXT(card
, 5, "write");
1112 channel
= &card
->data
;
1113 QETH_CARD_TEXT(card
, 5, "data");
1115 atomic_set(&channel
->irq_pending
, 0);
1117 if (irb
->scsw
.cmd
.fctl
& (SCSW_FCTL_CLEAR_FUNC
))
1118 channel
->state
= CH_STATE_STOPPED
;
1120 if (irb
->scsw
.cmd
.fctl
& (SCSW_FCTL_HALT_FUNC
))
1121 channel
->state
= CH_STATE_HALTED
;
1123 /*let's wake up immediately on data channel*/
1124 if ((channel
== &card
->data
) && (intparm
!= 0) &&
1125 (intparm
!= QETH_RCD_PARM
))
1128 if (intparm
== QETH_CLEAR_CHANNEL_PARM
) {
1129 QETH_CARD_TEXT(card
, 6, "clrchpar");
1130 /* we don't have to handle this further */
1133 if (intparm
== QETH_HALT_CHANNEL_PARM
) {
1134 QETH_CARD_TEXT(card
, 6, "hltchpar");
1135 /* we don't have to handle this further */
1138 if ((dstat
& DEV_STAT_UNIT_EXCEP
) ||
1139 (dstat
& DEV_STAT_UNIT_CHECK
) ||
1141 if (irb
->esw
.esw0
.erw
.cons
) {
1142 dev_warn(&channel
->ccwdev
->dev
,
1143 "The qeth device driver failed to recover "
1144 "an error on the device\n");
1145 QETH_DBF_MESSAGE(2, "%s sense data available. cstat "
1146 "0x%X dstat 0x%X\n",
1147 dev_name(&channel
->ccwdev
->dev
), cstat
, dstat
);
1148 print_hex_dump(KERN_WARNING
, "qeth: irb ",
1149 DUMP_PREFIX_OFFSET
, 16, 1, irb
, 32, 1);
1150 print_hex_dump(KERN_WARNING
, "qeth: sense data ",
1151 DUMP_PREFIX_OFFSET
, 16, 1, irb
->ecw
, 32, 1);
1153 if (intparm
== QETH_RCD_PARM
) {
1154 channel
->state
= CH_STATE_DOWN
;
1157 rc
= qeth_get_problem(cdev
, irb
);
1159 qeth_clear_ipacmd_list(card
);
1160 qeth_schedule_recovery(card
);
1165 if (intparm
== QETH_RCD_PARM
) {
1166 channel
->state
= CH_STATE_RCD_DONE
;
1170 buffer
= (struct qeth_cmd_buffer
*) __va((addr_t
)intparm
);
1171 buffer
->state
= BUF_STATE_PROCESSED
;
1173 if (channel
== &card
->data
)
1175 if (channel
== &card
->read
&&
1176 channel
->state
== CH_STATE_UP
)
1177 qeth_issue_next_read(card
);
1180 index
= channel
->buf_no
;
1181 while (iob
[index
].state
== BUF_STATE_PROCESSED
) {
1182 if (iob
[index
].callback
!= NULL
)
1183 iob
[index
].callback(channel
, iob
+ index
);
1185 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
1187 channel
->buf_no
= index
;
1189 wake_up(&card
->wait_q
);
1193 static void qeth_notify_skbs(struct qeth_qdio_out_q
*q
,
1194 struct qeth_qdio_out_buffer
*buf
,
1195 enum iucv_tx_notify notification
)
1197 struct sk_buff
*skb
;
1199 if (skb_queue_empty(&buf
->skb_list
))
1201 skb
= skb_peek(&buf
->skb_list
);
1203 QETH_CARD_TEXT_(q
->card
, 5, "skbn%d", notification
);
1204 QETH_CARD_TEXT_(q
->card
, 5, "%lx", (long) skb
);
1205 if (skb
->protocol
== ETH_P_AF_IUCV
) {
1207 struct iucv_sock
*iucv
= iucv_sk(skb
->sk
);
1208 iucv
->sk_txnotify(skb
, notification
);
1211 if (skb_queue_is_last(&buf
->skb_list
, skb
))
1214 skb
= skb_queue_next(&buf
->skb_list
, skb
);
1220 static void qeth_release_skbs(struct qeth_qdio_out_buffer
*buf
)
1222 struct sk_buff
*skb
;
1223 struct iucv_sock
*iucv
;
1224 int notify_general_error
= 0;
1226 if (atomic_read(&buf
->state
) == QETH_QDIO_BUF_PENDING
)
1227 notify_general_error
= 1;
1229 /* release may never happen from within CQ tasklet scope */
1230 WARN_ON_ONCE(atomic_read(&buf
->state
) == QETH_QDIO_BUF_IN_CQ
);
1232 skb
= skb_dequeue(&buf
->skb_list
);
1234 QETH_CARD_TEXT(buf
->q
->card
, 5, "skbr");
1235 QETH_CARD_TEXT_(buf
->q
->card
, 5, "%lx", (long) skb
);
1236 if (notify_general_error
&& skb
->protocol
== ETH_P_AF_IUCV
) {
1238 iucv
= iucv_sk(skb
->sk
);
1239 iucv
->sk_txnotify(skb
, TX_NOTIFY_GENERALERROR
);
1242 atomic_dec(&skb
->users
);
1243 dev_kfree_skb_any(skb
);
1244 skb
= skb_dequeue(&buf
->skb_list
);
1248 static void qeth_clear_output_buffer(struct qeth_qdio_out_q
*queue
,
1249 struct qeth_qdio_out_buffer
*buf
,
1250 enum qeth_qdio_buffer_states newbufstate
)
1254 /* is PCI flag set on buffer? */
1255 if (buf
->buffer
->element
[0].sflags
& SBAL_SFLAGS0_PCI_REQ
)
1256 atomic_dec(&queue
->set_pci_flags_count
);
1258 if (newbufstate
== QETH_QDIO_BUF_EMPTY
) {
1259 qeth_release_skbs(buf
);
1261 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(queue
->card
); ++i
) {
1262 if (buf
->buffer
->element
[i
].addr
&& buf
->is_header
[i
])
1263 kmem_cache_free(qeth_core_header_cache
,
1264 buf
->buffer
->element
[i
].addr
);
1265 buf
->is_header
[i
] = 0;
1266 buf
->buffer
->element
[i
].length
= 0;
1267 buf
->buffer
->element
[i
].addr
= NULL
;
1268 buf
->buffer
->element
[i
].eflags
= 0;
1269 buf
->buffer
->element
[i
].sflags
= 0;
1271 buf
->buffer
->element
[15].eflags
= 0;
1272 buf
->buffer
->element
[15].sflags
= 0;
1273 buf
->next_element_to_fill
= 0;
1274 atomic_set(&buf
->state
, newbufstate
);
1277 static void qeth_clear_outq_buffers(struct qeth_qdio_out_q
*q
, int free
)
1281 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
) {
1284 qeth_cleanup_handled_pending(q
, j
, 1);
1285 qeth_clear_output_buffer(q
, q
->bufs
[j
], QETH_QDIO_BUF_EMPTY
);
1287 kmem_cache_free(qeth_qdio_outbuf_cache
, q
->bufs
[j
]);
1293 void qeth_clear_qdio_buffers(struct qeth_card
*card
)
1297 QETH_CARD_TEXT(card
, 2, "clearqdbf");
1298 /* clear outbound buffers to free skbs */
1299 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
) {
1300 if (card
->qdio
.out_qs
[i
]) {
1301 qeth_clear_outq_buffers(card
->qdio
.out_qs
[i
], 0);
1305 EXPORT_SYMBOL_GPL(qeth_clear_qdio_buffers
);
1307 static void qeth_free_buffer_pool(struct qeth_card
*card
)
1309 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
1311 list_for_each_entry_safe(pool_entry
, tmp
,
1312 &card
->qdio
.init_pool
.entry_list
, init_list
){
1313 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
)
1314 free_page((unsigned long)pool_entry
->elements
[i
]);
1315 list_del(&pool_entry
->init_list
);
1320 static void qeth_clean_channel(struct qeth_channel
*channel
)
1324 QETH_DBF_TEXT(SETUP
, 2, "freech");
1325 for (cnt
= 0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
1326 kfree(channel
->iob
[cnt
].data
);
1329 static void qeth_set_single_write_queues(struct qeth_card
*card
)
1331 if ((atomic_read(&card
->qdio
.state
) != QETH_QDIO_UNINITIALIZED
) &&
1332 (card
->qdio
.no_out_queues
== 4))
1333 qeth_free_qdio_buffers(card
);
1335 card
->qdio
.no_out_queues
= 1;
1336 if (card
->qdio
.default_out_queue
!= 0)
1337 dev_info(&card
->gdev
->dev
, "Priority Queueing not supported\n");
1339 card
->qdio
.default_out_queue
= 0;
1342 static void qeth_set_multiple_write_queues(struct qeth_card
*card
)
1344 if ((atomic_read(&card
->qdio
.state
) != QETH_QDIO_UNINITIALIZED
) &&
1345 (card
->qdio
.no_out_queues
== 1)) {
1346 qeth_free_qdio_buffers(card
);
1347 card
->qdio
.default_out_queue
= 2;
1349 card
->qdio
.no_out_queues
= 4;
1352 static void qeth_update_from_chp_desc(struct qeth_card
*card
)
1354 struct ccw_device
*ccwdev
;
1355 struct channel_path_desc
*chp_dsc
;
1357 QETH_DBF_TEXT(SETUP
, 2, "chp_desc");
1359 ccwdev
= card
->data
.ccwdev
;
1360 chp_dsc
= ccw_device_get_chp_desc(ccwdev
, 0);
1364 card
->info
.func_level
= 0x4100 + chp_dsc
->desc
;
1365 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1368 /* CHPP field bit 6 == 1 -> single queue */
1369 if ((chp_dsc
->chpp
& 0x02) == 0x02)
1370 qeth_set_single_write_queues(card
);
1372 qeth_set_multiple_write_queues(card
);
1375 QETH_DBF_TEXT_(SETUP
, 2, "nr:%x", card
->qdio
.no_out_queues
);
1376 QETH_DBF_TEXT_(SETUP
, 2, "lvl:%02x", card
->info
.func_level
);
1379 static void qeth_init_qdio_info(struct qeth_card
*card
)
1381 QETH_DBF_TEXT(SETUP
, 4, "intqdinf");
1382 atomic_set(&card
->qdio
.state
, QETH_QDIO_UNINITIALIZED
);
1384 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
1385 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1386 card
->qdio
.init_pool
.buf_count
= QETH_IN_BUF_COUNT_HSDEFAULT
;
1388 card
->qdio
.init_pool
.buf_count
= QETH_IN_BUF_COUNT_DEFAULT
;
1389 card
->qdio
.in_buf_pool
.buf_count
= card
->qdio
.init_pool
.buf_count
;
1390 INIT_LIST_HEAD(&card
->qdio
.in_buf_pool
.entry_list
);
1391 INIT_LIST_HEAD(&card
->qdio
.init_pool
.entry_list
);
1394 static void qeth_set_intial_options(struct qeth_card
*card
)
1396 card
->options
.route4
.type
= NO_ROUTER
;
1397 card
->options
.route6
.type
= NO_ROUTER
;
1398 card
->options
.fake_broadcast
= 0;
1399 card
->options
.add_hhlen
= DEFAULT_ADD_HHLEN
;
1400 card
->options
.performance_stats
= 0;
1401 card
->options
.rx_sg_cb
= QETH_RX_SG_CB
;
1402 card
->options
.isolation
= ISOLATION_MODE_NONE
;
1403 card
->options
.cq
= QETH_CQ_DISABLED
;
1406 static int qeth_do_start_thread(struct qeth_card
*card
, unsigned long thread
)
1408 unsigned long flags
;
1411 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
1412 QETH_CARD_TEXT_(card
, 4, " %02x%02x%02x",
1413 (u8
) card
->thread_start_mask
,
1414 (u8
) card
->thread_allowed_mask
,
1415 (u8
) card
->thread_running_mask
);
1416 rc
= (card
->thread_start_mask
& thread
);
1417 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
1421 static void qeth_start_kernel_thread(struct work_struct
*work
)
1423 struct task_struct
*ts
;
1424 struct qeth_card
*card
= container_of(work
, struct qeth_card
,
1425 kernel_thread_starter
);
1426 QETH_CARD_TEXT(card
, 2, "strthrd");
1428 if (card
->read
.state
!= CH_STATE_UP
&&
1429 card
->write
.state
!= CH_STATE_UP
)
1431 if (qeth_do_start_thread(card
, QETH_RECOVER_THREAD
)) {
1432 ts
= kthread_run(card
->discipline
->recover
, (void *)card
,
1435 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
1436 qeth_clear_thread_running_bit(card
,
1437 QETH_RECOVER_THREAD
);
1442 static void qeth_buffer_reclaim_work(struct work_struct
*);
1443 static int qeth_setup_card(struct qeth_card
*card
)
1446 QETH_DBF_TEXT(SETUP
, 2, "setupcrd");
1447 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1449 card
->read
.state
= CH_STATE_DOWN
;
1450 card
->write
.state
= CH_STATE_DOWN
;
1451 card
->data
.state
= CH_STATE_DOWN
;
1452 card
->state
= CARD_STATE_DOWN
;
1453 card
->lan_online
= 0;
1454 card
->read_or_write_problem
= 0;
1456 spin_lock_init(&card
->vlanlock
);
1457 spin_lock_init(&card
->mclock
);
1458 spin_lock_init(&card
->lock
);
1459 spin_lock_init(&card
->ip_lock
);
1460 spin_lock_init(&card
->thread_mask_lock
);
1461 mutex_init(&card
->conf_mutex
);
1462 mutex_init(&card
->discipline_mutex
);
1463 card
->thread_start_mask
= 0;
1464 card
->thread_allowed_mask
= 0;
1465 card
->thread_running_mask
= 0;
1466 INIT_WORK(&card
->kernel_thread_starter
, qeth_start_kernel_thread
);
1467 INIT_LIST_HEAD(&card
->cmd_waiter_list
);
1468 init_waitqueue_head(&card
->wait_q
);
1469 /* initial options */
1470 qeth_set_intial_options(card
);
1471 /* IP address takeover */
1472 INIT_LIST_HEAD(&card
->ipato
.entries
);
1473 card
->ipato
.enabled
= 0;
1474 card
->ipato
.invert4
= 0;
1475 card
->ipato
.invert6
= 0;
1476 /* init QDIO stuff */
1477 qeth_init_qdio_info(card
);
1478 INIT_DELAYED_WORK(&card
->buffer_reclaim_work
, qeth_buffer_reclaim_work
);
1479 INIT_WORK(&card
->close_dev_work
, qeth_close_dev_handler
);
1483 static void qeth_core_sl_print(struct seq_file
*m
, struct service_level
*slr
)
1485 struct qeth_card
*card
= container_of(slr
, struct qeth_card
,
1486 qeth_service_level
);
1487 if (card
->info
.mcl_level
[0])
1488 seq_printf(m
, "qeth: %s firmware level %s\n",
1489 CARD_BUS_ID(card
), card
->info
.mcl_level
);
1492 static struct qeth_card
*qeth_alloc_card(void)
1494 struct qeth_card
*card
;
1496 QETH_DBF_TEXT(SETUP
, 2, "alloccrd");
1497 card
= kzalloc(sizeof(struct qeth_card
), GFP_DMA
|GFP_KERNEL
);
1500 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1501 if (qeth_setup_channel(&card
->read
))
1503 if (qeth_setup_channel(&card
->write
))
1505 card
->options
.layer2
= -1;
1506 card
->qeth_service_level
.seq_print
= qeth_core_sl_print
;
1507 register_service_level(&card
->qeth_service_level
);
1511 qeth_clean_channel(&card
->read
);
1518 static int qeth_determine_card_type(struct qeth_card
*card
)
1522 QETH_DBF_TEXT(SETUP
, 2, "detcdtyp");
1524 card
->qdio
.do_prio_queueing
= QETH_PRIOQ_DEFAULT
;
1525 card
->qdio
.default_out_queue
= QETH_DEFAULT_QUEUE
;
1526 while (known_devices
[i
][QETH_DEV_MODEL_IND
]) {
1527 if ((CARD_RDEV(card
)->id
.dev_type
==
1528 known_devices
[i
][QETH_DEV_TYPE_IND
]) &&
1529 (CARD_RDEV(card
)->id
.dev_model
==
1530 known_devices
[i
][QETH_DEV_MODEL_IND
])) {
1531 card
->info
.type
= known_devices
[i
][QETH_DEV_MODEL_IND
];
1532 card
->qdio
.no_out_queues
=
1533 known_devices
[i
][QETH_QUEUE_NO_IND
];
1534 card
->qdio
.no_in_queues
= 1;
1535 card
->info
.is_multicast_different
=
1536 known_devices
[i
][QETH_MULTICAST_IND
];
1537 qeth_update_from_chp_desc(card
);
1542 card
->info
.type
= QETH_CARD_TYPE_UNKNOWN
;
1543 dev_err(&card
->gdev
->dev
, "The adapter hardware is of an "
1548 static int qeth_clear_channel(struct qeth_channel
*channel
)
1550 unsigned long flags
;
1551 struct qeth_card
*card
;
1554 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1555 QETH_CARD_TEXT(card
, 3, "clearch");
1556 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1557 rc
= ccw_device_clear(channel
->ccwdev
, QETH_CLEAR_CHANNEL_PARM
);
1558 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1562 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1563 channel
->state
== CH_STATE_STOPPED
, QETH_TIMEOUT
);
1564 if (rc
== -ERESTARTSYS
)
1566 if (channel
->state
!= CH_STATE_STOPPED
)
1568 channel
->state
= CH_STATE_DOWN
;
1572 static int qeth_halt_channel(struct qeth_channel
*channel
)
1574 unsigned long flags
;
1575 struct qeth_card
*card
;
1578 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1579 QETH_CARD_TEXT(card
, 3, "haltch");
1580 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1581 rc
= ccw_device_halt(channel
->ccwdev
, QETH_HALT_CHANNEL_PARM
);
1582 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1586 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1587 channel
->state
== CH_STATE_HALTED
, QETH_TIMEOUT
);
1588 if (rc
== -ERESTARTSYS
)
1590 if (channel
->state
!= CH_STATE_HALTED
)
1595 static int qeth_halt_channels(struct qeth_card
*card
)
1597 int rc1
= 0, rc2
= 0, rc3
= 0;
1599 QETH_CARD_TEXT(card
, 3, "haltchs");
1600 rc1
= qeth_halt_channel(&card
->read
);
1601 rc2
= qeth_halt_channel(&card
->write
);
1602 rc3
= qeth_halt_channel(&card
->data
);
1610 static int qeth_clear_channels(struct qeth_card
*card
)
1612 int rc1
= 0, rc2
= 0, rc3
= 0;
1614 QETH_CARD_TEXT(card
, 3, "clearchs");
1615 rc1
= qeth_clear_channel(&card
->read
);
1616 rc2
= qeth_clear_channel(&card
->write
);
1617 rc3
= qeth_clear_channel(&card
->data
);
1625 static int qeth_clear_halt_card(struct qeth_card
*card
, int halt
)
1629 QETH_CARD_TEXT(card
, 3, "clhacrd");
1632 rc
= qeth_halt_channels(card
);
1635 return qeth_clear_channels(card
);
1638 int qeth_qdio_clear_card(struct qeth_card
*card
, int use_halt
)
1642 QETH_CARD_TEXT(card
, 3, "qdioclr");
1643 switch (atomic_cmpxchg(&card
->qdio
.state
, QETH_QDIO_ESTABLISHED
,
1644 QETH_QDIO_CLEANING
)) {
1645 case QETH_QDIO_ESTABLISHED
:
1646 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1647 rc
= qdio_shutdown(CARD_DDEV(card
),
1648 QDIO_FLAG_CLEANUP_USING_HALT
);
1650 rc
= qdio_shutdown(CARD_DDEV(card
),
1651 QDIO_FLAG_CLEANUP_USING_CLEAR
);
1653 QETH_CARD_TEXT_(card
, 3, "1err%d", rc
);
1654 atomic_set(&card
->qdio
.state
, QETH_QDIO_ALLOCATED
);
1656 case QETH_QDIO_CLEANING
:
1661 rc
= qeth_clear_halt_card(card
, use_halt
);
1663 QETH_CARD_TEXT_(card
, 3, "2err%d", rc
);
1664 card
->state
= CARD_STATE_DOWN
;
1667 EXPORT_SYMBOL_GPL(qeth_qdio_clear_card
);
1669 static int qeth_read_conf_data(struct qeth_card
*card
, void **buffer
,
1675 struct qeth_channel
*channel
= &card
->data
;
1676 unsigned long flags
;
1679 * scan for RCD command in extended SenseID data
1681 ciw
= ccw_device_get_ciw(channel
->ccwdev
, CIW_TYPE_RCD
);
1682 if (!ciw
|| ciw
->cmd
== 0)
1684 rcd_buf
= kzalloc(ciw
->count
, GFP_KERNEL
| GFP_DMA
);
1688 channel
->ccw
.cmd_code
= ciw
->cmd
;
1689 channel
->ccw
.cda
= (__u32
) __pa(rcd_buf
);
1690 channel
->ccw
.count
= ciw
->count
;
1691 channel
->ccw
.flags
= CCW_FLAG_SLI
;
1692 channel
->state
= CH_STATE_RCD
;
1693 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1694 ret
= ccw_device_start_timeout(channel
->ccwdev
, &channel
->ccw
,
1695 QETH_RCD_PARM
, LPM_ANYPATH
, 0,
1697 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1699 wait_event(card
->wait_q
,
1700 (channel
->state
== CH_STATE_RCD_DONE
||
1701 channel
->state
== CH_STATE_DOWN
));
1702 if (channel
->state
== CH_STATE_DOWN
)
1705 channel
->state
= CH_STATE_DOWN
;
1711 *length
= ciw
->count
;
1717 static void qeth_configure_unitaddr(struct qeth_card
*card
, char *prcd
)
1719 QETH_DBF_TEXT(SETUP
, 2, "cfgunit");
1720 card
->info
.chpid
= prcd
[30];
1721 card
->info
.unit_addr2
= prcd
[31];
1722 card
->info
.cula
= prcd
[63];
1723 card
->info
.guestlan
= ((prcd
[0x10] == _ascebc
['V']) &&
1724 (prcd
[0x11] == _ascebc
['M']));
1727 static void qeth_configure_blkt_default(struct qeth_card
*card
, char *prcd
)
1729 QETH_DBF_TEXT(SETUP
, 2, "cfgblkt");
1731 if (prcd
[74] == 0xF0 && prcd
[75] == 0xF0 &&
1732 prcd
[76] >= 0xF1 && prcd
[76] <= 0xF4) {
1733 card
->info
.blkt
.time_total
= 0;
1734 card
->info
.blkt
.inter_packet
= 0;
1735 card
->info
.blkt
.inter_packet_jumbo
= 0;
1737 card
->info
.blkt
.time_total
= 250;
1738 card
->info
.blkt
.inter_packet
= 5;
1739 card
->info
.blkt
.inter_packet_jumbo
= 15;
1743 static void qeth_init_tokens(struct qeth_card
*card
)
1745 card
->token
.issuer_rm_w
= 0x00010103UL
;
1746 card
->token
.cm_filter_w
= 0x00010108UL
;
1747 card
->token
.cm_connection_w
= 0x0001010aUL
;
1748 card
->token
.ulp_filter_w
= 0x0001010bUL
;
1749 card
->token
.ulp_connection_w
= 0x0001010dUL
;
1752 static void qeth_init_func_level(struct qeth_card
*card
)
1754 switch (card
->info
.type
) {
1755 case QETH_CARD_TYPE_IQD
:
1756 card
->info
.func_level
= QETH_IDX_FUNC_LEVEL_IQD
;
1758 case QETH_CARD_TYPE_OSD
:
1759 case QETH_CARD_TYPE_OSN
:
1760 card
->info
.func_level
= QETH_IDX_FUNC_LEVEL_OSD
;
1767 static int qeth_idx_activate_get_answer(struct qeth_channel
*channel
,
1768 void (*idx_reply_cb
)(struct qeth_channel
*,
1769 struct qeth_cmd_buffer
*))
1771 struct qeth_cmd_buffer
*iob
;
1772 unsigned long flags
;
1774 struct qeth_card
*card
;
1776 QETH_DBF_TEXT(SETUP
, 2, "idxanswr");
1777 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1778 iob
= qeth_get_buffer(channel
);
1781 iob
->callback
= idx_reply_cb
;
1782 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1783 channel
->ccw
.count
= QETH_BUFSIZE
;
1784 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1786 wait_event(card
->wait_q
,
1787 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1788 QETH_DBF_TEXT(SETUP
, 6, "noirqpnd");
1789 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1790 rc
= ccw_device_start(channel
->ccwdev
,
1791 &channel
->ccw
, (addr_t
) iob
, 0, 0);
1792 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1795 QETH_DBF_MESSAGE(2, "Error2 in activating channel rc=%d\n", rc
);
1796 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
1797 atomic_set(&channel
->irq_pending
, 0);
1798 wake_up(&card
->wait_q
);
1801 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1802 channel
->state
== CH_STATE_UP
, QETH_TIMEOUT
);
1803 if (rc
== -ERESTARTSYS
)
1805 if (channel
->state
!= CH_STATE_UP
) {
1807 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
1808 qeth_clear_cmd_buffers(channel
);
1814 static int qeth_idx_activate_channel(struct qeth_channel
*channel
,
1815 void (*idx_reply_cb
)(struct qeth_channel
*,
1816 struct qeth_cmd_buffer
*))
1818 struct qeth_card
*card
;
1819 struct qeth_cmd_buffer
*iob
;
1820 unsigned long flags
;
1824 struct ccw_dev_id temp_devid
;
1826 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1828 QETH_DBF_TEXT(SETUP
, 2, "idxactch");
1830 iob
= qeth_get_buffer(channel
);
1833 iob
->callback
= idx_reply_cb
;
1834 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1835 channel
->ccw
.count
= IDX_ACTIVATE_SIZE
;
1836 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1837 if (channel
== &card
->write
) {
1838 memcpy(iob
->data
, IDX_ACTIVATE_WRITE
, IDX_ACTIVATE_SIZE
);
1839 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1840 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1841 card
->seqno
.trans_hdr
++;
1843 memcpy(iob
->data
, IDX_ACTIVATE_READ
, IDX_ACTIVATE_SIZE
);
1844 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1845 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1847 tmp
= ((__u8
)card
->info
.portno
) | 0x80;
1848 memcpy(QETH_IDX_ACT_PNO(iob
->data
), &tmp
, 1);
1849 memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1850 &card
->token
.issuer_rm_w
, QETH_MPC_TOKEN_LENGTH
);
1851 memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob
->data
),
1852 &card
->info
.func_level
, sizeof(__u16
));
1853 ccw_device_get_id(CARD_DDEV(card
), &temp_devid
);
1854 memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob
->data
), &temp_devid
.devno
, 2);
1855 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
1856 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob
->data
), &temp
, 2);
1858 wait_event(card
->wait_q
,
1859 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1860 QETH_DBF_TEXT(SETUP
, 6, "noirqpnd");
1861 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1862 rc
= ccw_device_start(channel
->ccwdev
,
1863 &channel
->ccw
, (addr_t
) iob
, 0, 0);
1864 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1867 QETH_DBF_MESSAGE(2, "Error1 in activating channel. rc=%d\n",
1869 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
1870 atomic_set(&channel
->irq_pending
, 0);
1871 wake_up(&card
->wait_q
);
1874 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1875 channel
->state
== CH_STATE_ACTIVATING
, QETH_TIMEOUT
);
1876 if (rc
== -ERESTARTSYS
)
1878 if (channel
->state
!= CH_STATE_ACTIVATING
) {
1879 dev_warn(&channel
->ccwdev
->dev
, "The qeth device driver"
1880 " failed to recover an error on the device\n");
1881 QETH_DBF_MESSAGE(2, "%s IDX activate timed out\n",
1882 dev_name(&channel
->ccwdev
->dev
));
1883 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", -ETIME
);
1884 qeth_clear_cmd_buffers(channel
);
1887 return qeth_idx_activate_get_answer(channel
, idx_reply_cb
);
1890 static int qeth_peer_func_level(int level
)
1892 if ((level
& 0xff) == 8)
1893 return (level
& 0xff) + 0x400;
1894 if (((level
>> 8) & 3) == 1)
1895 return (level
& 0xff) + 0x200;
1899 static void qeth_idx_write_cb(struct qeth_channel
*channel
,
1900 struct qeth_cmd_buffer
*iob
)
1902 struct qeth_card
*card
;
1905 QETH_DBF_TEXT(SETUP
, 2, "idxwrcb");
1907 if (channel
->state
== CH_STATE_DOWN
) {
1908 channel
->state
= CH_STATE_ACTIVATING
;
1911 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1913 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1914 if (QETH_IDX_ACT_CAUSE_CODE(iob
->data
) == QETH_IDX_ACT_ERR_EXCL
)
1915 dev_err(&card
->write
.ccwdev
->dev
,
1916 "The adapter is used exclusively by another "
1919 QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on write channel:"
1920 " negative reply\n",
1921 dev_name(&card
->write
.ccwdev
->dev
));
1924 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1925 if ((temp
& ~0x0100) != qeth_peer_func_level(card
->info
.func_level
)) {
1926 QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on write channel: "
1927 "function level mismatch (sent: 0x%x, received: "
1928 "0x%x)\n", dev_name(&card
->write
.ccwdev
->dev
),
1929 card
->info
.func_level
, temp
);
1932 channel
->state
= CH_STATE_UP
;
1934 qeth_release_buffer(channel
, iob
);
1937 static void qeth_idx_read_cb(struct qeth_channel
*channel
,
1938 struct qeth_cmd_buffer
*iob
)
1940 struct qeth_card
*card
;
1943 QETH_DBF_TEXT(SETUP
, 2, "idxrdcb");
1944 if (channel
->state
== CH_STATE_DOWN
) {
1945 channel
->state
= CH_STATE_ACTIVATING
;
1949 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1950 if (qeth_check_idx_response(card
, iob
->data
))
1953 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1954 switch (QETH_IDX_ACT_CAUSE_CODE(iob
->data
)) {
1955 case QETH_IDX_ACT_ERR_EXCL
:
1956 dev_err(&card
->write
.ccwdev
->dev
,
1957 "The adapter is used exclusively by another "
1960 case QETH_IDX_ACT_ERR_AUTH
:
1961 case QETH_IDX_ACT_ERR_AUTH_USER
:
1962 dev_err(&card
->read
.ccwdev
->dev
,
1963 "Setting the device online failed because of "
1964 "insufficient authorization\n");
1967 QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on read channel:"
1968 " negative reply\n",
1969 dev_name(&card
->read
.ccwdev
->dev
));
1971 QETH_CARD_TEXT_(card
, 2, "idxread%c",
1972 QETH_IDX_ACT_CAUSE_CODE(iob
->data
));
1976 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1977 if (temp
!= qeth_peer_func_level(card
->info
.func_level
)) {
1978 QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on read channel: function "
1979 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1980 dev_name(&card
->read
.ccwdev
->dev
),
1981 card
->info
.func_level
, temp
);
1984 memcpy(&card
->token
.issuer_rm_r
,
1985 QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1986 QETH_MPC_TOKEN_LENGTH
);
1987 memcpy(&card
->info
.mcl_level
[0],
1988 QETH_IDX_REPLY_LEVEL(iob
->data
), QETH_MCL_LENGTH
);
1989 channel
->state
= CH_STATE_UP
;
1991 qeth_release_buffer(channel
, iob
);
1994 void qeth_prepare_control_data(struct qeth_card
*card
, int len
,
1995 struct qeth_cmd_buffer
*iob
)
1997 qeth_setup_ccw(&card
->write
, iob
->data
, len
);
1998 iob
->callback
= qeth_release_buffer
;
2000 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
2001 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
2002 card
->seqno
.trans_hdr
++;
2003 memcpy(QETH_PDU_HEADER_SEQ_NO(iob
->data
),
2004 &card
->seqno
.pdu_hdr
, QETH_SEQ_NO_LENGTH
);
2005 card
->seqno
.pdu_hdr
++;
2006 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob
->data
),
2007 &card
->seqno
.pdu_hdr_ack
, QETH_SEQ_NO_LENGTH
);
2008 QETH_DBF_HEX(CTRL
, 2, iob
->data
, QETH_DBF_CTRL_LEN
);
2010 EXPORT_SYMBOL_GPL(qeth_prepare_control_data
);
2013 * qeth_send_control_data() - send control command to the card
2014 * @card: qeth_card structure pointer
2015 * @len: size of the command buffer
2016 * @iob: qeth_cmd_buffer pointer
2017 * @reply_cb: callback function pointer
2018 * @cb_card: pointer to the qeth_card structure
2019 * @cb_reply: pointer to the qeth_reply structure
2020 * @cb_cmd: pointer to the original iob for non-IPA
2021 * commands, or to the qeth_ipa_cmd structure
2022 * for the IPA commands.
2023 * @reply_param: private pointer passed to the callback
2025 * Returns the value of the `return_code' field of the response
2026 * block returned from the hardware, or other error indication.
2027 * Value of zero indicates successful execution of the command.
2029 * Callback function gets called one or more times, with cb_cmd
2030 * pointing to the response returned by the hardware. Callback
2031 * function must return non-zero if more reply blocks are expected,
2032 * and zero if the last or only reply block is received. Callback
2033 * function can get the value of the reply_param pointer from the
2034 * field 'param' of the structure qeth_reply.
2037 int qeth_send_control_data(struct qeth_card
*card
, int len
,
2038 struct qeth_cmd_buffer
*iob
,
2039 int (*reply_cb
)(struct qeth_card
*cb_card
,
2040 struct qeth_reply
*cb_reply
,
2041 unsigned long cb_cmd
),
2045 unsigned long flags
;
2046 struct qeth_reply
*reply
= NULL
;
2047 unsigned long timeout
, event_timeout
;
2048 struct qeth_ipa_cmd
*cmd
;
2050 QETH_CARD_TEXT(card
, 2, "sendctl");
2052 if (card
->read_or_write_problem
) {
2053 qeth_release_buffer(iob
->channel
, iob
);
2056 reply
= qeth_alloc_reply(card
);
2060 reply
->callback
= reply_cb
;
2061 reply
->param
= reply_param
;
2062 if (card
->state
== CARD_STATE_DOWN
)
2063 reply
->seqno
= QETH_IDX_COMMAND_SEQNO
;
2065 reply
->seqno
= card
->seqno
.ipa
++;
2066 init_waitqueue_head(&reply
->wait_q
);
2067 spin_lock_irqsave(&card
->lock
, flags
);
2068 list_add_tail(&reply
->list
, &card
->cmd_waiter_list
);
2069 spin_unlock_irqrestore(&card
->lock
, flags
);
2070 QETH_DBF_HEX(CTRL
, 2, iob
->data
, QETH_DBF_CTRL_LEN
);
2072 while (atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1)) ;
2073 qeth_prepare_control_data(card
, len
, iob
);
2075 if (IS_IPA(iob
->data
))
2076 event_timeout
= QETH_IPA_TIMEOUT
;
2078 event_timeout
= QETH_TIMEOUT
;
2079 timeout
= jiffies
+ event_timeout
;
2081 QETH_CARD_TEXT(card
, 6, "noirqpnd");
2082 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
2083 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
2084 (addr_t
) iob
, 0, 0);
2085 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
2087 QETH_DBF_MESSAGE(2, "%s qeth_send_control_data: "
2088 "ccw_device_start rc = %i\n",
2089 dev_name(&card
->write
.ccwdev
->dev
), rc
);
2090 QETH_CARD_TEXT_(card
, 2, " err%d", rc
);
2091 spin_lock_irqsave(&card
->lock
, flags
);
2092 list_del_init(&reply
->list
);
2093 qeth_put_reply(reply
);
2094 spin_unlock_irqrestore(&card
->lock
, flags
);
2095 qeth_release_buffer(iob
->channel
, iob
);
2096 atomic_set(&card
->write
.irq_pending
, 0);
2097 wake_up(&card
->wait_q
);
2101 /* we have only one long running ipassist, since we can ensure
2102 process context of this command we can sleep */
2103 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
2104 if ((cmd
->hdr
.command
== IPA_CMD_SETIP
) &&
2105 (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)) {
2106 if (!wait_event_timeout(reply
->wait_q
,
2107 atomic_read(&reply
->received
), event_timeout
))
2110 while (!atomic_read(&reply
->received
)) {
2111 if (time_after(jiffies
, timeout
))
2117 if (reply
->rc
== -EIO
)
2120 qeth_put_reply(reply
);
2125 spin_lock_irqsave(&reply
->card
->lock
, flags
);
2126 list_del_init(&reply
->list
);
2127 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
2128 atomic_inc(&reply
->received
);
2130 atomic_set(&card
->write
.irq_pending
, 0);
2131 qeth_release_buffer(iob
->channel
, iob
);
2132 card
->write
.buf_no
= (card
->write
.buf_no
+ 1) % QETH_CMD_BUFFER_NO
;
2134 qeth_put_reply(reply
);
2137 EXPORT_SYMBOL_GPL(qeth_send_control_data
);
2139 static int qeth_cm_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2142 struct qeth_cmd_buffer
*iob
;
2144 QETH_DBF_TEXT(SETUP
, 2, "cmenblcb");
2146 iob
= (struct qeth_cmd_buffer
*) data
;
2147 memcpy(&card
->token
.cm_filter_r
,
2148 QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2149 QETH_MPC_TOKEN_LENGTH
);
2150 QETH_DBF_TEXT_(SETUP
, 2, " rc%d", iob
->rc
);
2154 static int qeth_cm_enable(struct qeth_card
*card
)
2157 struct qeth_cmd_buffer
*iob
;
2159 QETH_DBF_TEXT(SETUP
, 2, "cmenable");
2161 iob
= qeth_wait_for_buffer(&card
->write
);
2162 memcpy(iob
->data
, CM_ENABLE
, CM_ENABLE_SIZE
);
2163 memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob
->data
),
2164 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2165 memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob
->data
),
2166 &card
->token
.cm_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2168 rc
= qeth_send_control_data(card
, CM_ENABLE_SIZE
, iob
,
2169 qeth_cm_enable_cb
, NULL
);
2173 static int qeth_cm_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2177 struct qeth_cmd_buffer
*iob
;
2179 QETH_DBF_TEXT(SETUP
, 2, "cmsetpcb");
2181 iob
= (struct qeth_cmd_buffer
*) data
;
2182 memcpy(&card
->token
.cm_connection_r
,
2183 QETH_CM_SETUP_RESP_DEST_ADDR(iob
->data
),
2184 QETH_MPC_TOKEN_LENGTH
);
2185 QETH_DBF_TEXT_(SETUP
, 2, " rc%d", iob
->rc
);
2189 static int qeth_cm_setup(struct qeth_card
*card
)
2192 struct qeth_cmd_buffer
*iob
;
2194 QETH_DBF_TEXT(SETUP
, 2, "cmsetup");
2196 iob
= qeth_wait_for_buffer(&card
->write
);
2197 memcpy(iob
->data
, CM_SETUP
, CM_SETUP_SIZE
);
2198 memcpy(QETH_CM_SETUP_DEST_ADDR(iob
->data
),
2199 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2200 memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob
->data
),
2201 &card
->token
.cm_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2202 memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob
->data
),
2203 &card
->token
.cm_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2204 rc
= qeth_send_control_data(card
, CM_SETUP_SIZE
, iob
,
2205 qeth_cm_setup_cb
, NULL
);
2210 static inline int qeth_get_initial_mtu_for_card(struct qeth_card
*card
)
2212 switch (card
->info
.type
) {
2213 case QETH_CARD_TYPE_UNKNOWN
:
2215 case QETH_CARD_TYPE_IQD
:
2216 return card
->info
.max_mtu
;
2217 case QETH_CARD_TYPE_OSD
:
2218 switch (card
->info
.link_type
) {
2219 case QETH_LINK_TYPE_HSTR
:
2220 case QETH_LINK_TYPE_LANE_TR
:
2223 return card
->options
.layer2
? 1500 : 1492;
2225 case QETH_CARD_TYPE_OSM
:
2226 case QETH_CARD_TYPE_OSX
:
2227 return card
->options
.layer2
? 1500 : 1492;
2233 static inline int qeth_get_mtu_outof_framesize(int framesize
)
2235 switch (framesize
) {
2249 static inline int qeth_mtu_is_valid(struct qeth_card
*card
, int mtu
)
2251 switch (card
->info
.type
) {
2252 case QETH_CARD_TYPE_OSD
:
2253 case QETH_CARD_TYPE_OSM
:
2254 case QETH_CARD_TYPE_OSX
:
2255 case QETH_CARD_TYPE_IQD
:
2256 return ((mtu
>= 576) &&
2257 (mtu
<= card
->info
.max_mtu
));
2258 case QETH_CARD_TYPE_OSN
:
2259 case QETH_CARD_TYPE_UNKNOWN
:
2265 static int qeth_ulp_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2269 __u16 mtu
, framesize
;
2272 struct qeth_cmd_buffer
*iob
;
2274 QETH_DBF_TEXT(SETUP
, 2, "ulpenacb");
2276 iob
= (struct qeth_cmd_buffer
*) data
;
2277 memcpy(&card
->token
.ulp_filter_r
,
2278 QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2279 QETH_MPC_TOKEN_LENGTH
);
2280 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2281 memcpy(&framesize
, QETH_ULP_ENABLE_RESP_MAX_MTU(iob
->data
), 2);
2282 mtu
= qeth_get_mtu_outof_framesize(framesize
);
2285 QETH_DBF_TEXT_(SETUP
, 2, " rc%d", iob
->rc
);
2288 if (card
->info
.initial_mtu
&& (card
->info
.initial_mtu
!= mtu
)) {
2289 /* frame size has changed */
2291 ((card
->dev
->mtu
== card
->info
.initial_mtu
) ||
2292 (card
->dev
->mtu
> mtu
)))
2293 card
->dev
->mtu
= mtu
;
2294 qeth_free_qdio_buffers(card
);
2296 card
->info
.initial_mtu
= mtu
;
2297 card
->info
.max_mtu
= mtu
;
2298 card
->qdio
.in_buf_size
= mtu
+ 2 * PAGE_SIZE
;
2300 card
->info
.max_mtu
= *(__u16
*)QETH_ULP_ENABLE_RESP_MAX_MTU(
2302 card
->info
.initial_mtu
= min(card
->info
.max_mtu
,
2303 qeth_get_initial_mtu_for_card(card
));
2304 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
2307 memcpy(&len
, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob
->data
), 2);
2308 if (len
>= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE
) {
2310 QETH_ULP_ENABLE_RESP_LINK_TYPE(iob
->data
), 1);
2311 card
->info
.link_type
= link_type
;
2313 card
->info
.link_type
= 0;
2314 QETH_DBF_TEXT_(SETUP
, 2, "link%d", card
->info
.link_type
);
2315 QETH_DBF_TEXT_(SETUP
, 2, " rc%d", iob
->rc
);
2319 static int qeth_ulp_enable(struct qeth_card
*card
)
2323 struct qeth_cmd_buffer
*iob
;
2325 /*FIXME: trace view callbacks*/
2326 QETH_DBF_TEXT(SETUP
, 2, "ulpenabl");
2328 iob
= qeth_wait_for_buffer(&card
->write
);
2329 memcpy(iob
->data
, ULP_ENABLE
, ULP_ENABLE_SIZE
);
2331 *(QETH_ULP_ENABLE_LINKNUM(iob
->data
)) =
2332 (__u8
) card
->info
.portno
;
2333 if (card
->options
.layer2
)
2334 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2335 prot_type
= QETH_PROT_OSN2
;
2337 prot_type
= QETH_PROT_LAYER2
;
2339 prot_type
= QETH_PROT_TCPIP
;
2341 memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob
->data
), &prot_type
, 1);
2342 memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob
->data
),
2343 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2344 memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob
->data
),
2345 &card
->token
.ulp_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2346 rc
= qeth_send_control_data(card
, ULP_ENABLE_SIZE
, iob
,
2347 qeth_ulp_enable_cb
, NULL
);
2352 static int qeth_ulp_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2355 struct qeth_cmd_buffer
*iob
;
2357 QETH_DBF_TEXT(SETUP
, 2, "ulpstpcb");
2359 iob
= (struct qeth_cmd_buffer
*) data
;
2360 memcpy(&card
->token
.ulp_connection_r
,
2361 QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob
->data
),
2362 QETH_MPC_TOKEN_LENGTH
);
2363 if (!strncmp("00S", QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob
->data
),
2365 QETH_DBF_TEXT(SETUP
, 2, "olmlimit");
2366 dev_err(&card
->gdev
->dev
, "A connection could not be "
2367 "established because of an OLM limit\n");
2370 QETH_DBF_TEXT_(SETUP
, 2, " rc%d", iob
->rc
);
2374 static int qeth_ulp_setup(struct qeth_card
*card
)
2378 struct qeth_cmd_buffer
*iob
;
2379 struct ccw_dev_id dev_id
;
2381 QETH_DBF_TEXT(SETUP
, 2, "ulpsetup");
2383 iob
= qeth_wait_for_buffer(&card
->write
);
2384 memcpy(iob
->data
, ULP_SETUP
, ULP_SETUP_SIZE
);
2386 memcpy(QETH_ULP_SETUP_DEST_ADDR(iob
->data
),
2387 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2388 memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob
->data
),
2389 &card
->token
.ulp_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2390 memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob
->data
),
2391 &card
->token
.ulp_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2393 ccw_device_get_id(CARD_DDEV(card
), &dev_id
);
2394 memcpy(QETH_ULP_SETUP_CUA(iob
->data
), &dev_id
.devno
, 2);
2395 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
2396 memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob
->data
), &temp
, 2);
2397 rc
= qeth_send_control_data(card
, ULP_SETUP_SIZE
, iob
,
2398 qeth_ulp_setup_cb
, NULL
);
2402 static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q
*q
, int bidx
)
2405 struct qeth_qdio_out_buffer
*newbuf
;
2408 newbuf
= kmem_cache_zalloc(qeth_qdio_outbuf_cache
, GFP_ATOMIC
);
2413 newbuf
->buffer
= q
->qdio_bufs
[bidx
];
2414 skb_queue_head_init(&newbuf
->skb_list
);
2415 lockdep_set_class(&newbuf
->skb_list
.lock
, &qdio_out_skb_queue_key
);
2418 newbuf
->next_pending
= q
->bufs
[bidx
];
2419 atomic_set(&newbuf
->state
, QETH_QDIO_BUF_EMPTY
);
2420 q
->bufs
[bidx
] = newbuf
;
2422 q
->bufstates
[bidx
].user
= newbuf
;
2423 QETH_CARD_TEXT_(q
->card
, 2, "nbs%d", bidx
);
2424 QETH_CARD_TEXT_(q
->card
, 2, "%lx", (long) newbuf
);
2425 QETH_CARD_TEXT_(q
->card
, 2, "%lx",
2426 (long) newbuf
->next_pending
);
2432 static void qeth_free_qdio_out_buf(struct qeth_qdio_out_q
*q
)
2437 qdio_free_buffers(q
->qdio_bufs
, QDIO_MAX_BUFFERS_PER_Q
);
2441 static struct qeth_qdio_out_q
*qeth_alloc_qdio_out_buf(void)
2443 struct qeth_qdio_out_q
*q
= kzalloc(sizeof(*q
), GFP_KERNEL
);
2448 if (qdio_alloc_buffers(q
->qdio_bufs
, QDIO_MAX_BUFFERS_PER_Q
)) {
2455 static int qeth_alloc_qdio_buffers(struct qeth_card
*card
)
2459 QETH_DBF_TEXT(SETUP
, 2, "allcqdbf");
2461 if (atomic_cmpxchg(&card
->qdio
.state
, QETH_QDIO_UNINITIALIZED
,
2462 QETH_QDIO_ALLOCATED
) != QETH_QDIO_UNINITIALIZED
)
2465 QETH_DBF_TEXT(SETUP
, 2, "inq");
2466 card
->qdio
.in_q
= qeth_alloc_qdio_queue();
2467 if (!card
->qdio
.in_q
)
2470 /* inbound buffer pool */
2471 if (qeth_alloc_buffer_pool(card
))
2476 kzalloc(card
->qdio
.no_out_queues
*
2477 sizeof(struct qeth_qdio_out_q
*), GFP_KERNEL
);
2478 if (!card
->qdio
.out_qs
)
2480 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
) {
2481 card
->qdio
.out_qs
[i
] = qeth_alloc_qdio_out_buf();
2482 if (!card
->qdio
.out_qs
[i
])
2484 QETH_DBF_TEXT_(SETUP
, 2, "outq %i", i
);
2485 QETH_DBF_HEX(SETUP
, 2, &card
->qdio
.out_qs
[i
], sizeof(void *));
2486 card
->qdio
.out_qs
[i
]->queue_no
= i
;
2487 /* give outbound qeth_qdio_buffers their qdio_buffers */
2488 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
) {
2489 WARN_ON(card
->qdio
.out_qs
[i
]->bufs
[j
] != NULL
);
2490 if (qeth_init_qdio_out_buf(card
->qdio
.out_qs
[i
], j
))
2491 goto out_freeoutqbufs
;
2496 if (qeth_alloc_cq(card
))
2504 kmem_cache_free(qeth_qdio_outbuf_cache
,
2505 card
->qdio
.out_qs
[i
]->bufs
[j
]);
2506 card
->qdio
.out_qs
[i
]->bufs
[j
] = NULL
;
2510 qeth_free_qdio_out_buf(card
->qdio
.out_qs
[--i
]);
2511 qeth_clear_outq_buffers(card
->qdio
.out_qs
[i
], 1);
2513 kfree(card
->qdio
.out_qs
);
2514 card
->qdio
.out_qs
= NULL
;
2516 qeth_free_buffer_pool(card
);
2518 qeth_free_qdio_queue(card
->qdio
.in_q
);
2519 card
->qdio
.in_q
= NULL
;
2521 atomic_set(&card
->qdio
.state
, QETH_QDIO_UNINITIALIZED
);
2525 static void qeth_free_qdio_buffers(struct qeth_card
*card
)
2529 if (atomic_xchg(&card
->qdio
.state
, QETH_QDIO_UNINITIALIZED
) ==
2530 QETH_QDIO_UNINITIALIZED
)
2534 cancel_delayed_work_sync(&card
->buffer_reclaim_work
);
2535 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
) {
2536 if (card
->qdio
.in_q
->bufs
[j
].rx_skb
)
2537 dev_kfree_skb_any(card
->qdio
.in_q
->bufs
[j
].rx_skb
);
2539 qeth_free_qdio_queue(card
->qdio
.in_q
);
2540 card
->qdio
.in_q
= NULL
;
2541 /* inbound buffer pool */
2542 qeth_free_buffer_pool(card
);
2543 /* free outbound qdio_qs */
2544 if (card
->qdio
.out_qs
) {
2545 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
) {
2546 qeth_clear_outq_buffers(card
->qdio
.out_qs
[i
], 1);
2547 qeth_free_qdio_out_buf(card
->qdio
.out_qs
[i
]);
2549 kfree(card
->qdio
.out_qs
);
2550 card
->qdio
.out_qs
= NULL
;
2554 static void qeth_create_qib_param_field(struct qeth_card
*card
,
2558 param_field
[0] = _ascebc
['P'];
2559 param_field
[1] = _ascebc
['C'];
2560 param_field
[2] = _ascebc
['I'];
2561 param_field
[3] = _ascebc
['T'];
2562 *((unsigned int *) (¶m_field
[4])) = QETH_PCI_THRESHOLD_A(card
);
2563 *((unsigned int *) (¶m_field
[8])) = QETH_PCI_THRESHOLD_B(card
);
2564 *((unsigned int *) (¶m_field
[12])) = QETH_PCI_TIMER_VALUE(card
);
2567 static void qeth_create_qib_param_field_blkt(struct qeth_card
*card
,
2570 param_field
[16] = _ascebc
['B'];
2571 param_field
[17] = _ascebc
['L'];
2572 param_field
[18] = _ascebc
['K'];
2573 param_field
[19] = _ascebc
['T'];
2574 *((unsigned int *) (¶m_field
[20])) = card
->info
.blkt
.time_total
;
2575 *((unsigned int *) (¶m_field
[24])) = card
->info
.blkt
.inter_packet
;
2576 *((unsigned int *) (¶m_field
[28])) =
2577 card
->info
.blkt
.inter_packet_jumbo
;
2580 static int qeth_qdio_activate(struct qeth_card
*card
)
2582 QETH_DBF_TEXT(SETUP
, 3, "qdioact");
2583 return qdio_activate(CARD_DDEV(card
));
2586 static int qeth_dm_act(struct qeth_card
*card
)
2589 struct qeth_cmd_buffer
*iob
;
2591 QETH_DBF_TEXT(SETUP
, 2, "dmact");
2593 iob
= qeth_wait_for_buffer(&card
->write
);
2594 memcpy(iob
->data
, DM_ACT
, DM_ACT_SIZE
);
2596 memcpy(QETH_DM_ACT_DEST_ADDR(iob
->data
),
2597 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2598 memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob
->data
),
2599 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2600 rc
= qeth_send_control_data(card
, DM_ACT_SIZE
, iob
, NULL
, NULL
);
2604 static int qeth_mpc_initialize(struct qeth_card
*card
)
2608 QETH_DBF_TEXT(SETUP
, 2, "mpcinit");
2610 rc
= qeth_issue_next_read(card
);
2612 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
2615 rc
= qeth_cm_enable(card
);
2617 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
2620 rc
= qeth_cm_setup(card
);
2622 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
2625 rc
= qeth_ulp_enable(card
);
2627 QETH_DBF_TEXT_(SETUP
, 2, "4err%d", rc
);
2630 rc
= qeth_ulp_setup(card
);
2632 QETH_DBF_TEXT_(SETUP
, 2, "5err%d", rc
);
2635 rc
= qeth_alloc_qdio_buffers(card
);
2637 QETH_DBF_TEXT_(SETUP
, 2, "5err%d", rc
);
2640 rc
= qeth_qdio_establish(card
);
2642 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
2643 qeth_free_qdio_buffers(card
);
2646 rc
= qeth_qdio_activate(card
);
2648 QETH_DBF_TEXT_(SETUP
, 2, "7err%d", rc
);
2651 rc
= qeth_dm_act(card
);
2653 QETH_DBF_TEXT_(SETUP
, 2, "8err%d", rc
);
2659 qeth_qdio_clear_card(card
, card
->info
.type
!= QETH_CARD_TYPE_IQD
);
2660 qdio_free(CARD_DDEV(card
));
2664 void qeth_print_status_message(struct qeth_card
*card
)
2666 switch (card
->info
.type
) {
2667 case QETH_CARD_TYPE_OSD
:
2668 case QETH_CARD_TYPE_OSM
:
2669 case QETH_CARD_TYPE_OSX
:
2670 /* VM will use a non-zero first character
2671 * to indicate a HiperSockets like reporting
2672 * of the level OSA sets the first character to zero
2674 if (!card
->info
.mcl_level
[0]) {
2675 sprintf(card
->info
.mcl_level
, "%02x%02x",
2676 card
->info
.mcl_level
[2],
2677 card
->info
.mcl_level
[3]);
2681 case QETH_CARD_TYPE_IQD
:
2682 if ((card
->info
.guestlan
) ||
2683 (card
->info
.mcl_level
[0] & 0x80)) {
2684 card
->info
.mcl_level
[0] = (char) _ebcasc
[(__u8
)
2685 card
->info
.mcl_level
[0]];
2686 card
->info
.mcl_level
[1] = (char) _ebcasc
[(__u8
)
2687 card
->info
.mcl_level
[1]];
2688 card
->info
.mcl_level
[2] = (char) _ebcasc
[(__u8
)
2689 card
->info
.mcl_level
[2]];
2690 card
->info
.mcl_level
[3] = (char) _ebcasc
[(__u8
)
2691 card
->info
.mcl_level
[3]];
2692 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
2696 memset(&card
->info
.mcl_level
[0], 0, QETH_MCL_LENGTH
+ 1);
2698 dev_info(&card
->gdev
->dev
,
2699 "Device is a%s card%s%s%s\nwith link type %s.\n",
2700 qeth_get_cardname(card
),
2701 (card
->info
.mcl_level
[0]) ? " (level: " : "",
2702 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
2703 (card
->info
.mcl_level
[0]) ? ")" : "",
2704 qeth_get_cardname_short(card
));
2706 EXPORT_SYMBOL_GPL(qeth_print_status_message
);
2708 static void qeth_initialize_working_pool_list(struct qeth_card
*card
)
2710 struct qeth_buffer_pool_entry
*entry
;
2712 QETH_CARD_TEXT(card
, 5, "inwrklst");
2714 list_for_each_entry(entry
,
2715 &card
->qdio
.init_pool
.entry_list
, init_list
) {
2716 qeth_put_buffer_pool_entry(card
, entry
);
2720 static inline struct qeth_buffer_pool_entry
*qeth_find_free_buffer_pool_entry(
2721 struct qeth_card
*card
)
2723 struct list_head
*plh
;
2724 struct qeth_buffer_pool_entry
*entry
;
2728 if (list_empty(&card
->qdio
.in_buf_pool
.entry_list
))
2731 list_for_each(plh
, &card
->qdio
.in_buf_pool
.entry_list
) {
2732 entry
= list_entry(plh
, struct qeth_buffer_pool_entry
, list
);
2734 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
) {
2735 if (page_count(virt_to_page(entry
->elements
[i
])) > 1) {
2741 list_del_init(&entry
->list
);
2746 /* no free buffer in pool so take first one and swap pages */
2747 entry
= list_entry(card
->qdio
.in_buf_pool
.entry_list
.next
,
2748 struct qeth_buffer_pool_entry
, list
);
2749 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
) {
2750 if (page_count(virt_to_page(entry
->elements
[i
])) > 1) {
2751 page
= alloc_page(GFP_ATOMIC
);
2755 free_page((unsigned long)entry
->elements
[i
]);
2756 entry
->elements
[i
] = page_address(page
);
2757 if (card
->options
.performance_stats
)
2758 card
->perf_stats
.sg_alloc_page_rx
++;
2762 list_del_init(&entry
->list
);
2766 static int qeth_init_input_buffer(struct qeth_card
*card
,
2767 struct qeth_qdio_buffer
*buf
)
2769 struct qeth_buffer_pool_entry
*pool_entry
;
2772 if ((card
->options
.cq
== QETH_CQ_ENABLED
) && (!buf
->rx_skb
)) {
2773 buf
->rx_skb
= dev_alloc_skb(QETH_RX_PULL_LEN
+ ETH_HLEN
);
2778 pool_entry
= qeth_find_free_buffer_pool_entry(card
);
2783 * since the buffer is accessed only from the input_tasklet
2784 * there shouldn't be a need to synchronize; also, since we use
2785 * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off
2789 buf
->pool_entry
= pool_entry
;
2790 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
) {
2791 buf
->buffer
->element
[i
].length
= PAGE_SIZE
;
2792 buf
->buffer
->element
[i
].addr
= pool_entry
->elements
[i
];
2793 if (i
== QETH_MAX_BUFFER_ELEMENTS(card
) - 1)
2794 buf
->buffer
->element
[i
].eflags
= SBAL_EFLAGS_LAST_ENTRY
;
2796 buf
->buffer
->element
[i
].eflags
= 0;
2797 buf
->buffer
->element
[i
].sflags
= 0;
2802 int qeth_init_qdio_queues(struct qeth_card
*card
)
2807 QETH_DBF_TEXT(SETUP
, 2, "initqdqs");
2810 qdio_reset_buffers(card
->qdio
.in_q
->qdio_bufs
,
2811 QDIO_MAX_BUFFERS_PER_Q
);
2812 qeth_initialize_working_pool_list(card
);
2813 /*give only as many buffers to hardware as we have buffer pool entries*/
2814 for (i
= 0; i
< card
->qdio
.in_buf_pool
.buf_count
- 1; ++i
)
2815 qeth_init_input_buffer(card
, &card
->qdio
.in_q
->bufs
[i
]);
2816 card
->qdio
.in_q
->next_buf_to_init
=
2817 card
->qdio
.in_buf_pool
.buf_count
- 1;
2818 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0, 0,
2819 card
->qdio
.in_buf_pool
.buf_count
- 1);
2821 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
2826 rc
= qeth_cq_init(card
);
2831 /* outbound queue */
2832 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
) {
2833 qdio_reset_buffers(card
->qdio
.out_qs
[i
]->qdio_bufs
,
2834 QDIO_MAX_BUFFERS_PER_Q
);
2835 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
) {
2836 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
2837 card
->qdio
.out_qs
[i
]->bufs
[j
],
2838 QETH_QDIO_BUF_EMPTY
);
2840 card
->qdio
.out_qs
[i
]->card
= card
;
2841 card
->qdio
.out_qs
[i
]->next_buf_to_fill
= 0;
2842 card
->qdio
.out_qs
[i
]->do_pack
= 0;
2843 atomic_set(&card
->qdio
.out_qs
[i
]->used_buffers
, 0);
2844 atomic_set(&card
->qdio
.out_qs
[i
]->set_pci_flags_count
, 0);
2845 atomic_set(&card
->qdio
.out_qs
[i
]->state
,
2846 QETH_OUT_Q_UNLOCKED
);
2850 EXPORT_SYMBOL_GPL(qeth_init_qdio_queues
);
2852 static inline __u8
qeth_get_ipa_adp_type(enum qeth_link_types link_type
)
2854 switch (link_type
) {
2855 case QETH_LINK_TYPE_HSTR
:
2862 static void qeth_fill_ipacmd_header(struct qeth_card
*card
,
2863 struct qeth_ipa_cmd
*cmd
, __u8 command
,
2864 enum qeth_prot_versions prot
)
2866 memset(cmd
, 0, sizeof(struct qeth_ipa_cmd
));
2867 cmd
->hdr
.command
= command
;
2868 cmd
->hdr
.initiator
= IPA_CMD_INITIATOR_HOST
;
2869 cmd
->hdr
.seqno
= card
->seqno
.ipa
;
2870 cmd
->hdr
.adapter_type
= qeth_get_ipa_adp_type(card
->info
.link_type
);
2871 cmd
->hdr
.rel_adapter_no
= (__u8
) card
->info
.portno
;
2872 if (card
->options
.layer2
)
2873 cmd
->hdr
.prim_version_no
= 2;
2875 cmd
->hdr
.prim_version_no
= 1;
2876 cmd
->hdr
.param_count
= 1;
2877 cmd
->hdr
.prot_version
= prot
;
2878 cmd
->hdr
.ipa_supported
= 0;
2879 cmd
->hdr
.ipa_enabled
= 0;
2882 struct qeth_cmd_buffer
*qeth_get_ipacmd_buffer(struct qeth_card
*card
,
2883 enum qeth_ipa_cmds ipacmd
, enum qeth_prot_versions prot
)
2885 struct qeth_cmd_buffer
*iob
;
2886 struct qeth_ipa_cmd
*cmd
;
2888 iob
= qeth_get_buffer(&card
->write
);
2890 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
2891 qeth_fill_ipacmd_header(card
, cmd
, ipacmd
, prot
);
2893 dev_warn(&card
->gdev
->dev
,
2894 "The qeth driver ran out of channel command buffers\n");
2895 QETH_DBF_MESSAGE(1, "%s The qeth driver ran out of channel command buffers",
2896 dev_name(&card
->gdev
->dev
));
2901 EXPORT_SYMBOL_GPL(qeth_get_ipacmd_buffer
);
2903 void qeth_prepare_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
2906 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
2907 memcpy(QETH_IPA_CMD_PROT_TYPE(iob
->data
), &prot_type
, 1);
2908 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
2909 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2911 EXPORT_SYMBOL_GPL(qeth_prepare_ipa_cmd
);
2914 * qeth_send_ipa_cmd() - send an IPA command
2916 * See qeth_send_control_data() for explanation of the arguments.
2919 int qeth_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
2920 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
2927 QETH_CARD_TEXT(card
, 4, "sendipa");
2929 if (card
->options
.layer2
)
2930 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2931 prot_type
= QETH_PROT_OSN2
;
2933 prot_type
= QETH_PROT_LAYER2
;
2935 prot_type
= QETH_PROT_TCPIP
;
2936 qeth_prepare_ipa_cmd(card
, iob
, prot_type
);
2937 rc
= qeth_send_control_data(card
, IPA_CMD_LENGTH
,
2938 iob
, reply_cb
, reply_param
);
2940 qeth_clear_ipacmd_list(card
);
2941 qeth_schedule_recovery(card
);
2945 EXPORT_SYMBOL_GPL(qeth_send_ipa_cmd
);
2947 int qeth_send_startlan(struct qeth_card
*card
)
2950 struct qeth_cmd_buffer
*iob
;
2952 QETH_DBF_TEXT(SETUP
, 2, "strtlan");
2954 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_STARTLAN
, 0);
2957 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
2960 EXPORT_SYMBOL_GPL(qeth_send_startlan
);
2962 static int qeth_default_setadapterparms_cb(struct qeth_card
*card
,
2963 struct qeth_reply
*reply
, unsigned long data
)
2965 struct qeth_ipa_cmd
*cmd
;
2967 QETH_CARD_TEXT(card
, 4, "defadpcb");
2969 cmd
= (struct qeth_ipa_cmd
*) data
;
2970 if (cmd
->hdr
.return_code
== 0)
2971 cmd
->hdr
.return_code
=
2972 cmd
->data
.setadapterparms
.hdr
.return_code
;
2976 static int qeth_query_setadapterparms_cb(struct qeth_card
*card
,
2977 struct qeth_reply
*reply
, unsigned long data
)
2979 struct qeth_ipa_cmd
*cmd
;
2981 QETH_CARD_TEXT(card
, 3, "quyadpcb");
2983 cmd
= (struct qeth_ipa_cmd
*) data
;
2984 if (cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
& 0x7f) {
2985 card
->info
.link_type
=
2986 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
;
2987 QETH_DBF_TEXT_(SETUP
, 2, "lnk %d", card
->info
.link_type
);
2989 card
->options
.adp
.supported_funcs
=
2990 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.supported_cmds
;
2991 return qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
2994 static struct qeth_cmd_buffer
*qeth_get_adapter_cmd(struct qeth_card
*card
,
2995 __u32 command
, __u32 cmdlen
)
2997 struct qeth_cmd_buffer
*iob
;
2998 struct qeth_ipa_cmd
*cmd
;
3000 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETADAPTERPARMS
,
3003 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
3004 cmd
->data
.setadapterparms
.hdr
.cmdlength
= cmdlen
;
3005 cmd
->data
.setadapterparms
.hdr
.command_code
= command
;
3006 cmd
->data
.setadapterparms
.hdr
.used_total
= 1;
3007 cmd
->data
.setadapterparms
.hdr
.seq_no
= 1;
3013 int qeth_query_setadapterparms(struct qeth_card
*card
)
3016 struct qeth_cmd_buffer
*iob
;
3018 QETH_CARD_TEXT(card
, 3, "queryadp");
3019 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_COMMANDS_SUPPORTED
,
3020 sizeof(struct qeth_ipacmd_setadpparms
));
3023 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_setadapterparms_cb
, NULL
);
3026 EXPORT_SYMBOL_GPL(qeth_query_setadapterparms
);
3028 static int qeth_query_ipassists_cb(struct qeth_card
*card
,
3029 struct qeth_reply
*reply
, unsigned long data
)
3031 struct qeth_ipa_cmd
*cmd
;
3033 QETH_DBF_TEXT(SETUP
, 2, "qipasscb");
3035 cmd
= (struct qeth_ipa_cmd
*) data
;
3037 switch (cmd
->hdr
.return_code
) {
3038 case IPA_RC_NOTSUPP
:
3039 case IPA_RC_L2_UNSUPPORTED_CMD
:
3040 QETH_DBF_TEXT(SETUP
, 2, "ipaunsup");
3041 card
->options
.ipa4
.supported_funcs
|= IPA_SETADAPTERPARMS
;
3042 card
->options
.ipa6
.supported_funcs
|= IPA_SETADAPTERPARMS
;
3045 if (cmd
->hdr
.return_code
) {
3046 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Unhandled "
3048 dev_name(&card
->gdev
->dev
),
3049 cmd
->hdr
.return_code
);
3054 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
3055 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
3056 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
3057 } else if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
) {
3058 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
3059 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
3061 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Flawed LIC detected"
3062 "\n", dev_name(&card
->gdev
->dev
));
3066 int qeth_query_ipassists(struct qeth_card
*card
, enum qeth_prot_versions prot
)
3069 struct qeth_cmd_buffer
*iob
;
3071 QETH_DBF_TEXT_(SETUP
, 2, "qipassi%i", prot
);
3072 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_QIPASSIST
, prot
);
3075 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_ipassists_cb
, NULL
);
3078 EXPORT_SYMBOL_GPL(qeth_query_ipassists
);
3080 static int qeth_query_switch_attributes_cb(struct qeth_card
*card
,
3081 struct qeth_reply
*reply
, unsigned long data
)
3083 struct qeth_ipa_cmd
*cmd
;
3084 struct qeth_switch_info
*sw_info
;
3085 struct qeth_query_switch_attributes
*attrs
;
3087 QETH_CARD_TEXT(card
, 2, "qswiatcb");
3088 cmd
= (struct qeth_ipa_cmd
*) data
;
3089 sw_info
= (struct qeth_switch_info
*)reply
->param
;
3090 if (cmd
->data
.setadapterparms
.hdr
.return_code
== 0) {
3091 attrs
= &cmd
->data
.setadapterparms
.data
.query_switch_attributes
;
3092 sw_info
->capabilities
= attrs
->capabilities
;
3093 sw_info
->settings
= attrs
->settings
;
3094 QETH_CARD_TEXT_(card
, 2, "%04x%04x", sw_info
->capabilities
,
3097 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
3102 int qeth_query_switch_attributes(struct qeth_card
*card
,
3103 struct qeth_switch_info
*sw_info
)
3105 struct qeth_cmd_buffer
*iob
;
3107 QETH_CARD_TEXT(card
, 2, "qswiattr");
3108 if (!qeth_adp_supported(card
, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES
))
3110 if (!netif_carrier_ok(card
->dev
))
3112 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES
,
3113 sizeof(struct qeth_ipacmd_setadpparms_hdr
));
3116 return qeth_send_ipa_cmd(card
, iob
,
3117 qeth_query_switch_attributes_cb
, sw_info
);
3119 EXPORT_SYMBOL_GPL(qeth_query_switch_attributes
);
3121 static int qeth_query_setdiagass_cb(struct qeth_card
*card
,
3122 struct qeth_reply
*reply
, unsigned long data
)
3124 struct qeth_ipa_cmd
*cmd
;
3127 cmd
= (struct qeth_ipa_cmd
*)data
;
3128 rc
= cmd
->hdr
.return_code
;
3130 QETH_CARD_TEXT_(card
, 2, "diagq:%x", rc
);
3132 card
->info
.diagass_support
= cmd
->data
.diagass
.ext
;
3136 static int qeth_query_setdiagass(struct qeth_card
*card
)
3138 struct qeth_cmd_buffer
*iob
;
3139 struct qeth_ipa_cmd
*cmd
;
3141 QETH_DBF_TEXT(SETUP
, 2, "qdiagass");
3142 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SET_DIAG_ASS
, 0);
3145 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
3146 cmd
->data
.diagass
.subcmd_len
= 16;
3147 cmd
->data
.diagass
.subcmd
= QETH_DIAGS_CMD_QUERY
;
3148 return qeth_send_ipa_cmd(card
, iob
, qeth_query_setdiagass_cb
, NULL
);
3151 static void qeth_get_trap_id(struct qeth_card
*card
, struct qeth_trap_id
*tid
)
3153 unsigned long info
= get_zeroed_page(GFP_KERNEL
);
3154 struct sysinfo_2_2_2
*info222
= (struct sysinfo_2_2_2
*)info
;
3155 struct sysinfo_3_2_2
*info322
= (struct sysinfo_3_2_2
*)info
;
3156 struct ccw_dev_id ccwid
;
3159 tid
->chpid
= card
->info
.chpid
;
3160 ccw_device_get_id(CARD_RDEV(card
), &ccwid
);
3161 tid
->ssid
= ccwid
.ssid
;
3162 tid
->devno
= ccwid
.devno
;
3165 level
= stsi(NULL
, 0, 0, 0);
3166 if ((level
>= 2) && (stsi(info222
, 2, 2, 2) == 0))
3167 tid
->lparnr
= info222
->lpar_number
;
3168 if ((level
>= 3) && (stsi(info322
, 3, 2, 2) == 0)) {
3169 EBCASC(info322
->vm
[0].name
, sizeof(info322
->vm
[0].name
));
3170 memcpy(tid
->vmname
, info322
->vm
[0].name
, sizeof(tid
->vmname
));
3176 static int qeth_hw_trap_cb(struct qeth_card
*card
,
3177 struct qeth_reply
*reply
, unsigned long data
)
3179 struct qeth_ipa_cmd
*cmd
;
3182 cmd
= (struct qeth_ipa_cmd
*)data
;
3183 rc
= cmd
->hdr
.return_code
;
3185 QETH_CARD_TEXT_(card
, 2, "trapc:%x", rc
);
3189 int qeth_hw_trap(struct qeth_card
*card
, enum qeth_diags_trap_action action
)
3191 struct qeth_cmd_buffer
*iob
;
3192 struct qeth_ipa_cmd
*cmd
;
3194 QETH_DBF_TEXT(SETUP
, 2, "diagtrap");
3195 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SET_DIAG_ASS
, 0);
3198 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
3199 cmd
->data
.diagass
.subcmd_len
= 80;
3200 cmd
->data
.diagass
.subcmd
= QETH_DIAGS_CMD_TRAP
;
3201 cmd
->data
.diagass
.type
= 1;
3202 cmd
->data
.diagass
.action
= action
;
3204 case QETH_DIAGS_TRAP_ARM
:
3205 cmd
->data
.diagass
.options
= 0x0003;
3206 cmd
->data
.diagass
.ext
= 0x00010000 +
3207 sizeof(struct qeth_trap_id
);
3208 qeth_get_trap_id(card
,
3209 (struct qeth_trap_id
*)cmd
->data
.diagass
.cdata
);
3211 case QETH_DIAGS_TRAP_DISARM
:
3212 cmd
->data
.diagass
.options
= 0x0001;
3214 case QETH_DIAGS_TRAP_CAPTURE
:
3217 return qeth_send_ipa_cmd(card
, iob
, qeth_hw_trap_cb
, NULL
);
3219 EXPORT_SYMBOL_GPL(qeth_hw_trap
);
3221 int qeth_check_qdio_errors(struct qeth_card
*card
, struct qdio_buffer
*buf
,
3222 unsigned int qdio_error
, const char *dbftext
)
3225 QETH_CARD_TEXT(card
, 2, dbftext
);
3226 QETH_CARD_TEXT_(card
, 2, " F15=%02X",
3227 buf
->element
[15].sflags
);
3228 QETH_CARD_TEXT_(card
, 2, " F14=%02X",
3229 buf
->element
[14].sflags
);
3230 QETH_CARD_TEXT_(card
, 2, " qerr=%X", qdio_error
);
3231 if ((buf
->element
[15].sflags
) == 0x12) {
3232 card
->stats
.rx_dropped
++;
3239 EXPORT_SYMBOL_GPL(qeth_check_qdio_errors
);
3241 static void qeth_buffer_reclaim_work(struct work_struct
*work
)
3243 struct qeth_card
*card
= container_of(work
, struct qeth_card
,
3244 buffer_reclaim_work
.work
);
3246 QETH_CARD_TEXT_(card
, 2, "brw:%x", card
->reclaim_index
);
3247 qeth_queue_input_buffer(card
, card
->reclaim_index
);
3250 void qeth_queue_input_buffer(struct qeth_card
*card
, int index
)
3252 struct qeth_qdio_q
*queue
= card
->qdio
.in_q
;
3253 struct list_head
*lh
;
3259 count
= (index
< queue
->next_buf_to_init
)?
3260 card
->qdio
.in_buf_pool
.buf_count
-
3261 (queue
->next_buf_to_init
- index
) :
3262 card
->qdio
.in_buf_pool
.buf_count
-
3263 (queue
->next_buf_to_init
+ QDIO_MAX_BUFFERS_PER_Q
- index
);
3264 /* only requeue at a certain threshold to avoid SIGAs */
3265 if (count
>= QETH_IN_BUF_REQUEUE_THRESHOLD(card
)) {
3266 for (i
= queue
->next_buf_to_init
;
3267 i
< queue
->next_buf_to_init
+ count
; ++i
) {
3268 if (qeth_init_input_buffer(card
,
3269 &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
])) {
3276 if (newcount
< count
) {
3277 /* we are in memory shortage so we switch back to
3278 traditional skb allocation and drop packages */
3279 atomic_set(&card
->force_alloc_skb
, 3);
3282 atomic_add_unless(&card
->force_alloc_skb
, -1, 0);
3287 list_for_each(lh
, &card
->qdio
.in_buf_pool
.entry_list
)
3289 if (i
== card
->qdio
.in_buf_pool
.buf_count
) {
3290 QETH_CARD_TEXT(card
, 2, "qsarbw");
3291 card
->reclaim_index
= index
;
3292 schedule_delayed_work(
3293 &card
->buffer_reclaim_work
,
3294 QETH_RECLAIM_WORK_TIME
);
3300 * according to old code it should be avoided to requeue all
3301 * 128 buffers in order to benefit from PCI avoidance.
3302 * this function keeps at least one buffer (the buffer at
3303 * 'index') un-requeued -> this buffer is the first buffer that
3304 * will be requeued the next time
3306 if (card
->options
.performance_stats
) {
3307 card
->perf_stats
.inbound_do_qdio_cnt
++;
3308 card
->perf_stats
.inbound_do_qdio_start_time
=
3311 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0,
3312 queue
->next_buf_to_init
, count
);
3313 if (card
->options
.performance_stats
)
3314 card
->perf_stats
.inbound_do_qdio_time
+=
3316 card
->perf_stats
.inbound_do_qdio_start_time
;
3318 QETH_CARD_TEXT(card
, 2, "qinberr");
3320 queue
->next_buf_to_init
= (queue
->next_buf_to_init
+ count
) %
3321 QDIO_MAX_BUFFERS_PER_Q
;
3324 EXPORT_SYMBOL_GPL(qeth_queue_input_buffer
);
3326 static int qeth_handle_send_error(struct qeth_card
*card
,
3327 struct qeth_qdio_out_buffer
*buffer
, unsigned int qdio_err
)
3329 int sbalf15
= buffer
->buffer
->element
[15].sflags
;
3331 QETH_CARD_TEXT(card
, 6, "hdsnderr");
3332 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
3339 qeth_check_qdio_errors(card
, buffer
->buffer
, qdio_err
, "qouterr");
3342 return QETH_SEND_ERROR_NONE
;
3344 if ((sbalf15
>= 15) && (sbalf15
<= 31))
3345 return QETH_SEND_ERROR_RETRY
;
3347 QETH_CARD_TEXT(card
, 1, "lnkfail");
3348 QETH_CARD_TEXT_(card
, 1, "%04x %02x",
3349 (u16
)qdio_err
, (u8
)sbalf15
);
3350 return QETH_SEND_ERROR_LINK_FAILURE
;
3354 * Switched to packing state if the number of used buffers on a queue
3355 * reaches a certain limit.
3357 static void qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q
*queue
)
3359 if (!queue
->do_pack
) {
3360 if (atomic_read(&queue
->used_buffers
)
3361 >= QETH_HIGH_WATERMARK_PACK
){
3362 /* switch non-PACKING -> PACKING */
3363 QETH_CARD_TEXT(queue
->card
, 6, "np->pack");
3364 if (queue
->card
->options
.performance_stats
)
3365 queue
->card
->perf_stats
.sc_dp_p
++;
3372 * Switches from packing to non-packing mode. If there is a packing
3373 * buffer on the queue this buffer will be prepared to be flushed.
3374 * In that case 1 is returned to inform the caller. If no buffer
3375 * has to be flushed, zero is returned.
3377 static int qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q
*queue
)
3379 struct qeth_qdio_out_buffer
*buffer
;
3380 int flush_count
= 0;
3382 if (queue
->do_pack
) {
3383 if (atomic_read(&queue
->used_buffers
)
3384 <= QETH_LOW_WATERMARK_PACK
) {
3385 /* switch PACKING -> non-PACKING */
3386 QETH_CARD_TEXT(queue
->card
, 6, "pack->np");
3387 if (queue
->card
->options
.performance_stats
)
3388 queue
->card
->perf_stats
.sc_p_dp
++;
3390 /* flush packing buffers */
3391 buffer
= queue
->bufs
[queue
->next_buf_to_fill
];
3392 if ((atomic_read(&buffer
->state
) ==
3393 QETH_QDIO_BUF_EMPTY
) &&
3394 (buffer
->next_element_to_fill
> 0)) {
3395 atomic_set(&buffer
->state
,
3396 QETH_QDIO_BUF_PRIMED
);
3398 queue
->next_buf_to_fill
=
3399 (queue
->next_buf_to_fill
+ 1) %
3400 QDIO_MAX_BUFFERS_PER_Q
;
3409 * Called to flush a packing buffer if no more pci flags are on the queue.
3410 * Checks if there is a packing buffer and prepares it to be flushed.
3411 * In that case returns 1, otherwise zero.
3413 static int qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q
*queue
)
3415 struct qeth_qdio_out_buffer
*buffer
;
3417 buffer
= queue
->bufs
[queue
->next_buf_to_fill
];
3418 if ((atomic_read(&buffer
->state
) == QETH_QDIO_BUF_EMPTY
) &&
3419 (buffer
->next_element_to_fill
> 0)) {
3420 /* it's a packing buffer */
3421 atomic_set(&buffer
->state
, QETH_QDIO_BUF_PRIMED
);
3422 queue
->next_buf_to_fill
=
3423 (queue
->next_buf_to_fill
+ 1) % QDIO_MAX_BUFFERS_PER_Q
;
3429 static void qeth_flush_buffers(struct qeth_qdio_out_q
*queue
, int index
,
3432 struct qeth_qdio_out_buffer
*buf
;
3435 unsigned int qdio_flags
;
3437 for (i
= index
; i
< index
+ count
; ++i
) {
3438 int bidx
= i
% QDIO_MAX_BUFFERS_PER_Q
;
3439 buf
= queue
->bufs
[bidx
];
3440 buf
->buffer
->element
[buf
->next_element_to_fill
- 1].eflags
|=
3441 SBAL_EFLAGS_LAST_ENTRY
;
3443 if (queue
->bufstates
)
3444 queue
->bufstates
[bidx
].user
= buf
;
3446 if (queue
->card
->info
.type
== QETH_CARD_TYPE_IQD
)
3449 if (!queue
->do_pack
) {
3450 if ((atomic_read(&queue
->used_buffers
) >=
3451 (QETH_HIGH_WATERMARK_PACK
-
3452 QETH_WATERMARK_PACK_FUZZ
)) &&
3453 !atomic_read(&queue
->set_pci_flags_count
)) {
3454 /* it's likely that we'll go to packing
3456 atomic_inc(&queue
->set_pci_flags_count
);
3457 buf
->buffer
->element
[0].sflags
|= SBAL_SFLAGS0_PCI_REQ
;
3460 if (!atomic_read(&queue
->set_pci_flags_count
)) {
3462 * there's no outstanding PCI any more, so we
3463 * have to request a PCI to be sure the the PCI
3464 * will wake at some time in the future then we
3465 * can flush packed buffers that might still be
3466 * hanging around, which can happen if no
3467 * further send was requested by the stack
3469 atomic_inc(&queue
->set_pci_flags_count
);
3470 buf
->buffer
->element
[0].sflags
|= SBAL_SFLAGS0_PCI_REQ
;
3475 netif_trans_update(queue
->card
->dev
);
3476 if (queue
->card
->options
.performance_stats
) {
3477 queue
->card
->perf_stats
.outbound_do_qdio_cnt
++;
3478 queue
->card
->perf_stats
.outbound_do_qdio_start_time
=
3481 qdio_flags
= QDIO_FLAG_SYNC_OUTPUT
;
3482 if (atomic_read(&queue
->set_pci_flags_count
))
3483 qdio_flags
|= QDIO_FLAG_PCI_OUT
;
3484 rc
= do_QDIO(CARD_DDEV(queue
->card
), qdio_flags
,
3485 queue
->queue_no
, index
, count
);
3486 if (queue
->card
->options
.performance_stats
)
3487 queue
->card
->perf_stats
.outbound_do_qdio_time
+=
3489 queue
->card
->perf_stats
.outbound_do_qdio_start_time
;
3490 atomic_add(count
, &queue
->used_buffers
);
3492 queue
->card
->stats
.tx_errors
+= count
;
3493 /* ignore temporary SIGA errors without busy condition */
3496 QETH_CARD_TEXT(queue
->card
, 2, "flushbuf");
3497 QETH_CARD_TEXT_(queue
->card
, 2, " q%d", queue
->queue_no
);
3498 QETH_CARD_TEXT_(queue
->card
, 2, " idx%d", index
);
3499 QETH_CARD_TEXT_(queue
->card
, 2, " c%d", count
);
3500 QETH_CARD_TEXT_(queue
->card
, 2, " err%d", rc
);
3502 /* this must not happen under normal circumstances. if it
3503 * happens something is really wrong -> recover */
3504 qeth_schedule_recovery(queue
->card
);
3507 if (queue
->card
->options
.performance_stats
)
3508 queue
->card
->perf_stats
.bufs_sent
+= count
;
3511 static void qeth_check_outbound_queue(struct qeth_qdio_out_q
*queue
)
3515 int q_was_packing
= 0;
3518 * check if weed have to switch to non-packing mode or if
3519 * we have to get a pci flag out on the queue
3521 if ((atomic_read(&queue
->used_buffers
) <= QETH_LOW_WATERMARK_PACK
) ||
3522 !atomic_read(&queue
->set_pci_flags_count
)) {
3523 if (atomic_xchg(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
) ==
3524 QETH_OUT_Q_UNLOCKED
) {
3526 * If we get in here, there was no action in
3527 * do_send_packet. So, we check if there is a
3528 * packing buffer to be flushed here.
3530 netif_stop_queue(queue
->card
->dev
);
3531 index
= queue
->next_buf_to_fill
;
3532 q_was_packing
= queue
->do_pack
;
3533 /* queue->do_pack may change */
3535 flush_cnt
+= qeth_switch_to_nonpacking_if_needed(queue
);
3537 !atomic_read(&queue
->set_pci_flags_count
))
3539 qeth_flush_buffers_on_no_pci(queue
);
3540 if (queue
->card
->options
.performance_stats
&&
3542 queue
->card
->perf_stats
.bufs_sent_pack
+=
3545 qeth_flush_buffers(queue
, index
, flush_cnt
);
3546 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
3551 void qeth_qdio_start_poll(struct ccw_device
*ccwdev
, int queue
,
3552 unsigned long card_ptr
)
3554 struct qeth_card
*card
= (struct qeth_card
*)card_ptr
;
3556 if (card
->dev
&& (card
->dev
->flags
& IFF_UP
))
3557 napi_schedule(&card
->napi
);
3559 EXPORT_SYMBOL_GPL(qeth_qdio_start_poll
);
3561 int qeth_configure_cq(struct qeth_card
*card
, enum qeth_cq cq
)
3565 if (card
->options
.cq
== QETH_CQ_NOTAVAILABLE
) {
3569 if (card
->options
.cq
== cq
) {
3574 if (card
->state
!= CARD_STATE_DOWN
&&
3575 card
->state
!= CARD_STATE_RECOVER
) {
3580 qeth_free_qdio_buffers(card
);
3581 card
->options
.cq
= cq
;
3588 EXPORT_SYMBOL_GPL(qeth_configure_cq
);
3591 static void qeth_qdio_cq_handler(struct qeth_card
*card
,
3592 unsigned int qdio_err
,
3593 unsigned int queue
, int first_element
, int count
) {
3594 struct qeth_qdio_q
*cq
= card
->qdio
.c_q
;
3598 if (!qeth_is_cq(card
, queue
))
3601 QETH_CARD_TEXT_(card
, 5, "qcqhe%d", first_element
);
3602 QETH_CARD_TEXT_(card
, 5, "qcqhc%d", count
);
3603 QETH_CARD_TEXT_(card
, 5, "qcqherr%d", qdio_err
);
3606 netif_stop_queue(card
->dev
);
3607 qeth_schedule_recovery(card
);
3611 if (card
->options
.performance_stats
) {
3612 card
->perf_stats
.cq_cnt
++;
3613 card
->perf_stats
.cq_start_time
= qeth_get_micros();
3616 for (i
= first_element
; i
< first_element
+ count
; ++i
) {
3617 int bidx
= i
% QDIO_MAX_BUFFERS_PER_Q
;
3618 struct qdio_buffer
*buffer
= cq
->qdio_bufs
[bidx
];
3622 while ((e
< QDIO_MAX_ELEMENTS_PER_BUFFER
) &&
3623 buffer
->element
[e
].addr
) {
3624 unsigned long phys_aob_addr
;
3626 phys_aob_addr
= (unsigned long) buffer
->element
[e
].addr
;
3627 qeth_qdio_handle_aob(card
, phys_aob_addr
);
3628 buffer
->element
[e
].addr
= NULL
;
3629 buffer
->element
[e
].eflags
= 0;
3630 buffer
->element
[e
].sflags
= 0;
3631 buffer
->element
[e
].length
= 0;
3636 buffer
->element
[15].eflags
= 0;
3637 buffer
->element
[15].sflags
= 0;
3639 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, queue
,
3640 card
->qdio
.c_q
->next_buf_to_init
,
3643 dev_warn(&card
->gdev
->dev
,
3644 "QDIO reported an error, rc=%i\n", rc
);
3645 QETH_CARD_TEXT(card
, 2, "qcqherr");
3647 card
->qdio
.c_q
->next_buf_to_init
= (card
->qdio
.c_q
->next_buf_to_init
3648 + count
) % QDIO_MAX_BUFFERS_PER_Q
;
3650 netif_wake_queue(card
->dev
);
3652 if (card
->options
.performance_stats
) {
3653 int delta_t
= qeth_get_micros();
3654 delta_t
-= card
->perf_stats
.cq_start_time
;
3655 card
->perf_stats
.cq_time
+= delta_t
;
3661 void qeth_qdio_input_handler(struct ccw_device
*ccwdev
, unsigned int qdio_err
,
3662 unsigned int queue
, int first_elem
, int count
,
3663 unsigned long card_ptr
)
3665 struct qeth_card
*card
= (struct qeth_card
*)card_ptr
;
3667 QETH_CARD_TEXT_(card
, 2, "qihq%d", queue
);
3668 QETH_CARD_TEXT_(card
, 2, "qiec%d", qdio_err
);
3670 if (qeth_is_cq(card
, queue
))
3671 qeth_qdio_cq_handler(card
, qdio_err
, queue
, first_elem
, count
);
3673 qeth_schedule_recovery(card
);
3677 EXPORT_SYMBOL_GPL(qeth_qdio_input_handler
);
3679 void qeth_qdio_output_handler(struct ccw_device
*ccwdev
,
3680 unsigned int qdio_error
, int __queue
, int first_element
,
3681 int count
, unsigned long card_ptr
)
3683 struct qeth_card
*card
= (struct qeth_card
*) card_ptr
;
3684 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
[__queue
];
3685 struct qeth_qdio_out_buffer
*buffer
;
3688 QETH_CARD_TEXT(card
, 6, "qdouhdl");
3689 if (qdio_error
& QDIO_ERROR_FATAL
) {
3690 QETH_CARD_TEXT(card
, 2, "achkcond");
3691 netif_stop_queue(card
->dev
);
3692 qeth_schedule_recovery(card
);
3695 if (card
->options
.performance_stats
) {
3696 card
->perf_stats
.outbound_handler_cnt
++;
3697 card
->perf_stats
.outbound_handler_start_time
=
3700 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
3701 int bidx
= i
% QDIO_MAX_BUFFERS_PER_Q
;
3702 buffer
= queue
->bufs
[bidx
];
3703 qeth_handle_send_error(card
, buffer
, qdio_error
);
3705 if (queue
->bufstates
&&
3706 (queue
->bufstates
[bidx
].flags
&
3707 QDIO_OUTBUF_STATE_FLAG_PENDING
) != 0) {
3708 WARN_ON_ONCE(card
->options
.cq
!= QETH_CQ_ENABLED
);
3710 if (atomic_cmpxchg(&buffer
->state
,
3711 QETH_QDIO_BUF_PRIMED
,
3712 QETH_QDIO_BUF_PENDING
) ==
3713 QETH_QDIO_BUF_PRIMED
) {
3714 qeth_notify_skbs(queue
, buffer
,
3717 buffer
->aob
= queue
->bufstates
[bidx
].aob
;
3718 QETH_CARD_TEXT_(queue
->card
, 5, "pel%d", bidx
);
3719 QETH_CARD_TEXT(queue
->card
, 5, "aob");
3720 QETH_CARD_TEXT_(queue
->card
, 5, "%lx",
3721 virt_to_phys(buffer
->aob
));
3722 if (qeth_init_qdio_out_buf(queue
, bidx
)) {
3723 QETH_CARD_TEXT(card
, 2, "outofbuf");
3724 qeth_schedule_recovery(card
);
3727 if (card
->options
.cq
== QETH_CQ_ENABLED
) {
3728 enum iucv_tx_notify n
;
3730 n
= qeth_compute_cq_notification(
3731 buffer
->buffer
->element
[15].sflags
, 0);
3732 qeth_notify_skbs(queue
, buffer
, n
);
3735 qeth_clear_output_buffer(queue
, buffer
,
3736 QETH_QDIO_BUF_EMPTY
);
3738 qeth_cleanup_handled_pending(queue
, bidx
, 0);
3740 atomic_sub(count
, &queue
->used_buffers
);
3741 /* check if we need to do something on this outbound queue */
3742 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
3743 qeth_check_outbound_queue(queue
);
3745 netif_wake_queue(queue
->card
->dev
);
3746 if (card
->options
.performance_stats
)
3747 card
->perf_stats
.outbound_handler_time
+= qeth_get_micros() -
3748 card
->perf_stats
.outbound_handler_start_time
;
3750 EXPORT_SYMBOL_GPL(qeth_qdio_output_handler
);
3752 /* We cannot use outbound queue 3 for unicast packets on HiperSockets */
3753 static inline int qeth_cut_iqd_prio(struct qeth_card
*card
, int queue_num
)
3755 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) && (queue_num
== 3))
3761 * Note: Function assumes that we have 4 outbound queues.
3763 int qeth_get_priority_queue(struct qeth_card
*card
, struct sk_buff
*skb
,
3764 int ipv
, int cast_type
)
3769 if (cast_type
&& card
->info
.is_multicast_different
)
3770 return card
->info
.is_multicast_different
&
3771 (card
->qdio
.no_out_queues
- 1);
3773 switch (card
->qdio
.do_prio_queueing
) {
3774 case QETH_PRIO_Q_ING_TOS
:
3775 case QETH_PRIO_Q_ING_PREC
:
3778 tos
= ipv4_get_dsfield(ip_hdr(skb
));
3781 tos
= ipv6_get_dsfield(ipv6_hdr(skb
));
3784 return card
->qdio
.default_out_queue
;
3786 if (card
->qdio
.do_prio_queueing
== QETH_PRIO_Q_ING_PREC
)
3787 return qeth_cut_iqd_prio(card
, ~tos
>> 6 & 3);
3788 if (tos
& IPTOS_MINCOST
)
3789 return qeth_cut_iqd_prio(card
, 3);
3790 if (tos
& IPTOS_RELIABILITY
)
3792 if (tos
& IPTOS_THROUGHPUT
)
3794 if (tos
& IPTOS_LOWDELAY
)
3797 case QETH_PRIO_Q_ING_SKB
:
3798 if (skb
->priority
> 5)
3800 return qeth_cut_iqd_prio(card
, ~skb
->priority
>> 1 & 3);
3801 case QETH_PRIO_Q_ING_VLAN
:
3802 tci
= &((struct ethhdr
*)skb
->data
)->h_proto
;
3803 if (*tci
== ETH_P_8021Q
)
3804 return qeth_cut_iqd_prio(card
, ~*(tci
+ 1) >>
3805 (VLAN_PRIO_SHIFT
+ 1) & 3);
3810 return card
->qdio
.default_out_queue
;
3812 EXPORT_SYMBOL_GPL(qeth_get_priority_queue
);
3815 * qeth_get_elements_for_frags() - find number of SBALEs for skb frags.
3818 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
3819 * fragmented part of the SKB. Returns zero for linear SKB.
3821 int qeth_get_elements_for_frags(struct sk_buff
*skb
)
3823 int cnt
, elements
= 0;
3825 for (cnt
= 0; cnt
< skb_shinfo(skb
)->nr_frags
; cnt
++) {
3826 struct skb_frag_struct
*frag
= &skb_shinfo(skb
)->frags
[cnt
];
3828 elements
+= qeth_get_elements_for_range(
3829 (addr_t
)skb_frag_address(frag
),
3830 (addr_t
)skb_frag_address(frag
) + skb_frag_size(frag
));
3834 EXPORT_SYMBOL_GPL(qeth_get_elements_for_frags
);
3837 * qeth_get_elements_no() - find number of SBALEs for skb data, inc. frags.
3838 * @card: qeth card structure, to check max. elems.
3840 * @extra_elems: extra elems needed, to check against max.
3842 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
3843 * skb data, including linear part and fragments. Checks if the result plus
3844 * extra_elems fits under the limit for the card. Returns 0 if it does not.
3845 * Note: extra_elems is not included in the returned result.
3847 int qeth_get_elements_no(struct qeth_card
*card
,
3848 struct sk_buff
*skb
, int extra_elems
)
3850 int elements
= qeth_get_elements_for_range(
3852 (addr_t
)skb
->data
+ skb_headlen(skb
)) +
3853 qeth_get_elements_for_frags(skb
);
3855 if ((elements
+ extra_elems
) > QETH_MAX_BUFFER_ELEMENTS(card
)) {
3856 QETH_DBF_MESSAGE(2, "Invalid size of IP packet "
3857 "(Number=%d / Length=%d). Discarded.\n",
3858 elements
+ extra_elems
, skb
->len
);
3863 EXPORT_SYMBOL_GPL(qeth_get_elements_no
);
3865 int qeth_hdr_chk_and_bounce(struct sk_buff
*skb
, struct qeth_hdr
**hdr
, int len
)
3867 int hroom
, inpage
, rest
;
3869 if (((unsigned long)skb
->data
& PAGE_MASK
) !=
3870 (((unsigned long)skb
->data
+ len
- 1) & PAGE_MASK
)) {
3871 hroom
= skb_headroom(skb
);
3872 inpage
= PAGE_SIZE
- ((unsigned long) skb
->data
% PAGE_SIZE
);
3873 rest
= len
- inpage
;
3876 memmove(skb
->data
- rest
, skb
->data
, skb_headlen(skb
));
3879 *hdr
= (struct qeth_hdr
*)skb
->data
;
3880 QETH_DBF_MESSAGE(2, "skb bounce len: %d rest: %d\n", len
, rest
);
3884 EXPORT_SYMBOL_GPL(qeth_hdr_chk_and_bounce
);
3886 static inline void __qeth_fill_buffer(struct sk_buff
*skb
,
3887 struct qdio_buffer
*buffer
, int is_tso
, int *next_element_to_fill
,
3890 int length
= skb_headlen(skb
);
3895 struct skb_frag_struct
*frag
;
3897 element
= *next_element_to_fill
;
3899 first_lap
= (is_tso
== 0 ? 1 : 0);
3902 data
= skb
->data
+ offset
;
3907 while (length
> 0) {
3908 /* length_here is the remaining amount of data in this page */
3909 length_here
= PAGE_SIZE
- ((unsigned long) data
% PAGE_SIZE
);
3910 if (length
< length_here
)
3911 length_here
= length
;
3913 buffer
->element
[element
].addr
= data
;
3914 buffer
->element
[element
].length
= length_here
;
3915 length
-= length_here
;
3918 if (skb_shinfo(skb
)->nr_frags
)
3919 buffer
->element
[element
].eflags
=
3920 SBAL_EFLAGS_FIRST_FRAG
;
3922 buffer
->element
[element
].eflags
= 0;
3924 buffer
->element
[element
].eflags
=
3925 SBAL_EFLAGS_MIDDLE_FRAG
;
3928 buffer
->element
[element
].eflags
=
3929 SBAL_EFLAGS_FIRST_FRAG
;
3931 buffer
->element
[element
].eflags
=
3932 SBAL_EFLAGS_MIDDLE_FRAG
;
3934 data
+= length_here
;
3939 for (cnt
= 0; cnt
< skb_shinfo(skb
)->nr_frags
; cnt
++) {
3940 frag
= &skb_shinfo(skb
)->frags
[cnt
];
3941 data
= (char *)page_to_phys(skb_frag_page(frag
)) +
3943 length
= frag
->size
;
3944 while (length
> 0) {
3945 length_here
= PAGE_SIZE
-
3946 ((unsigned long) data
% PAGE_SIZE
);
3947 if (length
< length_here
)
3948 length_here
= length
;
3950 buffer
->element
[element
].addr
= data
;
3951 buffer
->element
[element
].length
= length_here
;
3952 buffer
->element
[element
].eflags
=
3953 SBAL_EFLAGS_MIDDLE_FRAG
;
3954 length
-= length_here
;
3955 data
+= length_here
;
3960 if (buffer
->element
[element
- 1].eflags
)
3961 buffer
->element
[element
- 1].eflags
= SBAL_EFLAGS_LAST_FRAG
;
3962 *next_element_to_fill
= element
;
3965 static inline int qeth_fill_buffer(struct qeth_qdio_out_q
*queue
,
3966 struct qeth_qdio_out_buffer
*buf
, struct sk_buff
*skb
,
3967 struct qeth_hdr
*hdr
, int offset
, int hd_len
)
3969 struct qdio_buffer
*buffer
;
3970 int flush_cnt
= 0, hdr_len
, large_send
= 0;
3972 buffer
= buf
->buffer
;
3973 atomic_inc(&skb
->users
);
3974 skb_queue_tail(&buf
->skb_list
, skb
);
3976 /*check first on TSO ....*/
3977 if (hdr
->hdr
.l3
.id
== QETH_HEADER_TYPE_TSO
) {
3978 int element
= buf
->next_element_to_fill
;
3980 hdr_len
= sizeof(struct qeth_hdr_tso
) +
3981 ((struct qeth_hdr_tso
*)hdr
)->ext
.dg_hdr_len
;
3982 /*fill first buffer entry only with header information */
3983 buffer
->element
[element
].addr
= skb
->data
;
3984 buffer
->element
[element
].length
= hdr_len
;
3985 buffer
->element
[element
].eflags
= SBAL_EFLAGS_FIRST_FRAG
;
3986 buf
->next_element_to_fill
++;
3987 skb
->data
+= hdr_len
;
3988 skb
->len
-= hdr_len
;
3993 int element
= buf
->next_element_to_fill
;
3994 buffer
->element
[element
].addr
= hdr
;
3995 buffer
->element
[element
].length
= sizeof(struct qeth_hdr
) +
3997 buffer
->element
[element
].eflags
= SBAL_EFLAGS_FIRST_FRAG
;
3998 buf
->is_header
[element
] = 1;
3999 buf
->next_element_to_fill
++;
4002 __qeth_fill_buffer(skb
, buffer
, large_send
,
4003 (int *)&buf
->next_element_to_fill
, offset
);
4005 if (!queue
->do_pack
) {
4006 QETH_CARD_TEXT(queue
->card
, 6, "fillbfnp");
4007 /* set state to PRIMED -> will be flushed */
4008 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4011 QETH_CARD_TEXT(queue
->card
, 6, "fillbfpa");
4012 if (queue
->card
->options
.performance_stats
)
4013 queue
->card
->perf_stats
.skbs_sent_pack
++;
4014 if (buf
->next_element_to_fill
>=
4015 QETH_MAX_BUFFER_ELEMENTS(queue
->card
)) {
4017 * packed buffer if full -> set state PRIMED
4018 * -> will be flushed
4020 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4027 int qeth_do_send_packet_fast(struct qeth_card
*card
,
4028 struct qeth_qdio_out_q
*queue
, struct sk_buff
*skb
,
4029 struct qeth_hdr
*hdr
, int elements_needed
,
4030 int offset
, int hd_len
)
4032 struct qeth_qdio_out_buffer
*buffer
;
4035 /* spin until we get the queue ... */
4036 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4037 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4038 /* ... now we've got the queue */
4039 index
= queue
->next_buf_to_fill
;
4040 buffer
= queue
->bufs
[queue
->next_buf_to_fill
];
4042 * check if buffer is empty to make sure that we do not 'overtake'
4043 * ourselves and try to fill a buffer that is already primed
4045 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
)
4047 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ 1) %
4048 QDIO_MAX_BUFFERS_PER_Q
;
4049 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4050 qeth_fill_buffer(queue
, buffer
, skb
, hdr
, offset
, hd_len
);
4051 qeth_flush_buffers(queue
, index
, 1);
4054 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4057 EXPORT_SYMBOL_GPL(qeth_do_send_packet_fast
);
4059 int qeth_do_send_packet(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4060 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4061 int elements_needed
)
4063 struct qeth_qdio_out_buffer
*buffer
;
4065 int flush_count
= 0;
4070 /* spin until we get the queue ... */
4071 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4072 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4073 start_index
= queue
->next_buf_to_fill
;
4074 buffer
= queue
->bufs
[queue
->next_buf_to_fill
];
4076 * check if buffer is empty to make sure that we do not 'overtake'
4077 * ourselves and try to fill a buffer that is already primed
4079 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
) {
4080 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4083 /* check if we need to switch packing state of this queue */
4084 qeth_switch_to_packing_if_needed(queue
);
4085 if (queue
->do_pack
) {
4087 /* does packet fit in current buffer? */
4088 if ((QETH_MAX_BUFFER_ELEMENTS(card
) -
4089 buffer
->next_element_to_fill
) < elements_needed
) {
4090 /* ... no -> set state PRIMED */
4091 atomic_set(&buffer
->state
, QETH_QDIO_BUF_PRIMED
);
4093 queue
->next_buf_to_fill
=
4094 (queue
->next_buf_to_fill
+ 1) %
4095 QDIO_MAX_BUFFERS_PER_Q
;
4096 buffer
= queue
->bufs
[queue
->next_buf_to_fill
];
4097 /* we did a step forward, so check buffer state
4099 if (atomic_read(&buffer
->state
) !=
4100 QETH_QDIO_BUF_EMPTY
) {
4101 qeth_flush_buffers(queue
, start_index
,
4103 atomic_set(&queue
->state
,
4104 QETH_OUT_Q_UNLOCKED
);
4109 tmp
= qeth_fill_buffer(queue
, buffer
, skb
, hdr
, -1, 0);
4110 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ tmp
) %
4111 QDIO_MAX_BUFFERS_PER_Q
;
4114 qeth_flush_buffers(queue
, start_index
, flush_count
);
4115 else if (!atomic_read(&queue
->set_pci_flags_count
))
4116 atomic_xchg(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
);
4118 * queue->state will go from LOCKED -> UNLOCKED or from
4119 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
4120 * (switch packing state or flush buffer to get another pci flag out).
4121 * In that case we will enter this loop
4123 while (atomic_dec_return(&queue
->state
)) {
4125 start_index
= queue
->next_buf_to_fill
;
4126 /* check if we can go back to non-packing state */
4127 flush_count
+= qeth_switch_to_nonpacking_if_needed(queue
);
4129 * check if we need to flush a packing buffer to get a pci
4130 * flag out on the queue
4132 if (!flush_count
&& !atomic_read(&queue
->set_pci_flags_count
))
4133 flush_count
+= qeth_flush_buffers_on_no_pci(queue
);
4135 qeth_flush_buffers(queue
, start_index
, flush_count
);
4137 /* at this point the queue is UNLOCKED again */
4138 if (queue
->card
->options
.performance_stats
&& do_pack
)
4139 queue
->card
->perf_stats
.bufs_sent_pack
+= flush_count
;
4143 EXPORT_SYMBOL_GPL(qeth_do_send_packet
);
4145 static int qeth_setadp_promisc_mode_cb(struct qeth_card
*card
,
4146 struct qeth_reply
*reply
, unsigned long data
)
4148 struct qeth_ipa_cmd
*cmd
;
4149 struct qeth_ipacmd_setadpparms
*setparms
;
4151 QETH_CARD_TEXT(card
, 4, "prmadpcb");
4153 cmd
= (struct qeth_ipa_cmd
*) data
;
4154 setparms
= &(cmd
->data
.setadapterparms
);
4156 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
4157 if (cmd
->hdr
.return_code
) {
4158 QETH_CARD_TEXT_(card
, 4, "prmrc%x", cmd
->hdr
.return_code
);
4159 setparms
->data
.mode
= SET_PROMISC_MODE_OFF
;
4161 card
->info
.promisc_mode
= setparms
->data
.mode
;
4165 void qeth_setadp_promisc_mode(struct qeth_card
*card
)
4167 enum qeth_ipa_promisc_modes mode
;
4168 struct net_device
*dev
= card
->dev
;
4169 struct qeth_cmd_buffer
*iob
;
4170 struct qeth_ipa_cmd
*cmd
;
4172 QETH_CARD_TEXT(card
, 4, "setprom");
4174 if (((dev
->flags
& IFF_PROMISC
) &&
4175 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
4176 (!(dev
->flags
& IFF_PROMISC
) &&
4177 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
4179 mode
= SET_PROMISC_MODE_OFF
;
4180 if (dev
->flags
& IFF_PROMISC
)
4181 mode
= SET_PROMISC_MODE_ON
;
4182 QETH_CARD_TEXT_(card
, 4, "mode:%x", mode
);
4184 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_PROMISC_MODE
,
4185 sizeof(struct qeth_ipacmd_setadpparms_hdr
) + 8);
4188 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+ IPA_PDU_HEADER_SIZE
);
4189 cmd
->data
.setadapterparms
.data
.mode
= mode
;
4190 qeth_send_ipa_cmd(card
, iob
, qeth_setadp_promisc_mode_cb
, NULL
);
4192 EXPORT_SYMBOL_GPL(qeth_setadp_promisc_mode
);
4194 int qeth_change_mtu(struct net_device
*dev
, int new_mtu
)
4196 struct qeth_card
*card
;
4199 card
= dev
->ml_priv
;
4201 QETH_CARD_TEXT(card
, 4, "chgmtu");
4202 sprintf(dbf_text
, "%8x", new_mtu
);
4203 QETH_CARD_TEXT(card
, 4, dbf_text
);
4205 if ((!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) &&
4206 (!qeth_mtu_is_valid(card
, new_mtu
)))
4211 EXPORT_SYMBOL_GPL(qeth_change_mtu
);
4213 struct net_device_stats
*qeth_get_stats(struct net_device
*dev
)
4215 struct qeth_card
*card
;
4217 card
= dev
->ml_priv
;
4219 QETH_CARD_TEXT(card
, 5, "getstat");
4221 return &card
->stats
;
4223 EXPORT_SYMBOL_GPL(qeth_get_stats
);
4225 static int qeth_setadpparms_change_macaddr_cb(struct qeth_card
*card
,
4226 struct qeth_reply
*reply
, unsigned long data
)
4228 struct qeth_ipa_cmd
*cmd
;
4230 QETH_CARD_TEXT(card
, 4, "chgmaccb");
4232 cmd
= (struct qeth_ipa_cmd
*) data
;
4233 if (!card
->options
.layer2
||
4234 !(card
->info
.mac_bits
& QETH_LAYER2_MAC_READ
)) {
4235 memcpy(card
->dev
->dev_addr
,
4236 &cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
4238 card
->info
.mac_bits
|= QETH_LAYER2_MAC_READ
;
4240 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
4244 int qeth_setadpparms_change_macaddr(struct qeth_card
*card
)
4247 struct qeth_cmd_buffer
*iob
;
4248 struct qeth_ipa_cmd
*cmd
;
4250 QETH_CARD_TEXT(card
, 4, "chgmac");
4252 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_ALTER_MAC_ADDRESS
,
4253 sizeof(struct qeth_ipacmd_setadpparms_hdr
) +
4254 sizeof(struct qeth_change_addr
));
4257 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4258 cmd
->data
.setadapterparms
.data
.change_addr
.cmd
= CHANGE_ADDR_READ_MAC
;
4259 cmd
->data
.setadapterparms
.data
.change_addr
.addr_size
= OSA_ADDR_LEN
;
4260 memcpy(&cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
4261 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
4262 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_change_macaddr_cb
,
4266 EXPORT_SYMBOL_GPL(qeth_setadpparms_change_macaddr
);
4268 static int qeth_setadpparms_set_access_ctrl_cb(struct qeth_card
*card
,
4269 struct qeth_reply
*reply
, unsigned long data
)
4271 struct qeth_ipa_cmd
*cmd
;
4272 struct qeth_set_access_ctrl
*access_ctrl_req
;
4273 int fallback
= *(int *)reply
->param
;
4275 QETH_CARD_TEXT(card
, 4, "setaccb");
4277 cmd
= (struct qeth_ipa_cmd
*) data
;
4278 access_ctrl_req
= &cmd
->data
.setadapterparms
.data
.set_access_ctrl
;
4279 QETH_DBF_TEXT_(SETUP
, 2, "setaccb");
4280 QETH_DBF_TEXT_(SETUP
, 2, "%s", card
->gdev
->dev
.kobj
.name
);
4281 QETH_DBF_TEXT_(SETUP
, 2, "rc=%d",
4282 cmd
->data
.setadapterparms
.hdr
.return_code
);
4283 if (cmd
->data
.setadapterparms
.hdr
.return_code
!=
4284 SET_ACCESS_CTRL_RC_SUCCESS
)
4285 QETH_DBF_MESSAGE(3, "ERR:SET_ACCESS_CTRL(%s,%d)==%d\n",
4286 card
->gdev
->dev
.kobj
.name
,
4287 access_ctrl_req
->subcmd_code
,
4288 cmd
->data
.setadapterparms
.hdr
.return_code
);
4289 switch (cmd
->data
.setadapterparms
.hdr
.return_code
) {
4290 case SET_ACCESS_CTRL_RC_SUCCESS
:
4291 if (card
->options
.isolation
== ISOLATION_MODE_NONE
) {
4292 dev_info(&card
->gdev
->dev
,
4293 "QDIO data connection isolation is deactivated\n");
4295 dev_info(&card
->gdev
->dev
,
4296 "QDIO data connection isolation is activated\n");
4299 case SET_ACCESS_CTRL_RC_ALREADY_NOT_ISOLATED
:
4300 QETH_DBF_MESSAGE(2, "%s QDIO data connection isolation already "
4301 "deactivated\n", dev_name(&card
->gdev
->dev
));
4303 card
->options
.isolation
= card
->options
.prev_isolation
;
4305 case SET_ACCESS_CTRL_RC_ALREADY_ISOLATED
:
4306 QETH_DBF_MESSAGE(2, "%s QDIO data connection isolation already"
4307 " activated\n", dev_name(&card
->gdev
->dev
));
4309 card
->options
.isolation
= card
->options
.prev_isolation
;
4311 case SET_ACCESS_CTRL_RC_NOT_SUPPORTED
:
4312 dev_err(&card
->gdev
->dev
, "Adapter does not "
4313 "support QDIO data connection isolation\n");
4315 case SET_ACCESS_CTRL_RC_NONE_SHARED_ADAPTER
:
4316 dev_err(&card
->gdev
->dev
,
4317 "Adapter is dedicated. "
4318 "QDIO data connection isolation not supported\n");
4320 card
->options
.isolation
= card
->options
.prev_isolation
;
4322 case SET_ACCESS_CTRL_RC_ACTIVE_CHECKSUM_OFF
:
4323 dev_err(&card
->gdev
->dev
,
4324 "TSO does not permit QDIO data connection isolation\n");
4326 card
->options
.isolation
= card
->options
.prev_isolation
;
4328 case SET_ACCESS_CTRL_RC_REFLREL_UNSUPPORTED
:
4329 dev_err(&card
->gdev
->dev
, "The adjacent switch port does not "
4330 "support reflective relay mode\n");
4332 card
->options
.isolation
= card
->options
.prev_isolation
;
4334 case SET_ACCESS_CTRL_RC_REFLREL_FAILED
:
4335 dev_err(&card
->gdev
->dev
, "The reflective relay mode cannot be "
4336 "enabled at the adjacent switch port");
4338 card
->options
.isolation
= card
->options
.prev_isolation
;
4340 case SET_ACCESS_CTRL_RC_REFLREL_DEACT_FAILED
:
4341 dev_warn(&card
->gdev
->dev
, "Turning off reflective relay mode "
4342 "at the adjacent switch failed\n");
4345 /* this should never happen */
4347 card
->options
.isolation
= card
->options
.prev_isolation
;
4350 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
4354 static int qeth_setadpparms_set_access_ctrl(struct qeth_card
*card
,
4355 enum qeth_ipa_isolation_modes isolation
, int fallback
)
4358 struct qeth_cmd_buffer
*iob
;
4359 struct qeth_ipa_cmd
*cmd
;
4360 struct qeth_set_access_ctrl
*access_ctrl_req
;
4362 QETH_CARD_TEXT(card
, 4, "setacctl");
4364 QETH_DBF_TEXT_(SETUP
, 2, "setacctl");
4365 QETH_DBF_TEXT_(SETUP
, 2, "%s", card
->gdev
->dev
.kobj
.name
);
4367 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_ACCESS_CONTROL
,
4368 sizeof(struct qeth_ipacmd_setadpparms_hdr
) +
4369 sizeof(struct qeth_set_access_ctrl
));
4372 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4373 access_ctrl_req
= &cmd
->data
.setadapterparms
.data
.set_access_ctrl
;
4374 access_ctrl_req
->subcmd_code
= isolation
;
4376 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_set_access_ctrl_cb
,
4378 QETH_DBF_TEXT_(SETUP
, 2, "rc=%d", rc
);
4382 int qeth_set_access_ctrl_online(struct qeth_card
*card
, int fallback
)
4386 QETH_CARD_TEXT(card
, 4, "setactlo");
4388 if ((card
->info
.type
== QETH_CARD_TYPE_OSD
||
4389 card
->info
.type
== QETH_CARD_TYPE_OSX
) &&
4390 qeth_adp_supported(card
, IPA_SETADP_SET_ACCESS_CONTROL
)) {
4391 rc
= qeth_setadpparms_set_access_ctrl(card
,
4392 card
->options
.isolation
, fallback
);
4395 "IPA(SET_ACCESS_CTRL,%s,%d) sent failed\n",
4396 card
->gdev
->dev
.kobj
.name
,
4400 } else if (card
->options
.isolation
!= ISOLATION_MODE_NONE
) {
4401 card
->options
.isolation
= ISOLATION_MODE_NONE
;
4403 dev_err(&card
->gdev
->dev
, "Adapter does not "
4404 "support QDIO data connection isolation\n");
4409 EXPORT_SYMBOL_GPL(qeth_set_access_ctrl_online
);
4411 void qeth_tx_timeout(struct net_device
*dev
)
4413 struct qeth_card
*card
;
4415 card
= dev
->ml_priv
;
4416 QETH_CARD_TEXT(card
, 4, "txtimeo");
4417 card
->stats
.tx_errors
++;
4418 qeth_schedule_recovery(card
);
4420 EXPORT_SYMBOL_GPL(qeth_tx_timeout
);
4422 int qeth_mdio_read(struct net_device
*dev
, int phy_id
, int regnum
)
4424 struct qeth_card
*card
= dev
->ml_priv
;
4428 case MII_BMCR
: /* Basic mode control register */
4430 if ((card
->info
.link_type
!= QETH_LINK_TYPE_GBIT_ETH
) &&
4431 (card
->info
.link_type
!= QETH_LINK_TYPE_OSN
) &&
4432 (card
->info
.link_type
!= QETH_LINK_TYPE_10GBIT_ETH
))
4433 rc
|= BMCR_SPEED100
;
4435 case MII_BMSR
: /* Basic mode status register */
4436 rc
= BMSR_ERCAP
| BMSR_ANEGCOMPLETE
| BMSR_LSTATUS
|
4437 BMSR_10HALF
| BMSR_10FULL
| BMSR_100HALF
| BMSR_100FULL
|
4440 case MII_PHYSID1
: /* PHYS ID 1 */
4441 rc
= (dev
->dev_addr
[0] << 16) | (dev
->dev_addr
[1] << 8) |
4443 rc
= (rc
>> 5) & 0xFFFF;
4445 case MII_PHYSID2
: /* PHYS ID 2 */
4446 rc
= (dev
->dev_addr
[2] << 10) & 0xFFFF;
4448 case MII_ADVERTISE
: /* Advertisement control reg */
4451 case MII_LPA
: /* Link partner ability reg */
4452 rc
= LPA_10HALF
| LPA_10FULL
| LPA_100HALF
| LPA_100FULL
|
4453 LPA_100BASE4
| LPA_LPACK
;
4455 case MII_EXPANSION
: /* Expansion register */
4457 case MII_DCOUNTER
: /* disconnect counter */
4459 case MII_FCSCOUNTER
: /* false carrier counter */
4461 case MII_NWAYTEST
: /* N-way auto-neg test register */
4463 case MII_RERRCOUNTER
: /* rx error counter */
4464 rc
= card
->stats
.rx_errors
;
4466 case MII_SREVISION
: /* silicon revision */
4468 case MII_RESV1
: /* reserved 1 */
4470 case MII_LBRERROR
: /* loopback, rx, bypass error */
4472 case MII_PHYADDR
: /* physical address */
4474 case MII_RESV2
: /* reserved 2 */
4476 case MII_TPISTATUS
: /* TPI status for 10mbps */
4478 case MII_NCONFIG
: /* network interface config */
4485 EXPORT_SYMBOL_GPL(qeth_mdio_read
);
4487 static int qeth_send_ipa_snmp_cmd(struct qeth_card
*card
,
4488 struct qeth_cmd_buffer
*iob
, int len
,
4489 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
4495 QETH_CARD_TEXT(card
, 4, "sendsnmp");
4497 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4498 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4499 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4500 /* adjust PDU length fields in IPA_PDU_HEADER */
4501 s1
= (u32
) IPA_PDU_HEADER_SIZE
+ len
;
4503 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
4504 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
4505 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
4506 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
4507 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4508 reply_cb
, reply_param
);
4511 static int qeth_snmp_command_cb(struct qeth_card
*card
,
4512 struct qeth_reply
*reply
, unsigned long sdata
)
4514 struct qeth_ipa_cmd
*cmd
;
4515 struct qeth_arp_query_info
*qinfo
;
4516 struct qeth_snmp_cmd
*snmp
;
4517 unsigned char *data
;
4520 QETH_CARD_TEXT(card
, 3, "snpcmdcb");
4522 cmd
= (struct qeth_ipa_cmd
*) sdata
;
4523 data
= (unsigned char *)((char *)cmd
- reply
->offset
);
4524 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4525 snmp
= &cmd
->data
.setadapterparms
.data
.snmp
;
4527 if (cmd
->hdr
.return_code
) {
4528 QETH_CARD_TEXT_(card
, 4, "scer1%x", cmd
->hdr
.return_code
);
4531 if (cmd
->data
.setadapterparms
.hdr
.return_code
) {
4532 cmd
->hdr
.return_code
=
4533 cmd
->data
.setadapterparms
.hdr
.return_code
;
4534 QETH_CARD_TEXT_(card
, 4, "scer2%x", cmd
->hdr
.return_code
);
4537 data_len
= *((__u16
*)QETH_IPA_PDU_LEN_PDU1(data
));
4538 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1)
4539 data_len
-= (__u16
)((char *)&snmp
->data
- (char *)cmd
);
4541 data_len
-= (__u16
)((char *)&snmp
->request
- (char *)cmd
);
4543 /* check if there is enough room in userspace */
4544 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < data_len
) {
4545 QETH_CARD_TEXT_(card
, 4, "scer3%i", -ENOMEM
);
4546 cmd
->hdr
.return_code
= IPA_RC_ENOMEM
;
4549 QETH_CARD_TEXT_(card
, 4, "snore%i",
4550 cmd
->data
.setadapterparms
.hdr
.used_total
);
4551 QETH_CARD_TEXT_(card
, 4, "sseqn%i",
4552 cmd
->data
.setadapterparms
.hdr
.seq_no
);
4553 /*copy entries to user buffer*/
4554 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1) {
4555 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4557 data_len
+ offsetof(struct qeth_snmp_cmd
, data
));
4558 qinfo
->udata_offset
+= offsetof(struct qeth_snmp_cmd
, data
);
4560 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4561 (char *)&snmp
->request
, data_len
);
4563 qinfo
->udata_offset
+= data_len
;
4564 /* check if all replies received ... */
4565 QETH_CARD_TEXT_(card
, 4, "srtot%i",
4566 cmd
->data
.setadapterparms
.hdr
.used_total
);
4567 QETH_CARD_TEXT_(card
, 4, "srseq%i",
4568 cmd
->data
.setadapterparms
.hdr
.seq_no
);
4569 if (cmd
->data
.setadapterparms
.hdr
.seq_no
<
4570 cmd
->data
.setadapterparms
.hdr
.used_total
)
4575 int qeth_snmp_command(struct qeth_card
*card
, char __user
*udata
)
4577 struct qeth_cmd_buffer
*iob
;
4578 struct qeth_ipa_cmd
*cmd
;
4579 struct qeth_snmp_ureq
*ureq
;
4580 unsigned int req_len
;
4581 struct qeth_arp_query_info qinfo
= {0, };
4584 QETH_CARD_TEXT(card
, 3, "snmpcmd");
4586 if (card
->info
.guestlan
)
4589 if ((!qeth_adp_supported(card
, IPA_SETADP_SET_SNMP_CONTROL
)) &&
4590 (!card
->options
.layer2
)) {
4593 /* skip 4 bytes (data_len struct member) to get req_len */
4594 if (copy_from_user(&req_len
, udata
+ sizeof(int), sizeof(int)))
4596 if (req_len
> (QETH_BUFSIZE
- IPA_PDU_HEADER_SIZE
-
4597 sizeof(struct qeth_ipacmd_hdr
) -
4598 sizeof(struct qeth_ipacmd_setadpparms_hdr
)))
4600 ureq
= memdup_user(udata
, req_len
+ sizeof(struct qeth_snmp_ureq_hdr
));
4602 QETH_CARD_TEXT(card
, 2, "snmpnome");
4603 return PTR_ERR(ureq
);
4605 qinfo
.udata_len
= ureq
->hdr
.data_len
;
4606 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
4611 qinfo
.udata_offset
= sizeof(struct qeth_snmp_ureq_hdr
);
4613 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_SNMP_CONTROL
,
4614 QETH_SNMP_SETADP_CMDLENGTH
+ req_len
);
4619 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4620 memcpy(&cmd
->data
.setadapterparms
.data
.snmp
, &ureq
->cmd
, req_len
);
4621 rc
= qeth_send_ipa_snmp_cmd(card
, iob
, QETH_SETADP_BASE_LEN
+ req_len
,
4622 qeth_snmp_command_cb
, (void *)&qinfo
);
4624 QETH_DBF_MESSAGE(2, "SNMP command failed on %s: (0x%x)\n",
4625 QETH_CARD_IFNAME(card
), rc
);
4627 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
))
4635 EXPORT_SYMBOL_GPL(qeth_snmp_command
);
4637 static int qeth_setadpparms_query_oat_cb(struct qeth_card
*card
,
4638 struct qeth_reply
*reply
, unsigned long data
)
4640 struct qeth_ipa_cmd
*cmd
;
4641 struct qeth_qoat_priv
*priv
;
4645 QETH_CARD_TEXT(card
, 3, "qoatcb");
4647 cmd
= (struct qeth_ipa_cmd
*)data
;
4648 priv
= (struct qeth_qoat_priv
*)reply
->param
;
4649 resdatalen
= cmd
->data
.setadapterparms
.hdr
.cmdlength
;
4650 resdata
= (char *)data
+ 28;
4652 if (resdatalen
> (priv
->buffer_len
- priv
->response_len
)) {
4653 cmd
->hdr
.return_code
= IPA_RC_FFFF
;
4657 memcpy((priv
->buffer
+ priv
->response_len
), resdata
,
4659 priv
->response_len
+= resdatalen
;
4661 if (cmd
->data
.setadapterparms
.hdr
.seq_no
<
4662 cmd
->data
.setadapterparms
.hdr
.used_total
)
4667 int qeth_query_oat_command(struct qeth_card
*card
, char __user
*udata
)
4670 struct qeth_cmd_buffer
*iob
;
4671 struct qeth_ipa_cmd
*cmd
;
4672 struct qeth_query_oat
*oat_req
;
4673 struct qeth_query_oat_data oat_data
;
4674 struct qeth_qoat_priv priv
;
4677 QETH_CARD_TEXT(card
, 3, "qoatcmd");
4679 if (!qeth_adp_supported(card
, IPA_SETADP_QUERY_OAT
)) {
4684 if (copy_from_user(&oat_data
, udata
,
4685 sizeof(struct qeth_query_oat_data
))) {
4690 priv
.buffer_len
= oat_data
.buffer_len
;
4691 priv
.response_len
= 0;
4692 priv
.buffer
= kzalloc(oat_data
.buffer_len
, GFP_KERNEL
);
4698 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_OAT
,
4699 sizeof(struct qeth_ipacmd_setadpparms_hdr
) +
4700 sizeof(struct qeth_query_oat
));
4705 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4706 oat_req
= &cmd
->data
.setadapterparms
.data
.query_oat
;
4707 oat_req
->subcmd_code
= oat_data
.command
;
4709 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_query_oat_cb
,
4712 if (is_compat_task())
4713 tmp
= compat_ptr(oat_data
.ptr
);
4715 tmp
= (void __user
*)(unsigned long)oat_data
.ptr
;
4717 if (copy_to_user(tmp
, priv
.buffer
,
4718 priv
.response_len
)) {
4723 oat_data
.response_len
= priv
.response_len
;
4725 if (copy_to_user(udata
, &oat_data
,
4726 sizeof(struct qeth_query_oat_data
)))
4729 if (rc
== IPA_RC_FFFF
)
4737 EXPORT_SYMBOL_GPL(qeth_query_oat_command
);
4739 static int qeth_query_card_info_cb(struct qeth_card
*card
,
4740 struct qeth_reply
*reply
, unsigned long data
)
4742 struct qeth_ipa_cmd
*cmd
;
4743 struct qeth_query_card_info
*card_info
;
4744 struct carrier_info
*carrier_info
;
4746 QETH_CARD_TEXT(card
, 2, "qcrdincb");
4747 carrier_info
= (struct carrier_info
*)reply
->param
;
4748 cmd
= (struct qeth_ipa_cmd
*)data
;
4749 card_info
= &cmd
->data
.setadapterparms
.data
.card_info
;
4750 if (cmd
->data
.setadapterparms
.hdr
.return_code
== 0) {
4751 carrier_info
->card_type
= card_info
->card_type
;
4752 carrier_info
->port_mode
= card_info
->port_mode
;
4753 carrier_info
->port_speed
= card_info
->port_speed
;
4756 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
4760 static int qeth_query_card_info(struct qeth_card
*card
,
4761 struct carrier_info
*carrier_info
)
4763 struct qeth_cmd_buffer
*iob
;
4765 QETH_CARD_TEXT(card
, 2, "qcrdinfo");
4766 if (!qeth_adp_supported(card
, IPA_SETADP_QUERY_CARD_INFO
))
4768 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_CARD_INFO
,
4769 sizeof(struct qeth_ipacmd_setadpparms_hdr
));
4772 return qeth_send_ipa_cmd(card
, iob
, qeth_query_card_info_cb
,
4773 (void *)carrier_info
);
4776 static inline int qeth_get_qdio_q_format(struct qeth_card
*card
)
4778 switch (card
->info
.type
) {
4779 case QETH_CARD_TYPE_IQD
:
4786 static void qeth_determine_capabilities(struct qeth_card
*card
)
4791 struct ccw_device
*ddev
;
4792 int ddev_offline
= 0;
4794 QETH_DBF_TEXT(SETUP
, 2, "detcapab");
4795 ddev
= CARD_DDEV(card
);
4796 if (!ddev
->online
) {
4798 rc
= ccw_device_set_online(ddev
);
4800 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
4805 rc
= qeth_read_conf_data(card
, (void **) &prcd
, &length
);
4807 QETH_DBF_MESSAGE(2, "%s qeth_read_conf_data returned %i\n",
4808 dev_name(&card
->gdev
->dev
), rc
);
4809 QETH_DBF_TEXT_(SETUP
, 2, "5err%d", rc
);
4812 qeth_configure_unitaddr(card
, prcd
);
4814 qeth_configure_blkt_default(card
, prcd
);
4817 rc
= qdio_get_ssqd_desc(ddev
, &card
->ssqd
);
4819 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
4821 QETH_DBF_TEXT_(SETUP
, 2, "qfmt%d", card
->ssqd
.qfmt
);
4822 QETH_DBF_TEXT_(SETUP
, 2, "%d", card
->ssqd
.qdioac1
);
4823 QETH_DBF_TEXT_(SETUP
, 2, "%d", card
->ssqd
.qdioac3
);
4824 QETH_DBF_TEXT_(SETUP
, 2, "icnt%d", card
->ssqd
.icnt
);
4825 if (!((card
->ssqd
.qfmt
!= QDIO_IQDIO_QFMT
) ||
4826 ((card
->ssqd
.qdioac1
& CHSC_AC1_INITIATE_INPUTQ
) == 0) ||
4827 ((card
->ssqd
.qdioac3
& CHSC_AC3_FORMAT2_CQ_AVAILABLE
) == 0))) {
4828 dev_info(&card
->gdev
->dev
,
4829 "Completion Queueing supported\n");
4831 card
->options
.cq
= QETH_CQ_NOTAVAILABLE
;
4836 if (ddev_offline
== 1)
4837 ccw_device_set_offline(ddev
);
4842 static inline void qeth_qdio_establish_cq(struct qeth_card
*card
,
4843 struct qdio_buffer
**in_sbal_ptrs
,
4844 void (**queue_start_poll
) (struct ccw_device
*, int, unsigned long)) {
4847 if (card
->options
.cq
== QETH_CQ_ENABLED
) {
4848 int offset
= QDIO_MAX_BUFFERS_PER_Q
*
4849 (card
->qdio
.no_in_queues
- 1);
4850 i
= QDIO_MAX_BUFFERS_PER_Q
* (card
->qdio
.no_in_queues
- 1);
4851 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
) {
4852 in_sbal_ptrs
[offset
+ i
] = (struct qdio_buffer
*)
4853 virt_to_phys(card
->qdio
.c_q
->bufs
[i
].buffer
);
4856 queue_start_poll
[card
->qdio
.no_in_queues
- 1] = NULL
;
4860 static int qeth_qdio_establish(struct qeth_card
*card
)
4862 struct qdio_initialize init_data
;
4863 char *qib_param_field
;
4864 struct qdio_buffer
**in_sbal_ptrs
;
4865 void (**queue_start_poll
) (struct ccw_device
*, int, unsigned long);
4866 struct qdio_buffer
**out_sbal_ptrs
;
4870 QETH_DBF_TEXT(SETUP
, 2, "qdioest");
4872 qib_param_field
= kzalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(char),
4874 if (!qib_param_field
) {
4876 goto out_free_nothing
;
4879 qeth_create_qib_param_field(card
, qib_param_field
);
4880 qeth_create_qib_param_field_blkt(card
, qib_param_field
);
4882 in_sbal_ptrs
= kzalloc(card
->qdio
.no_in_queues
*
4883 QDIO_MAX_BUFFERS_PER_Q
* sizeof(void *),
4885 if (!in_sbal_ptrs
) {
4887 goto out_free_qib_param
;
4889 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
) {
4890 in_sbal_ptrs
[i
] = (struct qdio_buffer
*)
4891 virt_to_phys(card
->qdio
.in_q
->bufs
[i
].buffer
);
4894 queue_start_poll
= kzalloc(sizeof(void *) * card
->qdio
.no_in_queues
,
4896 if (!queue_start_poll
) {
4898 goto out_free_in_sbals
;
4900 for (i
= 0; i
< card
->qdio
.no_in_queues
; ++i
)
4901 queue_start_poll
[i
] = card
->discipline
->start_poll
;
4903 qeth_qdio_establish_cq(card
, in_sbal_ptrs
, queue_start_poll
);
4906 kzalloc(card
->qdio
.no_out_queues
* QDIO_MAX_BUFFERS_PER_Q
*
4907 sizeof(void *), GFP_KERNEL
);
4908 if (!out_sbal_ptrs
) {
4910 goto out_free_queue_start_poll
;
4912 for (i
= 0, k
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
4913 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
, ++k
) {
4914 out_sbal_ptrs
[k
] = (struct qdio_buffer
*)virt_to_phys(
4915 card
->qdio
.out_qs
[i
]->bufs
[j
]->buffer
);
4918 memset(&init_data
, 0, sizeof(struct qdio_initialize
));
4919 init_data
.cdev
= CARD_DDEV(card
);
4920 init_data
.q_format
= qeth_get_qdio_q_format(card
);
4921 init_data
.qib_param_field_format
= 0;
4922 init_data
.qib_param_field
= qib_param_field
;
4923 init_data
.no_input_qs
= card
->qdio
.no_in_queues
;
4924 init_data
.no_output_qs
= card
->qdio
.no_out_queues
;
4925 init_data
.input_handler
= card
->discipline
->input_handler
;
4926 init_data
.output_handler
= card
->discipline
->output_handler
;
4927 init_data
.queue_start_poll_array
= queue_start_poll
;
4928 init_data
.int_parm
= (unsigned long) card
;
4929 init_data
.input_sbal_addr_array
= (void **) in_sbal_ptrs
;
4930 init_data
.output_sbal_addr_array
= (void **) out_sbal_ptrs
;
4931 init_data
.output_sbal_state_array
= card
->qdio
.out_bufstates
;
4932 init_data
.scan_threshold
=
4933 (card
->info
.type
== QETH_CARD_TYPE_IQD
) ? 1 : 32;
4935 if (atomic_cmpxchg(&card
->qdio
.state
, QETH_QDIO_ALLOCATED
,
4936 QETH_QDIO_ESTABLISHED
) == QETH_QDIO_ALLOCATED
) {
4937 rc
= qdio_allocate(&init_data
);
4939 atomic_set(&card
->qdio
.state
, QETH_QDIO_ALLOCATED
);
4942 rc
= qdio_establish(&init_data
);
4944 atomic_set(&card
->qdio
.state
, QETH_QDIO_ALLOCATED
);
4945 qdio_free(CARD_DDEV(card
));
4949 switch (card
->options
.cq
) {
4950 case QETH_CQ_ENABLED
:
4951 dev_info(&card
->gdev
->dev
, "Completion Queue support enabled");
4953 case QETH_CQ_DISABLED
:
4954 dev_info(&card
->gdev
->dev
, "Completion Queue support disabled");
4960 kfree(out_sbal_ptrs
);
4961 out_free_queue_start_poll
:
4962 kfree(queue_start_poll
);
4964 kfree(in_sbal_ptrs
);
4966 kfree(qib_param_field
);
4971 static void qeth_core_free_card(struct qeth_card
*card
)
4974 QETH_DBF_TEXT(SETUP
, 2, "freecrd");
4975 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
4976 qeth_clean_channel(&card
->read
);
4977 qeth_clean_channel(&card
->write
);
4979 free_netdev(card
->dev
);
4980 qeth_free_qdio_buffers(card
);
4981 unregister_service_level(&card
->qeth_service_level
);
4985 void qeth_trace_features(struct qeth_card
*card
)
4987 QETH_CARD_TEXT(card
, 2, "features");
4988 QETH_CARD_HEX(card
, 2, &card
->options
.ipa4
, sizeof(card
->options
.ipa4
));
4989 QETH_CARD_HEX(card
, 2, &card
->options
.ipa6
, sizeof(card
->options
.ipa6
));
4990 QETH_CARD_HEX(card
, 2, &card
->options
.adp
, sizeof(card
->options
.adp
));
4991 QETH_CARD_HEX(card
, 2, &card
->info
.diagass_support
,
4992 sizeof(card
->info
.diagass_support
));
4994 EXPORT_SYMBOL_GPL(qeth_trace_features
);
4996 static struct ccw_device_id qeth_ids
[] = {
4997 {CCW_DEVICE_DEVTYPE(0x1731, 0x01, 0x1732, 0x01),
4998 .driver_info
= QETH_CARD_TYPE_OSD
},
4999 {CCW_DEVICE_DEVTYPE(0x1731, 0x05, 0x1732, 0x05),
5000 .driver_info
= QETH_CARD_TYPE_IQD
},
5001 {CCW_DEVICE_DEVTYPE(0x1731, 0x06, 0x1732, 0x06),
5002 .driver_info
= QETH_CARD_TYPE_OSN
},
5003 {CCW_DEVICE_DEVTYPE(0x1731, 0x02, 0x1732, 0x03),
5004 .driver_info
= QETH_CARD_TYPE_OSM
},
5005 {CCW_DEVICE_DEVTYPE(0x1731, 0x02, 0x1732, 0x02),
5006 .driver_info
= QETH_CARD_TYPE_OSX
},
5009 MODULE_DEVICE_TABLE(ccw
, qeth_ids
);
5011 static struct ccw_driver qeth_ccw_driver
= {
5013 .owner
= THIS_MODULE
,
5017 .probe
= ccwgroup_probe_ccwdev
,
5018 .remove
= ccwgroup_remove_ccwdev
,
5021 int qeth_core_hardsetup_card(struct qeth_card
*card
)
5026 QETH_DBF_TEXT(SETUP
, 2, "hrdsetup");
5027 atomic_set(&card
->force_alloc_skb
, 0);
5028 qeth_update_from_chp_desc(card
);
5031 QETH_DBF_MESSAGE(2, "%s Retrying to do IDX activates.\n",
5032 dev_name(&card
->gdev
->dev
));
5033 rc
= qeth_qdio_clear_card(card
, card
->info
.type
!= QETH_CARD_TYPE_IQD
);
5034 ccw_device_set_offline(CARD_DDEV(card
));
5035 ccw_device_set_offline(CARD_WDEV(card
));
5036 ccw_device_set_offline(CARD_RDEV(card
));
5037 qdio_free(CARD_DDEV(card
));
5038 rc
= ccw_device_set_online(CARD_RDEV(card
));
5041 rc
= ccw_device_set_online(CARD_WDEV(card
));
5044 rc
= ccw_device_set_online(CARD_DDEV(card
));
5048 if (rc
== -ERESTARTSYS
) {
5049 QETH_DBF_TEXT(SETUP
, 2, "break1");
5052 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
5058 qeth_determine_capabilities(card
);
5059 qeth_init_tokens(card
);
5060 qeth_init_func_level(card
);
5061 rc
= qeth_idx_activate_channel(&card
->read
, qeth_idx_read_cb
);
5062 if (rc
== -ERESTARTSYS
) {
5063 QETH_DBF_TEXT(SETUP
, 2, "break2");
5066 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
5072 rc
= qeth_idx_activate_channel(&card
->write
, qeth_idx_write_cb
);
5073 if (rc
== -ERESTARTSYS
) {
5074 QETH_DBF_TEXT(SETUP
, 2, "break3");
5077 QETH_DBF_TEXT_(SETUP
, 2, "4err%d", rc
);
5083 card
->read_or_write_problem
= 0;
5084 rc
= qeth_mpc_initialize(card
);
5086 QETH_DBF_TEXT_(SETUP
, 2, "5err%d", rc
);
5090 card
->options
.ipa4
.supported_funcs
= 0;
5091 card
->options
.ipa6
.supported_funcs
= 0;
5092 card
->options
.adp
.supported_funcs
= 0;
5093 card
->options
.sbp
.supported_funcs
= 0;
5094 card
->info
.diagass_support
= 0;
5095 rc
= qeth_query_ipassists(card
, QETH_PROT_IPV4
);
5098 if (qeth_is_supported(card
, IPA_SETADAPTERPARMS
)) {
5099 rc
= qeth_query_setadapterparms(card
);
5101 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
5105 if (qeth_adp_supported(card
, IPA_SETADP_SET_DIAG_ASSIST
)) {
5106 rc
= qeth_query_setdiagass(card
);
5108 QETH_DBF_TEXT_(SETUP
, 2, "7err%d", rc
);
5114 dev_warn(&card
->gdev
->dev
, "The qeth device driver failed to recover "
5115 "an error on the device\n");
5116 QETH_DBF_MESSAGE(2, "%s Initialization in hardsetup failed! rc=%d\n",
5117 dev_name(&card
->gdev
->dev
), rc
);
5120 EXPORT_SYMBOL_GPL(qeth_core_hardsetup_card
);
5122 static inline int qeth_create_skb_frag(struct qeth_qdio_buffer
*qethbuffer
,
5123 struct qdio_buffer_element
*element
,
5124 struct sk_buff
**pskb
, int offset
, int *pfrag
, int data_len
)
5126 struct page
*page
= virt_to_page(element
->addr
);
5127 if (*pskb
== NULL
) {
5128 if (qethbuffer
->rx_skb
) {
5129 /* only if qeth_card.options.cq == QETH_CQ_ENABLED */
5130 *pskb
= qethbuffer
->rx_skb
;
5131 qethbuffer
->rx_skb
= NULL
;
5133 *pskb
= dev_alloc_skb(QETH_RX_PULL_LEN
+ ETH_HLEN
);
5138 skb_reserve(*pskb
, ETH_HLEN
);
5139 if (data_len
<= QETH_RX_PULL_LEN
) {
5140 memcpy(skb_put(*pskb
, data_len
), element
->addr
+ offset
,
5144 memcpy(skb_put(*pskb
, QETH_RX_PULL_LEN
),
5145 element
->addr
+ offset
, QETH_RX_PULL_LEN
);
5146 skb_fill_page_desc(*pskb
, *pfrag
, page
,
5147 offset
+ QETH_RX_PULL_LEN
,
5148 data_len
- QETH_RX_PULL_LEN
);
5149 (*pskb
)->data_len
+= data_len
- QETH_RX_PULL_LEN
;
5150 (*pskb
)->len
+= data_len
- QETH_RX_PULL_LEN
;
5151 (*pskb
)->truesize
+= data_len
- QETH_RX_PULL_LEN
;
5156 skb_fill_page_desc(*pskb
, *pfrag
, page
, offset
, data_len
);
5157 (*pskb
)->data_len
+= data_len
;
5158 (*pskb
)->len
+= data_len
;
5159 (*pskb
)->truesize
+= data_len
;
5167 static inline int qeth_is_last_sbale(struct qdio_buffer_element
*sbale
)
5169 return (sbale
->eflags
& SBAL_EFLAGS_LAST_ENTRY
);
5172 struct sk_buff
*qeth_core_get_next_skb(struct qeth_card
*card
,
5173 struct qeth_qdio_buffer
*qethbuffer
,
5174 struct qdio_buffer_element
**__element
, int *__offset
,
5175 struct qeth_hdr
**hdr
)
5177 struct qdio_buffer_element
*element
= *__element
;
5178 struct qdio_buffer
*buffer
= qethbuffer
->buffer
;
5179 int offset
= *__offset
;
5180 struct sk_buff
*skb
= NULL
;
5188 /* qeth_hdr must not cross element boundaries */
5189 if (element
->length
< offset
+ sizeof(struct qeth_hdr
)) {
5190 if (qeth_is_last_sbale(element
))
5194 if (element
->length
< sizeof(struct qeth_hdr
))
5197 *hdr
= element
->addr
+ offset
;
5199 offset
+= sizeof(struct qeth_hdr
);
5200 switch ((*hdr
)->hdr
.l2
.id
) {
5201 case QETH_HEADER_TYPE_LAYER2
:
5202 skb_len
= (*hdr
)->hdr
.l2
.pkt_length
;
5204 case QETH_HEADER_TYPE_LAYER3
:
5205 skb_len
= (*hdr
)->hdr
.l3
.length
;
5206 headroom
= ETH_HLEN
;
5208 case QETH_HEADER_TYPE_OSN
:
5209 skb_len
= (*hdr
)->hdr
.osn
.pdu_length
;
5210 headroom
= sizeof(struct qeth_hdr
);
5219 if (((skb_len
>= card
->options
.rx_sg_cb
) &&
5220 (!(card
->info
.type
== QETH_CARD_TYPE_OSN
)) &&
5221 (!atomic_read(&card
->force_alloc_skb
))) ||
5222 (card
->options
.cq
== QETH_CQ_ENABLED
)) {
5225 skb
= dev_alloc_skb(skb_len
+ headroom
);
5229 skb_reserve(skb
, headroom
);
5232 data_ptr
= element
->addr
+ offset
;
5234 data_len
= min(skb_len
, (int)(element
->length
- offset
));
5237 if (qeth_create_skb_frag(qethbuffer
, element
,
5238 &skb
, offset
, &frag
, data_len
))
5241 memcpy(skb_put(skb
, data_len
), data_ptr
,
5245 skb_len
-= data_len
;
5247 if (qeth_is_last_sbale(element
)) {
5248 QETH_CARD_TEXT(card
, 4, "unexeob");
5249 QETH_CARD_HEX(card
, 2, buffer
, sizeof(void *));
5250 dev_kfree_skb_any(skb
);
5251 card
->stats
.rx_errors
++;
5256 data_ptr
= element
->addr
;
5261 *__element
= element
;
5263 if (use_rx_sg
&& card
->options
.performance_stats
) {
5264 card
->perf_stats
.sg_skbs_rx
++;
5265 card
->perf_stats
.sg_frags_rx
+= skb_shinfo(skb
)->nr_frags
;
5269 if (net_ratelimit()) {
5270 QETH_CARD_TEXT(card
, 2, "noskbmem");
5272 card
->stats
.rx_dropped
++;
5275 EXPORT_SYMBOL_GPL(qeth_core_get_next_skb
);
5277 int qeth_setassparms_cb(struct qeth_card
*card
,
5278 struct qeth_reply
*reply
, unsigned long data
)
5280 struct qeth_ipa_cmd
*cmd
;
5282 QETH_CARD_TEXT(card
, 4, "defadpcb");
5284 cmd
= (struct qeth_ipa_cmd
*) data
;
5285 if (cmd
->hdr
.return_code
== 0) {
5286 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
5287 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
5288 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
5289 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
5290 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
5292 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
5293 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
5294 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
5295 QETH_CARD_TEXT_(card
, 3, "csum:%d", card
->info
.csum_mask
);
5297 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_OUTBOUND_CHECKSUM
&&
5298 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
5299 card
->info
.tx_csum_mask
=
5300 cmd
->data
.setassparms
.data
.flags_32bit
;
5301 QETH_CARD_TEXT_(card
, 3, "tcsu:%d", card
->info
.tx_csum_mask
);
5306 EXPORT_SYMBOL_GPL(qeth_setassparms_cb
);
5308 struct qeth_cmd_buffer
*qeth_get_setassparms_cmd(struct qeth_card
*card
,
5309 enum qeth_ipa_funcs ipa_func
,
5310 __u16 cmd_code
, __u16 len
,
5311 enum qeth_prot_versions prot
)
5313 struct qeth_cmd_buffer
*iob
;
5314 struct qeth_ipa_cmd
*cmd
;
5316 QETH_CARD_TEXT(card
, 4, "getasscm");
5317 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETASSPARMS
, prot
);
5320 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5321 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
5322 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
5323 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
5324 cmd
->data
.setassparms
.hdr
.return_code
= 0;
5325 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
5330 EXPORT_SYMBOL_GPL(qeth_get_setassparms_cmd
);
5332 int qeth_send_setassparms(struct qeth_card
*card
,
5333 struct qeth_cmd_buffer
*iob
, __u16 len
, long data
,
5334 int (*reply_cb
)(struct qeth_card
*,
5335 struct qeth_reply
*, unsigned long),
5339 struct qeth_ipa_cmd
*cmd
;
5341 QETH_CARD_TEXT(card
, 4, "sendassp");
5343 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5344 if (len
<= sizeof(__u32
))
5345 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
5346 else /* (len > sizeof(__u32)) */
5347 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
5349 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
5352 EXPORT_SYMBOL_GPL(qeth_send_setassparms
);
5354 int qeth_send_simple_setassparms(struct qeth_card
*card
,
5355 enum qeth_ipa_funcs ipa_func
,
5356 __u16 cmd_code
, long data
)
5360 struct qeth_cmd_buffer
*iob
;
5362 QETH_CARD_TEXT(card
, 4, "simassp4");
5364 length
= sizeof(__u32
);
5365 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
5366 length
, QETH_PROT_IPV4
);
5369 rc
= qeth_send_setassparms(card
, iob
, length
, data
,
5370 qeth_setassparms_cb
, NULL
);
5373 EXPORT_SYMBOL_GPL(qeth_send_simple_setassparms
);
5375 static void qeth_unregister_dbf_views(void)
5378 for (x
= 0; x
< QETH_DBF_INFOS
; x
++) {
5379 debug_unregister(qeth_dbf
[x
].id
);
5380 qeth_dbf
[x
].id
= NULL
;
5384 void qeth_dbf_longtext(debug_info_t
*id
, int level
, char *fmt
, ...)
5386 char dbf_txt_buf
[32];
5389 if (!debug_level_enabled(id
, level
))
5391 va_start(args
, fmt
);
5392 vsnprintf(dbf_txt_buf
, sizeof(dbf_txt_buf
), fmt
, args
);
5394 debug_text_event(id
, level
, dbf_txt_buf
);
5396 EXPORT_SYMBOL_GPL(qeth_dbf_longtext
);
5398 static int qeth_register_dbf_views(void)
5403 for (x
= 0; x
< QETH_DBF_INFOS
; x
++) {
5404 /* register the areas */
5405 qeth_dbf
[x
].id
= debug_register(qeth_dbf
[x
].name
,
5409 if (qeth_dbf
[x
].id
== NULL
) {
5410 qeth_unregister_dbf_views();
5414 /* register a view */
5415 ret
= debug_register_view(qeth_dbf
[x
].id
, qeth_dbf
[x
].view
);
5417 qeth_unregister_dbf_views();
5421 /* set a passing level */
5422 debug_set_level(qeth_dbf
[x
].id
, qeth_dbf
[x
].level
);
5428 int qeth_core_load_discipline(struct qeth_card
*card
,
5429 enum qeth_discipline_id discipline
)
5432 mutex_lock(&qeth_mod_mutex
);
5433 switch (discipline
) {
5434 case QETH_DISCIPLINE_LAYER3
:
5435 card
->discipline
= try_then_request_module(
5436 symbol_get(qeth_l3_discipline
), "qeth_l3");
5438 case QETH_DISCIPLINE_LAYER2
:
5439 card
->discipline
= try_then_request_module(
5440 symbol_get(qeth_l2_discipline
), "qeth_l2");
5443 if (!card
->discipline
) {
5444 dev_err(&card
->gdev
->dev
, "There is no kernel module to "
5445 "support discipline %d\n", discipline
);
5448 mutex_unlock(&qeth_mod_mutex
);
5452 void qeth_core_free_discipline(struct qeth_card
*card
)
5454 if (card
->options
.layer2
)
5455 symbol_put(qeth_l2_discipline
);
5457 symbol_put(qeth_l3_discipline
);
5458 card
->discipline
= NULL
;
5461 static const struct device_type qeth_generic_devtype
= {
5462 .name
= "qeth_generic",
5463 .groups
= qeth_generic_attr_groups
,
5465 static const struct device_type qeth_osn_devtype
= {
5467 .groups
= qeth_osn_attr_groups
,
5470 #define DBF_NAME_LEN 20
5472 struct qeth_dbf_entry
{
5473 char dbf_name
[DBF_NAME_LEN
];
5474 debug_info_t
*dbf_info
;
5475 struct list_head dbf_list
;
5478 static LIST_HEAD(qeth_dbf_list
);
5479 static DEFINE_MUTEX(qeth_dbf_list_mutex
);
5481 static debug_info_t
*qeth_get_dbf_entry(char *name
)
5483 struct qeth_dbf_entry
*entry
;
5484 debug_info_t
*rc
= NULL
;
5486 mutex_lock(&qeth_dbf_list_mutex
);
5487 list_for_each_entry(entry
, &qeth_dbf_list
, dbf_list
) {
5488 if (strcmp(entry
->dbf_name
, name
) == 0) {
5489 rc
= entry
->dbf_info
;
5493 mutex_unlock(&qeth_dbf_list_mutex
);
5497 static int qeth_add_dbf_entry(struct qeth_card
*card
, char *name
)
5499 struct qeth_dbf_entry
*new_entry
;
5501 card
->debug
= debug_register(name
, 2, 1, 8);
5503 QETH_DBF_TEXT_(SETUP
, 2, "%s", "qcdbf");
5506 if (debug_register_view(card
->debug
, &debug_hex_ascii_view
))
5508 new_entry
= kzalloc(sizeof(struct qeth_dbf_entry
), GFP_KERNEL
);
5511 strncpy(new_entry
->dbf_name
, name
, DBF_NAME_LEN
);
5512 new_entry
->dbf_info
= card
->debug
;
5513 mutex_lock(&qeth_dbf_list_mutex
);
5514 list_add(&new_entry
->dbf_list
, &qeth_dbf_list
);
5515 mutex_unlock(&qeth_dbf_list_mutex
);
5520 debug_unregister(card
->debug
);
5525 static void qeth_clear_dbf_list(void)
5527 struct qeth_dbf_entry
*entry
, *tmp
;
5529 mutex_lock(&qeth_dbf_list_mutex
);
5530 list_for_each_entry_safe(entry
, tmp
, &qeth_dbf_list
, dbf_list
) {
5531 list_del(&entry
->dbf_list
);
5532 debug_unregister(entry
->dbf_info
);
5535 mutex_unlock(&qeth_dbf_list_mutex
);
5538 static int qeth_core_probe_device(struct ccwgroup_device
*gdev
)
5540 struct qeth_card
*card
;
5543 unsigned long flags
;
5544 char dbf_name
[DBF_NAME_LEN
];
5546 QETH_DBF_TEXT(SETUP
, 2, "probedev");
5549 if (!get_device(dev
))
5552 QETH_DBF_TEXT_(SETUP
, 2, "%s", dev_name(&gdev
->dev
));
5554 card
= qeth_alloc_card();
5556 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", -ENOMEM
);
5561 snprintf(dbf_name
, sizeof(dbf_name
), "qeth_card_%s",
5562 dev_name(&gdev
->dev
));
5563 card
->debug
= qeth_get_dbf_entry(dbf_name
);
5565 rc
= qeth_add_dbf_entry(card
, dbf_name
);
5570 card
->read
.ccwdev
= gdev
->cdev
[0];
5571 card
->write
.ccwdev
= gdev
->cdev
[1];
5572 card
->data
.ccwdev
= gdev
->cdev
[2];
5573 dev_set_drvdata(&gdev
->dev
, card
);
5575 gdev
->cdev
[0]->handler
= qeth_irq
;
5576 gdev
->cdev
[1]->handler
= qeth_irq
;
5577 gdev
->cdev
[2]->handler
= qeth_irq
;
5579 rc
= qeth_determine_card_type(card
);
5581 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
5584 rc
= qeth_setup_card(card
);
5586 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
5590 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
5591 gdev
->dev
.type
= &qeth_osn_devtype
;
5593 gdev
->dev
.type
= &qeth_generic_devtype
;
5595 switch (card
->info
.type
) {
5596 case QETH_CARD_TYPE_OSN
:
5597 case QETH_CARD_TYPE_OSM
:
5598 rc
= qeth_core_load_discipline(card
, QETH_DISCIPLINE_LAYER2
);
5601 rc
= card
->discipline
->setup(card
->gdev
);
5604 case QETH_CARD_TYPE_OSD
:
5605 case QETH_CARD_TYPE_OSX
:
5610 write_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
5611 list_add_tail(&card
->list
, &qeth_core_card_list
.list
);
5612 write_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
5614 qeth_determine_capabilities(card
);
5618 qeth_core_free_discipline(card
);
5620 qeth_core_free_card(card
);
5626 static void qeth_core_remove_device(struct ccwgroup_device
*gdev
)
5628 unsigned long flags
;
5629 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5631 QETH_DBF_TEXT(SETUP
, 2, "removedv");
5633 if (card
->discipline
) {
5634 card
->discipline
->remove(gdev
);
5635 qeth_core_free_discipline(card
);
5638 write_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
5639 list_del(&card
->list
);
5640 write_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
5641 qeth_core_free_card(card
);
5642 dev_set_drvdata(&gdev
->dev
, NULL
);
5643 put_device(&gdev
->dev
);
5647 static int qeth_core_set_online(struct ccwgroup_device
*gdev
)
5649 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5653 if (!card
->discipline
) {
5654 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
5655 def_discipline
= QETH_DISCIPLINE_LAYER3
;
5657 def_discipline
= QETH_DISCIPLINE_LAYER2
;
5658 rc
= qeth_core_load_discipline(card
, def_discipline
);
5661 rc
= card
->discipline
->setup(card
->gdev
);
5665 rc
= card
->discipline
->set_online(gdev
);
5670 static int qeth_core_set_offline(struct ccwgroup_device
*gdev
)
5672 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5673 return card
->discipline
->set_offline(gdev
);
5676 static void qeth_core_shutdown(struct ccwgroup_device
*gdev
)
5678 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5679 if (card
->discipline
&& card
->discipline
->shutdown
)
5680 card
->discipline
->shutdown(gdev
);
5683 static int qeth_core_prepare(struct ccwgroup_device
*gdev
)
5685 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5686 if (card
->discipline
&& card
->discipline
->prepare
)
5687 return card
->discipline
->prepare(gdev
);
5691 static void qeth_core_complete(struct ccwgroup_device
*gdev
)
5693 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5694 if (card
->discipline
&& card
->discipline
->complete
)
5695 card
->discipline
->complete(gdev
);
5698 static int qeth_core_freeze(struct ccwgroup_device
*gdev
)
5700 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5701 if (card
->discipline
&& card
->discipline
->freeze
)
5702 return card
->discipline
->freeze(gdev
);
5706 static int qeth_core_thaw(struct ccwgroup_device
*gdev
)
5708 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5709 if (card
->discipline
&& card
->discipline
->thaw
)
5710 return card
->discipline
->thaw(gdev
);
5714 static int qeth_core_restore(struct ccwgroup_device
*gdev
)
5716 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
5717 if (card
->discipline
&& card
->discipline
->restore
)
5718 return card
->discipline
->restore(gdev
);
5722 static struct ccwgroup_driver qeth_core_ccwgroup_driver
= {
5724 .owner
= THIS_MODULE
,
5727 .setup
= qeth_core_probe_device
,
5728 .remove
= qeth_core_remove_device
,
5729 .set_online
= qeth_core_set_online
,
5730 .set_offline
= qeth_core_set_offline
,
5731 .shutdown
= qeth_core_shutdown
,
5732 .prepare
= qeth_core_prepare
,
5733 .complete
= qeth_core_complete
,
5734 .freeze
= qeth_core_freeze
,
5735 .thaw
= qeth_core_thaw
,
5736 .restore
= qeth_core_restore
,
5739 static ssize_t
qeth_core_driver_group_store(struct device_driver
*ddrv
,
5740 const char *buf
, size_t count
)
5744 err
= ccwgroup_create_dev(qeth_core_root_dev
,
5745 &qeth_core_ccwgroup_driver
, 3, buf
);
5747 return err
? err
: count
;
5749 static DRIVER_ATTR(group
, 0200, NULL
, qeth_core_driver_group_store
);
5751 static struct attribute
*qeth_drv_attrs
[] = {
5752 &driver_attr_group
.attr
,
5755 static struct attribute_group qeth_drv_attr_group
= {
5756 .attrs
= qeth_drv_attrs
,
5758 static const struct attribute_group
*qeth_drv_attr_groups
[] = {
5759 &qeth_drv_attr_group
,
5764 const char str
[ETH_GSTRING_LEN
];
5765 } qeth_ethtool_stats_keys
[] = {
5770 {"tx skbs no packing"},
5771 {"tx buffers no packing"},
5772 {"tx skbs packing"},
5773 {"tx buffers packing"},
5776 /* 10 */{"rx sg skbs"},
5778 {"rx sg page allocs"},
5779 {"tx large kbytes"},
5781 {"tx pk state ch n->p"},
5782 {"tx pk state ch p->n"},
5783 {"tx pk watermark low"},
5784 {"tx pk watermark high"},
5785 {"queue 0 buffer usage"},
5786 /* 20 */{"queue 1 buffer usage"},
5787 {"queue 2 buffer usage"},
5788 {"queue 3 buffer usage"},
5791 {"rx do_QDIO time"},
5792 {"rx do_QDIO count"},
5793 {"tx handler time"},
5794 {"tx handler count"},
5796 /* 30 */{"tx count"},
5797 {"tx do_QDIO time"},
5798 {"tx do_QDIO count"},
5802 {"cq handler count"},
5806 int qeth_core_get_sset_count(struct net_device
*dev
, int stringset
)
5808 switch (stringset
) {
5810 return (sizeof(qeth_ethtool_stats_keys
) / ETH_GSTRING_LEN
);
5815 EXPORT_SYMBOL_GPL(qeth_core_get_sset_count
);
5817 void qeth_core_get_ethtool_stats(struct net_device
*dev
,
5818 struct ethtool_stats
*stats
, u64
*data
)
5820 struct qeth_card
*card
= dev
->ml_priv
;
5821 data
[0] = card
->stats
.rx_packets
-
5822 card
->perf_stats
.initial_rx_packets
;
5823 data
[1] = card
->perf_stats
.bufs_rec
;
5824 data
[2] = card
->stats
.tx_packets
-
5825 card
->perf_stats
.initial_tx_packets
;
5826 data
[3] = card
->perf_stats
.bufs_sent
;
5827 data
[4] = card
->stats
.tx_packets
- card
->perf_stats
.initial_tx_packets
5828 - card
->perf_stats
.skbs_sent_pack
;
5829 data
[5] = card
->perf_stats
.bufs_sent
- card
->perf_stats
.bufs_sent_pack
;
5830 data
[6] = card
->perf_stats
.skbs_sent_pack
;
5831 data
[7] = card
->perf_stats
.bufs_sent_pack
;
5832 data
[8] = card
->perf_stats
.sg_skbs_sent
;
5833 data
[9] = card
->perf_stats
.sg_frags_sent
;
5834 data
[10] = card
->perf_stats
.sg_skbs_rx
;
5835 data
[11] = card
->perf_stats
.sg_frags_rx
;
5836 data
[12] = card
->perf_stats
.sg_alloc_page_rx
;
5837 data
[13] = (card
->perf_stats
.large_send_bytes
>> 10);
5838 data
[14] = card
->perf_stats
.large_send_cnt
;
5839 data
[15] = card
->perf_stats
.sc_dp_p
;
5840 data
[16] = card
->perf_stats
.sc_p_dp
;
5841 data
[17] = QETH_LOW_WATERMARK_PACK
;
5842 data
[18] = QETH_HIGH_WATERMARK_PACK
;
5843 data
[19] = atomic_read(&card
->qdio
.out_qs
[0]->used_buffers
);
5844 data
[20] = (card
->qdio
.no_out_queues
> 1) ?
5845 atomic_read(&card
->qdio
.out_qs
[1]->used_buffers
) : 0;
5846 data
[21] = (card
->qdio
.no_out_queues
> 2) ?
5847 atomic_read(&card
->qdio
.out_qs
[2]->used_buffers
) : 0;
5848 data
[22] = (card
->qdio
.no_out_queues
> 3) ?
5849 atomic_read(&card
->qdio
.out_qs
[3]->used_buffers
) : 0;
5850 data
[23] = card
->perf_stats
.inbound_time
;
5851 data
[24] = card
->perf_stats
.inbound_cnt
;
5852 data
[25] = card
->perf_stats
.inbound_do_qdio_time
;
5853 data
[26] = card
->perf_stats
.inbound_do_qdio_cnt
;
5854 data
[27] = card
->perf_stats
.outbound_handler_time
;
5855 data
[28] = card
->perf_stats
.outbound_handler_cnt
;
5856 data
[29] = card
->perf_stats
.outbound_time
;
5857 data
[30] = card
->perf_stats
.outbound_cnt
;
5858 data
[31] = card
->perf_stats
.outbound_do_qdio_time
;
5859 data
[32] = card
->perf_stats
.outbound_do_qdio_cnt
;
5860 data
[33] = card
->perf_stats
.tx_csum
;
5861 data
[34] = card
->perf_stats
.tx_lin
;
5862 data
[35] = card
->perf_stats
.tx_linfail
;
5863 data
[36] = card
->perf_stats
.cq_cnt
;
5864 data
[37] = card
->perf_stats
.cq_time
;
5866 EXPORT_SYMBOL_GPL(qeth_core_get_ethtool_stats
);
5868 void qeth_core_get_strings(struct net_device
*dev
, u32 stringset
, u8
*data
)
5870 switch (stringset
) {
5872 memcpy(data
, &qeth_ethtool_stats_keys
,
5873 sizeof(qeth_ethtool_stats_keys
));
5880 EXPORT_SYMBOL_GPL(qeth_core_get_strings
);
5882 void qeth_core_get_drvinfo(struct net_device
*dev
,
5883 struct ethtool_drvinfo
*info
)
5885 struct qeth_card
*card
= dev
->ml_priv
;
5887 strlcpy(info
->driver
, card
->options
.layer2
? "qeth_l2" : "qeth_l3",
5888 sizeof(info
->driver
));
5889 strlcpy(info
->version
, "1.0", sizeof(info
->version
));
5890 strlcpy(info
->fw_version
, card
->info
.mcl_level
,
5891 sizeof(info
->fw_version
));
5892 snprintf(info
->bus_info
, sizeof(info
->bus_info
), "%s/%s/%s",
5893 CARD_RDEV_ID(card
), CARD_WDEV_ID(card
), CARD_DDEV_ID(card
));
5895 EXPORT_SYMBOL_GPL(qeth_core_get_drvinfo
);
5897 /* Helper function to fill 'advertizing' and 'supported' which are the same. */
5898 /* Autoneg and full-duplex are supported and advertized uncondionally. */
5899 /* Always advertize and support all speeds up to specified, and only one */
5900 /* specified port type. */
5901 static void qeth_set_ecmd_adv_sup(struct ethtool_cmd
*ecmd
,
5902 int maxspeed
, int porttype
)
5904 int port_sup
, port_adv
, spd_sup
, spd_adv
;
5908 port_sup
= SUPPORTED_TP
;
5909 port_adv
= ADVERTISED_TP
;
5912 port_sup
= SUPPORTED_FIBRE
;
5913 port_adv
= ADVERTISED_FIBRE
;
5916 port_sup
= SUPPORTED_TP
;
5917 port_adv
= ADVERTISED_TP
;
5921 /* "Fallthrough" case'es ordered from high to low result in setting */
5922 /* flags cumulatively, starting from the specified speed and down to */
5923 /* the lowest possible. */
5928 spd_sup
|= SUPPORTED_10000baseT_Full
;
5929 spd_adv
|= ADVERTISED_10000baseT_Full
;
5931 spd_sup
|= SUPPORTED_1000baseT_Half
| SUPPORTED_1000baseT_Full
;
5932 spd_adv
|= ADVERTISED_1000baseT_Half
|
5933 ADVERTISED_1000baseT_Full
;
5935 spd_sup
|= SUPPORTED_100baseT_Half
| SUPPORTED_100baseT_Full
;
5936 spd_adv
|= ADVERTISED_100baseT_Half
| ADVERTISED_100baseT_Full
;
5938 spd_sup
|= SUPPORTED_10baseT_Half
| SUPPORTED_10baseT_Full
;
5939 spd_adv
|= ADVERTISED_10baseT_Half
| ADVERTISED_10baseT_Full
;
5942 spd_sup
= SUPPORTED_10baseT_Half
| SUPPORTED_10baseT_Full
;
5943 spd_adv
= ADVERTISED_10baseT_Half
| ADVERTISED_10baseT_Full
;
5946 ecmd
->advertising
= ADVERTISED_Autoneg
| port_adv
| spd_adv
;
5947 ecmd
->supported
= SUPPORTED_Autoneg
| port_sup
| spd_sup
;
5950 int qeth_core_ethtool_get_settings(struct net_device
*netdev
,
5951 struct ethtool_cmd
*ecmd
)
5953 struct qeth_card
*card
= netdev
->ml_priv
;
5954 enum qeth_link_types link_type
;
5955 struct carrier_info carrier_info
;
5959 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) || (card
->info
.guestlan
))
5960 link_type
= QETH_LINK_TYPE_10GBIT_ETH
;
5962 link_type
= card
->info
.link_type
;
5964 ecmd
->transceiver
= XCVR_INTERNAL
;
5965 ecmd
->duplex
= DUPLEX_FULL
;
5966 ecmd
->autoneg
= AUTONEG_ENABLE
;
5968 switch (link_type
) {
5969 case QETH_LINK_TYPE_FAST_ETH
:
5970 case QETH_LINK_TYPE_LANE_ETH100
:
5971 qeth_set_ecmd_adv_sup(ecmd
, SPEED_100
, PORT_TP
);
5973 ecmd
->port
= PORT_TP
;
5976 case QETH_LINK_TYPE_GBIT_ETH
:
5977 case QETH_LINK_TYPE_LANE_ETH1000
:
5978 qeth_set_ecmd_adv_sup(ecmd
, SPEED_1000
, PORT_FIBRE
);
5980 ecmd
->port
= PORT_FIBRE
;
5983 case QETH_LINK_TYPE_10GBIT_ETH
:
5984 qeth_set_ecmd_adv_sup(ecmd
, SPEED_10000
, PORT_FIBRE
);
5985 speed
= SPEED_10000
;
5986 ecmd
->port
= PORT_FIBRE
;
5990 qeth_set_ecmd_adv_sup(ecmd
, SPEED_10
, PORT_TP
);
5992 ecmd
->port
= PORT_TP
;
5994 ethtool_cmd_speed_set(ecmd
, speed
);
5996 /* Check if we can obtain more accurate information. */
5997 /* If QUERY_CARD_INFO command is not supported or fails, */
5998 /* just return the heuristics that was filled above. */
5999 if (!qeth_card_hw_is_reachable(card
))
6001 rc
= qeth_query_card_info(card
, &carrier_info
);
6002 if (rc
== -EOPNOTSUPP
) /* for old hardware, return heuristic */
6004 if (rc
) /* report error from the hardware operation */
6006 /* on success, fill in the information got from the hardware */
6009 "card info: card_type=0x%02x, port_mode=0x%04x, port_speed=0x%08x\n",
6010 carrier_info
.card_type
,
6011 carrier_info
.port_mode
,
6012 carrier_info
.port_speed
);
6014 /* Update attributes for which we've obtained more authoritative */
6015 /* information, leave the rest the way they where filled above. */
6016 switch (carrier_info
.card_type
) {
6017 case CARD_INFO_TYPE_1G_COPPER_A
:
6018 case CARD_INFO_TYPE_1G_COPPER_B
:
6019 qeth_set_ecmd_adv_sup(ecmd
, SPEED_1000
, PORT_TP
);
6020 ecmd
->port
= PORT_TP
;
6022 case CARD_INFO_TYPE_1G_FIBRE_A
:
6023 case CARD_INFO_TYPE_1G_FIBRE_B
:
6024 qeth_set_ecmd_adv_sup(ecmd
, SPEED_1000
, PORT_FIBRE
);
6025 ecmd
->port
= PORT_FIBRE
;
6027 case CARD_INFO_TYPE_10G_FIBRE_A
:
6028 case CARD_INFO_TYPE_10G_FIBRE_B
:
6029 qeth_set_ecmd_adv_sup(ecmd
, SPEED_10000
, PORT_FIBRE
);
6030 ecmd
->port
= PORT_FIBRE
;
6034 switch (carrier_info
.port_mode
) {
6035 case CARD_INFO_PORTM_FULLDUPLEX
:
6036 ecmd
->duplex
= DUPLEX_FULL
;
6038 case CARD_INFO_PORTM_HALFDUPLEX
:
6039 ecmd
->duplex
= DUPLEX_HALF
;
6043 switch (carrier_info
.port_speed
) {
6044 case CARD_INFO_PORTS_10M
:
6047 case CARD_INFO_PORTS_100M
:
6050 case CARD_INFO_PORTS_1G
:
6053 case CARD_INFO_PORTS_10G
:
6054 speed
= SPEED_10000
;
6057 ethtool_cmd_speed_set(ecmd
, speed
);
6061 EXPORT_SYMBOL_GPL(qeth_core_ethtool_get_settings
);
6063 static int qeth_send_checksum_on(struct qeth_card
*card
, int cstype
)
6068 rc
= qeth_send_simple_setassparms(card
, cstype
, IPA_CMD_ASS_START
, 0);
6070 dev_warn(&card
->gdev
->dev
,
6071 "Starting HW checksumming for %s failed, using SW checksumming\n",
6072 QETH_CARD_IFNAME(card
));
6075 rxtx_arg
= (cstype
== IPA_OUTBOUND_CHECKSUM
) ? card
->info
.tx_csum_mask
6076 : card
->info
.csum_mask
;
6077 rc
= qeth_send_simple_setassparms(card
, cstype
, IPA_CMD_ASS_ENABLE
,
6080 dev_warn(&card
->gdev
->dev
,
6081 "Enabling HW checksumming for %s failed, using SW checksumming\n",
6082 QETH_CARD_IFNAME(card
));
6086 dev_info(&card
->gdev
->dev
, "HW Checksumming (%sbound) enabled\n",
6087 cstype
== IPA_INBOUND_CHECKSUM
? "in" : "out");
6091 static int qeth_set_ipa_csum(struct qeth_card
*card
, int on
, int cstype
)
6096 rc
= qeth_send_checksum_on(card
, cstype
);
6100 rc
= qeth_send_simple_setassparms(card
, cstype
,
6101 IPA_CMD_ASS_STOP
, 0);
6108 static int qeth_set_ipa_tso(struct qeth_card
*card
, int on
)
6112 QETH_CARD_TEXT(card
, 3, "sttso");
6115 rc
= qeth_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
6116 IPA_CMD_ASS_START
, 0);
6118 dev_warn(&card
->gdev
->dev
,
6119 "Starting outbound TCP segmentation offload for %s failed\n",
6120 QETH_CARD_IFNAME(card
));
6123 dev_info(&card
->gdev
->dev
, "Outbound TSO enabled\n");
6125 rc
= qeth_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
6126 IPA_CMD_ASS_STOP
, 0);
6131 /* try to restore device features on a device after recovery */
6132 int qeth_recover_features(struct net_device
*dev
)
6134 struct qeth_card
*card
= dev
->ml_priv
;
6135 netdev_features_t recover
= dev
->features
;
6137 if (recover
& NETIF_F_IP_CSUM
) {
6138 if (qeth_set_ipa_csum(card
, 1, IPA_OUTBOUND_CHECKSUM
))
6139 recover
^= NETIF_F_IP_CSUM
;
6141 if (recover
& NETIF_F_RXCSUM
) {
6142 if (qeth_set_ipa_csum(card
, 1, IPA_INBOUND_CHECKSUM
))
6143 recover
^= NETIF_F_RXCSUM
;
6145 if (recover
& NETIF_F_TSO
) {
6146 if (qeth_set_ipa_tso(card
, 1))
6147 recover
^= NETIF_F_TSO
;
6150 if (recover
== dev
->features
)
6153 dev_warn(&card
->gdev
->dev
,
6154 "Device recovery failed to restore all offload features\n");
6155 dev
->features
= recover
;
6158 EXPORT_SYMBOL_GPL(qeth_recover_features
);
6160 int qeth_set_features(struct net_device
*dev
, netdev_features_t features
)
6162 struct qeth_card
*card
= dev
->ml_priv
;
6163 netdev_features_t changed
= dev
->features
^ features
;
6166 QETH_DBF_TEXT(SETUP
, 2, "setfeat");
6167 QETH_DBF_HEX(SETUP
, 2, &features
, sizeof(features
));
6169 if ((changed
& NETIF_F_IP_CSUM
)) {
6170 rc
= qeth_set_ipa_csum(card
,
6171 features
& NETIF_F_IP_CSUM
? 1 : 0,
6172 IPA_OUTBOUND_CHECKSUM
);
6174 changed
^= NETIF_F_IP_CSUM
;
6176 if ((changed
& NETIF_F_RXCSUM
)) {
6177 rc
= qeth_set_ipa_csum(card
,
6178 features
& NETIF_F_RXCSUM
? 1 : 0,
6179 IPA_INBOUND_CHECKSUM
);
6181 changed
^= NETIF_F_RXCSUM
;
6183 if ((changed
& NETIF_F_TSO
)) {
6184 rc
= qeth_set_ipa_tso(card
, features
& NETIF_F_TSO
? 1 : 0);
6186 changed
^= NETIF_F_TSO
;
6189 /* everything changed successfully? */
6190 if ((dev
->features
^ features
) == changed
)
6192 /* something went wrong. save changed features and return error */
6193 dev
->features
^= changed
;
6196 EXPORT_SYMBOL_GPL(qeth_set_features
);
6198 netdev_features_t
qeth_fix_features(struct net_device
*dev
,
6199 netdev_features_t features
)
6201 struct qeth_card
*card
= dev
->ml_priv
;
6203 QETH_DBF_TEXT(SETUP
, 2, "fixfeat");
6204 if (!qeth_is_supported(card
, IPA_OUTBOUND_CHECKSUM
))
6205 features
&= ~NETIF_F_IP_CSUM
;
6206 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
))
6207 features
&= ~NETIF_F_RXCSUM
;
6208 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
6209 features
&= ~NETIF_F_TSO
;
6210 dev_info(&card
->gdev
->dev
, "Outbound TSO not supported on %s\n",
6211 QETH_CARD_IFNAME(card
));
6213 /* if the card isn't up, remove features that require hw changes */
6214 if (card
->state
== CARD_STATE_DOWN
||
6215 card
->state
== CARD_STATE_RECOVER
)
6216 features
= features
& ~(NETIF_F_IP_CSUM
| NETIF_F_RXCSUM
|
6218 QETH_DBF_HEX(SETUP
, 2, &features
, sizeof(features
));
6221 EXPORT_SYMBOL_GPL(qeth_fix_features
);
6223 static int __init
qeth_core_init(void)
6227 pr_info("loading core functions\n");
6228 INIT_LIST_HEAD(&qeth_core_card_list
.list
);
6229 INIT_LIST_HEAD(&qeth_dbf_list
);
6230 rwlock_init(&qeth_core_card_list
.rwlock
);
6231 mutex_init(&qeth_mod_mutex
);
6233 qeth_wq
= create_singlethread_workqueue("qeth_wq");
6235 rc
= qeth_register_dbf_views();
6238 qeth_core_root_dev
= root_device_register("qeth");
6239 rc
= PTR_ERR_OR_ZERO(qeth_core_root_dev
);
6242 qeth_core_header_cache
= kmem_cache_create("qeth_hdr",
6243 sizeof(struct qeth_hdr
) + ETH_HLEN
, 64, 0, NULL
);
6244 if (!qeth_core_header_cache
) {
6248 qeth_qdio_outbuf_cache
= kmem_cache_create("qeth_buf",
6249 sizeof(struct qeth_qdio_out_buffer
), 0, 0, NULL
);
6250 if (!qeth_qdio_outbuf_cache
) {
6254 rc
= ccw_driver_register(&qeth_ccw_driver
);
6257 qeth_core_ccwgroup_driver
.driver
.groups
= qeth_drv_attr_groups
;
6258 rc
= ccwgroup_driver_register(&qeth_core_ccwgroup_driver
);
6265 ccw_driver_unregister(&qeth_ccw_driver
);
6267 kmem_cache_destroy(qeth_qdio_outbuf_cache
);
6269 kmem_cache_destroy(qeth_core_header_cache
);
6271 root_device_unregister(qeth_core_root_dev
);
6273 qeth_unregister_dbf_views();
6275 pr_err("Initializing the qeth device driver failed\n");
6279 static void __exit
qeth_core_exit(void)
6281 qeth_clear_dbf_list();
6282 destroy_workqueue(qeth_wq
);
6283 ccwgroup_driver_unregister(&qeth_core_ccwgroup_driver
);
6284 ccw_driver_unregister(&qeth_ccw_driver
);
6285 kmem_cache_destroy(qeth_qdio_outbuf_cache
);
6286 kmem_cache_destroy(qeth_core_header_cache
);
6287 root_device_unregister(qeth_core_root_dev
);
6288 qeth_unregister_dbf_views();
6289 pr_info("core functions removed\n");
6292 module_init(qeth_core_init
);
6293 module_exit(qeth_core_exit
);
6294 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
6295 MODULE_DESCRIPTION("qeth core functions");
6296 MODULE_LICENSE("GPL");