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 #define KMSG_COMPONENT "lcs"
30 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
32 #include <linux/module.h>
34 #include <linux/netdevice.h>
35 #include <linux/etherdevice.h>
36 #include <linux/trdevice.h>
37 #include <linux/fddidevice.h>
38 #include <linux/inetdevice.h>
40 #include <linux/igmp.h>
41 #include <linux/delay.h>
45 #include <asm/debug.h>
46 #include <asm/idals.h>
47 #include <asm/timex.h>
48 #include <linux/device.h>
49 #include <asm/ccwgroup.h>
55 #if !defined(CONFIG_NET_ETHERNET) && \
56 !defined(CONFIG_TR) && !defined(CONFIG_FDDI)
57 #error Cannot compile lcs.c without some net devices switched on.
61 * initialization string for output
64 static char version[] __initdata = "LCS driver";
65 static char debug_buffer[255];
70 static void lcs_tasklet(unsigned long);
71 static void lcs_start_kernel_thread(struct work_struct *);
72 static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
73 static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
74 static int lcs_recovery(void *ptr);
77 * Debug Facility Stuff
79 static debug_info_t *lcs_dbf_setup;
80 static debug_info_t *lcs_dbf_trace;
83 * LCS Debug Facility functions
86 lcs_unregister_debug_facility(void)
89 debug_unregister(lcs_dbf_setup);
91 debug_unregister(lcs_dbf_trace);
95 lcs_register_debug_facility(void)
97 lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
98 lcs_dbf_trace = debug_register("lcs_trace", 4, 1, 8);
99 if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
100 pr_err("Not enough memory for debug facility.\n");
101 lcs_unregister_debug_facility();
104 debug_register_view(lcs_dbf_setup, &debug_hex_ascii_view);
105 debug_set_level(lcs_dbf_setup, 2);
106 debug_register_view(lcs_dbf_trace, &debug_hex_ascii_view);
107 debug_set_level(lcs_dbf_trace, 2);
112 * Allocate io buffers.
115 lcs_alloc_channel(struct lcs_channel *channel)
119 LCS_DBF_TEXT(2, setup, "ichalloc");
120 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
121 /* alloc memory fo iobuffer */
122 channel->iob[cnt].data =
123 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
124 if (channel->iob[cnt].data == NULL)
126 channel->iob[cnt].state = LCS_BUF_STATE_EMPTY;
128 if (cnt < LCS_NUM_BUFFS) {
129 /* Not all io buffers could be allocated. */
130 LCS_DBF_TEXT(2, setup, "echalloc");
132 kfree(channel->iob[cnt].data);
142 lcs_free_channel(struct lcs_channel *channel)
146 LCS_DBF_TEXT(2, setup, "ichfree");
147 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
148 kfree(channel->iob[cnt].data);
149 channel->iob[cnt].data = NULL;
157 lcs_cleanup_channel(struct lcs_channel *channel)
159 LCS_DBF_TEXT(3, setup, "cleanch");
160 /* Kill write channel tasklets. */
161 tasklet_kill(&channel->irq_tasklet);
162 /* Free channel buffers. */
163 lcs_free_channel(channel);
167 * LCS free memory for card and channels.
170 lcs_free_card(struct lcs_card *card)
172 LCS_DBF_TEXT(2, setup, "remcard");
173 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
178 * LCS alloc memory for card and channels
180 static struct lcs_card *
183 struct lcs_card *card;
186 LCS_DBF_TEXT(2, setup, "alloclcs");
188 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
191 card->lan_type = LCS_FRAME_TYPE_AUTO;
193 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
194 /* Allocate io buffers for the read channel. */
195 rc = lcs_alloc_channel(&card->read);
197 LCS_DBF_TEXT(2, setup, "iccwerr");
201 /* Allocate io buffers for the write channel. */
202 rc = lcs_alloc_channel(&card->write);
204 LCS_DBF_TEXT(2, setup, "iccwerr");
205 lcs_cleanup_channel(&card->read);
210 #ifdef CONFIG_IP_MULTICAST
211 INIT_LIST_HEAD(&card->ipm_list);
213 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
218 * Setup read channel.
221 lcs_setup_read_ccws(struct lcs_card *card)
225 LCS_DBF_TEXT(2, setup, "ireadccw");
226 /* Setup read ccws. */
227 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1));
228 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
229 card->read.ccws[cnt].cmd_code = LCS_CCW_READ;
230 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE;
231 card->read.ccws[cnt].flags =
232 CCW_FLAG_CC | CCW_FLAG_SLI | CCW_FLAG_PCI;
234 * Note: we have allocated the buffer with GFP_DMA, so
235 * we do not need to do set_normalized_cda.
237 card->read.ccws[cnt].cda =
238 (__u32) __pa(card->read.iob[cnt].data);
239 ((struct lcs_header *)
240 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET;
241 card->read.iob[cnt].callback = lcs_get_frames_cb;
242 card->read.iob[cnt].state = LCS_BUF_STATE_READY;
243 card->read.iob[cnt].count = LCS_IOBUFFERSIZE;
245 card->read.ccws[0].flags &= ~CCW_FLAG_PCI;
246 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI;
247 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND;
248 /* Last ccw is a tic (transfer in channel). */
249 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
250 card->read.ccws[LCS_NUM_BUFFS].cda =
251 (__u32) __pa(card->read.ccws);
252 /* Setg initial state of the read channel. */
253 card->read.state = LCS_CH_STATE_INIT;
255 card->read.io_idx = 0;
256 card->read.buf_idx = 0;
260 lcs_setup_read(struct lcs_card *card)
262 LCS_DBF_TEXT(3, setup, "initread");
264 lcs_setup_read_ccws(card);
265 /* Initialize read channel tasklet. */
266 card->read.irq_tasklet.data = (unsigned long) &card->read;
267 card->read.irq_tasklet.func = lcs_tasklet;
268 /* Initialize waitqueue. */
269 init_waitqueue_head(&card->read.wait_q);
273 * Setup write channel.
276 lcs_setup_write_ccws(struct lcs_card *card)
280 LCS_DBF_TEXT(3, setup, "iwritccw");
281 /* Setup write ccws. */
282 memset(card->write.ccws, 0, sizeof(struct ccw1) * LCS_NUM_BUFFS + 1);
283 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
284 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE;
285 card->write.ccws[cnt].count = 0;
286 card->write.ccws[cnt].flags =
287 CCW_FLAG_SUSPEND | CCW_FLAG_CC | CCW_FLAG_SLI;
289 * Note: we have allocated the buffer with GFP_DMA, so
290 * we do not need to do set_normalized_cda.
292 card->write.ccws[cnt].cda =
293 (__u32) __pa(card->write.iob[cnt].data);
295 /* Last ccw is a tic (transfer in channel). */
296 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
297 card->write.ccws[LCS_NUM_BUFFS].cda =
298 (__u32) __pa(card->write.ccws);
299 /* Set initial state of the write channel. */
300 card->read.state = LCS_CH_STATE_INIT;
302 card->write.io_idx = 0;
303 card->write.buf_idx = 0;
307 lcs_setup_write(struct lcs_card *card)
309 LCS_DBF_TEXT(3, setup, "initwrit");
311 lcs_setup_write_ccws(card);
312 /* Initialize write channel tasklet. */
313 card->write.irq_tasklet.data = (unsigned long) &card->write;
314 card->write.irq_tasklet.func = lcs_tasklet;
315 /* Initialize waitqueue. */
316 init_waitqueue_head(&card->write.wait_q);
320 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads)
324 spin_lock_irqsave(&card->mask_lock, flags);
325 card->thread_allowed_mask = threads;
326 spin_unlock_irqrestore(&card->mask_lock, flags);
327 wake_up(&card->wait_q);
330 lcs_threads_running(struct lcs_card *card, unsigned long threads)
335 spin_lock_irqsave(&card->mask_lock, flags);
336 rc = (card->thread_running_mask & threads);
337 spin_unlock_irqrestore(&card->mask_lock, flags);
342 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads)
344 return wait_event_interruptible(card->wait_q,
345 lcs_threads_running(card, threads) == 0);
349 lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread)
353 spin_lock_irqsave(&card->mask_lock, flags);
354 if ( !(card->thread_allowed_mask & thread) ||
355 (card->thread_start_mask & thread) ) {
356 spin_unlock_irqrestore(&card->mask_lock, flags);
359 card->thread_start_mask |= thread;
360 spin_unlock_irqrestore(&card->mask_lock, flags);
365 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread)
369 spin_lock_irqsave(&card->mask_lock, flags);
370 card->thread_running_mask &= ~thread;
371 spin_unlock_irqrestore(&card->mask_lock, flags);
372 wake_up(&card->wait_q);
376 __lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
381 spin_lock_irqsave(&card->mask_lock, flags);
382 if (card->thread_start_mask & thread){
383 if ((card->thread_allowed_mask & thread) &&
384 !(card->thread_running_mask & thread)){
386 card->thread_start_mask &= ~thread;
387 card->thread_running_mask |= thread;
391 spin_unlock_irqrestore(&card->mask_lock, flags);
396 lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
399 wait_event(card->wait_q,
400 (rc = __lcs_do_run_thread(card, thread)) >= 0);
405 lcs_do_start_thread(struct lcs_card *card, unsigned long thread)
410 spin_lock_irqsave(&card->mask_lock, flags);
411 LCS_DBF_TEXT_(4, trace, " %02x%02x%02x",
412 (u8) card->thread_start_mask,
413 (u8) card->thread_allowed_mask,
414 (u8) card->thread_running_mask);
415 rc = (card->thread_start_mask & thread);
416 spin_unlock_irqrestore(&card->mask_lock, flags);
421 * Initialize channels,card and state machines.
424 lcs_setup_card(struct lcs_card *card)
426 LCS_DBF_TEXT(2, setup, "initcard");
427 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
429 lcs_setup_read(card);
430 lcs_setup_write(card);
431 /* Set cards initial state. */
432 card->state = DEV_STATE_DOWN;
433 card->tx_buffer = NULL;
434 card->tx_emitted = 0;
436 init_waitqueue_head(&card->wait_q);
437 spin_lock_init(&card->lock);
438 spin_lock_init(&card->ipm_lock);
439 spin_lock_init(&card->mask_lock);
440 #ifdef CONFIG_IP_MULTICAST
441 INIT_LIST_HEAD(&card->ipm_list);
443 INIT_LIST_HEAD(&card->lancmd_waiters);
447 lcs_clear_multicast_list(struct lcs_card *card)
449 #ifdef CONFIG_IP_MULTICAST
450 struct lcs_ipm_list *ipm;
453 /* Free multicast list. */
454 LCS_DBF_TEXT(3, setup, "clmclist");
455 spin_lock_irqsave(&card->ipm_lock, flags);
456 while (!list_empty(&card->ipm_list)){
457 ipm = list_entry(card->ipm_list.next,
458 struct lcs_ipm_list, list);
459 list_del(&ipm->list);
460 if (ipm->ipm_state != LCS_IPM_STATE_SET_REQUIRED){
461 spin_unlock_irqrestore(&card->ipm_lock, flags);
462 lcs_send_delipm(card, ipm);
463 spin_lock_irqsave(&card->ipm_lock, flags);
467 spin_unlock_irqrestore(&card->ipm_lock, flags);
471 * Cleanup channels,card and state machines.
474 lcs_cleanup_card(struct lcs_card *card)
477 LCS_DBF_TEXT(3, setup, "cleancrd");
478 LCS_DBF_HEX(2,setup,&card,sizeof(void*));
480 if (card->dev != NULL)
481 free_netdev(card->dev);
482 /* Cleanup channels. */
483 lcs_cleanup_channel(&card->write);
484 lcs_cleanup_channel(&card->read);
491 lcs_start_channel(struct lcs_channel *channel)
496 LCS_DBF_TEXT_(4, trace,"ssch%s", dev_name(&channel->ccwdev->dev));
497 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
498 rc = ccw_device_start(channel->ccwdev,
499 channel->ccws + channel->io_idx, 0, 0,
500 DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND);
502 channel->state = LCS_CH_STATE_RUNNING;
503 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
505 LCS_DBF_TEXT_(4,trace,"essh%s",
506 dev_name(&channel->ccwdev->dev));
507 dev_err(&channel->ccwdev->dev,
508 "Starting an LCS device resulted in an error,"
515 lcs_clear_channel(struct lcs_channel *channel)
520 LCS_DBF_TEXT(4,trace,"clearch");
521 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
522 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
523 rc = ccw_device_clear(channel->ccwdev, (addr_t) channel);
524 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
526 LCS_DBF_TEXT_(4, trace, "ecsc%s",
527 dev_name(&channel->ccwdev->dev));
530 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_CLEARED));
531 channel->state = LCS_CH_STATE_STOPPED;
540 lcs_stop_channel(struct lcs_channel *channel)
545 if (channel->state == LCS_CH_STATE_STOPPED)
547 LCS_DBF_TEXT(4,trace,"haltsch");
548 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
549 channel->state = LCS_CH_STATE_INIT;
550 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
551 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
552 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
554 LCS_DBF_TEXT_(4, trace, "ehsc%s",
555 dev_name(&channel->ccwdev->dev));
558 /* Asynchronous halt initialted. Wait for its completion. */
559 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_HALTED));
560 lcs_clear_channel(channel);
565 * start read and write channel
568 lcs_start_channels(struct lcs_card *card)
572 LCS_DBF_TEXT(2, trace, "chstart");
573 /* start read channel */
574 rc = lcs_start_channel(&card->read);
577 /* start write channel */
578 rc = lcs_start_channel(&card->write);
580 lcs_stop_channel(&card->read);
585 * stop read and write channel
588 lcs_stop_channels(struct lcs_card *card)
590 LCS_DBF_TEXT(2, trace, "chhalt");
591 lcs_stop_channel(&card->read);
592 lcs_stop_channel(&card->write);
599 static struct lcs_buffer *
600 __lcs_get_buffer(struct lcs_channel *channel)
604 LCS_DBF_TEXT(5, trace, "_getbuff");
605 index = channel->io_idx;
607 if (channel->iob[index].state == LCS_BUF_STATE_EMPTY) {
608 channel->iob[index].state = LCS_BUF_STATE_LOCKED;
609 return channel->iob + index;
611 index = (index + 1) & (LCS_NUM_BUFFS - 1);
612 } while (index != channel->io_idx);
616 static struct lcs_buffer *
617 lcs_get_buffer(struct lcs_channel *channel)
619 struct lcs_buffer *buffer;
622 LCS_DBF_TEXT(5, trace, "getbuff");
623 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
624 buffer = __lcs_get_buffer(channel);
625 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
630 * Resume channel program if the channel is suspended.
633 __lcs_resume_channel(struct lcs_channel *channel)
637 if (channel->state != LCS_CH_STATE_SUSPENDED)
639 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
641 LCS_DBF_TEXT_(5, trace, "rsch%s", dev_name(&channel->ccwdev->dev));
642 rc = ccw_device_resume(channel->ccwdev);
644 LCS_DBF_TEXT_(4, trace, "ersc%s",
645 dev_name(&channel->ccwdev->dev));
646 dev_err(&channel->ccwdev->dev,
647 "Sending data from the LCS device to the LAN failed"
650 channel->state = LCS_CH_STATE_RUNNING;
656 * Make a buffer ready for processing.
659 __lcs_ready_buffer_bits(struct lcs_channel *channel, int index)
663 LCS_DBF_TEXT(5, trace, "rdybits");
664 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
665 next = (index + 1) & (LCS_NUM_BUFFS - 1);
666 /* Check if we may clear the suspend bit of this buffer. */
667 if (channel->ccws[next].flags & CCW_FLAG_SUSPEND) {
668 /* Check if we have to set the PCI bit. */
669 if (!(channel->ccws[prev].flags & CCW_FLAG_SUSPEND))
670 /* Suspend bit of the previous buffer is not set. */
671 channel->ccws[index].flags |= CCW_FLAG_PCI;
672 /* Suspend bit of the next buffer is set. */
673 channel->ccws[index].flags &= ~CCW_FLAG_SUSPEND;
678 lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
683 LCS_DBF_TEXT(5, trace, "rdybuff");
684 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
685 buffer->state != LCS_BUF_STATE_PROCESSED);
686 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
687 buffer->state = LCS_BUF_STATE_READY;
688 index = buffer - channel->iob;
690 channel->ccws[index].count = buffer->count;
691 /* Check relevant PCI/suspend bits. */
692 __lcs_ready_buffer_bits(channel, index);
693 rc = __lcs_resume_channel(channel);
694 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
699 * Mark the buffer as processed. Take care of the suspend bit
700 * of the previous buffer. This function is called from
701 * interrupt context, so the lock must not be taken.
704 __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
706 int index, prev, next;
708 LCS_DBF_TEXT(5, trace, "prcsbuff");
709 BUG_ON(buffer->state != LCS_BUF_STATE_READY);
710 buffer->state = LCS_BUF_STATE_PROCESSED;
711 index = buffer - channel->iob;
712 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
713 next = (index + 1) & (LCS_NUM_BUFFS - 1);
714 /* Set the suspend bit and clear the PCI bit of this buffer. */
715 channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
716 channel->ccws[index].flags &= ~CCW_FLAG_PCI;
717 /* Check the suspend bit of the previous buffer. */
718 if (channel->iob[prev].state == LCS_BUF_STATE_READY) {
720 * Previous buffer is in state ready. It might have
721 * happened in lcs_ready_buffer that the suspend bit
722 * has not been cleared to avoid an endless loop.
725 __lcs_ready_buffer_bits(channel, prev);
727 /* Clear PCI bit of next buffer. */
728 channel->ccws[next].flags &= ~CCW_FLAG_PCI;
729 return __lcs_resume_channel(channel);
733 * Put a processed buffer back to state empty.
736 lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
740 LCS_DBF_TEXT(5, trace, "relbuff");
741 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
742 buffer->state != LCS_BUF_STATE_PROCESSED);
743 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
744 buffer->state = LCS_BUF_STATE_EMPTY;
745 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
749 * Get buffer for a lan command.
751 static struct lcs_buffer *
752 lcs_get_lancmd(struct lcs_card *card, int count)
754 struct lcs_buffer *buffer;
757 LCS_DBF_TEXT(4, trace, "getlncmd");
758 /* Get buffer and wait if none is available. */
759 wait_event(card->write.wait_q,
760 ((buffer = lcs_get_buffer(&card->write)) != NULL));
761 count += sizeof(struct lcs_header);
762 *(__u16 *)(buffer->data + count) = 0;
763 buffer->count = count + sizeof(__u16);
764 buffer->callback = lcs_release_buffer;
765 cmd = (struct lcs_cmd *) buffer->data;
767 cmd->type = LCS_FRAME_TYPE_CONTROL;
774 lcs_get_reply(struct lcs_reply *reply)
776 WARN_ON(atomic_read(&reply->refcnt) <= 0);
777 atomic_inc(&reply->refcnt);
781 lcs_put_reply(struct lcs_reply *reply)
783 WARN_ON(atomic_read(&reply->refcnt) <= 0);
784 if (atomic_dec_and_test(&reply->refcnt)) {
790 static struct lcs_reply *
791 lcs_alloc_reply(struct lcs_cmd *cmd)
793 struct lcs_reply *reply;
795 LCS_DBF_TEXT(4, trace, "getreply");
797 reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
800 atomic_set(&reply->refcnt,1);
801 reply->sequence_no = cmd->sequence_no;
804 init_waitqueue_head(&reply->wait_q);
810 * Notifier function for lancmd replies. Called from read irq.
813 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
815 struct list_head *l, *n;
816 struct lcs_reply *reply;
818 LCS_DBF_TEXT(4, trace, "notiwait");
819 spin_lock(&card->lock);
820 list_for_each_safe(l, n, &card->lancmd_waiters) {
821 reply = list_entry(l, struct lcs_reply, list);
822 if (reply->sequence_no == cmd->sequence_no) {
823 lcs_get_reply(reply);
824 list_del_init(&reply->list);
825 if (reply->callback != NULL)
826 reply->callback(card, cmd);
828 reply->rc = cmd->return_code;
829 wake_up(&reply->wait_q);
830 lcs_put_reply(reply);
834 spin_unlock(&card->lock);
838 * Emit buffer of a lan comand.
841 lcs_lancmd_timeout(unsigned long data)
843 struct lcs_reply *reply, *list_reply, *r;
846 LCS_DBF_TEXT(4, trace, "timeout");
847 reply = (struct lcs_reply *) data;
848 spin_lock_irqsave(&reply->card->lock, flags);
849 list_for_each_entry_safe(list_reply, r,
850 &reply->card->lancmd_waiters,list) {
851 if (reply == list_reply) {
852 lcs_get_reply(reply);
853 list_del_init(&reply->list);
854 spin_unlock_irqrestore(&reply->card->lock, flags);
857 wake_up(&reply->wait_q);
858 lcs_put_reply(reply);
862 spin_unlock_irqrestore(&reply->card->lock, flags);
866 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
867 void (*reply_callback)(struct lcs_card *, struct lcs_cmd *))
869 struct lcs_reply *reply;
871 struct timer_list timer;
875 LCS_DBF_TEXT(4, trace, "sendcmd");
876 cmd = (struct lcs_cmd *) buffer->data;
877 cmd->return_code = 0;
878 cmd->sequence_no = card->sequence_no++;
879 reply = lcs_alloc_reply(cmd);
882 reply->callback = reply_callback;
884 spin_lock_irqsave(&card->lock, flags);
885 list_add_tail(&reply->list, &card->lancmd_waiters);
886 spin_unlock_irqrestore(&card->lock, flags);
888 buffer->callback = lcs_release_buffer;
889 rc = lcs_ready_buffer(&card->write, buffer);
893 timer.function = lcs_lancmd_timeout;
894 timer.data = (unsigned long) reply;
895 timer.expires = jiffies + HZ*card->lancmd_timeout;
897 wait_event(reply->wait_q, reply->received);
898 del_timer_sync(&timer);
899 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
901 lcs_put_reply(reply);
902 return rc ? -EIO : 0;
906 * LCS startup command
909 lcs_send_startup(struct lcs_card *card, __u8 initiator)
911 struct lcs_buffer *buffer;
914 LCS_DBF_TEXT(2, trace, "startup");
915 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
916 cmd = (struct lcs_cmd *) buffer->data;
917 cmd->cmd_code = LCS_CMD_STARTUP;
918 cmd->initiator = initiator;
919 cmd->cmd.lcs_startup.buff_size = LCS_IOBUFFERSIZE;
920 return lcs_send_lancmd(card, buffer, NULL);
924 * LCS shutdown command
927 lcs_send_shutdown(struct lcs_card *card)
929 struct lcs_buffer *buffer;
932 LCS_DBF_TEXT(2, trace, "shutdown");
933 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
934 cmd = (struct lcs_cmd *) buffer->data;
935 cmd->cmd_code = LCS_CMD_SHUTDOWN;
936 cmd->initiator = LCS_INITIATOR_TCPIP;
937 return lcs_send_lancmd(card, buffer, NULL);
941 * LCS lanstat command
944 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd)
946 LCS_DBF_TEXT(2, trace, "statcb");
947 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH);
951 lcs_send_lanstat(struct lcs_card *card)
953 struct lcs_buffer *buffer;
956 LCS_DBF_TEXT(2,trace, "cmdstat");
957 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
958 cmd = (struct lcs_cmd *) buffer->data;
959 /* Setup lanstat command. */
960 cmd->cmd_code = LCS_CMD_LANSTAT;
961 cmd->initiator = LCS_INITIATOR_TCPIP;
962 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
963 cmd->cmd.lcs_std_cmd.portno = card->portno;
964 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb);
968 * send stoplan command
971 lcs_send_stoplan(struct lcs_card *card, __u8 initiator)
973 struct lcs_buffer *buffer;
976 LCS_DBF_TEXT(2, trace, "cmdstpln");
977 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
978 cmd = (struct lcs_cmd *) buffer->data;
979 cmd->cmd_code = LCS_CMD_STOPLAN;
980 cmd->initiator = initiator;
981 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
982 cmd->cmd.lcs_std_cmd.portno = card->portno;
983 return lcs_send_lancmd(card, buffer, NULL);
987 * send startlan command
990 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd)
992 LCS_DBF_TEXT(2, trace, "srtlancb");
993 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type;
994 card->portno = cmd->cmd.lcs_std_cmd.portno;
998 lcs_send_startlan(struct lcs_card *card, __u8 initiator)
1000 struct lcs_buffer *buffer;
1001 struct lcs_cmd *cmd;
1003 LCS_DBF_TEXT(2, trace, "cmdstaln");
1004 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1005 cmd = (struct lcs_cmd *) buffer->data;
1006 cmd->cmd_code = LCS_CMD_STARTLAN;
1007 cmd->initiator = initiator;
1008 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
1009 cmd->cmd.lcs_std_cmd.portno = card->portno;
1010 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb);
1013 #ifdef CONFIG_IP_MULTICAST
1015 * send setipm command (Multicast)
1018 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1020 struct lcs_buffer *buffer;
1021 struct lcs_cmd *cmd;
1023 LCS_DBF_TEXT(2, trace, "cmdsetim");
1024 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1025 cmd = (struct lcs_cmd *) buffer->data;
1026 cmd->cmd_code = LCS_CMD_SETIPM;
1027 cmd->initiator = LCS_INITIATOR_TCPIP;
1028 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1029 cmd->cmd.lcs_qipassist.portno = card->portno;
1030 cmd->cmd.lcs_qipassist.version = 4;
1031 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1032 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1033 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1034 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1035 return lcs_send_lancmd(card, buffer, NULL);
1039 * send delipm command (Multicast)
1042 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1044 struct lcs_buffer *buffer;
1045 struct lcs_cmd *cmd;
1047 LCS_DBF_TEXT(2, trace, "cmddelim");
1048 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1049 cmd = (struct lcs_cmd *) buffer->data;
1050 cmd->cmd_code = LCS_CMD_DELIPM;
1051 cmd->initiator = LCS_INITIATOR_TCPIP;
1052 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1053 cmd->cmd.lcs_qipassist.portno = card->portno;
1054 cmd->cmd.lcs_qipassist.version = 4;
1055 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1056 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1057 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1058 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1059 return lcs_send_lancmd(card, buffer, NULL);
1063 * check if multicast is supported by LCS
1066 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd)
1068 LCS_DBF_TEXT(2, trace, "chkmccb");
1069 card->ip_assists_supported =
1070 cmd->cmd.lcs_qipassist.ip_assists_supported;
1071 card->ip_assists_enabled =
1072 cmd->cmd.lcs_qipassist.ip_assists_enabled;
1076 lcs_check_multicast_support(struct lcs_card *card)
1078 struct lcs_buffer *buffer;
1079 struct lcs_cmd *cmd;
1082 LCS_DBF_TEXT(2, trace, "cmdqipa");
1083 /* Send query ipassist. */
1084 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1085 cmd = (struct lcs_cmd *) buffer->data;
1086 cmd->cmd_code = LCS_CMD_QIPASSIST;
1087 cmd->initiator = LCS_INITIATOR_TCPIP;
1088 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1089 cmd->cmd.lcs_qipassist.portno = card->portno;
1090 cmd->cmd.lcs_qipassist.version = 4;
1091 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1092 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
1094 pr_err("Query IPAssist failed. Assuming unsupported!\n");
1097 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
1103 * set or del multicast address on LCS card
1106 lcs_fix_multicast_list(struct lcs_card *card)
1108 struct list_head failed_list;
1109 struct lcs_ipm_list *ipm, *tmp;
1110 unsigned long flags;
1113 LCS_DBF_TEXT(4,trace, "fixipm");
1114 INIT_LIST_HEAD(&failed_list);
1115 spin_lock_irqsave(&card->ipm_lock, flags);
1117 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){
1118 switch (ipm->ipm_state) {
1119 case LCS_IPM_STATE_SET_REQUIRED:
1120 /* del from ipm_list so noone else can tamper with
1122 list_del_init(&ipm->list);
1123 spin_unlock_irqrestore(&card->ipm_lock, flags);
1124 rc = lcs_send_setipm(card, ipm);
1125 spin_lock_irqsave(&card->ipm_lock, flags);
1127 pr_info("Adding multicast address failed."
1128 " Table possibly full!\n");
1129 /* store ipm in failed list -> will be added
1130 * to ipm_list again, so a retry will be done
1131 * during the next call of this function */
1132 list_add_tail(&ipm->list, &failed_list);
1134 ipm->ipm_state = LCS_IPM_STATE_ON_CARD;
1135 /* re-insert into ipm_list */
1136 list_add_tail(&ipm->list, &card->ipm_list);
1139 case LCS_IPM_STATE_DEL_REQUIRED:
1140 list_del(&ipm->list);
1141 spin_unlock_irqrestore(&card->ipm_lock, flags);
1142 lcs_send_delipm(card, ipm);
1143 spin_lock_irqsave(&card->ipm_lock, flags);
1146 case LCS_IPM_STATE_ON_CARD:
1150 /* re-insert all entries from the failed_list into ipm_list */
1151 list_for_each_entry_safe(ipm, tmp, &failed_list, list)
1152 list_move_tail(&ipm->list, &card->ipm_list);
1154 spin_unlock_irqrestore(&card->ipm_lock, flags);
1158 * get mac address for the relevant Multicast address
1161 lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1163 LCS_DBF_TEXT(4,trace, "getmac");
1164 if (dev->type == ARPHRD_IEEE802_TR)
1165 ip_tr_mc_map(ipm, mac);
1167 ip_eth_mc_map(ipm, mac);
1171 * function called by net device to handle multicast address relevant things
1174 lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1176 struct ip_mc_list *im4;
1177 struct list_head *l;
1178 struct lcs_ipm_list *ipm;
1179 unsigned long flags;
1180 char buf[MAX_ADDR_LEN];
1182 LCS_DBF_TEXT(4, trace, "remmclst");
1183 spin_lock_irqsave(&card->ipm_lock, flags);
1184 list_for_each(l, &card->ipm_list) {
1185 ipm = list_entry(l, struct lcs_ipm_list, list);
1186 for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
1187 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1188 if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
1189 (memcmp(buf, &ipm->ipm.mac_addr,
1190 LCS_MAC_LENGTH) == 0) )
1194 ipm->ipm_state = LCS_IPM_STATE_DEL_REQUIRED;
1196 spin_unlock_irqrestore(&card->ipm_lock, flags);
1199 static inline struct lcs_ipm_list *
1200 lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf)
1202 struct lcs_ipm_list *tmp, *ipm = NULL;
1203 struct list_head *l;
1204 unsigned long flags;
1206 LCS_DBF_TEXT(4, trace, "chkmcent");
1207 spin_lock_irqsave(&card->ipm_lock, flags);
1208 list_for_each(l, &card->ipm_list) {
1209 tmp = list_entry(l, struct lcs_ipm_list, list);
1210 if ( (tmp->ipm.ip_addr == im4->multiaddr) &&
1211 (memcmp(buf, &tmp->ipm.mac_addr,
1212 LCS_MAC_LENGTH) == 0) ) {
1217 spin_unlock_irqrestore(&card->ipm_lock, flags);
1222 lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1225 struct ip_mc_list *im4;
1226 struct lcs_ipm_list *ipm;
1227 char buf[MAX_ADDR_LEN];
1228 unsigned long flags;
1230 LCS_DBF_TEXT(4, trace, "setmclst");
1231 for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
1232 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1233 ipm = lcs_check_addr_entry(card, im4, buf);
1235 continue; /* Address already in list. */
1236 ipm = (struct lcs_ipm_list *)
1237 kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
1239 pr_info("Not enough memory to add"
1240 " new multicast entry!\n");
1243 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
1244 ipm->ipm.ip_addr = im4->multiaddr;
1245 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
1246 spin_lock_irqsave(&card->ipm_lock, flags);
1247 LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4);
1248 list_add(&ipm->list, &card->ipm_list);
1249 spin_unlock_irqrestore(&card->ipm_lock, flags);
1254 lcs_register_mc_addresses(void *data)
1256 struct lcs_card *card;
1257 struct in_device *in4_dev;
1259 card = (struct lcs_card *) data;
1260 daemonize("regipm");
1262 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD))
1264 LCS_DBF_TEXT(4, trace, "regmulti");
1266 in4_dev = in_dev_get(card->dev);
1267 if (in4_dev == NULL)
1269 read_lock(&in4_dev->mc_list_lock);
1270 lcs_remove_mc_addresses(card,in4_dev);
1271 lcs_set_mc_addresses(card, in4_dev);
1272 read_unlock(&in4_dev->mc_list_lock);
1273 in_dev_put(in4_dev);
1275 netif_carrier_off(card->dev);
1276 netif_tx_disable(card->dev);
1277 wait_event(card->write.wait_q,
1278 (card->write.state != LCS_CH_STATE_RUNNING));
1279 lcs_fix_multicast_list(card);
1280 if (card->state == DEV_STATE_UP) {
1281 netif_carrier_on(card->dev);
1282 netif_wake_queue(card->dev);
1285 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
1289 * function called by net device to
1290 * handle multicast address relevant things
1293 lcs_set_multicast_list(struct net_device *dev)
1295 struct lcs_card *card;
1297 LCS_DBF_TEXT(4, trace, "setmulti");
1298 card = (struct lcs_card *) dev->ml_priv;
1300 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD))
1301 schedule_work(&card->kernel_thread_starter);
1304 #endif /* CONFIG_IP_MULTICAST */
1307 lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
1312 switch (PTR_ERR(irb)) {
1314 dev_warn(&cdev->dev,
1315 "An I/O-error occurred on the LCS device\n");
1316 LCS_DBF_TEXT(2, trace, "ckirberr");
1317 LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
1320 dev_warn(&cdev->dev,
1321 "A command timed out on the LCS device\n");
1322 LCS_DBF_TEXT(2, trace, "ckirberr");
1323 LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
1326 dev_warn(&cdev->dev,
1327 "An error occurred on the LCS device, rc=%ld\n",
1329 LCS_DBF_TEXT(2, trace, "ckirberr");
1330 LCS_DBF_TEXT(2, trace, " rc???");
1332 return PTR_ERR(irb);
1336 lcs_get_problem(struct ccw_device *cdev, struct irb *irb)
1341 sense = (char *) irb->ecw;
1342 cstat = irb->scsw.cmd.cstat;
1343 dstat = irb->scsw.cmd.dstat;
1345 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
1346 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
1347 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
1348 LCS_DBF_TEXT(2, trace, "CGENCHK");
1351 if (dstat & DEV_STAT_UNIT_CHECK) {
1352 if (sense[LCS_SENSE_BYTE_1] &
1353 LCS_SENSE_RESETTING_EVENT) {
1354 LCS_DBF_TEXT(2, trace, "REVIND");
1357 if (sense[LCS_SENSE_BYTE_0] &
1358 LCS_SENSE_CMD_REJECT) {
1359 LCS_DBF_TEXT(2, trace, "CMDREJ");
1362 if ((!sense[LCS_SENSE_BYTE_0]) &&
1363 (!sense[LCS_SENSE_BYTE_1]) &&
1364 (!sense[LCS_SENSE_BYTE_2]) &&
1365 (!sense[LCS_SENSE_BYTE_3])) {
1366 LCS_DBF_TEXT(2, trace, "ZEROSEN");
1369 LCS_DBF_TEXT(2, trace, "DGENCHK");
1376 lcs_schedule_recovery(struct lcs_card *card)
1378 LCS_DBF_TEXT(2, trace, "startrec");
1379 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD))
1380 schedule_work(&card->kernel_thread_starter);
1384 * IRQ Handler for LCS channels
1387 lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1389 struct lcs_card *card;
1390 struct lcs_channel *channel;
1394 if (lcs_check_irb_error(cdev, irb))
1397 card = CARD_FROM_DEV(cdev);
1398 if (card->read.ccwdev == cdev)
1399 channel = &card->read;
1401 channel = &card->write;
1403 cstat = irb->scsw.cmd.cstat;
1404 dstat = irb->scsw.cmd.dstat;
1405 LCS_DBF_TEXT_(5, trace, "Rint%s", dev_name(&cdev->dev));
1406 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.cstat,
1407 irb->scsw.cmd.dstat);
1408 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.fctl,
1409 irb->scsw.cmd.actl);
1411 /* Check for channel and device errors presented */
1412 rc = lcs_get_problem(cdev, irb);
1413 if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
1414 dev_warn(&cdev->dev,
1415 "The LCS device stopped because of an error,"
1416 " dstat=0x%X, cstat=0x%X \n",
1419 channel->state = LCS_CH_STATE_ERROR;
1422 if (channel->state == LCS_CH_STATE_ERROR) {
1423 lcs_schedule_recovery(card);
1424 wake_up(&card->wait_q);
1427 /* How far in the ccw chain have we processed? */
1428 if ((channel->state != LCS_CH_STATE_INIT) &&
1429 (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) &&
1430 (irb->scsw.cmd.cpa != 0)) {
1431 index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa)
1433 if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) ||
1434 (irb->scsw.cmd.cstat & SCHN_STAT_PCI))
1435 /* Bloody io subsystem tells us lies about cpa... */
1436 index = (index - 1) & (LCS_NUM_BUFFS - 1);
1437 while (channel->io_idx != index) {
1438 __lcs_processed_buffer(channel,
1439 channel->iob + channel->io_idx);
1441 (channel->io_idx + 1) & (LCS_NUM_BUFFS - 1);
1445 if ((irb->scsw.cmd.dstat & DEV_STAT_DEV_END) ||
1446 (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) ||
1447 (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK))
1448 /* Mark channel as stopped. */
1449 channel->state = LCS_CH_STATE_STOPPED;
1450 else if (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)
1451 /* CCW execution stopped on a suspend bit. */
1452 channel->state = LCS_CH_STATE_SUSPENDED;
1453 if (irb->scsw.cmd.fctl & SCSW_FCTL_HALT_FUNC) {
1454 if (irb->scsw.cmd.cc != 0) {
1455 ccw_device_halt(channel->ccwdev, (addr_t) channel);
1458 /* The channel has been stopped by halt_IO. */
1459 channel->state = LCS_CH_STATE_HALTED;
1461 if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC)
1462 channel->state = LCS_CH_STATE_CLEARED;
1463 /* Do the rest in the tasklet. */
1464 tasklet_schedule(&channel->irq_tasklet);
1468 * Tasklet for IRQ handler
1471 lcs_tasklet(unsigned long data)
1473 unsigned long flags;
1474 struct lcs_channel *channel;
1475 struct lcs_buffer *iob;
1479 channel = (struct lcs_channel *) data;
1480 LCS_DBF_TEXT_(5, trace, "tlet%s", dev_name(&channel->ccwdev->dev));
1482 /* Check for processed buffers. */
1484 buf_idx = channel->buf_idx;
1485 while (iob[buf_idx].state == LCS_BUF_STATE_PROCESSED) {
1486 /* Do the callback thing. */
1487 if (iob[buf_idx].callback != NULL)
1488 iob[buf_idx].callback(channel, iob + buf_idx);
1489 buf_idx = (buf_idx + 1) & (LCS_NUM_BUFFS - 1);
1491 channel->buf_idx = buf_idx;
1493 if (channel->state == LCS_CH_STATE_STOPPED)
1494 // FIXME: what if rc != 0 ??
1495 rc = lcs_start_channel(channel);
1496 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1497 if (channel->state == LCS_CH_STATE_SUSPENDED &&
1498 channel->iob[channel->io_idx].state == LCS_BUF_STATE_READY) {
1499 // FIXME: what if rc != 0 ??
1500 rc = __lcs_resume_channel(channel);
1502 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1504 /* Something happened on the channel. Wake up waiters. */
1505 wake_up(&channel->wait_q);
1509 * Finish current tx buffer and make it ready for transmit.
1512 __lcs_emit_txbuffer(struct lcs_card *card)
1514 LCS_DBF_TEXT(5, trace, "emittx");
1515 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0;
1516 card->tx_buffer->count += 2;
1517 lcs_ready_buffer(&card->write, card->tx_buffer);
1518 card->tx_buffer = NULL;
1523 * Callback for finished tx buffers.
1526 lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1528 struct lcs_card *card;
1530 LCS_DBF_TEXT(5, trace, "txbuffcb");
1531 /* Put buffer back to pool. */
1532 lcs_release_buffer(channel, buffer);
1533 card = container_of(channel, struct lcs_card, write);
1534 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1535 netif_wake_queue(card->dev);
1536 spin_lock(&card->lock);
1538 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1540 * Last running tx buffer has finished. Submit partially
1541 * filled current buffer.
1543 __lcs_emit_txbuffer(card);
1544 spin_unlock(&card->lock);
1548 * Packet transmit function called by network stack
1551 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
1552 struct net_device *dev)
1554 struct lcs_header *header;
1557 LCS_DBF_TEXT(5, trace, "hardxmit");
1559 card->stats.tx_dropped++;
1560 card->stats.tx_errors++;
1563 if (card->state != DEV_STATE_UP) {
1565 card->stats.tx_dropped++;
1566 card->stats.tx_errors++;
1567 card->stats.tx_carrier_errors++;
1570 if (skb->protocol == htons(ETH_P_IPV6)) {
1574 netif_stop_queue(card->dev);
1575 spin_lock(&card->lock);
1576 if (card->tx_buffer != NULL &&
1577 card->tx_buffer->count + sizeof(struct lcs_header) +
1578 skb->len + sizeof(u16) > LCS_IOBUFFERSIZE)
1579 /* skb too big for current tx buffer. */
1580 __lcs_emit_txbuffer(card);
1581 if (card->tx_buffer == NULL) {
1582 /* Get new tx buffer */
1583 card->tx_buffer = lcs_get_buffer(&card->write);
1584 if (card->tx_buffer == NULL) {
1585 card->stats.tx_dropped++;
1589 card->tx_buffer->callback = lcs_txbuffer_cb;
1590 card->tx_buffer->count = 0;
1592 header = (struct lcs_header *)
1593 (card->tx_buffer->data + card->tx_buffer->count);
1594 card->tx_buffer->count += skb->len + sizeof(struct lcs_header);
1595 header->offset = card->tx_buffer->count;
1596 header->type = card->lan_type;
1597 header->slot = card->portno;
1598 skb_copy_from_linear_data(skb, header + 1, skb->len);
1599 spin_unlock(&card->lock);
1600 card->stats.tx_bytes += skb->len;
1601 card->stats.tx_packets++;
1603 netif_wake_queue(card->dev);
1604 spin_lock(&card->lock);
1605 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1606 /* If this is the first tx buffer emit it immediately. */
1607 __lcs_emit_txbuffer(card);
1609 spin_unlock(&card->lock);
1614 lcs_start_xmit(struct sk_buff *skb, struct net_device *dev)
1616 struct lcs_card *card;
1619 LCS_DBF_TEXT(5, trace, "pktxmit");
1620 card = (struct lcs_card *) dev->ml_priv;
1621 rc = __lcs_start_xmit(card, skb, dev);
1626 * send startlan and lanstat command to make LCS device ready
1629 lcs_startlan_auto(struct lcs_card *card)
1633 LCS_DBF_TEXT(2, trace, "strtauto");
1634 #ifdef CONFIG_NET_ETHERNET
1635 card->lan_type = LCS_FRAME_TYPE_ENET;
1636 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1642 card->lan_type = LCS_FRAME_TYPE_TR;
1643 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1648 card->lan_type = LCS_FRAME_TYPE_FDDI;
1649 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1657 lcs_startlan(struct lcs_card *card)
1661 LCS_DBF_TEXT(2, trace, "startlan");
1663 if (card->portno != LCS_INVALID_PORT_NO) {
1664 if (card->lan_type == LCS_FRAME_TYPE_AUTO)
1665 rc = lcs_startlan_auto(card);
1667 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1669 for (i = 0; i <= 16; i++) {
1671 if (card->lan_type != LCS_FRAME_TYPE_AUTO)
1672 rc = lcs_send_startlan(card,
1673 LCS_INITIATOR_TCPIP);
1675 /* autodetecting lan type */
1676 rc = lcs_startlan_auto(card);
1682 return lcs_send_lanstat(card);
1687 * LCS detect function
1688 * setup channels and make them I/O ready
1691 lcs_detect(struct lcs_card *card)
1695 LCS_DBF_TEXT(2, setup, "lcsdetct");
1696 /* start/reset card */
1698 netif_stop_queue(card->dev);
1699 rc = lcs_stop_channels(card);
1701 rc = lcs_start_channels(card);
1703 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP);
1705 rc = lcs_startlan(card);
1709 card->state = DEV_STATE_UP;
1711 card->state = DEV_STATE_DOWN;
1712 card->write.state = LCS_CH_STATE_INIT;
1713 card->read.state = LCS_CH_STATE_INIT;
1722 lcs_stopcard(struct lcs_card *card)
1726 LCS_DBF_TEXT(3, setup, "stopcard");
1728 if (card->read.state != LCS_CH_STATE_STOPPED &&
1729 card->write.state != LCS_CH_STATE_STOPPED &&
1730 card->read.state != LCS_CH_STATE_ERROR &&
1731 card->write.state != LCS_CH_STATE_ERROR &&
1732 card->state == DEV_STATE_UP) {
1733 lcs_clear_multicast_list(card);
1734 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
1735 rc = lcs_send_shutdown(card);
1737 rc = lcs_stop_channels(card);
1738 card->state = DEV_STATE_DOWN;
1744 * Kernel Thread helper functions for LGW initiated commands
1747 lcs_start_kernel_thread(struct work_struct *work)
1749 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1750 LCS_DBF_TEXT(5, trace, "krnthrd");
1751 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1752 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
1753 #ifdef CONFIG_IP_MULTICAST
1754 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
1755 kernel_thread(lcs_register_mc_addresses,
1756 (void *) card, SIGCHLD);
1761 * Process control frames.
1764 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
1766 LCS_DBF_TEXT(5, trace, "getctrl");
1767 if (cmd->initiator == LCS_INITIATOR_LGW) {
1768 switch(cmd->cmd_code) {
1769 case LCS_CMD_STARTUP:
1770 case LCS_CMD_STARTLAN:
1771 lcs_schedule_recovery(card);
1773 case LCS_CMD_STOPLAN:
1774 pr_warning("Stoplan for %s initiated by LGW.\n",
1777 netif_carrier_off(card->dev);
1780 LCS_DBF_TEXT(5, trace, "noLGWcmd");
1784 lcs_notify_lancmd_waiters(card, cmd);
1788 * Unpack network packet.
1791 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
1793 struct sk_buff *skb;
1795 LCS_DBF_TEXT(5, trace, "getskb");
1796 if (card->dev == NULL ||
1797 card->state != DEV_STATE_UP)
1798 /* The card isn't up. Ignore the packet. */
1801 skb = dev_alloc_skb(skb_len);
1803 dev_err(&card->dev->dev,
1804 " Allocating a socket buffer to interface %s failed\n",
1806 card->stats.rx_dropped++;
1809 memcpy(skb_put(skb, skb_len), skb_data, skb_len);
1810 skb->protocol = card->lan_type_trans(skb, card->dev);
1811 card->stats.rx_bytes += skb_len;
1812 card->stats.rx_packets++;
1813 if (skb->protocol == htons(ETH_P_802_2))
1814 *((__u32 *)skb->cb) = ++card->pkt_seq;
1819 * LCS main routine to get packets and lancmd replies from the buffers
1822 lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1824 struct lcs_card *card;
1825 struct lcs_header *lcs_hdr;
1828 LCS_DBF_TEXT(5, trace, "lcsgtpkt");
1829 lcs_hdr = (struct lcs_header *) buffer->data;
1830 if (lcs_hdr->offset == LCS_ILLEGAL_OFFSET) {
1831 LCS_DBF_TEXT(4, trace, "-eiogpkt");
1834 card = container_of(channel, struct lcs_card, read);
1836 while (lcs_hdr->offset != 0) {
1837 if (lcs_hdr->offset <= 0 ||
1838 lcs_hdr->offset > LCS_IOBUFFERSIZE ||
1839 lcs_hdr->offset < offset) {
1840 /* Offset invalid. */
1841 card->stats.rx_length_errors++;
1842 card->stats.rx_errors++;
1845 /* What kind of frame is it? */
1846 if (lcs_hdr->type == LCS_FRAME_TYPE_CONTROL)
1847 /* Control frame. */
1848 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr);
1849 else if (lcs_hdr->type == LCS_FRAME_TYPE_ENET ||
1850 lcs_hdr->type == LCS_FRAME_TYPE_TR ||
1851 lcs_hdr->type == LCS_FRAME_TYPE_FDDI)
1852 /* Normal network packet. */
1853 lcs_get_skb(card, (char *)(lcs_hdr + 1),
1854 lcs_hdr->offset - offset -
1855 sizeof(struct lcs_header));
1857 /* Unknown frame type. */
1858 ; // FIXME: error message ?
1859 /* Proceed to next frame. */
1860 offset = lcs_hdr->offset;
1861 lcs_hdr->offset = LCS_ILLEGAL_OFFSET;
1862 lcs_hdr = (struct lcs_header *) (buffer->data + offset);
1864 /* The buffer is now empty. Make it ready again. */
1865 lcs_ready_buffer(&card->read, buffer);
1869 * get network statistics for ifconfig and other user programs
1871 static struct net_device_stats *
1872 lcs_getstats(struct net_device *dev)
1874 struct lcs_card *card;
1876 LCS_DBF_TEXT(4, trace, "netstats");
1877 card = (struct lcs_card *) dev->ml_priv;
1878 return &card->stats;
1883 * This function will be called by user doing ifconfig xxx down
1886 lcs_stop_device(struct net_device *dev)
1888 struct lcs_card *card;
1891 LCS_DBF_TEXT(2, trace, "stopdev");
1892 card = (struct lcs_card *) dev->ml_priv;
1893 netif_carrier_off(dev);
1894 netif_tx_disable(dev);
1895 dev->flags &= ~IFF_UP;
1896 wait_event(card->write.wait_q,
1897 (card->write.state != LCS_CH_STATE_RUNNING));
1898 rc = lcs_stopcard(card);
1900 dev_err(&card->dev->dev,
1901 " Shutting down the LCS device failed\n ");
1906 * start lcs device and make it runnable
1907 * This function will be called by user doing ifconfig xxx up
1910 lcs_open_device(struct net_device *dev)
1912 struct lcs_card *card;
1915 LCS_DBF_TEXT(2, trace, "opendev");
1916 card = (struct lcs_card *) dev->ml_priv;
1917 /* initialize statistics */
1918 rc = lcs_detect(card);
1920 pr_err("Error in opening device!\n");
1923 dev->flags |= IFF_UP;
1924 netif_carrier_on(dev);
1925 netif_wake_queue(dev);
1926 card->state = DEV_STATE_UP;
1932 * show function for portno called by cat or similar things
1935 lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
1937 struct lcs_card *card;
1939 card = (struct lcs_card *)dev->driver_data;
1944 return sprintf(buf, "%d\n", card->portno);
1948 * store the value which is piped to file portno
1951 lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1953 struct lcs_card *card;
1956 card = (struct lcs_card *)dev->driver_data;
1961 sscanf(buf, "%u", &value);
1962 /* TODO: sanity checks */
1963 card->portno = value;
1969 static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
1972 lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1974 struct ccwgroup_device *cgdev;
1976 cgdev = to_ccwgroupdev(dev);
1980 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
1983 static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
1986 lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
1988 struct lcs_card *card;
1990 card = (struct lcs_card *)dev->driver_data;
1992 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
1996 lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1998 struct lcs_card *card;
2001 card = (struct lcs_card *)dev->driver_data;
2006 sscanf(buf, "%u", &value);
2007 /* TODO: sanity checks */
2008 card->lancmd_timeout = value;
2014 static DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
2017 lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
2018 const char *buf, size_t count)
2020 struct lcs_card *card = dev->driver_data;
2026 if (card->state != DEV_STATE_UP)
2028 i = simple_strtoul(buf, &tmp, 16);
2030 lcs_schedule_recovery(card);
2034 static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store);
2036 static struct attribute * lcs_attrs[] = {
2037 &dev_attr_portno.attr,
2038 &dev_attr_type.attr,
2039 &dev_attr_lancmd_timeout.attr,
2040 &dev_attr_recover.attr,
2044 static struct attribute_group lcs_attr_group = {
2049 * lcs_probe_device is called on establishing a new ccwgroup_device.
2052 lcs_probe_device(struct ccwgroup_device *ccwgdev)
2054 struct lcs_card *card;
2057 if (!get_device(&ccwgdev->dev))
2060 LCS_DBF_TEXT(2, setup, "add_dev");
2061 card = lcs_alloc_card();
2063 LCS_DBF_TEXT_(2, setup, " rc%d", -ENOMEM);
2064 put_device(&ccwgdev->dev);
2067 ret = sysfs_create_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2069 lcs_free_card(card);
2070 put_device(&ccwgdev->dev);
2073 ccwgdev->dev.driver_data = card;
2074 ccwgdev->cdev[0]->handler = lcs_irq;
2075 ccwgdev->cdev[1]->handler = lcs_irq;
2076 card->gdev = ccwgdev;
2077 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2078 card->thread_start_mask = 0;
2079 card->thread_allowed_mask = 0;
2080 card->thread_running_mask = 0;
2085 lcs_register_netdev(struct ccwgroup_device *ccwgdev)
2087 struct lcs_card *card;
2089 LCS_DBF_TEXT(2, setup, "regnetdv");
2090 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2091 if (card->dev->reg_state != NETREG_UNINITIALIZED)
2093 SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
2094 return register_netdev(card->dev);
2098 * lcs_new_device will be called by setting the group device online.
2102 lcs_new_device(struct ccwgroup_device *ccwgdev)
2104 struct lcs_card *card;
2105 struct net_device *dev=NULL;
2106 enum lcs_dev_states recover_state;
2109 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2113 LCS_DBF_TEXT(2, setup, "newdev");
2114 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2115 card->read.ccwdev = ccwgdev->cdev[0];
2116 card->write.ccwdev = ccwgdev->cdev[1];
2118 recover_state = card->state;
2119 ccw_device_set_online(card->read.ccwdev);
2120 ccw_device_set_online(card->write.ccwdev);
2122 LCS_DBF_TEXT(3, setup, "lcsnewdv");
2124 lcs_setup_card(card);
2125 rc = lcs_detect(card);
2127 LCS_DBF_TEXT(2, setup, "dtctfail");
2128 dev_err(&card->dev->dev,
2129 "Detecting a network adapter for LCS devices"
2130 " failed with rc=%d (0x%x)\n", rc, rc);
2135 LCS_DBF_TEXT(2, setup, "samedev");
2136 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2139 switch (card->lan_type) {
2140 #ifdef CONFIG_NET_ETHERNET
2141 case LCS_FRAME_TYPE_ENET:
2142 card->lan_type_trans = eth_type_trans;
2143 dev = alloc_etherdev(0);
2147 case LCS_FRAME_TYPE_TR:
2148 card->lan_type_trans = tr_type_trans;
2149 dev = alloc_trdev(0);
2153 case LCS_FRAME_TYPE_FDDI:
2154 card->lan_type_trans = fddi_type_trans;
2155 dev = alloc_fddidev(0);
2159 LCS_DBF_TEXT(3, setup, "errinit");
2160 pr_err(" Initialization failed\n");
2166 card->dev->ml_priv = card;
2167 card->dev->open = lcs_open_device;
2168 card->dev->stop = lcs_stop_device;
2169 card->dev->hard_start_xmit = lcs_start_xmit;
2170 card->dev->get_stats = lcs_getstats;
2171 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
2172 #ifdef CONFIG_IP_MULTICAST
2173 if (!lcs_check_multicast_support(card))
2174 card->dev->set_multicast_list = lcs_set_multicast_list;
2177 lcs_set_allowed_threads(card,0xffffffff);
2178 if (recover_state == DEV_STATE_RECOVER) {
2179 lcs_set_multicast_list(card->dev);
2180 card->dev->flags |= IFF_UP;
2181 netif_carrier_on(card->dev);
2182 netif_wake_queue(card->dev);
2183 card->state = DEV_STATE_UP;
2188 if (lcs_register_netdev(ccwgdev) != 0)
2191 /* Print out supported assists: IPv6 */
2192 pr_info("LCS device %s %s IPv6 support\n", card->dev->name,
2193 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
2194 "with" : "without");
2195 /* Print out supported assist: Multicast */
2196 pr_info("LCS device %s %s Multicast support\n", card->dev->name,
2197 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
2198 "with" : "without");
2202 ccw_device_set_offline(card->read.ccwdev);
2203 ccw_device_set_offline(card->write.ccwdev);
2208 * lcs_shutdown_device, called when setting the group device offline.
2211 __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
2213 struct lcs_card *card;
2214 enum lcs_dev_states recover_state;
2217 LCS_DBF_TEXT(3, setup, "shtdndev");
2218 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2221 if (recovery_mode == 0) {
2222 lcs_set_allowed_threads(card, 0);
2223 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
2224 return -ERESTARTSYS;
2226 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2227 recover_state = card->state;
2229 ret = lcs_stop_device(card->dev);
2230 ret = ccw_device_set_offline(card->read.ccwdev);
2231 ret = ccw_device_set_offline(card->write.ccwdev);
2232 if (recover_state == DEV_STATE_UP) {
2233 card->state = DEV_STATE_RECOVER;
2241 lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2243 return __lcs_shutdown_device(ccwgdev, 0);
2247 * drive lcs recovery after startup and startlan initiated by Lan Gateway
2250 lcs_recovery(void *ptr)
2252 struct lcs_card *card;
2253 struct ccwgroup_device *gdev;
2256 card = (struct lcs_card *) ptr;
2257 daemonize("lcs_recover");
2259 LCS_DBF_TEXT(4, trace, "recover1");
2260 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD))
2262 LCS_DBF_TEXT(4, trace, "recover2");
2264 dev_warn(&gdev->dev,
2265 "A recovery process has been started for the LCS device\n");
2266 rc = __lcs_shutdown_device(gdev, 1);
2267 rc = lcs_new_device(gdev);
2269 pr_info("Device %s successfully recovered!\n",
2272 pr_info("Device %s could not be recovered!\n",
2274 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
2279 * lcs_remove_device, free buffers and card
2282 lcs_remove_device(struct ccwgroup_device *ccwgdev)
2284 struct lcs_card *card;
2286 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2290 LCS_DBF_TEXT(3, setup, "remdev");
2291 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2292 if (ccwgdev->state == CCWGROUP_ONLINE) {
2293 lcs_shutdown_device(ccwgdev);
2296 unregister_netdev(card->dev);
2297 sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2298 lcs_cleanup_card(card);
2299 lcs_free_card(card);
2300 put_device(&ccwgdev->dev);
2304 * LCS ccwgroup driver registration
2306 static struct ccwgroup_driver lcs_group_driver = {
2307 .owner = THIS_MODULE,
2310 .driver_id = 0xD3C3E2,
2311 .probe = lcs_probe_device,
2312 .remove = lcs_remove_device,
2313 .set_online = lcs_new_device,
2314 .set_offline = lcs_shutdown_device,
2318 * LCS Module/Kernel initialization function
2321 __init lcs_init_module(void)
2325 pr_info("Loading %s\n", version);
2326 rc = lcs_register_debug_facility();
2327 LCS_DBF_TEXT(0, setup, "lcsinit");
2329 pr_err("Initialization failed\n");
2333 rc = register_cu3088_discipline(&lcs_group_driver);
2335 pr_err("Initialization failed\n");
2343 * LCS module cleanup function
2346 __exit lcs_cleanup_module(void)
2348 pr_info("Terminating lcs module.\n");
2349 LCS_DBF_TEXT(0, trace, "cleanup");
2350 unregister_cu3088_discipline(&lcs_group_driver);
2351 lcs_unregister_debug_facility();
2354 module_init(lcs_init_module);
2355 module_exit(lcs_cleanup_module);
2357 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
2358 MODULE_LICENSE("GPL");