2 * linux/drivers/s390/net/lcs.c
4 * Linux for S/390 Lan Channel Station Network Driver
6 * Copyright (C) 1999-2001 IBM Deutschland Entwicklung GmbH,
8 * Author(s): Original Code written by
9 * DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
11 * Frank Pavlic (fpavlic@de.ibm.com) and
12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <linux/module.h>
31 #include <linux/netdevice.h>
32 #include <linux/etherdevice.h>
33 #include <linux/trdevice.h>
34 #include <linux/fddidevice.h>
35 #include <linux/inetdevice.h>
37 #include <linux/igmp.h>
38 #include <linux/delay.h>
42 #include <asm/debug.h>
43 #include <asm/idals.h>
44 #include <asm/timex.h>
45 #include <linux/device.h>
46 #include <asm/ccwgroup.h>
52 #if !defined(CONFIG_NET_ETHERNET) && \
53 !defined(CONFIG_TR) && !defined(CONFIG_FDDI)
54 #error Cannot compile lcs.c without some net devices switched on.
57 #define PRINTK_HEADER " lcs: "
60 * initialization string for output
63 static char version[] __initdata = "LCS driver";
64 static char debug_buffer[255];
69 static void lcs_tasklet(unsigned long);
70 static void lcs_start_kernel_thread(struct work_struct *);
71 static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
72 static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
73 static int lcs_recovery(void *ptr);
76 * Debug Facility Stuff
78 static debug_info_t *lcs_dbf_setup;
79 static debug_info_t *lcs_dbf_trace;
82 * LCS Debug Facility functions
85 lcs_unregister_debug_facility(void)
88 debug_unregister(lcs_dbf_setup);
90 debug_unregister(lcs_dbf_trace);
94 lcs_register_debug_facility(void)
96 lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
97 lcs_dbf_trace = debug_register("lcs_trace", 4, 1, 8);
98 if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
99 PRINT_ERR("Not enough memory for debug facility.\n");
100 lcs_unregister_debug_facility();
103 debug_register_view(lcs_dbf_setup, &debug_hex_ascii_view);
104 debug_set_level(lcs_dbf_setup, 2);
105 debug_register_view(lcs_dbf_trace, &debug_hex_ascii_view);
106 debug_set_level(lcs_dbf_trace, 2);
111 * Allocate io buffers.
114 lcs_alloc_channel(struct lcs_channel *channel)
118 LCS_DBF_TEXT(2, setup, "ichalloc");
119 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
120 /* alloc memory fo iobuffer */
121 channel->iob[cnt].data =
122 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
123 if (channel->iob[cnt].data == NULL)
125 channel->iob[cnt].state = LCS_BUF_STATE_EMPTY;
127 if (cnt < LCS_NUM_BUFFS) {
128 /* Not all io buffers could be allocated. */
129 LCS_DBF_TEXT(2, setup, "echalloc");
131 kfree(channel->iob[cnt].data);
141 lcs_free_channel(struct lcs_channel *channel)
145 LCS_DBF_TEXT(2, setup, "ichfree");
146 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
147 kfree(channel->iob[cnt].data);
148 channel->iob[cnt].data = NULL;
156 lcs_cleanup_channel(struct lcs_channel *channel)
158 LCS_DBF_TEXT(3, setup, "cleanch");
159 /* Kill write channel tasklets. */
160 tasklet_kill(&channel->irq_tasklet);
161 /* Free channel buffers. */
162 lcs_free_channel(channel);
166 * LCS free memory for card and channels.
169 lcs_free_card(struct lcs_card *card)
171 LCS_DBF_TEXT(2, setup, "remcard");
172 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
177 * LCS alloc memory for card and channels
179 static struct lcs_card *
182 struct lcs_card *card;
185 LCS_DBF_TEXT(2, setup, "alloclcs");
187 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
190 card->lan_type = LCS_FRAME_TYPE_AUTO;
192 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
193 /* Allocate io buffers for the read channel. */
194 rc = lcs_alloc_channel(&card->read);
196 LCS_DBF_TEXT(2, setup, "iccwerr");
200 /* Allocate io buffers for the write channel. */
201 rc = lcs_alloc_channel(&card->write);
203 LCS_DBF_TEXT(2, setup, "iccwerr");
204 lcs_cleanup_channel(&card->read);
209 #ifdef CONFIG_IP_MULTICAST
210 INIT_LIST_HEAD(&card->ipm_list);
212 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
217 * Setup read channel.
220 lcs_setup_read_ccws(struct lcs_card *card)
224 LCS_DBF_TEXT(2, setup, "ireadccw");
225 /* Setup read ccws. */
226 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1));
227 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
228 card->read.ccws[cnt].cmd_code = LCS_CCW_READ;
229 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE;
230 card->read.ccws[cnt].flags =
231 CCW_FLAG_CC | CCW_FLAG_SLI | CCW_FLAG_PCI;
233 * Note: we have allocated the buffer with GFP_DMA, so
234 * we do not need to do set_normalized_cda.
236 card->read.ccws[cnt].cda =
237 (__u32) __pa(card->read.iob[cnt].data);
238 ((struct lcs_header *)
239 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET;
240 card->read.iob[cnt].callback = lcs_get_frames_cb;
241 card->read.iob[cnt].state = LCS_BUF_STATE_READY;
242 card->read.iob[cnt].count = LCS_IOBUFFERSIZE;
244 card->read.ccws[0].flags &= ~CCW_FLAG_PCI;
245 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI;
246 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND;
247 /* Last ccw is a tic (transfer in channel). */
248 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
249 card->read.ccws[LCS_NUM_BUFFS].cda =
250 (__u32) __pa(card->read.ccws);
251 /* Setg initial state of the read channel. */
252 card->read.state = LCS_CH_STATE_INIT;
254 card->read.io_idx = 0;
255 card->read.buf_idx = 0;
259 lcs_setup_read(struct lcs_card *card)
261 LCS_DBF_TEXT(3, setup, "initread");
263 lcs_setup_read_ccws(card);
264 /* Initialize read channel tasklet. */
265 card->read.irq_tasklet.data = (unsigned long) &card->read;
266 card->read.irq_tasklet.func = lcs_tasklet;
267 /* Initialize waitqueue. */
268 init_waitqueue_head(&card->read.wait_q);
272 * Setup write channel.
275 lcs_setup_write_ccws(struct lcs_card *card)
279 LCS_DBF_TEXT(3, setup, "iwritccw");
280 /* Setup write ccws. */
281 memset(card->write.ccws, 0, sizeof(struct ccw1) * LCS_NUM_BUFFS + 1);
282 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
283 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE;
284 card->write.ccws[cnt].count = 0;
285 card->write.ccws[cnt].flags =
286 CCW_FLAG_SUSPEND | CCW_FLAG_CC | CCW_FLAG_SLI;
288 * Note: we have allocated the buffer with GFP_DMA, so
289 * we do not need to do set_normalized_cda.
291 card->write.ccws[cnt].cda =
292 (__u32) __pa(card->write.iob[cnt].data);
294 /* Last ccw is a tic (transfer in channel). */
295 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
296 card->write.ccws[LCS_NUM_BUFFS].cda =
297 (__u32) __pa(card->write.ccws);
298 /* Set initial state of the write channel. */
299 card->read.state = LCS_CH_STATE_INIT;
301 card->write.io_idx = 0;
302 card->write.buf_idx = 0;
306 lcs_setup_write(struct lcs_card *card)
308 LCS_DBF_TEXT(3, setup, "initwrit");
310 lcs_setup_write_ccws(card);
311 /* Initialize write channel tasklet. */
312 card->write.irq_tasklet.data = (unsigned long) &card->write;
313 card->write.irq_tasklet.func = lcs_tasklet;
314 /* Initialize waitqueue. */
315 init_waitqueue_head(&card->write.wait_q);
319 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads)
323 spin_lock_irqsave(&card->mask_lock, flags);
324 card->thread_allowed_mask = threads;
325 spin_unlock_irqrestore(&card->mask_lock, flags);
326 wake_up(&card->wait_q);
329 lcs_threads_running(struct lcs_card *card, unsigned long threads)
334 spin_lock_irqsave(&card->mask_lock, flags);
335 rc = (card->thread_running_mask & threads);
336 spin_unlock_irqrestore(&card->mask_lock, flags);
341 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads)
343 return wait_event_interruptible(card->wait_q,
344 lcs_threads_running(card, threads) == 0);
348 lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread)
352 spin_lock_irqsave(&card->mask_lock, flags);
353 if ( !(card->thread_allowed_mask & thread) ||
354 (card->thread_start_mask & thread) ) {
355 spin_unlock_irqrestore(&card->mask_lock, flags);
358 card->thread_start_mask |= thread;
359 spin_unlock_irqrestore(&card->mask_lock, flags);
364 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread)
368 spin_lock_irqsave(&card->mask_lock, flags);
369 card->thread_running_mask &= ~thread;
370 spin_unlock_irqrestore(&card->mask_lock, flags);
371 wake_up(&card->wait_q);
375 __lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
380 spin_lock_irqsave(&card->mask_lock, flags);
381 if (card->thread_start_mask & thread){
382 if ((card->thread_allowed_mask & thread) &&
383 !(card->thread_running_mask & thread)){
385 card->thread_start_mask &= ~thread;
386 card->thread_running_mask |= thread;
390 spin_unlock_irqrestore(&card->mask_lock, flags);
395 lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
398 wait_event(card->wait_q,
399 (rc = __lcs_do_run_thread(card, thread)) >= 0);
404 lcs_do_start_thread(struct lcs_card *card, unsigned long thread)
409 spin_lock_irqsave(&card->mask_lock, flags);
410 LCS_DBF_TEXT_(4, trace, " %02x%02x%02x",
411 (u8) card->thread_start_mask,
412 (u8) card->thread_allowed_mask,
413 (u8) card->thread_running_mask);
414 rc = (card->thread_start_mask & thread);
415 spin_unlock_irqrestore(&card->mask_lock, flags);
420 * Initialize channels,card and state machines.
423 lcs_setup_card(struct lcs_card *card)
425 LCS_DBF_TEXT(2, setup, "initcard");
426 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
428 lcs_setup_read(card);
429 lcs_setup_write(card);
430 /* Set cards initial state. */
431 card->state = DEV_STATE_DOWN;
432 card->tx_buffer = NULL;
433 card->tx_emitted = 0;
435 init_waitqueue_head(&card->wait_q);
436 spin_lock_init(&card->lock);
437 spin_lock_init(&card->ipm_lock);
438 spin_lock_init(&card->mask_lock);
439 #ifdef CONFIG_IP_MULTICAST
440 INIT_LIST_HEAD(&card->ipm_list);
442 INIT_LIST_HEAD(&card->lancmd_waiters);
446 lcs_clear_multicast_list(struct lcs_card *card)
448 #ifdef CONFIG_IP_MULTICAST
449 struct lcs_ipm_list *ipm;
452 /* Free multicast list. */
453 LCS_DBF_TEXT(3, setup, "clmclist");
454 spin_lock_irqsave(&card->ipm_lock, flags);
455 while (!list_empty(&card->ipm_list)){
456 ipm = list_entry(card->ipm_list.next,
457 struct lcs_ipm_list, list);
458 list_del(&ipm->list);
459 if (ipm->ipm_state != LCS_IPM_STATE_SET_REQUIRED){
460 spin_unlock_irqrestore(&card->ipm_lock, flags);
461 lcs_send_delipm(card, ipm);
462 spin_lock_irqsave(&card->ipm_lock, flags);
466 spin_unlock_irqrestore(&card->ipm_lock, flags);
470 * Cleanup channels,card and state machines.
473 lcs_cleanup_card(struct lcs_card *card)
476 LCS_DBF_TEXT(3, setup, "cleancrd");
477 LCS_DBF_HEX(2,setup,&card,sizeof(void*));
479 if (card->dev != NULL)
480 free_netdev(card->dev);
481 /* Cleanup channels. */
482 lcs_cleanup_channel(&card->write);
483 lcs_cleanup_channel(&card->read);
490 lcs_start_channel(struct lcs_channel *channel)
495 LCS_DBF_TEXT_(4,trace,"ssch%s", channel->ccwdev->dev.bus_id);
496 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
497 rc = ccw_device_start(channel->ccwdev,
498 channel->ccws + channel->io_idx, 0, 0,
499 DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND);
501 channel->state = LCS_CH_STATE_RUNNING;
502 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
504 LCS_DBF_TEXT_(4,trace,"essh%s", channel->ccwdev->dev.bus_id);
505 PRINT_ERR("Error in starting channel, rc=%d!\n", rc);
511 lcs_clear_channel(struct lcs_channel *channel)
516 LCS_DBF_TEXT(4,trace,"clearch");
517 LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
518 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
519 rc = ccw_device_clear(channel->ccwdev, (addr_t) channel);
520 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
522 LCS_DBF_TEXT_(4,trace,"ecsc%s", channel->ccwdev->dev.bus_id);
525 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_CLEARED));
526 channel->state = LCS_CH_STATE_STOPPED;
535 lcs_stop_channel(struct lcs_channel *channel)
540 if (channel->state == LCS_CH_STATE_STOPPED)
542 LCS_DBF_TEXT(4,trace,"haltsch");
543 LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
544 channel->state = LCS_CH_STATE_INIT;
545 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
546 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
547 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
549 LCS_DBF_TEXT_(4,trace,"ehsc%s", channel->ccwdev->dev.bus_id);
552 /* Asynchronous halt initialted. Wait for its completion. */
553 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_HALTED));
554 lcs_clear_channel(channel);
559 * start read and write channel
562 lcs_start_channels(struct lcs_card *card)
566 LCS_DBF_TEXT(2, trace, "chstart");
567 /* start read channel */
568 rc = lcs_start_channel(&card->read);
571 /* start write channel */
572 rc = lcs_start_channel(&card->write);
574 lcs_stop_channel(&card->read);
579 * stop read and write channel
582 lcs_stop_channels(struct lcs_card *card)
584 LCS_DBF_TEXT(2, trace, "chhalt");
585 lcs_stop_channel(&card->read);
586 lcs_stop_channel(&card->write);
593 static struct lcs_buffer *
594 __lcs_get_buffer(struct lcs_channel *channel)
598 LCS_DBF_TEXT(5, trace, "_getbuff");
599 index = channel->io_idx;
601 if (channel->iob[index].state == LCS_BUF_STATE_EMPTY) {
602 channel->iob[index].state = LCS_BUF_STATE_LOCKED;
603 return channel->iob + index;
605 index = (index + 1) & (LCS_NUM_BUFFS - 1);
606 } while (index != channel->io_idx);
610 static struct lcs_buffer *
611 lcs_get_buffer(struct lcs_channel *channel)
613 struct lcs_buffer *buffer;
616 LCS_DBF_TEXT(5, trace, "getbuff");
617 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
618 buffer = __lcs_get_buffer(channel);
619 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
624 * Resume channel program if the channel is suspended.
627 __lcs_resume_channel(struct lcs_channel *channel)
631 if (channel->state != LCS_CH_STATE_SUSPENDED)
633 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
635 LCS_DBF_TEXT_(5, trace, "rsch%s", channel->ccwdev->dev.bus_id);
636 rc = ccw_device_resume(channel->ccwdev);
638 LCS_DBF_TEXT_(4, trace, "ersc%s", channel->ccwdev->dev.bus_id);
639 PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc);
641 channel->state = LCS_CH_STATE_RUNNING;
647 * Make a buffer ready for processing.
650 __lcs_ready_buffer_bits(struct lcs_channel *channel, int index)
654 LCS_DBF_TEXT(5, trace, "rdybits");
655 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
656 next = (index + 1) & (LCS_NUM_BUFFS - 1);
657 /* Check if we may clear the suspend bit of this buffer. */
658 if (channel->ccws[next].flags & CCW_FLAG_SUSPEND) {
659 /* Check if we have to set the PCI bit. */
660 if (!(channel->ccws[prev].flags & CCW_FLAG_SUSPEND))
661 /* Suspend bit of the previous buffer is not set. */
662 channel->ccws[index].flags |= CCW_FLAG_PCI;
663 /* Suspend bit of the next buffer is set. */
664 channel->ccws[index].flags &= ~CCW_FLAG_SUSPEND;
669 lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
674 LCS_DBF_TEXT(5, trace, "rdybuff");
675 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
676 buffer->state != LCS_BUF_STATE_PROCESSED);
677 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
678 buffer->state = LCS_BUF_STATE_READY;
679 index = buffer - channel->iob;
681 channel->ccws[index].count = buffer->count;
682 /* Check relevant PCI/suspend bits. */
683 __lcs_ready_buffer_bits(channel, index);
684 rc = __lcs_resume_channel(channel);
685 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
690 * Mark the buffer as processed. Take care of the suspend bit
691 * of the previous buffer. This function is called from
692 * interrupt context, so the lock must not be taken.
695 __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
697 int index, prev, next;
699 LCS_DBF_TEXT(5, trace, "prcsbuff");
700 BUG_ON(buffer->state != LCS_BUF_STATE_READY);
701 buffer->state = LCS_BUF_STATE_PROCESSED;
702 index = buffer - channel->iob;
703 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
704 next = (index + 1) & (LCS_NUM_BUFFS - 1);
705 /* Set the suspend bit and clear the PCI bit of this buffer. */
706 channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
707 channel->ccws[index].flags &= ~CCW_FLAG_PCI;
708 /* Check the suspend bit of the previous buffer. */
709 if (channel->iob[prev].state == LCS_BUF_STATE_READY) {
711 * Previous buffer is in state ready. It might have
712 * happened in lcs_ready_buffer that the suspend bit
713 * has not been cleared to avoid an endless loop.
716 __lcs_ready_buffer_bits(channel, prev);
718 /* Clear PCI bit of next buffer. */
719 channel->ccws[next].flags &= ~CCW_FLAG_PCI;
720 return __lcs_resume_channel(channel);
724 * Put a processed buffer back to state empty.
727 lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
731 LCS_DBF_TEXT(5, trace, "relbuff");
732 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
733 buffer->state != LCS_BUF_STATE_PROCESSED);
734 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
735 buffer->state = LCS_BUF_STATE_EMPTY;
736 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
740 * Get buffer for a lan command.
742 static struct lcs_buffer *
743 lcs_get_lancmd(struct lcs_card *card, int count)
745 struct lcs_buffer *buffer;
748 LCS_DBF_TEXT(4, trace, "getlncmd");
749 /* Get buffer and wait if none is available. */
750 wait_event(card->write.wait_q,
751 ((buffer = lcs_get_buffer(&card->write)) != NULL));
752 count += sizeof(struct lcs_header);
753 *(__u16 *)(buffer->data + count) = 0;
754 buffer->count = count + sizeof(__u16);
755 buffer->callback = lcs_release_buffer;
756 cmd = (struct lcs_cmd *) buffer->data;
758 cmd->type = LCS_FRAME_TYPE_CONTROL;
765 lcs_get_reply(struct lcs_reply *reply)
767 WARN_ON(atomic_read(&reply->refcnt) <= 0);
768 atomic_inc(&reply->refcnt);
772 lcs_put_reply(struct lcs_reply *reply)
774 WARN_ON(atomic_read(&reply->refcnt) <= 0);
775 if (atomic_dec_and_test(&reply->refcnt)) {
781 static struct lcs_reply *
782 lcs_alloc_reply(struct lcs_cmd *cmd)
784 struct lcs_reply *reply;
786 LCS_DBF_TEXT(4, trace, "getreply");
788 reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
791 atomic_set(&reply->refcnt,1);
792 reply->sequence_no = cmd->sequence_no;
795 init_waitqueue_head(&reply->wait_q);
801 * Notifier function for lancmd replies. Called from read irq.
804 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
806 struct list_head *l, *n;
807 struct lcs_reply *reply;
809 LCS_DBF_TEXT(4, trace, "notiwait");
810 spin_lock(&card->lock);
811 list_for_each_safe(l, n, &card->lancmd_waiters) {
812 reply = list_entry(l, struct lcs_reply, list);
813 if (reply->sequence_no == cmd->sequence_no) {
814 lcs_get_reply(reply);
815 list_del_init(&reply->list);
816 if (reply->callback != NULL)
817 reply->callback(card, cmd);
819 reply->rc = cmd->return_code;
820 wake_up(&reply->wait_q);
821 lcs_put_reply(reply);
825 spin_unlock(&card->lock);
829 * Emit buffer of a lan comand.
832 lcs_lancmd_timeout(unsigned long data)
834 struct lcs_reply *reply, *list_reply, *r;
837 LCS_DBF_TEXT(4, trace, "timeout");
838 reply = (struct lcs_reply *) data;
839 spin_lock_irqsave(&reply->card->lock, flags);
840 list_for_each_entry_safe(list_reply, r,
841 &reply->card->lancmd_waiters,list) {
842 if (reply == list_reply) {
843 lcs_get_reply(reply);
844 list_del_init(&reply->list);
845 spin_unlock_irqrestore(&reply->card->lock, flags);
848 wake_up(&reply->wait_q);
849 lcs_put_reply(reply);
853 spin_unlock_irqrestore(&reply->card->lock, flags);
857 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
858 void (*reply_callback)(struct lcs_card *, struct lcs_cmd *))
860 struct lcs_reply *reply;
862 struct timer_list timer;
866 LCS_DBF_TEXT(4, trace, "sendcmd");
867 cmd = (struct lcs_cmd *) buffer->data;
868 cmd->return_code = 0;
869 cmd->sequence_no = card->sequence_no++;
870 reply = lcs_alloc_reply(cmd);
873 reply->callback = reply_callback;
875 spin_lock_irqsave(&card->lock, flags);
876 list_add_tail(&reply->list, &card->lancmd_waiters);
877 spin_unlock_irqrestore(&card->lock, flags);
879 buffer->callback = lcs_release_buffer;
880 rc = lcs_ready_buffer(&card->write, buffer);
884 timer.function = lcs_lancmd_timeout;
885 timer.data = (unsigned long) reply;
886 timer.expires = jiffies + HZ*card->lancmd_timeout;
888 wait_event(reply->wait_q, reply->received);
889 del_timer_sync(&timer);
890 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
892 lcs_put_reply(reply);
893 return rc ? -EIO : 0;
897 * LCS startup command
900 lcs_send_startup(struct lcs_card *card, __u8 initiator)
902 struct lcs_buffer *buffer;
905 LCS_DBF_TEXT(2, trace, "startup");
906 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
907 cmd = (struct lcs_cmd *) buffer->data;
908 cmd->cmd_code = LCS_CMD_STARTUP;
909 cmd->initiator = initiator;
910 cmd->cmd.lcs_startup.buff_size = LCS_IOBUFFERSIZE;
911 return lcs_send_lancmd(card, buffer, NULL);
915 * LCS shutdown command
918 lcs_send_shutdown(struct lcs_card *card)
920 struct lcs_buffer *buffer;
923 LCS_DBF_TEXT(2, trace, "shutdown");
924 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
925 cmd = (struct lcs_cmd *) buffer->data;
926 cmd->cmd_code = LCS_CMD_SHUTDOWN;
927 cmd->initiator = LCS_INITIATOR_TCPIP;
928 return lcs_send_lancmd(card, buffer, NULL);
932 * LCS lanstat command
935 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd)
937 LCS_DBF_TEXT(2, trace, "statcb");
938 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH);
942 lcs_send_lanstat(struct lcs_card *card)
944 struct lcs_buffer *buffer;
947 LCS_DBF_TEXT(2,trace, "cmdstat");
948 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
949 cmd = (struct lcs_cmd *) buffer->data;
950 /* Setup lanstat command. */
951 cmd->cmd_code = LCS_CMD_LANSTAT;
952 cmd->initiator = LCS_INITIATOR_TCPIP;
953 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
954 cmd->cmd.lcs_std_cmd.portno = card->portno;
955 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb);
959 * send stoplan command
962 lcs_send_stoplan(struct lcs_card *card, __u8 initiator)
964 struct lcs_buffer *buffer;
967 LCS_DBF_TEXT(2, trace, "cmdstpln");
968 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
969 cmd = (struct lcs_cmd *) buffer->data;
970 cmd->cmd_code = LCS_CMD_STOPLAN;
971 cmd->initiator = initiator;
972 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
973 cmd->cmd.lcs_std_cmd.portno = card->portno;
974 return lcs_send_lancmd(card, buffer, NULL);
978 * send startlan command
981 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd)
983 LCS_DBF_TEXT(2, trace, "srtlancb");
984 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type;
985 card->portno = cmd->cmd.lcs_std_cmd.portno;
989 lcs_send_startlan(struct lcs_card *card, __u8 initiator)
991 struct lcs_buffer *buffer;
994 LCS_DBF_TEXT(2, trace, "cmdstaln");
995 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
996 cmd = (struct lcs_cmd *) buffer->data;
997 cmd->cmd_code = LCS_CMD_STARTLAN;
998 cmd->initiator = initiator;
999 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
1000 cmd->cmd.lcs_std_cmd.portno = card->portno;
1001 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb);
1004 #ifdef CONFIG_IP_MULTICAST
1006 * send setipm command (Multicast)
1009 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1011 struct lcs_buffer *buffer;
1012 struct lcs_cmd *cmd;
1014 LCS_DBF_TEXT(2, trace, "cmdsetim");
1015 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1016 cmd = (struct lcs_cmd *) buffer->data;
1017 cmd->cmd_code = LCS_CMD_SETIPM;
1018 cmd->initiator = LCS_INITIATOR_TCPIP;
1019 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1020 cmd->cmd.lcs_qipassist.portno = card->portno;
1021 cmd->cmd.lcs_qipassist.version = 4;
1022 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1023 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1024 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1025 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1026 return lcs_send_lancmd(card, buffer, NULL);
1030 * send delipm command (Multicast)
1033 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1035 struct lcs_buffer *buffer;
1036 struct lcs_cmd *cmd;
1038 LCS_DBF_TEXT(2, trace, "cmddelim");
1039 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1040 cmd = (struct lcs_cmd *) buffer->data;
1041 cmd->cmd_code = LCS_CMD_DELIPM;
1042 cmd->initiator = LCS_INITIATOR_TCPIP;
1043 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1044 cmd->cmd.lcs_qipassist.portno = card->portno;
1045 cmd->cmd.lcs_qipassist.version = 4;
1046 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1047 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1048 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1049 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1050 return lcs_send_lancmd(card, buffer, NULL);
1054 * check if multicast is supported by LCS
1057 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd)
1059 LCS_DBF_TEXT(2, trace, "chkmccb");
1060 card->ip_assists_supported =
1061 cmd->cmd.lcs_qipassist.ip_assists_supported;
1062 card->ip_assists_enabled =
1063 cmd->cmd.lcs_qipassist.ip_assists_enabled;
1067 lcs_check_multicast_support(struct lcs_card *card)
1069 struct lcs_buffer *buffer;
1070 struct lcs_cmd *cmd;
1073 LCS_DBF_TEXT(2, trace, "cmdqipa");
1074 /* Send query ipassist. */
1075 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1076 cmd = (struct lcs_cmd *) buffer->data;
1077 cmd->cmd_code = LCS_CMD_QIPASSIST;
1078 cmd->initiator = LCS_INITIATOR_TCPIP;
1079 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1080 cmd->cmd.lcs_qipassist.portno = card->portno;
1081 cmd->cmd.lcs_qipassist.version = 4;
1082 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1083 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
1085 PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n");
1088 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
1094 * set or del multicast address on LCS card
1097 lcs_fix_multicast_list(struct lcs_card *card)
1099 struct list_head failed_list;
1100 struct lcs_ipm_list *ipm, *tmp;
1101 unsigned long flags;
1104 LCS_DBF_TEXT(4,trace, "fixipm");
1105 INIT_LIST_HEAD(&failed_list);
1106 spin_lock_irqsave(&card->ipm_lock, flags);
1108 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){
1109 switch (ipm->ipm_state) {
1110 case LCS_IPM_STATE_SET_REQUIRED:
1111 /* del from ipm_list so noone else can tamper with
1113 list_del_init(&ipm->list);
1114 spin_unlock_irqrestore(&card->ipm_lock, flags);
1115 rc = lcs_send_setipm(card, ipm);
1116 spin_lock_irqsave(&card->ipm_lock, flags);
1118 PRINT_INFO("Adding multicast address failed. "
1119 "Table possibly full!\n");
1120 /* store ipm in failed list -> will be added
1121 * to ipm_list again, so a retry will be done
1122 * during the next call of this function */
1123 list_add_tail(&ipm->list, &failed_list);
1125 ipm->ipm_state = LCS_IPM_STATE_ON_CARD;
1126 /* re-insert into ipm_list */
1127 list_add_tail(&ipm->list, &card->ipm_list);
1130 case LCS_IPM_STATE_DEL_REQUIRED:
1131 list_del(&ipm->list);
1132 spin_unlock_irqrestore(&card->ipm_lock, flags);
1133 lcs_send_delipm(card, ipm);
1134 spin_lock_irqsave(&card->ipm_lock, flags);
1137 case LCS_IPM_STATE_ON_CARD:
1141 /* re-insert all entries from the failed_list into ipm_list */
1142 list_for_each_entry_safe(ipm, tmp, &failed_list, list)
1143 list_move_tail(&ipm->list, &card->ipm_list);
1145 spin_unlock_irqrestore(&card->ipm_lock, flags);
1149 * get mac address for the relevant Multicast address
1152 lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1154 LCS_DBF_TEXT(4,trace, "getmac");
1155 if (dev->type == ARPHRD_IEEE802_TR)
1156 ip_tr_mc_map(ipm, mac);
1158 ip_eth_mc_map(ipm, mac);
1162 * function called by net device to handle multicast address relevant things
1165 lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1167 struct ip_mc_list *im4;
1168 struct list_head *l;
1169 struct lcs_ipm_list *ipm;
1170 unsigned long flags;
1171 char buf[MAX_ADDR_LEN];
1173 LCS_DBF_TEXT(4, trace, "remmclst");
1174 spin_lock_irqsave(&card->ipm_lock, flags);
1175 list_for_each(l, &card->ipm_list) {
1176 ipm = list_entry(l, struct lcs_ipm_list, list);
1177 for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
1178 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1179 if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
1180 (memcmp(buf, &ipm->ipm.mac_addr,
1181 LCS_MAC_LENGTH) == 0) )
1185 ipm->ipm_state = LCS_IPM_STATE_DEL_REQUIRED;
1187 spin_unlock_irqrestore(&card->ipm_lock, flags);
1190 static inline struct lcs_ipm_list *
1191 lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf)
1193 struct lcs_ipm_list *tmp, *ipm = NULL;
1194 struct list_head *l;
1195 unsigned long flags;
1197 LCS_DBF_TEXT(4, trace, "chkmcent");
1198 spin_lock_irqsave(&card->ipm_lock, flags);
1199 list_for_each(l, &card->ipm_list) {
1200 tmp = list_entry(l, struct lcs_ipm_list, list);
1201 if ( (tmp->ipm.ip_addr == im4->multiaddr) &&
1202 (memcmp(buf, &tmp->ipm.mac_addr,
1203 LCS_MAC_LENGTH) == 0) ) {
1208 spin_unlock_irqrestore(&card->ipm_lock, flags);
1213 lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1216 struct ip_mc_list *im4;
1217 struct lcs_ipm_list *ipm;
1218 char buf[MAX_ADDR_LEN];
1219 unsigned long flags;
1221 LCS_DBF_TEXT(4, trace, "setmclst");
1222 for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
1223 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1224 ipm = lcs_check_addr_entry(card, im4, buf);
1226 continue; /* Address already in list. */
1227 ipm = (struct lcs_ipm_list *)
1228 kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
1230 PRINT_INFO("Not enough memory to add "
1231 "new multicast entry!\n");
1234 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
1235 ipm->ipm.ip_addr = im4->multiaddr;
1236 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
1237 spin_lock_irqsave(&card->ipm_lock, flags);
1238 LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4);
1239 list_add(&ipm->list, &card->ipm_list);
1240 spin_unlock_irqrestore(&card->ipm_lock, flags);
1245 lcs_register_mc_addresses(void *data)
1247 struct lcs_card *card;
1248 struct in_device *in4_dev;
1250 card = (struct lcs_card *) data;
1251 daemonize("regipm");
1253 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD))
1255 LCS_DBF_TEXT(4, trace, "regmulti");
1257 in4_dev = in_dev_get(card->dev);
1258 if (in4_dev == NULL)
1260 read_lock(&in4_dev->mc_list_lock);
1261 lcs_remove_mc_addresses(card,in4_dev);
1262 lcs_set_mc_addresses(card, in4_dev);
1263 read_unlock(&in4_dev->mc_list_lock);
1264 in_dev_put(in4_dev);
1266 netif_carrier_off(card->dev);
1267 netif_tx_disable(card->dev);
1268 wait_event(card->write.wait_q,
1269 (card->write.state != LCS_CH_STATE_RUNNING));
1270 lcs_fix_multicast_list(card);
1271 if (card->state == DEV_STATE_UP) {
1272 netif_carrier_on(card->dev);
1273 netif_wake_queue(card->dev);
1276 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
1280 * function called by net device to
1281 * handle multicast address relevant things
1284 lcs_set_multicast_list(struct net_device *dev)
1286 struct lcs_card *card;
1288 LCS_DBF_TEXT(4, trace, "setmulti");
1289 card = (struct lcs_card *) dev->priv;
1291 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD))
1292 schedule_work(&card->kernel_thread_starter);
1295 #endif /* CONFIG_IP_MULTICAST */
1298 lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
1303 switch (PTR_ERR(irb)) {
1305 PRINT_WARN("i/o-error on device %s\n", cdev->dev.bus_id);
1306 LCS_DBF_TEXT(2, trace, "ckirberr");
1307 LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
1310 PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id);
1311 LCS_DBF_TEXT(2, trace, "ckirberr");
1312 LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
1315 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
1317 LCS_DBF_TEXT(2, trace, "ckirberr");
1318 LCS_DBF_TEXT(2, trace, " rc???");
1320 return PTR_ERR(irb);
1324 lcs_get_problem(struct ccw_device *cdev, struct irb *irb)
1329 sense = (char *) irb->ecw;
1330 cstat = irb->scsw.cmd.cstat;
1331 dstat = irb->scsw.cmd.dstat;
1333 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
1334 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
1335 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
1336 LCS_DBF_TEXT(2, trace, "CGENCHK");
1339 if (dstat & DEV_STAT_UNIT_CHECK) {
1340 if (sense[LCS_SENSE_BYTE_1] &
1341 LCS_SENSE_RESETTING_EVENT) {
1342 LCS_DBF_TEXT(2, trace, "REVIND");
1345 if (sense[LCS_SENSE_BYTE_0] &
1346 LCS_SENSE_CMD_REJECT) {
1347 LCS_DBF_TEXT(2, trace, "CMDREJ");
1350 if ((!sense[LCS_SENSE_BYTE_0]) &&
1351 (!sense[LCS_SENSE_BYTE_1]) &&
1352 (!sense[LCS_SENSE_BYTE_2]) &&
1353 (!sense[LCS_SENSE_BYTE_3])) {
1354 LCS_DBF_TEXT(2, trace, "ZEROSEN");
1357 LCS_DBF_TEXT(2, trace, "DGENCHK");
1364 lcs_schedule_recovery(struct lcs_card *card)
1366 LCS_DBF_TEXT(2, trace, "startrec");
1367 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD))
1368 schedule_work(&card->kernel_thread_starter);
1372 * IRQ Handler for LCS channels
1375 lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1377 struct lcs_card *card;
1378 struct lcs_channel *channel;
1382 if (lcs_check_irb_error(cdev, irb))
1385 card = CARD_FROM_DEV(cdev);
1386 if (card->read.ccwdev == cdev)
1387 channel = &card->read;
1389 channel = &card->write;
1391 cstat = irb->scsw.cmd.cstat;
1392 dstat = irb->scsw.cmd.dstat;
1393 LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id);
1394 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.cstat,
1395 irb->scsw.cmd.dstat);
1396 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.fctl,
1397 irb->scsw.cmd.actl);
1399 /* Check for channel and device errors presented */
1400 rc = lcs_get_problem(cdev, irb);
1401 if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
1402 PRINT_WARN("check on device %s, dstat=0x%X, cstat=0x%X \n",
1403 cdev->dev.bus_id, dstat, cstat);
1405 channel->state = LCS_CH_STATE_ERROR;
1408 if (channel->state == LCS_CH_STATE_ERROR) {
1409 lcs_schedule_recovery(card);
1410 wake_up(&card->wait_q);
1413 /* How far in the ccw chain have we processed? */
1414 if ((channel->state != LCS_CH_STATE_INIT) &&
1415 (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC)) {
1416 index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa)
1418 if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) ||
1419 (irb->scsw.cmd.cstat & SCHN_STAT_PCI))
1420 /* Bloody io subsystem tells us lies about cpa... */
1421 index = (index - 1) & (LCS_NUM_BUFFS - 1);
1422 while (channel->io_idx != index) {
1423 __lcs_processed_buffer(channel,
1424 channel->iob + channel->io_idx);
1426 (channel->io_idx + 1) & (LCS_NUM_BUFFS - 1);
1430 if ((irb->scsw.cmd.dstat & DEV_STAT_DEV_END) ||
1431 (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) ||
1432 (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK))
1433 /* Mark channel as stopped. */
1434 channel->state = LCS_CH_STATE_STOPPED;
1435 else if (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)
1436 /* CCW execution stopped on a suspend bit. */
1437 channel->state = LCS_CH_STATE_SUSPENDED;
1438 if (irb->scsw.cmd.fctl & SCSW_FCTL_HALT_FUNC) {
1439 if (irb->scsw.cmd.cc != 0) {
1440 ccw_device_halt(channel->ccwdev, (addr_t) channel);
1443 /* The channel has been stopped by halt_IO. */
1444 channel->state = LCS_CH_STATE_HALTED;
1446 if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC)
1447 channel->state = LCS_CH_STATE_CLEARED;
1448 /* Do the rest in the tasklet. */
1449 tasklet_schedule(&channel->irq_tasklet);
1453 * Tasklet for IRQ handler
1456 lcs_tasklet(unsigned long data)
1458 unsigned long flags;
1459 struct lcs_channel *channel;
1460 struct lcs_buffer *iob;
1464 channel = (struct lcs_channel *) data;
1465 LCS_DBF_TEXT_(5, trace, "tlet%s",channel->ccwdev->dev.bus_id);
1467 /* Check for processed buffers. */
1469 buf_idx = channel->buf_idx;
1470 while (iob[buf_idx].state == LCS_BUF_STATE_PROCESSED) {
1471 /* Do the callback thing. */
1472 if (iob[buf_idx].callback != NULL)
1473 iob[buf_idx].callback(channel, iob + buf_idx);
1474 buf_idx = (buf_idx + 1) & (LCS_NUM_BUFFS - 1);
1476 channel->buf_idx = buf_idx;
1478 if (channel->state == LCS_CH_STATE_STOPPED)
1479 // FIXME: what if rc != 0 ??
1480 rc = lcs_start_channel(channel);
1481 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1482 if (channel->state == LCS_CH_STATE_SUSPENDED &&
1483 channel->iob[channel->io_idx].state == LCS_BUF_STATE_READY) {
1484 // FIXME: what if rc != 0 ??
1485 rc = __lcs_resume_channel(channel);
1487 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1489 /* Something happened on the channel. Wake up waiters. */
1490 wake_up(&channel->wait_q);
1494 * Finish current tx buffer and make it ready for transmit.
1497 __lcs_emit_txbuffer(struct lcs_card *card)
1499 LCS_DBF_TEXT(5, trace, "emittx");
1500 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0;
1501 card->tx_buffer->count += 2;
1502 lcs_ready_buffer(&card->write, card->tx_buffer);
1503 card->tx_buffer = NULL;
1508 * Callback for finished tx buffers.
1511 lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1513 struct lcs_card *card;
1515 LCS_DBF_TEXT(5, trace, "txbuffcb");
1516 /* Put buffer back to pool. */
1517 lcs_release_buffer(channel, buffer);
1518 card = container_of(channel, struct lcs_card, write);
1519 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1520 netif_wake_queue(card->dev);
1521 spin_lock(&card->lock);
1523 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1525 * Last running tx buffer has finished. Submit partially
1526 * filled current buffer.
1528 __lcs_emit_txbuffer(card);
1529 spin_unlock(&card->lock);
1533 * Packet transmit function called by network stack
1536 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
1537 struct net_device *dev)
1539 struct lcs_header *header;
1542 LCS_DBF_TEXT(5, trace, "hardxmit");
1544 card->stats.tx_dropped++;
1545 card->stats.tx_errors++;
1548 if (card->state != DEV_STATE_UP) {
1550 card->stats.tx_dropped++;
1551 card->stats.tx_errors++;
1552 card->stats.tx_carrier_errors++;
1555 if (skb->protocol == htons(ETH_P_IPV6)) {
1559 netif_stop_queue(card->dev);
1560 spin_lock(&card->lock);
1561 if (card->tx_buffer != NULL &&
1562 card->tx_buffer->count + sizeof(struct lcs_header) +
1563 skb->len + sizeof(u16) > LCS_IOBUFFERSIZE)
1564 /* skb too big for current tx buffer. */
1565 __lcs_emit_txbuffer(card);
1566 if (card->tx_buffer == NULL) {
1567 /* Get new tx buffer */
1568 card->tx_buffer = lcs_get_buffer(&card->write);
1569 if (card->tx_buffer == NULL) {
1570 card->stats.tx_dropped++;
1574 card->tx_buffer->callback = lcs_txbuffer_cb;
1575 card->tx_buffer->count = 0;
1577 header = (struct lcs_header *)
1578 (card->tx_buffer->data + card->tx_buffer->count);
1579 card->tx_buffer->count += skb->len + sizeof(struct lcs_header);
1580 header->offset = card->tx_buffer->count;
1581 header->type = card->lan_type;
1582 header->slot = card->portno;
1583 skb_copy_from_linear_data(skb, header + 1, skb->len);
1584 spin_unlock(&card->lock);
1585 card->stats.tx_bytes += skb->len;
1586 card->stats.tx_packets++;
1588 netif_wake_queue(card->dev);
1589 spin_lock(&card->lock);
1590 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1591 /* If this is the first tx buffer emit it immediately. */
1592 __lcs_emit_txbuffer(card);
1594 spin_unlock(&card->lock);
1599 lcs_start_xmit(struct sk_buff *skb, struct net_device *dev)
1601 struct lcs_card *card;
1604 LCS_DBF_TEXT(5, trace, "pktxmit");
1605 card = (struct lcs_card *) dev->priv;
1606 rc = __lcs_start_xmit(card, skb, dev);
1611 * send startlan and lanstat command to make LCS device ready
1614 lcs_startlan_auto(struct lcs_card *card)
1618 LCS_DBF_TEXT(2, trace, "strtauto");
1619 #ifdef CONFIG_NET_ETHERNET
1620 card->lan_type = LCS_FRAME_TYPE_ENET;
1621 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1627 card->lan_type = LCS_FRAME_TYPE_TR;
1628 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1633 card->lan_type = LCS_FRAME_TYPE_FDDI;
1634 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1642 lcs_startlan(struct lcs_card *card)
1646 LCS_DBF_TEXT(2, trace, "startlan");
1648 if (card->portno != LCS_INVALID_PORT_NO) {
1649 if (card->lan_type == LCS_FRAME_TYPE_AUTO)
1650 rc = lcs_startlan_auto(card);
1652 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1654 for (i = 0; i <= 16; i++) {
1656 if (card->lan_type != LCS_FRAME_TYPE_AUTO)
1657 rc = lcs_send_startlan(card,
1658 LCS_INITIATOR_TCPIP);
1660 /* autodetecting lan type */
1661 rc = lcs_startlan_auto(card);
1667 return lcs_send_lanstat(card);
1672 * LCS detect function
1673 * setup channels and make them I/O ready
1676 lcs_detect(struct lcs_card *card)
1680 LCS_DBF_TEXT(2, setup, "lcsdetct");
1681 /* start/reset card */
1683 netif_stop_queue(card->dev);
1684 rc = lcs_stop_channels(card);
1686 rc = lcs_start_channels(card);
1688 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP);
1690 rc = lcs_startlan(card);
1694 card->state = DEV_STATE_UP;
1696 card->state = DEV_STATE_DOWN;
1697 card->write.state = LCS_CH_STATE_INIT;
1698 card->read.state = LCS_CH_STATE_INIT;
1707 lcs_stopcard(struct lcs_card *card)
1711 LCS_DBF_TEXT(3, setup, "stopcard");
1713 if (card->read.state != LCS_CH_STATE_STOPPED &&
1714 card->write.state != LCS_CH_STATE_STOPPED &&
1715 card->read.state != LCS_CH_STATE_ERROR &&
1716 card->write.state != LCS_CH_STATE_ERROR &&
1717 card->state == DEV_STATE_UP) {
1718 lcs_clear_multicast_list(card);
1719 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
1720 rc = lcs_send_shutdown(card);
1722 rc = lcs_stop_channels(card);
1723 card->state = DEV_STATE_DOWN;
1729 * Kernel Thread helper functions for LGW initiated commands
1732 lcs_start_kernel_thread(struct work_struct *work)
1734 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1735 LCS_DBF_TEXT(5, trace, "krnthrd");
1736 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1737 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
1738 #ifdef CONFIG_IP_MULTICAST
1739 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
1740 kernel_thread(lcs_register_mc_addresses,
1741 (void *) card, SIGCHLD);
1746 * Process control frames.
1749 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
1751 LCS_DBF_TEXT(5, trace, "getctrl");
1752 if (cmd->initiator == LCS_INITIATOR_LGW) {
1753 switch(cmd->cmd_code) {
1754 case LCS_CMD_STARTUP:
1755 case LCS_CMD_STARTLAN:
1756 lcs_schedule_recovery(card);
1758 case LCS_CMD_STOPLAN:
1759 PRINT_WARN("Stoplan for %s initiated by LGW.\n",
1762 netif_carrier_off(card->dev);
1765 LCS_DBF_TEXT(5, trace, "noLGWcmd");
1769 lcs_notify_lancmd_waiters(card, cmd);
1773 * Unpack network packet.
1776 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
1778 struct sk_buff *skb;
1780 LCS_DBF_TEXT(5, trace, "getskb");
1781 if (card->dev == NULL ||
1782 card->state != DEV_STATE_UP)
1783 /* The card isn't up. Ignore the packet. */
1786 skb = dev_alloc_skb(skb_len);
1788 PRINT_ERR("LCS: alloc_skb failed for device=%s\n",
1790 card->stats.rx_dropped++;
1793 memcpy(skb_put(skb, skb_len), skb_data, skb_len);
1794 skb->protocol = card->lan_type_trans(skb, card->dev);
1795 card->stats.rx_bytes += skb_len;
1796 card->stats.rx_packets++;
1797 if (skb->protocol == htons(ETH_P_802_2))
1798 *((__u32 *)skb->cb) = ++card->pkt_seq;
1803 * LCS main routine to get packets and lancmd replies from the buffers
1806 lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1808 struct lcs_card *card;
1809 struct lcs_header *lcs_hdr;
1812 LCS_DBF_TEXT(5, trace, "lcsgtpkt");
1813 lcs_hdr = (struct lcs_header *) buffer->data;
1814 if (lcs_hdr->offset == LCS_ILLEGAL_OFFSET) {
1815 LCS_DBF_TEXT(4, trace, "-eiogpkt");
1818 card = container_of(channel, struct lcs_card, read);
1820 while (lcs_hdr->offset != 0) {
1821 if (lcs_hdr->offset <= 0 ||
1822 lcs_hdr->offset > LCS_IOBUFFERSIZE ||
1823 lcs_hdr->offset < offset) {
1824 /* Offset invalid. */
1825 card->stats.rx_length_errors++;
1826 card->stats.rx_errors++;
1829 /* What kind of frame is it? */
1830 if (lcs_hdr->type == LCS_FRAME_TYPE_CONTROL)
1831 /* Control frame. */
1832 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr);
1833 else if (lcs_hdr->type == LCS_FRAME_TYPE_ENET ||
1834 lcs_hdr->type == LCS_FRAME_TYPE_TR ||
1835 lcs_hdr->type == LCS_FRAME_TYPE_FDDI)
1836 /* Normal network packet. */
1837 lcs_get_skb(card, (char *)(lcs_hdr + 1),
1838 lcs_hdr->offset - offset -
1839 sizeof(struct lcs_header));
1841 /* Unknown frame type. */
1842 ; // FIXME: error message ?
1843 /* Proceed to next frame. */
1844 offset = lcs_hdr->offset;
1845 lcs_hdr->offset = LCS_ILLEGAL_OFFSET;
1846 lcs_hdr = (struct lcs_header *) (buffer->data + offset);
1848 /* The buffer is now empty. Make it ready again. */
1849 lcs_ready_buffer(&card->read, buffer);
1853 * get network statistics for ifconfig and other user programs
1855 static struct net_device_stats *
1856 lcs_getstats(struct net_device *dev)
1858 struct lcs_card *card;
1860 LCS_DBF_TEXT(4, trace, "netstats");
1861 card = (struct lcs_card *) dev->priv;
1862 return &card->stats;
1867 * This function will be called by user doing ifconfig xxx down
1870 lcs_stop_device(struct net_device *dev)
1872 struct lcs_card *card;
1875 LCS_DBF_TEXT(2, trace, "stopdev");
1876 card = (struct lcs_card *) dev->priv;
1877 netif_carrier_off(dev);
1878 netif_tx_disable(dev);
1879 dev->flags &= ~IFF_UP;
1880 wait_event(card->write.wait_q,
1881 (card->write.state != LCS_CH_STATE_RUNNING));
1882 rc = lcs_stopcard(card);
1884 PRINT_ERR("Try it again!\n ");
1889 * start lcs device and make it runnable
1890 * This function will be called by user doing ifconfig xxx up
1893 lcs_open_device(struct net_device *dev)
1895 struct lcs_card *card;
1898 LCS_DBF_TEXT(2, trace, "opendev");
1899 card = (struct lcs_card *) dev->priv;
1900 /* initialize statistics */
1901 rc = lcs_detect(card);
1903 PRINT_ERR("LCS:Error in opening device!\n");
1906 dev->flags |= IFF_UP;
1907 netif_carrier_on(dev);
1908 netif_wake_queue(dev);
1909 card->state = DEV_STATE_UP;
1915 * show function for portno called by cat or similar things
1918 lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
1920 struct lcs_card *card;
1922 card = (struct lcs_card *)dev->driver_data;
1927 return sprintf(buf, "%d\n", card->portno);
1931 * store the value which is piped to file portno
1934 lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1936 struct lcs_card *card;
1939 card = (struct lcs_card *)dev->driver_data;
1944 sscanf(buf, "%u", &value);
1945 /* TODO: sanity checks */
1946 card->portno = value;
1952 static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
1955 lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1957 struct ccwgroup_device *cgdev;
1959 cgdev = to_ccwgroupdev(dev);
1963 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
1966 static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
1969 lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
1971 struct lcs_card *card;
1973 card = (struct lcs_card *)dev->driver_data;
1975 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
1979 lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1981 struct lcs_card *card;
1984 card = (struct lcs_card *)dev->driver_data;
1989 sscanf(buf, "%u", &value);
1990 /* TODO: sanity checks */
1991 card->lancmd_timeout = value;
1997 static DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
2000 lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
2001 const char *buf, size_t count)
2003 struct lcs_card *card = dev->driver_data;
2009 if (card->state != DEV_STATE_UP)
2011 i = simple_strtoul(buf, &tmp, 16);
2013 lcs_schedule_recovery(card);
2017 static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store);
2019 static struct attribute * lcs_attrs[] = {
2020 &dev_attr_portno.attr,
2021 &dev_attr_type.attr,
2022 &dev_attr_lancmd_timeout.attr,
2023 &dev_attr_recover.attr,
2027 static struct attribute_group lcs_attr_group = {
2032 * lcs_probe_device is called on establishing a new ccwgroup_device.
2035 lcs_probe_device(struct ccwgroup_device *ccwgdev)
2037 struct lcs_card *card;
2040 if (!get_device(&ccwgdev->dev))
2043 LCS_DBF_TEXT(2, setup, "add_dev");
2044 card = lcs_alloc_card();
2046 LCS_DBF_TEXT_(2, setup, " rc%d", -ENOMEM);
2047 put_device(&ccwgdev->dev);
2050 ret = sysfs_create_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2052 lcs_free_card(card);
2053 put_device(&ccwgdev->dev);
2056 ccwgdev->dev.driver_data = card;
2057 ccwgdev->cdev[0]->handler = lcs_irq;
2058 ccwgdev->cdev[1]->handler = lcs_irq;
2059 card->gdev = ccwgdev;
2060 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2061 card->thread_start_mask = 0;
2062 card->thread_allowed_mask = 0;
2063 card->thread_running_mask = 0;
2068 lcs_register_netdev(struct ccwgroup_device *ccwgdev)
2070 struct lcs_card *card;
2072 LCS_DBF_TEXT(2, setup, "regnetdv");
2073 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2074 if (card->dev->reg_state != NETREG_UNINITIALIZED)
2076 SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
2077 return register_netdev(card->dev);
2081 * lcs_new_device will be called by setting the group device online.
2085 lcs_new_device(struct ccwgroup_device *ccwgdev)
2087 struct lcs_card *card;
2088 struct net_device *dev=NULL;
2089 enum lcs_dev_states recover_state;
2092 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2096 LCS_DBF_TEXT(2, setup, "newdev");
2097 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2098 card->read.ccwdev = ccwgdev->cdev[0];
2099 card->write.ccwdev = ccwgdev->cdev[1];
2101 recover_state = card->state;
2102 ccw_device_set_online(card->read.ccwdev);
2103 ccw_device_set_online(card->write.ccwdev);
2105 LCS_DBF_TEXT(3, setup, "lcsnewdv");
2107 lcs_setup_card(card);
2108 rc = lcs_detect(card);
2110 LCS_DBF_TEXT(2, setup, "dtctfail");
2111 PRINT_WARN("Detection of LCS card failed with return code "
2112 "%d (0x%x)\n", rc, rc);
2117 LCS_DBF_TEXT(2, setup, "samedev");
2118 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2121 switch (card->lan_type) {
2122 #ifdef CONFIG_NET_ETHERNET
2123 case LCS_FRAME_TYPE_ENET:
2124 card->lan_type_trans = eth_type_trans;
2125 dev = alloc_etherdev(0);
2129 case LCS_FRAME_TYPE_TR:
2130 card->lan_type_trans = tr_type_trans;
2131 dev = alloc_trdev(0);
2135 case LCS_FRAME_TYPE_FDDI:
2136 card->lan_type_trans = fddi_type_trans;
2137 dev = alloc_fddidev(0);
2141 LCS_DBF_TEXT(3, setup, "errinit");
2142 PRINT_ERR("LCS: Initialization failed\n");
2148 card->dev->priv = card;
2149 card->dev->open = lcs_open_device;
2150 card->dev->stop = lcs_stop_device;
2151 card->dev->hard_start_xmit = lcs_start_xmit;
2152 card->dev->get_stats = lcs_getstats;
2153 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
2154 #ifdef CONFIG_IP_MULTICAST
2155 if (!lcs_check_multicast_support(card))
2156 card->dev->set_multicast_list = lcs_set_multicast_list;
2159 lcs_set_allowed_threads(card,0xffffffff);
2160 if (recover_state == DEV_STATE_RECOVER) {
2161 lcs_set_multicast_list(card->dev);
2162 card->dev->flags |= IFF_UP;
2163 netif_carrier_on(card->dev);
2164 netif_wake_queue(card->dev);
2165 card->state = DEV_STATE_UP;
2170 if (lcs_register_netdev(ccwgdev) != 0)
2173 /* Print out supported assists: IPv6 */
2174 PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
2175 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
2176 "with" : "without");
2177 /* Print out supported assist: Multicast */
2178 PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
2179 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
2180 "with" : "without");
2184 ccw_device_set_offline(card->read.ccwdev);
2185 ccw_device_set_offline(card->write.ccwdev);
2190 * lcs_shutdown_device, called when setting the group device offline.
2193 __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
2195 struct lcs_card *card;
2196 enum lcs_dev_states recover_state;
2199 LCS_DBF_TEXT(3, setup, "shtdndev");
2200 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2203 if (recovery_mode == 0) {
2204 lcs_set_allowed_threads(card, 0);
2205 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
2206 return -ERESTARTSYS;
2208 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2209 recover_state = card->state;
2211 ret = lcs_stop_device(card->dev);
2212 ret = ccw_device_set_offline(card->read.ccwdev);
2213 ret = ccw_device_set_offline(card->write.ccwdev);
2214 if (recover_state == DEV_STATE_UP) {
2215 card->state = DEV_STATE_RECOVER;
2223 lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2225 return __lcs_shutdown_device(ccwgdev, 0);
2229 * drive lcs recovery after startup and startlan initiated by Lan Gateway
2232 lcs_recovery(void *ptr)
2234 struct lcs_card *card;
2235 struct ccwgroup_device *gdev;
2238 card = (struct lcs_card *) ptr;
2239 daemonize("lcs_recover");
2241 LCS_DBF_TEXT(4, trace, "recover1");
2242 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD))
2244 LCS_DBF_TEXT(4, trace, "recover2");
2246 PRINT_WARN("Recovery of device %s started...\n", gdev->dev.bus_id);
2247 rc = __lcs_shutdown_device(gdev, 1);
2248 rc = lcs_new_device(gdev);
2250 PRINT_INFO("Device %s successfully recovered!\n",
2253 PRINT_INFO("Device %s could not be recovered!\n",
2255 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
2260 * lcs_remove_device, free buffers and card
2263 lcs_remove_device(struct ccwgroup_device *ccwgdev)
2265 struct lcs_card *card;
2267 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2271 LCS_DBF_TEXT(3, setup, "remdev");
2272 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2273 if (ccwgdev->state == CCWGROUP_ONLINE) {
2274 lcs_shutdown_device(ccwgdev);
2277 unregister_netdev(card->dev);
2278 sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2279 lcs_cleanup_card(card);
2280 lcs_free_card(card);
2281 put_device(&ccwgdev->dev);
2285 * LCS ccwgroup driver registration
2287 static struct ccwgroup_driver lcs_group_driver = {
2288 .owner = THIS_MODULE,
2291 .driver_id = 0xD3C3E2,
2292 .probe = lcs_probe_device,
2293 .remove = lcs_remove_device,
2294 .set_online = lcs_new_device,
2295 .set_offline = lcs_shutdown_device,
2299 * LCS Module/Kernel initialization function
2302 __init lcs_init_module(void)
2306 PRINT_INFO("Loading %s\n",version);
2307 rc = lcs_register_debug_facility();
2308 LCS_DBF_TEXT(0, setup, "lcsinit");
2310 PRINT_ERR("Initialization failed\n");
2314 rc = register_cu3088_discipline(&lcs_group_driver);
2316 PRINT_ERR("Initialization failed\n");
2324 * LCS module cleanup function
2327 __exit lcs_cleanup_module(void)
2329 PRINT_INFO("Terminating lcs module.\n");
2330 LCS_DBF_TEXT(0, trace, "cleanup");
2331 unregister_cu3088_discipline(&lcs_group_driver);
2332 lcs_unregister_debug_facility();
2335 module_init(lcs_init_module);
2336 module_exit(lcs_cleanup_module);
2338 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
2339 MODULE_LICENSE("GPL");