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", dev_name(&channel->ccwdev->dev));
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",
505 dev_name(&channel->ccwdev->dev));
506 PRINT_ERR("Error in starting channel, rc=%d!\n", rc);
512 lcs_clear_channel(struct lcs_channel *channel)
517 LCS_DBF_TEXT(4,trace,"clearch");
518 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
519 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
520 rc = ccw_device_clear(channel->ccwdev, (addr_t) channel);
521 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
523 LCS_DBF_TEXT_(4, trace, "ecsc%s",
524 dev_name(&channel->ccwdev->dev));
527 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_CLEARED));
528 channel->state = LCS_CH_STATE_STOPPED;
537 lcs_stop_channel(struct lcs_channel *channel)
542 if (channel->state == LCS_CH_STATE_STOPPED)
544 LCS_DBF_TEXT(4,trace,"haltsch");
545 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
546 channel->state = LCS_CH_STATE_INIT;
547 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
548 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
549 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
551 LCS_DBF_TEXT_(4, trace, "ehsc%s",
552 dev_name(&channel->ccwdev->dev));
555 /* Asynchronous halt initialted. Wait for its completion. */
556 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_HALTED));
557 lcs_clear_channel(channel);
562 * start read and write channel
565 lcs_start_channels(struct lcs_card *card)
569 LCS_DBF_TEXT(2, trace, "chstart");
570 /* start read channel */
571 rc = lcs_start_channel(&card->read);
574 /* start write channel */
575 rc = lcs_start_channel(&card->write);
577 lcs_stop_channel(&card->read);
582 * stop read and write channel
585 lcs_stop_channels(struct lcs_card *card)
587 LCS_DBF_TEXT(2, trace, "chhalt");
588 lcs_stop_channel(&card->read);
589 lcs_stop_channel(&card->write);
596 static struct lcs_buffer *
597 __lcs_get_buffer(struct lcs_channel *channel)
601 LCS_DBF_TEXT(5, trace, "_getbuff");
602 index = channel->io_idx;
604 if (channel->iob[index].state == LCS_BUF_STATE_EMPTY) {
605 channel->iob[index].state = LCS_BUF_STATE_LOCKED;
606 return channel->iob + index;
608 index = (index + 1) & (LCS_NUM_BUFFS - 1);
609 } while (index != channel->io_idx);
613 static struct lcs_buffer *
614 lcs_get_buffer(struct lcs_channel *channel)
616 struct lcs_buffer *buffer;
619 LCS_DBF_TEXT(5, trace, "getbuff");
620 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
621 buffer = __lcs_get_buffer(channel);
622 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
627 * Resume channel program if the channel is suspended.
630 __lcs_resume_channel(struct lcs_channel *channel)
634 if (channel->state != LCS_CH_STATE_SUSPENDED)
636 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
638 LCS_DBF_TEXT_(5, trace, "rsch%s", dev_name(&channel->ccwdev->dev));
639 rc = ccw_device_resume(channel->ccwdev);
641 LCS_DBF_TEXT_(4, trace, "ersc%s",
642 dev_name(&channel->ccwdev->dev));
643 PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc);
645 channel->state = LCS_CH_STATE_RUNNING;
651 * Make a buffer ready for processing.
654 __lcs_ready_buffer_bits(struct lcs_channel *channel, int index)
658 LCS_DBF_TEXT(5, trace, "rdybits");
659 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
660 next = (index + 1) & (LCS_NUM_BUFFS - 1);
661 /* Check if we may clear the suspend bit of this buffer. */
662 if (channel->ccws[next].flags & CCW_FLAG_SUSPEND) {
663 /* Check if we have to set the PCI bit. */
664 if (!(channel->ccws[prev].flags & CCW_FLAG_SUSPEND))
665 /* Suspend bit of the previous buffer is not set. */
666 channel->ccws[index].flags |= CCW_FLAG_PCI;
667 /* Suspend bit of the next buffer is set. */
668 channel->ccws[index].flags &= ~CCW_FLAG_SUSPEND;
673 lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
678 LCS_DBF_TEXT(5, trace, "rdybuff");
679 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
680 buffer->state != LCS_BUF_STATE_PROCESSED);
681 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
682 buffer->state = LCS_BUF_STATE_READY;
683 index = buffer - channel->iob;
685 channel->ccws[index].count = buffer->count;
686 /* Check relevant PCI/suspend bits. */
687 __lcs_ready_buffer_bits(channel, index);
688 rc = __lcs_resume_channel(channel);
689 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
694 * Mark the buffer as processed. Take care of the suspend bit
695 * of the previous buffer. This function is called from
696 * interrupt context, so the lock must not be taken.
699 __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
701 int index, prev, next;
703 LCS_DBF_TEXT(5, trace, "prcsbuff");
704 BUG_ON(buffer->state != LCS_BUF_STATE_READY);
705 buffer->state = LCS_BUF_STATE_PROCESSED;
706 index = buffer - channel->iob;
707 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
708 next = (index + 1) & (LCS_NUM_BUFFS - 1);
709 /* Set the suspend bit and clear the PCI bit of this buffer. */
710 channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
711 channel->ccws[index].flags &= ~CCW_FLAG_PCI;
712 /* Check the suspend bit of the previous buffer. */
713 if (channel->iob[prev].state == LCS_BUF_STATE_READY) {
715 * Previous buffer is in state ready. It might have
716 * happened in lcs_ready_buffer that the suspend bit
717 * has not been cleared to avoid an endless loop.
720 __lcs_ready_buffer_bits(channel, prev);
722 /* Clear PCI bit of next buffer. */
723 channel->ccws[next].flags &= ~CCW_FLAG_PCI;
724 return __lcs_resume_channel(channel);
728 * Put a processed buffer back to state empty.
731 lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
735 LCS_DBF_TEXT(5, trace, "relbuff");
736 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
737 buffer->state != LCS_BUF_STATE_PROCESSED);
738 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
739 buffer->state = LCS_BUF_STATE_EMPTY;
740 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
744 * Get buffer for a lan command.
746 static struct lcs_buffer *
747 lcs_get_lancmd(struct lcs_card *card, int count)
749 struct lcs_buffer *buffer;
752 LCS_DBF_TEXT(4, trace, "getlncmd");
753 /* Get buffer and wait if none is available. */
754 wait_event(card->write.wait_q,
755 ((buffer = lcs_get_buffer(&card->write)) != NULL));
756 count += sizeof(struct lcs_header);
757 *(__u16 *)(buffer->data + count) = 0;
758 buffer->count = count + sizeof(__u16);
759 buffer->callback = lcs_release_buffer;
760 cmd = (struct lcs_cmd *) buffer->data;
762 cmd->type = LCS_FRAME_TYPE_CONTROL;
769 lcs_get_reply(struct lcs_reply *reply)
771 WARN_ON(atomic_read(&reply->refcnt) <= 0);
772 atomic_inc(&reply->refcnt);
776 lcs_put_reply(struct lcs_reply *reply)
778 WARN_ON(atomic_read(&reply->refcnt) <= 0);
779 if (atomic_dec_and_test(&reply->refcnt)) {
785 static struct lcs_reply *
786 lcs_alloc_reply(struct lcs_cmd *cmd)
788 struct lcs_reply *reply;
790 LCS_DBF_TEXT(4, trace, "getreply");
792 reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
795 atomic_set(&reply->refcnt,1);
796 reply->sequence_no = cmd->sequence_no;
799 init_waitqueue_head(&reply->wait_q);
805 * Notifier function for lancmd replies. Called from read irq.
808 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
810 struct list_head *l, *n;
811 struct lcs_reply *reply;
813 LCS_DBF_TEXT(4, trace, "notiwait");
814 spin_lock(&card->lock);
815 list_for_each_safe(l, n, &card->lancmd_waiters) {
816 reply = list_entry(l, struct lcs_reply, list);
817 if (reply->sequence_no == cmd->sequence_no) {
818 lcs_get_reply(reply);
819 list_del_init(&reply->list);
820 if (reply->callback != NULL)
821 reply->callback(card, cmd);
823 reply->rc = cmd->return_code;
824 wake_up(&reply->wait_q);
825 lcs_put_reply(reply);
829 spin_unlock(&card->lock);
833 * Emit buffer of a lan comand.
836 lcs_lancmd_timeout(unsigned long data)
838 struct lcs_reply *reply, *list_reply, *r;
841 LCS_DBF_TEXT(4, trace, "timeout");
842 reply = (struct lcs_reply *) data;
843 spin_lock_irqsave(&reply->card->lock, flags);
844 list_for_each_entry_safe(list_reply, r,
845 &reply->card->lancmd_waiters,list) {
846 if (reply == list_reply) {
847 lcs_get_reply(reply);
848 list_del_init(&reply->list);
849 spin_unlock_irqrestore(&reply->card->lock, flags);
852 wake_up(&reply->wait_q);
853 lcs_put_reply(reply);
857 spin_unlock_irqrestore(&reply->card->lock, flags);
861 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
862 void (*reply_callback)(struct lcs_card *, struct lcs_cmd *))
864 struct lcs_reply *reply;
866 struct timer_list timer;
870 LCS_DBF_TEXT(4, trace, "sendcmd");
871 cmd = (struct lcs_cmd *) buffer->data;
872 cmd->return_code = 0;
873 cmd->sequence_no = card->sequence_no++;
874 reply = lcs_alloc_reply(cmd);
877 reply->callback = reply_callback;
879 spin_lock_irqsave(&card->lock, flags);
880 list_add_tail(&reply->list, &card->lancmd_waiters);
881 spin_unlock_irqrestore(&card->lock, flags);
883 buffer->callback = lcs_release_buffer;
884 rc = lcs_ready_buffer(&card->write, buffer);
888 timer.function = lcs_lancmd_timeout;
889 timer.data = (unsigned long) reply;
890 timer.expires = jiffies + HZ*card->lancmd_timeout;
892 wait_event(reply->wait_q, reply->received);
893 del_timer_sync(&timer);
894 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
896 lcs_put_reply(reply);
897 return rc ? -EIO : 0;
901 * LCS startup command
904 lcs_send_startup(struct lcs_card *card, __u8 initiator)
906 struct lcs_buffer *buffer;
909 LCS_DBF_TEXT(2, trace, "startup");
910 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
911 cmd = (struct lcs_cmd *) buffer->data;
912 cmd->cmd_code = LCS_CMD_STARTUP;
913 cmd->initiator = initiator;
914 cmd->cmd.lcs_startup.buff_size = LCS_IOBUFFERSIZE;
915 return lcs_send_lancmd(card, buffer, NULL);
919 * LCS shutdown command
922 lcs_send_shutdown(struct lcs_card *card)
924 struct lcs_buffer *buffer;
927 LCS_DBF_TEXT(2, trace, "shutdown");
928 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
929 cmd = (struct lcs_cmd *) buffer->data;
930 cmd->cmd_code = LCS_CMD_SHUTDOWN;
931 cmd->initiator = LCS_INITIATOR_TCPIP;
932 return lcs_send_lancmd(card, buffer, NULL);
936 * LCS lanstat command
939 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd)
941 LCS_DBF_TEXT(2, trace, "statcb");
942 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH);
946 lcs_send_lanstat(struct lcs_card *card)
948 struct lcs_buffer *buffer;
951 LCS_DBF_TEXT(2,trace, "cmdstat");
952 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
953 cmd = (struct lcs_cmd *) buffer->data;
954 /* Setup lanstat command. */
955 cmd->cmd_code = LCS_CMD_LANSTAT;
956 cmd->initiator = LCS_INITIATOR_TCPIP;
957 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
958 cmd->cmd.lcs_std_cmd.portno = card->portno;
959 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb);
963 * send stoplan command
966 lcs_send_stoplan(struct lcs_card *card, __u8 initiator)
968 struct lcs_buffer *buffer;
971 LCS_DBF_TEXT(2, trace, "cmdstpln");
972 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
973 cmd = (struct lcs_cmd *) buffer->data;
974 cmd->cmd_code = LCS_CMD_STOPLAN;
975 cmd->initiator = initiator;
976 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
977 cmd->cmd.lcs_std_cmd.portno = card->portno;
978 return lcs_send_lancmd(card, buffer, NULL);
982 * send startlan command
985 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd)
987 LCS_DBF_TEXT(2, trace, "srtlancb");
988 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type;
989 card->portno = cmd->cmd.lcs_std_cmd.portno;
993 lcs_send_startlan(struct lcs_card *card, __u8 initiator)
995 struct lcs_buffer *buffer;
998 LCS_DBF_TEXT(2, trace, "cmdstaln");
999 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1000 cmd = (struct lcs_cmd *) buffer->data;
1001 cmd->cmd_code = LCS_CMD_STARTLAN;
1002 cmd->initiator = initiator;
1003 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
1004 cmd->cmd.lcs_std_cmd.portno = card->portno;
1005 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb);
1008 #ifdef CONFIG_IP_MULTICAST
1010 * send setipm command (Multicast)
1013 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1015 struct lcs_buffer *buffer;
1016 struct lcs_cmd *cmd;
1018 LCS_DBF_TEXT(2, trace, "cmdsetim");
1019 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1020 cmd = (struct lcs_cmd *) buffer->data;
1021 cmd->cmd_code = LCS_CMD_SETIPM;
1022 cmd->initiator = LCS_INITIATOR_TCPIP;
1023 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1024 cmd->cmd.lcs_qipassist.portno = card->portno;
1025 cmd->cmd.lcs_qipassist.version = 4;
1026 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1027 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1028 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1029 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1030 return lcs_send_lancmd(card, buffer, NULL);
1034 * send delipm command (Multicast)
1037 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1039 struct lcs_buffer *buffer;
1040 struct lcs_cmd *cmd;
1042 LCS_DBF_TEXT(2, trace, "cmddelim");
1043 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1044 cmd = (struct lcs_cmd *) buffer->data;
1045 cmd->cmd_code = LCS_CMD_DELIPM;
1046 cmd->initiator = LCS_INITIATOR_TCPIP;
1047 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1048 cmd->cmd.lcs_qipassist.portno = card->portno;
1049 cmd->cmd.lcs_qipassist.version = 4;
1050 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1051 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1052 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1053 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1054 return lcs_send_lancmd(card, buffer, NULL);
1058 * check if multicast is supported by LCS
1061 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd)
1063 LCS_DBF_TEXT(2, trace, "chkmccb");
1064 card->ip_assists_supported =
1065 cmd->cmd.lcs_qipassist.ip_assists_supported;
1066 card->ip_assists_enabled =
1067 cmd->cmd.lcs_qipassist.ip_assists_enabled;
1071 lcs_check_multicast_support(struct lcs_card *card)
1073 struct lcs_buffer *buffer;
1074 struct lcs_cmd *cmd;
1077 LCS_DBF_TEXT(2, trace, "cmdqipa");
1078 /* Send query ipassist. */
1079 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1080 cmd = (struct lcs_cmd *) buffer->data;
1081 cmd->cmd_code = LCS_CMD_QIPASSIST;
1082 cmd->initiator = LCS_INITIATOR_TCPIP;
1083 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1084 cmd->cmd.lcs_qipassist.portno = card->portno;
1085 cmd->cmd.lcs_qipassist.version = 4;
1086 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1087 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
1089 PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n");
1092 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
1098 * set or del multicast address on LCS card
1101 lcs_fix_multicast_list(struct lcs_card *card)
1103 struct list_head failed_list;
1104 struct lcs_ipm_list *ipm, *tmp;
1105 unsigned long flags;
1108 LCS_DBF_TEXT(4,trace, "fixipm");
1109 INIT_LIST_HEAD(&failed_list);
1110 spin_lock_irqsave(&card->ipm_lock, flags);
1112 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){
1113 switch (ipm->ipm_state) {
1114 case LCS_IPM_STATE_SET_REQUIRED:
1115 /* del from ipm_list so noone else can tamper with
1117 list_del_init(&ipm->list);
1118 spin_unlock_irqrestore(&card->ipm_lock, flags);
1119 rc = lcs_send_setipm(card, ipm);
1120 spin_lock_irqsave(&card->ipm_lock, flags);
1122 PRINT_INFO("Adding multicast address failed. "
1123 "Table possibly full!\n");
1124 /* store ipm in failed list -> will be added
1125 * to ipm_list again, so a retry will be done
1126 * during the next call of this function */
1127 list_add_tail(&ipm->list, &failed_list);
1129 ipm->ipm_state = LCS_IPM_STATE_ON_CARD;
1130 /* re-insert into ipm_list */
1131 list_add_tail(&ipm->list, &card->ipm_list);
1134 case LCS_IPM_STATE_DEL_REQUIRED:
1135 list_del(&ipm->list);
1136 spin_unlock_irqrestore(&card->ipm_lock, flags);
1137 lcs_send_delipm(card, ipm);
1138 spin_lock_irqsave(&card->ipm_lock, flags);
1141 case LCS_IPM_STATE_ON_CARD:
1145 /* re-insert all entries from the failed_list into ipm_list */
1146 list_for_each_entry_safe(ipm, tmp, &failed_list, list)
1147 list_move_tail(&ipm->list, &card->ipm_list);
1149 spin_unlock_irqrestore(&card->ipm_lock, flags);
1153 * get mac address for the relevant Multicast address
1156 lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1158 LCS_DBF_TEXT(4,trace, "getmac");
1159 if (dev->type == ARPHRD_IEEE802_TR)
1160 ip_tr_mc_map(ipm, mac);
1162 ip_eth_mc_map(ipm, mac);
1166 * function called by net device to handle multicast address relevant things
1169 lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1171 struct ip_mc_list *im4;
1172 struct list_head *l;
1173 struct lcs_ipm_list *ipm;
1174 unsigned long flags;
1175 char buf[MAX_ADDR_LEN];
1177 LCS_DBF_TEXT(4, trace, "remmclst");
1178 spin_lock_irqsave(&card->ipm_lock, flags);
1179 list_for_each(l, &card->ipm_list) {
1180 ipm = list_entry(l, struct lcs_ipm_list, list);
1181 for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
1182 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1183 if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
1184 (memcmp(buf, &ipm->ipm.mac_addr,
1185 LCS_MAC_LENGTH) == 0) )
1189 ipm->ipm_state = LCS_IPM_STATE_DEL_REQUIRED;
1191 spin_unlock_irqrestore(&card->ipm_lock, flags);
1194 static inline struct lcs_ipm_list *
1195 lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf)
1197 struct lcs_ipm_list *tmp, *ipm = NULL;
1198 struct list_head *l;
1199 unsigned long flags;
1201 LCS_DBF_TEXT(4, trace, "chkmcent");
1202 spin_lock_irqsave(&card->ipm_lock, flags);
1203 list_for_each(l, &card->ipm_list) {
1204 tmp = list_entry(l, struct lcs_ipm_list, list);
1205 if ( (tmp->ipm.ip_addr == im4->multiaddr) &&
1206 (memcmp(buf, &tmp->ipm.mac_addr,
1207 LCS_MAC_LENGTH) == 0) ) {
1212 spin_unlock_irqrestore(&card->ipm_lock, flags);
1217 lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1220 struct ip_mc_list *im4;
1221 struct lcs_ipm_list *ipm;
1222 char buf[MAX_ADDR_LEN];
1223 unsigned long flags;
1225 LCS_DBF_TEXT(4, trace, "setmclst");
1226 for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
1227 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1228 ipm = lcs_check_addr_entry(card, im4, buf);
1230 continue; /* Address already in list. */
1231 ipm = (struct lcs_ipm_list *)
1232 kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
1234 PRINT_INFO("Not enough memory to add "
1235 "new multicast entry!\n");
1238 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
1239 ipm->ipm.ip_addr = im4->multiaddr;
1240 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
1241 spin_lock_irqsave(&card->ipm_lock, flags);
1242 LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4);
1243 list_add(&ipm->list, &card->ipm_list);
1244 spin_unlock_irqrestore(&card->ipm_lock, flags);
1249 lcs_register_mc_addresses(void *data)
1251 struct lcs_card *card;
1252 struct in_device *in4_dev;
1254 card = (struct lcs_card *) data;
1255 daemonize("regipm");
1257 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD))
1259 LCS_DBF_TEXT(4, trace, "regmulti");
1261 in4_dev = in_dev_get(card->dev);
1262 if (in4_dev == NULL)
1264 read_lock(&in4_dev->mc_list_lock);
1265 lcs_remove_mc_addresses(card,in4_dev);
1266 lcs_set_mc_addresses(card, in4_dev);
1267 read_unlock(&in4_dev->mc_list_lock);
1268 in_dev_put(in4_dev);
1270 netif_carrier_off(card->dev);
1271 netif_tx_disable(card->dev);
1272 wait_event(card->write.wait_q,
1273 (card->write.state != LCS_CH_STATE_RUNNING));
1274 lcs_fix_multicast_list(card);
1275 if (card->state == DEV_STATE_UP) {
1276 netif_carrier_on(card->dev);
1277 netif_wake_queue(card->dev);
1280 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
1284 * function called by net device to
1285 * handle multicast address relevant things
1288 lcs_set_multicast_list(struct net_device *dev)
1290 struct lcs_card *card;
1292 LCS_DBF_TEXT(4, trace, "setmulti");
1293 card = (struct lcs_card *) dev->priv;
1295 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD))
1296 schedule_work(&card->kernel_thread_starter);
1299 #endif /* CONFIG_IP_MULTICAST */
1302 lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
1307 switch (PTR_ERR(irb)) {
1309 PRINT_WARN("i/o-error on device %s\n", dev_name(&cdev->dev));
1310 LCS_DBF_TEXT(2, trace, "ckirberr");
1311 LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
1314 PRINT_WARN("timeout on device %s\n", dev_name(&cdev->dev));
1315 LCS_DBF_TEXT(2, trace, "ckirberr");
1316 LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
1319 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
1320 dev_name(&cdev->dev));
1321 LCS_DBF_TEXT(2, trace, "ckirberr");
1322 LCS_DBF_TEXT(2, trace, " rc???");
1324 return PTR_ERR(irb);
1328 lcs_get_problem(struct ccw_device *cdev, struct irb *irb)
1333 sense = (char *) irb->ecw;
1334 cstat = irb->scsw.cmd.cstat;
1335 dstat = irb->scsw.cmd.dstat;
1337 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
1338 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
1339 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
1340 LCS_DBF_TEXT(2, trace, "CGENCHK");
1343 if (dstat & DEV_STAT_UNIT_CHECK) {
1344 if (sense[LCS_SENSE_BYTE_1] &
1345 LCS_SENSE_RESETTING_EVENT) {
1346 LCS_DBF_TEXT(2, trace, "REVIND");
1349 if (sense[LCS_SENSE_BYTE_0] &
1350 LCS_SENSE_CMD_REJECT) {
1351 LCS_DBF_TEXT(2, trace, "CMDREJ");
1354 if ((!sense[LCS_SENSE_BYTE_0]) &&
1355 (!sense[LCS_SENSE_BYTE_1]) &&
1356 (!sense[LCS_SENSE_BYTE_2]) &&
1357 (!sense[LCS_SENSE_BYTE_3])) {
1358 LCS_DBF_TEXT(2, trace, "ZEROSEN");
1361 LCS_DBF_TEXT(2, trace, "DGENCHK");
1368 lcs_schedule_recovery(struct lcs_card *card)
1370 LCS_DBF_TEXT(2, trace, "startrec");
1371 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD))
1372 schedule_work(&card->kernel_thread_starter);
1376 * IRQ Handler for LCS channels
1379 lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1381 struct lcs_card *card;
1382 struct lcs_channel *channel;
1386 if (lcs_check_irb_error(cdev, irb))
1389 card = CARD_FROM_DEV(cdev);
1390 if (card->read.ccwdev == cdev)
1391 channel = &card->read;
1393 channel = &card->write;
1395 cstat = irb->scsw.cmd.cstat;
1396 dstat = irb->scsw.cmd.dstat;
1397 LCS_DBF_TEXT_(5, trace, "Rint%s", dev_name(&cdev->dev));
1398 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.cstat,
1399 irb->scsw.cmd.dstat);
1400 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.fctl,
1401 irb->scsw.cmd.actl);
1403 /* Check for channel and device errors presented */
1404 rc = lcs_get_problem(cdev, irb);
1405 if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
1406 PRINT_WARN("check on device %s, dstat=0x%X, cstat=0x%X \n",
1407 dev_name(&cdev->dev), dstat, cstat);
1409 channel->state = LCS_CH_STATE_ERROR;
1412 if (channel->state == LCS_CH_STATE_ERROR) {
1413 lcs_schedule_recovery(card);
1414 wake_up(&card->wait_q);
1417 /* How far in the ccw chain have we processed? */
1418 if ((channel->state != LCS_CH_STATE_INIT) &&
1419 (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) &&
1420 (irb->scsw.cmd.cpa != 0)) {
1421 index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa)
1423 if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) ||
1424 (irb->scsw.cmd.cstat & SCHN_STAT_PCI))
1425 /* Bloody io subsystem tells us lies about cpa... */
1426 index = (index - 1) & (LCS_NUM_BUFFS - 1);
1427 while (channel->io_idx != index) {
1428 __lcs_processed_buffer(channel,
1429 channel->iob + channel->io_idx);
1431 (channel->io_idx + 1) & (LCS_NUM_BUFFS - 1);
1435 if ((irb->scsw.cmd.dstat & DEV_STAT_DEV_END) ||
1436 (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) ||
1437 (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK))
1438 /* Mark channel as stopped. */
1439 channel->state = LCS_CH_STATE_STOPPED;
1440 else if (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)
1441 /* CCW execution stopped on a suspend bit. */
1442 channel->state = LCS_CH_STATE_SUSPENDED;
1443 if (irb->scsw.cmd.fctl & SCSW_FCTL_HALT_FUNC) {
1444 if (irb->scsw.cmd.cc != 0) {
1445 ccw_device_halt(channel->ccwdev, (addr_t) channel);
1448 /* The channel has been stopped by halt_IO. */
1449 channel->state = LCS_CH_STATE_HALTED;
1451 if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC)
1452 channel->state = LCS_CH_STATE_CLEARED;
1453 /* Do the rest in the tasklet. */
1454 tasklet_schedule(&channel->irq_tasklet);
1458 * Tasklet for IRQ handler
1461 lcs_tasklet(unsigned long data)
1463 unsigned long flags;
1464 struct lcs_channel *channel;
1465 struct lcs_buffer *iob;
1469 channel = (struct lcs_channel *) data;
1470 LCS_DBF_TEXT_(5, trace, "tlet%s", dev_name(&channel->ccwdev->dev));
1472 /* Check for processed buffers. */
1474 buf_idx = channel->buf_idx;
1475 while (iob[buf_idx].state == LCS_BUF_STATE_PROCESSED) {
1476 /* Do the callback thing. */
1477 if (iob[buf_idx].callback != NULL)
1478 iob[buf_idx].callback(channel, iob + buf_idx);
1479 buf_idx = (buf_idx + 1) & (LCS_NUM_BUFFS - 1);
1481 channel->buf_idx = buf_idx;
1483 if (channel->state == LCS_CH_STATE_STOPPED)
1484 // FIXME: what if rc != 0 ??
1485 rc = lcs_start_channel(channel);
1486 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1487 if (channel->state == LCS_CH_STATE_SUSPENDED &&
1488 channel->iob[channel->io_idx].state == LCS_BUF_STATE_READY) {
1489 // FIXME: what if rc != 0 ??
1490 rc = __lcs_resume_channel(channel);
1492 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1494 /* Something happened on the channel. Wake up waiters. */
1495 wake_up(&channel->wait_q);
1499 * Finish current tx buffer and make it ready for transmit.
1502 __lcs_emit_txbuffer(struct lcs_card *card)
1504 LCS_DBF_TEXT(5, trace, "emittx");
1505 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0;
1506 card->tx_buffer->count += 2;
1507 lcs_ready_buffer(&card->write, card->tx_buffer);
1508 card->tx_buffer = NULL;
1513 * Callback for finished tx buffers.
1516 lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1518 struct lcs_card *card;
1520 LCS_DBF_TEXT(5, trace, "txbuffcb");
1521 /* Put buffer back to pool. */
1522 lcs_release_buffer(channel, buffer);
1523 card = container_of(channel, struct lcs_card, write);
1524 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1525 netif_wake_queue(card->dev);
1526 spin_lock(&card->lock);
1528 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1530 * Last running tx buffer has finished. Submit partially
1531 * filled current buffer.
1533 __lcs_emit_txbuffer(card);
1534 spin_unlock(&card->lock);
1538 * Packet transmit function called by network stack
1541 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
1542 struct net_device *dev)
1544 struct lcs_header *header;
1547 LCS_DBF_TEXT(5, trace, "hardxmit");
1549 card->stats.tx_dropped++;
1550 card->stats.tx_errors++;
1553 if (card->state != DEV_STATE_UP) {
1555 card->stats.tx_dropped++;
1556 card->stats.tx_errors++;
1557 card->stats.tx_carrier_errors++;
1560 if (skb->protocol == htons(ETH_P_IPV6)) {
1564 netif_stop_queue(card->dev);
1565 spin_lock(&card->lock);
1566 if (card->tx_buffer != NULL &&
1567 card->tx_buffer->count + sizeof(struct lcs_header) +
1568 skb->len + sizeof(u16) > LCS_IOBUFFERSIZE)
1569 /* skb too big for current tx buffer. */
1570 __lcs_emit_txbuffer(card);
1571 if (card->tx_buffer == NULL) {
1572 /* Get new tx buffer */
1573 card->tx_buffer = lcs_get_buffer(&card->write);
1574 if (card->tx_buffer == NULL) {
1575 card->stats.tx_dropped++;
1579 card->tx_buffer->callback = lcs_txbuffer_cb;
1580 card->tx_buffer->count = 0;
1582 header = (struct lcs_header *)
1583 (card->tx_buffer->data + card->tx_buffer->count);
1584 card->tx_buffer->count += skb->len + sizeof(struct lcs_header);
1585 header->offset = card->tx_buffer->count;
1586 header->type = card->lan_type;
1587 header->slot = card->portno;
1588 skb_copy_from_linear_data(skb, header + 1, skb->len);
1589 spin_unlock(&card->lock);
1590 card->stats.tx_bytes += skb->len;
1591 card->stats.tx_packets++;
1593 netif_wake_queue(card->dev);
1594 spin_lock(&card->lock);
1595 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1596 /* If this is the first tx buffer emit it immediately. */
1597 __lcs_emit_txbuffer(card);
1599 spin_unlock(&card->lock);
1604 lcs_start_xmit(struct sk_buff *skb, struct net_device *dev)
1606 struct lcs_card *card;
1609 LCS_DBF_TEXT(5, trace, "pktxmit");
1610 card = (struct lcs_card *) dev->priv;
1611 rc = __lcs_start_xmit(card, skb, dev);
1616 * send startlan and lanstat command to make LCS device ready
1619 lcs_startlan_auto(struct lcs_card *card)
1623 LCS_DBF_TEXT(2, trace, "strtauto");
1624 #ifdef CONFIG_NET_ETHERNET
1625 card->lan_type = LCS_FRAME_TYPE_ENET;
1626 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1632 card->lan_type = LCS_FRAME_TYPE_TR;
1633 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1638 card->lan_type = LCS_FRAME_TYPE_FDDI;
1639 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1647 lcs_startlan(struct lcs_card *card)
1651 LCS_DBF_TEXT(2, trace, "startlan");
1653 if (card->portno != LCS_INVALID_PORT_NO) {
1654 if (card->lan_type == LCS_FRAME_TYPE_AUTO)
1655 rc = lcs_startlan_auto(card);
1657 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1659 for (i = 0; i <= 16; i++) {
1661 if (card->lan_type != LCS_FRAME_TYPE_AUTO)
1662 rc = lcs_send_startlan(card,
1663 LCS_INITIATOR_TCPIP);
1665 /* autodetecting lan type */
1666 rc = lcs_startlan_auto(card);
1672 return lcs_send_lanstat(card);
1677 * LCS detect function
1678 * setup channels and make them I/O ready
1681 lcs_detect(struct lcs_card *card)
1685 LCS_DBF_TEXT(2, setup, "lcsdetct");
1686 /* start/reset card */
1688 netif_stop_queue(card->dev);
1689 rc = lcs_stop_channels(card);
1691 rc = lcs_start_channels(card);
1693 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP);
1695 rc = lcs_startlan(card);
1699 card->state = DEV_STATE_UP;
1701 card->state = DEV_STATE_DOWN;
1702 card->write.state = LCS_CH_STATE_INIT;
1703 card->read.state = LCS_CH_STATE_INIT;
1712 lcs_stopcard(struct lcs_card *card)
1716 LCS_DBF_TEXT(3, setup, "stopcard");
1718 if (card->read.state != LCS_CH_STATE_STOPPED &&
1719 card->write.state != LCS_CH_STATE_STOPPED &&
1720 card->read.state != LCS_CH_STATE_ERROR &&
1721 card->write.state != LCS_CH_STATE_ERROR &&
1722 card->state == DEV_STATE_UP) {
1723 lcs_clear_multicast_list(card);
1724 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
1725 rc = lcs_send_shutdown(card);
1727 rc = lcs_stop_channels(card);
1728 card->state = DEV_STATE_DOWN;
1734 * Kernel Thread helper functions for LGW initiated commands
1737 lcs_start_kernel_thread(struct work_struct *work)
1739 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1740 LCS_DBF_TEXT(5, trace, "krnthrd");
1741 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1742 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
1743 #ifdef CONFIG_IP_MULTICAST
1744 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
1745 kernel_thread(lcs_register_mc_addresses,
1746 (void *) card, SIGCHLD);
1751 * Process control frames.
1754 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
1756 LCS_DBF_TEXT(5, trace, "getctrl");
1757 if (cmd->initiator == LCS_INITIATOR_LGW) {
1758 switch(cmd->cmd_code) {
1759 case LCS_CMD_STARTUP:
1760 case LCS_CMD_STARTLAN:
1761 lcs_schedule_recovery(card);
1763 case LCS_CMD_STOPLAN:
1764 PRINT_WARN("Stoplan for %s initiated by LGW.\n",
1767 netif_carrier_off(card->dev);
1770 LCS_DBF_TEXT(5, trace, "noLGWcmd");
1774 lcs_notify_lancmd_waiters(card, cmd);
1778 * Unpack network packet.
1781 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
1783 struct sk_buff *skb;
1785 LCS_DBF_TEXT(5, trace, "getskb");
1786 if (card->dev == NULL ||
1787 card->state != DEV_STATE_UP)
1788 /* The card isn't up. Ignore the packet. */
1791 skb = dev_alloc_skb(skb_len);
1793 PRINT_ERR("LCS: alloc_skb failed for device=%s\n",
1795 card->stats.rx_dropped++;
1798 memcpy(skb_put(skb, skb_len), skb_data, skb_len);
1799 skb->protocol = card->lan_type_trans(skb, card->dev);
1800 card->stats.rx_bytes += skb_len;
1801 card->stats.rx_packets++;
1802 if (skb->protocol == htons(ETH_P_802_2))
1803 *((__u32 *)skb->cb) = ++card->pkt_seq;
1808 * LCS main routine to get packets and lancmd replies from the buffers
1811 lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1813 struct lcs_card *card;
1814 struct lcs_header *lcs_hdr;
1817 LCS_DBF_TEXT(5, trace, "lcsgtpkt");
1818 lcs_hdr = (struct lcs_header *) buffer->data;
1819 if (lcs_hdr->offset == LCS_ILLEGAL_OFFSET) {
1820 LCS_DBF_TEXT(4, trace, "-eiogpkt");
1823 card = container_of(channel, struct lcs_card, read);
1825 while (lcs_hdr->offset != 0) {
1826 if (lcs_hdr->offset <= 0 ||
1827 lcs_hdr->offset > LCS_IOBUFFERSIZE ||
1828 lcs_hdr->offset < offset) {
1829 /* Offset invalid. */
1830 card->stats.rx_length_errors++;
1831 card->stats.rx_errors++;
1834 /* What kind of frame is it? */
1835 if (lcs_hdr->type == LCS_FRAME_TYPE_CONTROL)
1836 /* Control frame. */
1837 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr);
1838 else if (lcs_hdr->type == LCS_FRAME_TYPE_ENET ||
1839 lcs_hdr->type == LCS_FRAME_TYPE_TR ||
1840 lcs_hdr->type == LCS_FRAME_TYPE_FDDI)
1841 /* Normal network packet. */
1842 lcs_get_skb(card, (char *)(lcs_hdr + 1),
1843 lcs_hdr->offset - offset -
1844 sizeof(struct lcs_header));
1846 /* Unknown frame type. */
1847 ; // FIXME: error message ?
1848 /* Proceed to next frame. */
1849 offset = lcs_hdr->offset;
1850 lcs_hdr->offset = LCS_ILLEGAL_OFFSET;
1851 lcs_hdr = (struct lcs_header *) (buffer->data + offset);
1853 /* The buffer is now empty. Make it ready again. */
1854 lcs_ready_buffer(&card->read, buffer);
1858 * get network statistics for ifconfig and other user programs
1860 static struct net_device_stats *
1861 lcs_getstats(struct net_device *dev)
1863 struct lcs_card *card;
1865 LCS_DBF_TEXT(4, trace, "netstats");
1866 card = (struct lcs_card *) dev->priv;
1867 return &card->stats;
1872 * This function will be called by user doing ifconfig xxx down
1875 lcs_stop_device(struct net_device *dev)
1877 struct lcs_card *card;
1880 LCS_DBF_TEXT(2, trace, "stopdev");
1881 card = (struct lcs_card *) dev->priv;
1882 netif_carrier_off(dev);
1883 netif_tx_disable(dev);
1884 dev->flags &= ~IFF_UP;
1885 wait_event(card->write.wait_q,
1886 (card->write.state != LCS_CH_STATE_RUNNING));
1887 rc = lcs_stopcard(card);
1889 PRINT_ERR("Try it again!\n ");
1894 * start lcs device and make it runnable
1895 * This function will be called by user doing ifconfig xxx up
1898 lcs_open_device(struct net_device *dev)
1900 struct lcs_card *card;
1903 LCS_DBF_TEXT(2, trace, "opendev");
1904 card = (struct lcs_card *) dev->priv;
1905 /* initialize statistics */
1906 rc = lcs_detect(card);
1908 PRINT_ERR("LCS:Error in opening device!\n");
1911 dev->flags |= IFF_UP;
1912 netif_carrier_on(dev);
1913 netif_wake_queue(dev);
1914 card->state = DEV_STATE_UP;
1920 * show function for portno called by cat or similar things
1923 lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
1925 struct lcs_card *card;
1927 card = (struct lcs_card *)dev->driver_data;
1932 return sprintf(buf, "%d\n", card->portno);
1936 * store the value which is piped to file portno
1939 lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1941 struct lcs_card *card;
1944 card = (struct lcs_card *)dev->driver_data;
1949 sscanf(buf, "%u", &value);
1950 /* TODO: sanity checks */
1951 card->portno = value;
1957 static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
1960 lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1962 struct ccwgroup_device *cgdev;
1964 cgdev = to_ccwgroupdev(dev);
1968 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
1971 static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
1974 lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
1976 struct lcs_card *card;
1978 card = (struct lcs_card *)dev->driver_data;
1980 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
1984 lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1986 struct lcs_card *card;
1989 card = (struct lcs_card *)dev->driver_data;
1994 sscanf(buf, "%u", &value);
1995 /* TODO: sanity checks */
1996 card->lancmd_timeout = value;
2002 static DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
2005 lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
2006 const char *buf, size_t count)
2008 struct lcs_card *card = dev->driver_data;
2014 if (card->state != DEV_STATE_UP)
2016 i = simple_strtoul(buf, &tmp, 16);
2018 lcs_schedule_recovery(card);
2022 static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store);
2024 static struct attribute * lcs_attrs[] = {
2025 &dev_attr_portno.attr,
2026 &dev_attr_type.attr,
2027 &dev_attr_lancmd_timeout.attr,
2028 &dev_attr_recover.attr,
2032 static struct attribute_group lcs_attr_group = {
2037 * lcs_probe_device is called on establishing a new ccwgroup_device.
2040 lcs_probe_device(struct ccwgroup_device *ccwgdev)
2042 struct lcs_card *card;
2045 if (!get_device(&ccwgdev->dev))
2048 LCS_DBF_TEXT(2, setup, "add_dev");
2049 card = lcs_alloc_card();
2051 LCS_DBF_TEXT_(2, setup, " rc%d", -ENOMEM);
2052 put_device(&ccwgdev->dev);
2055 ret = sysfs_create_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2057 lcs_free_card(card);
2058 put_device(&ccwgdev->dev);
2061 ccwgdev->dev.driver_data = card;
2062 ccwgdev->cdev[0]->handler = lcs_irq;
2063 ccwgdev->cdev[1]->handler = lcs_irq;
2064 card->gdev = ccwgdev;
2065 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2066 card->thread_start_mask = 0;
2067 card->thread_allowed_mask = 0;
2068 card->thread_running_mask = 0;
2073 lcs_register_netdev(struct ccwgroup_device *ccwgdev)
2075 struct lcs_card *card;
2077 LCS_DBF_TEXT(2, setup, "regnetdv");
2078 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2079 if (card->dev->reg_state != NETREG_UNINITIALIZED)
2081 SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
2082 return register_netdev(card->dev);
2086 * lcs_new_device will be called by setting the group device online.
2090 lcs_new_device(struct ccwgroup_device *ccwgdev)
2092 struct lcs_card *card;
2093 struct net_device *dev=NULL;
2094 enum lcs_dev_states recover_state;
2097 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2101 LCS_DBF_TEXT(2, setup, "newdev");
2102 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2103 card->read.ccwdev = ccwgdev->cdev[0];
2104 card->write.ccwdev = ccwgdev->cdev[1];
2106 recover_state = card->state;
2107 ccw_device_set_online(card->read.ccwdev);
2108 ccw_device_set_online(card->write.ccwdev);
2110 LCS_DBF_TEXT(3, setup, "lcsnewdv");
2112 lcs_setup_card(card);
2113 rc = lcs_detect(card);
2115 LCS_DBF_TEXT(2, setup, "dtctfail");
2116 PRINT_WARN("Detection of LCS card failed with return code "
2117 "%d (0x%x)\n", rc, rc);
2122 LCS_DBF_TEXT(2, setup, "samedev");
2123 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2126 switch (card->lan_type) {
2127 #ifdef CONFIG_NET_ETHERNET
2128 case LCS_FRAME_TYPE_ENET:
2129 card->lan_type_trans = eth_type_trans;
2130 dev = alloc_etherdev(0);
2134 case LCS_FRAME_TYPE_TR:
2135 card->lan_type_trans = tr_type_trans;
2136 dev = alloc_trdev(0);
2140 case LCS_FRAME_TYPE_FDDI:
2141 card->lan_type_trans = fddi_type_trans;
2142 dev = alloc_fddidev(0);
2146 LCS_DBF_TEXT(3, setup, "errinit");
2147 PRINT_ERR("LCS: Initialization failed\n");
2153 card->dev->priv = card;
2154 card->dev->open = lcs_open_device;
2155 card->dev->stop = lcs_stop_device;
2156 card->dev->hard_start_xmit = lcs_start_xmit;
2157 card->dev->get_stats = lcs_getstats;
2158 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
2159 #ifdef CONFIG_IP_MULTICAST
2160 if (!lcs_check_multicast_support(card))
2161 card->dev->set_multicast_list = lcs_set_multicast_list;
2164 lcs_set_allowed_threads(card,0xffffffff);
2165 if (recover_state == DEV_STATE_RECOVER) {
2166 lcs_set_multicast_list(card->dev);
2167 card->dev->flags |= IFF_UP;
2168 netif_carrier_on(card->dev);
2169 netif_wake_queue(card->dev);
2170 card->state = DEV_STATE_UP;
2175 if (lcs_register_netdev(ccwgdev) != 0)
2178 /* Print out supported assists: IPv6 */
2179 PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
2180 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
2181 "with" : "without");
2182 /* Print out supported assist: Multicast */
2183 PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
2184 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
2185 "with" : "without");
2189 ccw_device_set_offline(card->read.ccwdev);
2190 ccw_device_set_offline(card->write.ccwdev);
2195 * lcs_shutdown_device, called when setting the group device offline.
2198 __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
2200 struct lcs_card *card;
2201 enum lcs_dev_states recover_state;
2204 LCS_DBF_TEXT(3, setup, "shtdndev");
2205 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2208 if (recovery_mode == 0) {
2209 lcs_set_allowed_threads(card, 0);
2210 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
2211 return -ERESTARTSYS;
2213 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2214 recover_state = card->state;
2216 ret = lcs_stop_device(card->dev);
2217 ret = ccw_device_set_offline(card->read.ccwdev);
2218 ret = ccw_device_set_offline(card->write.ccwdev);
2219 if (recover_state == DEV_STATE_UP) {
2220 card->state = DEV_STATE_RECOVER;
2228 lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2230 return __lcs_shutdown_device(ccwgdev, 0);
2234 * drive lcs recovery after startup and startlan initiated by Lan Gateway
2237 lcs_recovery(void *ptr)
2239 struct lcs_card *card;
2240 struct ccwgroup_device *gdev;
2243 card = (struct lcs_card *) ptr;
2244 daemonize("lcs_recover");
2246 LCS_DBF_TEXT(4, trace, "recover1");
2247 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD))
2249 LCS_DBF_TEXT(4, trace, "recover2");
2251 PRINT_WARN("Recovery of device %s started...\n", dev_name(&gdev->dev));
2252 rc = __lcs_shutdown_device(gdev, 1);
2253 rc = lcs_new_device(gdev);
2255 PRINT_INFO("Device %s successfully recovered!\n",
2258 PRINT_INFO("Device %s could not be recovered!\n",
2260 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
2265 * lcs_remove_device, free buffers and card
2268 lcs_remove_device(struct ccwgroup_device *ccwgdev)
2270 struct lcs_card *card;
2272 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2276 LCS_DBF_TEXT(3, setup, "remdev");
2277 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2278 if (ccwgdev->state == CCWGROUP_ONLINE) {
2279 lcs_shutdown_device(ccwgdev);
2282 unregister_netdev(card->dev);
2283 sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2284 lcs_cleanup_card(card);
2285 lcs_free_card(card);
2286 put_device(&ccwgdev->dev);
2290 * LCS ccwgroup driver registration
2292 static struct ccwgroup_driver lcs_group_driver = {
2293 .owner = THIS_MODULE,
2296 .driver_id = 0xD3C3E2,
2297 .probe = lcs_probe_device,
2298 .remove = lcs_remove_device,
2299 .set_online = lcs_new_device,
2300 .set_offline = lcs_shutdown_device,
2304 * LCS Module/Kernel initialization function
2307 __init lcs_init_module(void)
2311 PRINT_INFO("Loading %s\n",version);
2312 rc = lcs_register_debug_facility();
2313 LCS_DBF_TEXT(0, setup, "lcsinit");
2315 PRINT_ERR("Initialization failed\n");
2319 rc = register_cu3088_discipline(&lcs_group_driver);
2321 PRINT_ERR("Initialization failed\n");
2329 * LCS module cleanup function
2332 __exit lcs_cleanup_module(void)
2334 PRINT_INFO("Terminating lcs module.\n");
2335 LCS_DBF_TEXT(0, trace, "cleanup");
2336 unregister_cu3088_discipline(&lcs_group_driver);
2337 lcs_unregister_debug_facility();
2340 module_init(lcs_init_module);
2341 module_exit(lcs_cleanup_module);
2343 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
2344 MODULE_LICENSE("GPL");