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 #ifdef CONFIG_IP_MULTICAST
74 static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
75 #endif /* CONFIG_IP_MULTICAST */
76 static int lcs_recovery(void *ptr);
79 * Debug Facility Stuff
81 static debug_info_t *lcs_dbf_setup;
82 static debug_info_t *lcs_dbf_trace;
85 * LCS Debug Facility functions
88 lcs_unregister_debug_facility(void)
91 debug_unregister(lcs_dbf_setup);
93 debug_unregister(lcs_dbf_trace);
97 lcs_register_debug_facility(void)
99 lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
100 lcs_dbf_trace = debug_register("lcs_trace", 4, 1, 8);
101 if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
102 pr_err("Not enough memory for debug facility.\n");
103 lcs_unregister_debug_facility();
106 debug_register_view(lcs_dbf_setup, &debug_hex_ascii_view);
107 debug_set_level(lcs_dbf_setup, 2);
108 debug_register_view(lcs_dbf_trace, &debug_hex_ascii_view);
109 debug_set_level(lcs_dbf_trace, 2);
114 * Allocate io buffers.
117 lcs_alloc_channel(struct lcs_channel *channel)
121 LCS_DBF_TEXT(2, setup, "ichalloc");
122 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
123 /* alloc memory fo iobuffer */
124 channel->iob[cnt].data =
125 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
126 if (channel->iob[cnt].data == NULL)
128 channel->iob[cnt].state = LCS_BUF_STATE_EMPTY;
130 if (cnt < LCS_NUM_BUFFS) {
131 /* Not all io buffers could be allocated. */
132 LCS_DBF_TEXT(2, setup, "echalloc");
134 kfree(channel->iob[cnt].data);
144 lcs_free_channel(struct lcs_channel *channel)
148 LCS_DBF_TEXT(2, setup, "ichfree");
149 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
150 kfree(channel->iob[cnt].data);
151 channel->iob[cnt].data = NULL;
159 lcs_cleanup_channel(struct lcs_channel *channel)
161 LCS_DBF_TEXT(3, setup, "cleanch");
162 /* Kill write channel tasklets. */
163 tasklet_kill(&channel->irq_tasklet);
164 /* Free channel buffers. */
165 lcs_free_channel(channel);
169 * LCS free memory for card and channels.
172 lcs_free_card(struct lcs_card *card)
174 LCS_DBF_TEXT(2, setup, "remcard");
175 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
180 * LCS alloc memory for card and channels
182 static struct lcs_card *
185 struct lcs_card *card;
188 LCS_DBF_TEXT(2, setup, "alloclcs");
190 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
193 card->lan_type = LCS_FRAME_TYPE_AUTO;
195 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
196 /* Allocate io buffers for the read channel. */
197 rc = lcs_alloc_channel(&card->read);
199 LCS_DBF_TEXT(2, setup, "iccwerr");
203 /* Allocate io buffers for the write channel. */
204 rc = lcs_alloc_channel(&card->write);
206 LCS_DBF_TEXT(2, setup, "iccwerr");
207 lcs_cleanup_channel(&card->read);
212 #ifdef CONFIG_IP_MULTICAST
213 INIT_LIST_HEAD(&card->ipm_list);
215 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
220 * Setup read channel.
223 lcs_setup_read_ccws(struct lcs_card *card)
227 LCS_DBF_TEXT(2, setup, "ireadccw");
228 /* Setup read ccws. */
229 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1));
230 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
231 card->read.ccws[cnt].cmd_code = LCS_CCW_READ;
232 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE;
233 card->read.ccws[cnt].flags =
234 CCW_FLAG_CC | CCW_FLAG_SLI | CCW_FLAG_PCI;
236 * Note: we have allocated the buffer with GFP_DMA, so
237 * we do not need to do set_normalized_cda.
239 card->read.ccws[cnt].cda =
240 (__u32) __pa(card->read.iob[cnt].data);
241 ((struct lcs_header *)
242 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET;
243 card->read.iob[cnt].callback = lcs_get_frames_cb;
244 card->read.iob[cnt].state = LCS_BUF_STATE_READY;
245 card->read.iob[cnt].count = LCS_IOBUFFERSIZE;
247 card->read.ccws[0].flags &= ~CCW_FLAG_PCI;
248 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI;
249 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND;
250 /* Last ccw is a tic (transfer in channel). */
251 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
252 card->read.ccws[LCS_NUM_BUFFS].cda =
253 (__u32) __pa(card->read.ccws);
254 /* Setg initial state of the read channel. */
255 card->read.state = LCS_CH_STATE_INIT;
257 card->read.io_idx = 0;
258 card->read.buf_idx = 0;
262 lcs_setup_read(struct lcs_card *card)
264 LCS_DBF_TEXT(3, setup, "initread");
266 lcs_setup_read_ccws(card);
267 /* Initialize read channel tasklet. */
268 card->read.irq_tasklet.data = (unsigned long) &card->read;
269 card->read.irq_tasklet.func = lcs_tasklet;
270 /* Initialize waitqueue. */
271 init_waitqueue_head(&card->read.wait_q);
275 * Setup write channel.
278 lcs_setup_write_ccws(struct lcs_card *card)
282 LCS_DBF_TEXT(3, setup, "iwritccw");
283 /* Setup write ccws. */
284 memset(card->write.ccws, 0, sizeof(struct ccw1) * LCS_NUM_BUFFS + 1);
285 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
286 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE;
287 card->write.ccws[cnt].count = 0;
288 card->write.ccws[cnt].flags =
289 CCW_FLAG_SUSPEND | CCW_FLAG_CC | CCW_FLAG_SLI;
291 * Note: we have allocated the buffer with GFP_DMA, so
292 * we do not need to do set_normalized_cda.
294 card->write.ccws[cnt].cda =
295 (__u32) __pa(card->write.iob[cnt].data);
297 /* Last ccw is a tic (transfer in channel). */
298 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER;
299 card->write.ccws[LCS_NUM_BUFFS].cda =
300 (__u32) __pa(card->write.ccws);
301 /* Set initial state of the write channel. */
302 card->read.state = LCS_CH_STATE_INIT;
304 card->write.io_idx = 0;
305 card->write.buf_idx = 0;
309 lcs_setup_write(struct lcs_card *card)
311 LCS_DBF_TEXT(3, setup, "initwrit");
313 lcs_setup_write_ccws(card);
314 /* Initialize write channel tasklet. */
315 card->write.irq_tasklet.data = (unsigned long) &card->write;
316 card->write.irq_tasklet.func = lcs_tasklet;
317 /* Initialize waitqueue. */
318 init_waitqueue_head(&card->write.wait_q);
322 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads)
326 spin_lock_irqsave(&card->mask_lock, flags);
327 card->thread_allowed_mask = threads;
328 spin_unlock_irqrestore(&card->mask_lock, flags);
329 wake_up(&card->wait_q);
332 lcs_threads_running(struct lcs_card *card, unsigned long threads)
337 spin_lock_irqsave(&card->mask_lock, flags);
338 rc = (card->thread_running_mask & threads);
339 spin_unlock_irqrestore(&card->mask_lock, flags);
344 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads)
346 return wait_event_interruptible(card->wait_q,
347 lcs_threads_running(card, threads) == 0);
351 lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread)
355 spin_lock_irqsave(&card->mask_lock, flags);
356 if ( !(card->thread_allowed_mask & thread) ||
357 (card->thread_start_mask & thread) ) {
358 spin_unlock_irqrestore(&card->mask_lock, flags);
361 card->thread_start_mask |= thread;
362 spin_unlock_irqrestore(&card->mask_lock, flags);
367 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread)
371 spin_lock_irqsave(&card->mask_lock, flags);
372 card->thread_running_mask &= ~thread;
373 spin_unlock_irqrestore(&card->mask_lock, flags);
374 wake_up(&card->wait_q);
378 __lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
383 spin_lock_irqsave(&card->mask_lock, flags);
384 if (card->thread_start_mask & thread){
385 if ((card->thread_allowed_mask & thread) &&
386 !(card->thread_running_mask & thread)){
388 card->thread_start_mask &= ~thread;
389 card->thread_running_mask |= thread;
393 spin_unlock_irqrestore(&card->mask_lock, flags);
398 lcs_do_run_thread(struct lcs_card *card, unsigned long thread)
401 wait_event(card->wait_q,
402 (rc = __lcs_do_run_thread(card, thread)) >= 0);
407 lcs_do_start_thread(struct lcs_card *card, unsigned long thread)
412 spin_lock_irqsave(&card->mask_lock, flags);
413 LCS_DBF_TEXT_(4, trace, " %02x%02x%02x",
414 (u8) card->thread_start_mask,
415 (u8) card->thread_allowed_mask,
416 (u8) card->thread_running_mask);
417 rc = (card->thread_start_mask & thread);
418 spin_unlock_irqrestore(&card->mask_lock, flags);
423 * Initialize channels,card and state machines.
426 lcs_setup_card(struct lcs_card *card)
428 LCS_DBF_TEXT(2, setup, "initcard");
429 LCS_DBF_HEX(2, setup, &card, sizeof(void*));
431 lcs_setup_read(card);
432 lcs_setup_write(card);
433 /* Set cards initial state. */
434 card->state = DEV_STATE_DOWN;
435 card->tx_buffer = NULL;
436 card->tx_emitted = 0;
438 init_waitqueue_head(&card->wait_q);
439 spin_lock_init(&card->lock);
440 spin_lock_init(&card->ipm_lock);
441 spin_lock_init(&card->mask_lock);
442 #ifdef CONFIG_IP_MULTICAST
443 INIT_LIST_HEAD(&card->ipm_list);
445 INIT_LIST_HEAD(&card->lancmd_waiters);
449 lcs_clear_multicast_list(struct lcs_card *card)
451 #ifdef CONFIG_IP_MULTICAST
452 struct lcs_ipm_list *ipm;
455 /* Free multicast list. */
456 LCS_DBF_TEXT(3, setup, "clmclist");
457 spin_lock_irqsave(&card->ipm_lock, flags);
458 while (!list_empty(&card->ipm_list)){
459 ipm = list_entry(card->ipm_list.next,
460 struct lcs_ipm_list, list);
461 list_del(&ipm->list);
462 if (ipm->ipm_state != LCS_IPM_STATE_SET_REQUIRED){
463 spin_unlock_irqrestore(&card->ipm_lock, flags);
464 lcs_send_delipm(card, ipm);
465 spin_lock_irqsave(&card->ipm_lock, flags);
469 spin_unlock_irqrestore(&card->ipm_lock, flags);
473 * Cleanup channels,card and state machines.
476 lcs_cleanup_card(struct lcs_card *card)
479 LCS_DBF_TEXT(3, setup, "cleancrd");
480 LCS_DBF_HEX(2,setup,&card,sizeof(void*));
482 if (card->dev != NULL)
483 free_netdev(card->dev);
484 /* Cleanup channels. */
485 lcs_cleanup_channel(&card->write);
486 lcs_cleanup_channel(&card->read);
493 lcs_start_channel(struct lcs_channel *channel)
498 LCS_DBF_TEXT_(4, trace,"ssch%s", dev_name(&channel->ccwdev->dev));
499 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
500 rc = ccw_device_start(channel->ccwdev,
501 channel->ccws + channel->io_idx, 0, 0,
502 DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND);
504 channel->state = LCS_CH_STATE_RUNNING;
505 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
507 LCS_DBF_TEXT_(4,trace,"essh%s",
508 dev_name(&channel->ccwdev->dev));
509 dev_err(&channel->ccwdev->dev,
510 "Starting an LCS device resulted in an error,"
517 lcs_clear_channel(struct lcs_channel *channel)
522 LCS_DBF_TEXT(4,trace,"clearch");
523 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
524 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
525 rc = ccw_device_clear(channel->ccwdev, (addr_t) channel);
526 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
528 LCS_DBF_TEXT_(4, trace, "ecsc%s",
529 dev_name(&channel->ccwdev->dev));
532 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_CLEARED));
533 channel->state = LCS_CH_STATE_STOPPED;
542 lcs_stop_channel(struct lcs_channel *channel)
547 if (channel->state == LCS_CH_STATE_STOPPED)
549 LCS_DBF_TEXT(4,trace,"haltsch");
550 LCS_DBF_TEXT_(4, trace, "%s", dev_name(&channel->ccwdev->dev));
551 channel->state = LCS_CH_STATE_INIT;
552 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
553 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
554 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
556 LCS_DBF_TEXT_(4, trace, "ehsc%s",
557 dev_name(&channel->ccwdev->dev));
560 /* Asynchronous halt initialted. Wait for its completion. */
561 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_HALTED));
562 lcs_clear_channel(channel);
567 * start read and write channel
570 lcs_start_channels(struct lcs_card *card)
574 LCS_DBF_TEXT(2, trace, "chstart");
575 /* start read channel */
576 rc = lcs_start_channel(&card->read);
579 /* start write channel */
580 rc = lcs_start_channel(&card->write);
582 lcs_stop_channel(&card->read);
587 * stop read and write channel
590 lcs_stop_channels(struct lcs_card *card)
592 LCS_DBF_TEXT(2, trace, "chhalt");
593 lcs_stop_channel(&card->read);
594 lcs_stop_channel(&card->write);
601 static struct lcs_buffer *
602 __lcs_get_buffer(struct lcs_channel *channel)
606 LCS_DBF_TEXT(5, trace, "_getbuff");
607 index = channel->io_idx;
609 if (channel->iob[index].state == LCS_BUF_STATE_EMPTY) {
610 channel->iob[index].state = LCS_BUF_STATE_LOCKED;
611 return channel->iob + index;
613 index = (index + 1) & (LCS_NUM_BUFFS - 1);
614 } while (index != channel->io_idx);
618 static struct lcs_buffer *
619 lcs_get_buffer(struct lcs_channel *channel)
621 struct lcs_buffer *buffer;
624 LCS_DBF_TEXT(5, trace, "getbuff");
625 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
626 buffer = __lcs_get_buffer(channel);
627 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
632 * Resume channel program if the channel is suspended.
635 __lcs_resume_channel(struct lcs_channel *channel)
639 if (channel->state != LCS_CH_STATE_SUSPENDED)
641 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
643 LCS_DBF_TEXT_(5, trace, "rsch%s", dev_name(&channel->ccwdev->dev));
644 rc = ccw_device_resume(channel->ccwdev);
646 LCS_DBF_TEXT_(4, trace, "ersc%s",
647 dev_name(&channel->ccwdev->dev));
648 dev_err(&channel->ccwdev->dev,
649 "Sending data from the LCS device to the LAN failed"
652 channel->state = LCS_CH_STATE_RUNNING;
658 * Make a buffer ready for processing.
661 __lcs_ready_buffer_bits(struct lcs_channel *channel, int index)
665 LCS_DBF_TEXT(5, trace, "rdybits");
666 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
667 next = (index + 1) & (LCS_NUM_BUFFS - 1);
668 /* Check if we may clear the suspend bit of this buffer. */
669 if (channel->ccws[next].flags & CCW_FLAG_SUSPEND) {
670 /* Check if we have to set the PCI bit. */
671 if (!(channel->ccws[prev].flags & CCW_FLAG_SUSPEND))
672 /* Suspend bit of the previous buffer is not set. */
673 channel->ccws[index].flags |= CCW_FLAG_PCI;
674 /* Suspend bit of the next buffer is set. */
675 channel->ccws[index].flags &= ~CCW_FLAG_SUSPEND;
680 lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
685 LCS_DBF_TEXT(5, trace, "rdybuff");
686 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
687 buffer->state != LCS_BUF_STATE_PROCESSED);
688 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
689 buffer->state = LCS_BUF_STATE_READY;
690 index = buffer - channel->iob;
692 channel->ccws[index].count = buffer->count;
693 /* Check relevant PCI/suspend bits. */
694 __lcs_ready_buffer_bits(channel, index);
695 rc = __lcs_resume_channel(channel);
696 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
701 * Mark the buffer as processed. Take care of the suspend bit
702 * of the previous buffer. This function is called from
703 * interrupt context, so the lock must not be taken.
706 __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
708 int index, prev, next;
710 LCS_DBF_TEXT(5, trace, "prcsbuff");
711 BUG_ON(buffer->state != LCS_BUF_STATE_READY);
712 buffer->state = LCS_BUF_STATE_PROCESSED;
713 index = buffer - channel->iob;
714 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
715 next = (index + 1) & (LCS_NUM_BUFFS - 1);
716 /* Set the suspend bit and clear the PCI bit of this buffer. */
717 channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
718 channel->ccws[index].flags &= ~CCW_FLAG_PCI;
719 /* Check the suspend bit of the previous buffer. */
720 if (channel->iob[prev].state == LCS_BUF_STATE_READY) {
722 * Previous buffer is in state ready. It might have
723 * happened in lcs_ready_buffer that the suspend bit
724 * has not been cleared to avoid an endless loop.
727 __lcs_ready_buffer_bits(channel, prev);
729 /* Clear PCI bit of next buffer. */
730 channel->ccws[next].flags &= ~CCW_FLAG_PCI;
731 return __lcs_resume_channel(channel);
735 * Put a processed buffer back to state empty.
738 lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
742 LCS_DBF_TEXT(5, trace, "relbuff");
743 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
744 buffer->state != LCS_BUF_STATE_PROCESSED);
745 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
746 buffer->state = LCS_BUF_STATE_EMPTY;
747 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
751 * Get buffer for a lan command.
753 static struct lcs_buffer *
754 lcs_get_lancmd(struct lcs_card *card, int count)
756 struct lcs_buffer *buffer;
759 LCS_DBF_TEXT(4, trace, "getlncmd");
760 /* Get buffer and wait if none is available. */
761 wait_event(card->write.wait_q,
762 ((buffer = lcs_get_buffer(&card->write)) != NULL));
763 count += sizeof(struct lcs_header);
764 *(__u16 *)(buffer->data + count) = 0;
765 buffer->count = count + sizeof(__u16);
766 buffer->callback = lcs_release_buffer;
767 cmd = (struct lcs_cmd *) buffer->data;
769 cmd->type = LCS_FRAME_TYPE_CONTROL;
776 lcs_get_reply(struct lcs_reply *reply)
778 WARN_ON(atomic_read(&reply->refcnt) <= 0);
779 atomic_inc(&reply->refcnt);
783 lcs_put_reply(struct lcs_reply *reply)
785 WARN_ON(atomic_read(&reply->refcnt) <= 0);
786 if (atomic_dec_and_test(&reply->refcnt)) {
792 static struct lcs_reply *
793 lcs_alloc_reply(struct lcs_cmd *cmd)
795 struct lcs_reply *reply;
797 LCS_DBF_TEXT(4, trace, "getreply");
799 reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
802 atomic_set(&reply->refcnt,1);
803 reply->sequence_no = cmd->sequence_no;
806 init_waitqueue_head(&reply->wait_q);
812 * Notifier function for lancmd replies. Called from read irq.
815 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
817 struct list_head *l, *n;
818 struct lcs_reply *reply;
820 LCS_DBF_TEXT(4, trace, "notiwait");
821 spin_lock(&card->lock);
822 list_for_each_safe(l, n, &card->lancmd_waiters) {
823 reply = list_entry(l, struct lcs_reply, list);
824 if (reply->sequence_no == cmd->sequence_no) {
825 lcs_get_reply(reply);
826 list_del_init(&reply->list);
827 if (reply->callback != NULL)
828 reply->callback(card, cmd);
830 reply->rc = cmd->return_code;
831 wake_up(&reply->wait_q);
832 lcs_put_reply(reply);
836 spin_unlock(&card->lock);
840 * Emit buffer of a lan comand.
843 lcs_lancmd_timeout(unsigned long data)
845 struct lcs_reply *reply, *list_reply, *r;
848 LCS_DBF_TEXT(4, trace, "timeout");
849 reply = (struct lcs_reply *) data;
850 spin_lock_irqsave(&reply->card->lock, flags);
851 list_for_each_entry_safe(list_reply, r,
852 &reply->card->lancmd_waiters,list) {
853 if (reply == list_reply) {
854 lcs_get_reply(reply);
855 list_del_init(&reply->list);
856 spin_unlock_irqrestore(&reply->card->lock, flags);
859 wake_up(&reply->wait_q);
860 lcs_put_reply(reply);
864 spin_unlock_irqrestore(&reply->card->lock, flags);
868 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
869 void (*reply_callback)(struct lcs_card *, struct lcs_cmd *))
871 struct lcs_reply *reply;
873 struct timer_list timer;
877 LCS_DBF_TEXT(4, trace, "sendcmd");
878 cmd = (struct lcs_cmd *) buffer->data;
879 cmd->return_code = 0;
880 cmd->sequence_no = card->sequence_no++;
881 reply = lcs_alloc_reply(cmd);
884 reply->callback = reply_callback;
886 spin_lock_irqsave(&card->lock, flags);
887 list_add_tail(&reply->list, &card->lancmd_waiters);
888 spin_unlock_irqrestore(&card->lock, flags);
890 buffer->callback = lcs_release_buffer;
891 rc = lcs_ready_buffer(&card->write, buffer);
895 timer.function = lcs_lancmd_timeout;
896 timer.data = (unsigned long) reply;
897 timer.expires = jiffies + HZ*card->lancmd_timeout;
899 wait_event(reply->wait_q, reply->received);
900 del_timer_sync(&timer);
901 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
903 lcs_put_reply(reply);
904 return rc ? -EIO : 0;
908 * LCS startup command
911 lcs_send_startup(struct lcs_card *card, __u8 initiator)
913 struct lcs_buffer *buffer;
916 LCS_DBF_TEXT(2, trace, "startup");
917 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
918 cmd = (struct lcs_cmd *) buffer->data;
919 cmd->cmd_code = LCS_CMD_STARTUP;
920 cmd->initiator = initiator;
921 cmd->cmd.lcs_startup.buff_size = LCS_IOBUFFERSIZE;
922 return lcs_send_lancmd(card, buffer, NULL);
926 * LCS shutdown command
929 lcs_send_shutdown(struct lcs_card *card)
931 struct lcs_buffer *buffer;
934 LCS_DBF_TEXT(2, trace, "shutdown");
935 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
936 cmd = (struct lcs_cmd *) buffer->data;
937 cmd->cmd_code = LCS_CMD_SHUTDOWN;
938 cmd->initiator = LCS_INITIATOR_TCPIP;
939 return lcs_send_lancmd(card, buffer, NULL);
943 * LCS lanstat command
946 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd)
948 LCS_DBF_TEXT(2, trace, "statcb");
949 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH);
953 lcs_send_lanstat(struct lcs_card *card)
955 struct lcs_buffer *buffer;
958 LCS_DBF_TEXT(2,trace, "cmdstat");
959 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
960 cmd = (struct lcs_cmd *) buffer->data;
961 /* Setup lanstat command. */
962 cmd->cmd_code = LCS_CMD_LANSTAT;
963 cmd->initiator = LCS_INITIATOR_TCPIP;
964 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
965 cmd->cmd.lcs_std_cmd.portno = card->portno;
966 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb);
970 * send stoplan command
973 lcs_send_stoplan(struct lcs_card *card, __u8 initiator)
975 struct lcs_buffer *buffer;
978 LCS_DBF_TEXT(2, trace, "cmdstpln");
979 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
980 cmd = (struct lcs_cmd *) buffer->data;
981 cmd->cmd_code = LCS_CMD_STOPLAN;
982 cmd->initiator = initiator;
983 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
984 cmd->cmd.lcs_std_cmd.portno = card->portno;
985 return lcs_send_lancmd(card, buffer, NULL);
989 * send startlan command
992 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd)
994 LCS_DBF_TEXT(2, trace, "srtlancb");
995 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type;
996 card->portno = cmd->cmd.lcs_std_cmd.portno;
1000 lcs_send_startlan(struct lcs_card *card, __u8 initiator)
1002 struct lcs_buffer *buffer;
1003 struct lcs_cmd *cmd;
1005 LCS_DBF_TEXT(2, trace, "cmdstaln");
1006 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1007 cmd = (struct lcs_cmd *) buffer->data;
1008 cmd->cmd_code = LCS_CMD_STARTLAN;
1009 cmd->initiator = initiator;
1010 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type;
1011 cmd->cmd.lcs_std_cmd.portno = card->portno;
1012 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb);
1015 #ifdef CONFIG_IP_MULTICAST
1017 * send setipm command (Multicast)
1020 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1022 struct lcs_buffer *buffer;
1023 struct lcs_cmd *cmd;
1025 LCS_DBF_TEXT(2, trace, "cmdsetim");
1026 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1027 cmd = (struct lcs_cmd *) buffer->data;
1028 cmd->cmd_code = LCS_CMD_SETIPM;
1029 cmd->initiator = LCS_INITIATOR_TCPIP;
1030 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1031 cmd->cmd.lcs_qipassist.portno = card->portno;
1032 cmd->cmd.lcs_qipassist.version = 4;
1033 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1034 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1035 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1036 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1037 return lcs_send_lancmd(card, buffer, NULL);
1041 * send delipm command (Multicast)
1044 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list)
1046 struct lcs_buffer *buffer;
1047 struct lcs_cmd *cmd;
1049 LCS_DBF_TEXT(2, trace, "cmddelim");
1050 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE);
1051 cmd = (struct lcs_cmd *) buffer->data;
1052 cmd->cmd_code = LCS_CMD_DELIPM;
1053 cmd->initiator = LCS_INITIATOR_TCPIP;
1054 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1055 cmd->cmd.lcs_qipassist.portno = card->portno;
1056 cmd->cmd.lcs_qipassist.version = 4;
1057 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1058 memcpy(cmd->cmd.lcs_qipassist.lcs_ipass_ctlmsg.ip_mac_pair,
1059 &ipm_list->ipm, sizeof (struct lcs_ip_mac_pair));
1060 LCS_DBF_TEXT_(2, trace, "%x",ipm_list->ipm.ip_addr);
1061 return lcs_send_lancmd(card, buffer, NULL);
1065 * check if multicast is supported by LCS
1068 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd)
1070 LCS_DBF_TEXT(2, trace, "chkmccb");
1071 card->ip_assists_supported =
1072 cmd->cmd.lcs_qipassist.ip_assists_supported;
1073 card->ip_assists_enabled =
1074 cmd->cmd.lcs_qipassist.ip_assists_enabled;
1078 lcs_check_multicast_support(struct lcs_card *card)
1080 struct lcs_buffer *buffer;
1081 struct lcs_cmd *cmd;
1084 LCS_DBF_TEXT(2, trace, "cmdqipa");
1085 /* Send query ipassist. */
1086 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE);
1087 cmd = (struct lcs_cmd *) buffer->data;
1088 cmd->cmd_code = LCS_CMD_QIPASSIST;
1089 cmd->initiator = LCS_INITIATOR_TCPIP;
1090 cmd->cmd.lcs_qipassist.lan_type = card->lan_type;
1091 cmd->cmd.lcs_qipassist.portno = card->portno;
1092 cmd->cmd.lcs_qipassist.version = 4;
1093 cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
1094 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
1096 pr_err("Query IPAssist failed. Assuming unsupported!\n");
1099 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
1105 * set or del multicast address on LCS card
1108 lcs_fix_multicast_list(struct lcs_card *card)
1110 struct list_head failed_list;
1111 struct lcs_ipm_list *ipm, *tmp;
1112 unsigned long flags;
1115 LCS_DBF_TEXT(4,trace, "fixipm");
1116 INIT_LIST_HEAD(&failed_list);
1117 spin_lock_irqsave(&card->ipm_lock, flags);
1119 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){
1120 switch (ipm->ipm_state) {
1121 case LCS_IPM_STATE_SET_REQUIRED:
1122 /* del from ipm_list so noone else can tamper with
1124 list_del_init(&ipm->list);
1125 spin_unlock_irqrestore(&card->ipm_lock, flags);
1126 rc = lcs_send_setipm(card, ipm);
1127 spin_lock_irqsave(&card->ipm_lock, flags);
1129 pr_info("Adding multicast address failed."
1130 " Table possibly full!\n");
1131 /* store ipm in failed list -> will be added
1132 * to ipm_list again, so a retry will be done
1133 * during the next call of this function */
1134 list_add_tail(&ipm->list, &failed_list);
1136 ipm->ipm_state = LCS_IPM_STATE_ON_CARD;
1137 /* re-insert into ipm_list */
1138 list_add_tail(&ipm->list, &card->ipm_list);
1141 case LCS_IPM_STATE_DEL_REQUIRED:
1142 list_del(&ipm->list);
1143 spin_unlock_irqrestore(&card->ipm_lock, flags);
1144 lcs_send_delipm(card, ipm);
1145 spin_lock_irqsave(&card->ipm_lock, flags);
1148 case LCS_IPM_STATE_ON_CARD:
1152 /* re-insert all entries from the failed_list into ipm_list */
1153 list_for_each_entry_safe(ipm, tmp, &failed_list, list)
1154 list_move_tail(&ipm->list, &card->ipm_list);
1156 spin_unlock_irqrestore(&card->ipm_lock, flags);
1160 * get mac address for the relevant Multicast address
1163 lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1165 LCS_DBF_TEXT(4,trace, "getmac");
1166 if (dev->type == ARPHRD_IEEE802_TR)
1167 ip_tr_mc_map(ipm, mac);
1169 ip_eth_mc_map(ipm, mac);
1173 * function called by net device to handle multicast address relevant things
1176 lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1178 struct ip_mc_list *im4;
1179 struct list_head *l;
1180 struct lcs_ipm_list *ipm;
1181 unsigned long flags;
1182 char buf[MAX_ADDR_LEN];
1184 LCS_DBF_TEXT(4, trace, "remmclst");
1185 spin_lock_irqsave(&card->ipm_lock, flags);
1186 list_for_each(l, &card->ipm_list) {
1187 ipm = list_entry(l, struct lcs_ipm_list, list);
1188 for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
1189 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1190 if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
1191 (memcmp(buf, &ipm->ipm.mac_addr,
1192 LCS_MAC_LENGTH) == 0) )
1196 ipm->ipm_state = LCS_IPM_STATE_DEL_REQUIRED;
1198 spin_unlock_irqrestore(&card->ipm_lock, flags);
1201 static inline struct lcs_ipm_list *
1202 lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf)
1204 struct lcs_ipm_list *tmp, *ipm = NULL;
1205 struct list_head *l;
1206 unsigned long flags;
1208 LCS_DBF_TEXT(4, trace, "chkmcent");
1209 spin_lock_irqsave(&card->ipm_lock, flags);
1210 list_for_each(l, &card->ipm_list) {
1211 tmp = list_entry(l, struct lcs_ipm_list, list);
1212 if ( (tmp->ipm.ip_addr == im4->multiaddr) &&
1213 (memcmp(buf, &tmp->ipm.mac_addr,
1214 LCS_MAC_LENGTH) == 0) ) {
1219 spin_unlock_irqrestore(&card->ipm_lock, flags);
1224 lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1227 struct ip_mc_list *im4;
1228 struct lcs_ipm_list *ipm;
1229 char buf[MAX_ADDR_LEN];
1230 unsigned long flags;
1232 LCS_DBF_TEXT(4, trace, "setmclst");
1233 for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
1234 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
1235 ipm = lcs_check_addr_entry(card, im4, buf);
1237 continue; /* Address already in list. */
1238 ipm = (struct lcs_ipm_list *)
1239 kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
1241 pr_info("Not enough memory to add"
1242 " new multicast entry!\n");
1245 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
1246 ipm->ipm.ip_addr = im4->multiaddr;
1247 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
1248 spin_lock_irqsave(&card->ipm_lock, flags);
1249 LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4);
1250 list_add(&ipm->list, &card->ipm_list);
1251 spin_unlock_irqrestore(&card->ipm_lock, flags);
1256 lcs_register_mc_addresses(void *data)
1258 struct lcs_card *card;
1259 struct in_device *in4_dev;
1261 card = (struct lcs_card *) data;
1262 daemonize("regipm");
1264 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD))
1266 LCS_DBF_TEXT(4, trace, "regmulti");
1268 in4_dev = in_dev_get(card->dev);
1269 if (in4_dev == NULL)
1271 read_lock(&in4_dev->mc_list_lock);
1272 lcs_remove_mc_addresses(card,in4_dev);
1273 lcs_set_mc_addresses(card, in4_dev);
1274 read_unlock(&in4_dev->mc_list_lock);
1275 in_dev_put(in4_dev);
1277 netif_carrier_off(card->dev);
1278 netif_tx_disable(card->dev);
1279 wait_event(card->write.wait_q,
1280 (card->write.state != LCS_CH_STATE_RUNNING));
1281 lcs_fix_multicast_list(card);
1282 if (card->state == DEV_STATE_UP) {
1283 netif_carrier_on(card->dev);
1284 netif_wake_queue(card->dev);
1287 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
1290 #endif /* CONFIG_IP_MULTICAST */
1293 * function called by net device to
1294 * handle multicast address relevant things
1297 lcs_set_multicast_list(struct net_device *dev)
1299 #ifdef CONFIG_IP_MULTICAST
1300 struct lcs_card *card;
1302 LCS_DBF_TEXT(4, trace, "setmulti");
1303 card = (struct lcs_card *) dev->ml_priv;
1305 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD))
1306 schedule_work(&card->kernel_thread_starter);
1307 #endif /* CONFIG_IP_MULTICAST */
1311 lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
1316 switch (PTR_ERR(irb)) {
1318 dev_warn(&cdev->dev,
1319 "An I/O-error occurred on the LCS device\n");
1320 LCS_DBF_TEXT(2, trace, "ckirberr");
1321 LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
1324 dev_warn(&cdev->dev,
1325 "A command timed out on the LCS device\n");
1326 LCS_DBF_TEXT(2, trace, "ckirberr");
1327 LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
1330 dev_warn(&cdev->dev,
1331 "An error occurred on the LCS device, rc=%ld\n",
1333 LCS_DBF_TEXT(2, trace, "ckirberr");
1334 LCS_DBF_TEXT(2, trace, " rc???");
1336 return PTR_ERR(irb);
1340 lcs_get_problem(struct ccw_device *cdev, struct irb *irb)
1345 sense = (char *) irb->ecw;
1346 cstat = irb->scsw.cmd.cstat;
1347 dstat = irb->scsw.cmd.dstat;
1349 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
1350 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
1351 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
1352 LCS_DBF_TEXT(2, trace, "CGENCHK");
1355 if (dstat & DEV_STAT_UNIT_CHECK) {
1356 if (sense[LCS_SENSE_BYTE_1] &
1357 LCS_SENSE_RESETTING_EVENT) {
1358 LCS_DBF_TEXT(2, trace, "REVIND");
1361 if (sense[LCS_SENSE_BYTE_0] &
1362 LCS_SENSE_CMD_REJECT) {
1363 LCS_DBF_TEXT(2, trace, "CMDREJ");
1366 if ((!sense[LCS_SENSE_BYTE_0]) &&
1367 (!sense[LCS_SENSE_BYTE_1]) &&
1368 (!sense[LCS_SENSE_BYTE_2]) &&
1369 (!sense[LCS_SENSE_BYTE_3])) {
1370 LCS_DBF_TEXT(2, trace, "ZEROSEN");
1373 LCS_DBF_TEXT(2, trace, "DGENCHK");
1380 lcs_schedule_recovery(struct lcs_card *card)
1382 LCS_DBF_TEXT(2, trace, "startrec");
1383 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD))
1384 schedule_work(&card->kernel_thread_starter);
1388 * IRQ Handler for LCS channels
1391 lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1393 struct lcs_card *card;
1394 struct lcs_channel *channel;
1398 if (lcs_check_irb_error(cdev, irb))
1401 card = CARD_FROM_DEV(cdev);
1402 if (card->read.ccwdev == cdev)
1403 channel = &card->read;
1405 channel = &card->write;
1407 cstat = irb->scsw.cmd.cstat;
1408 dstat = irb->scsw.cmd.dstat;
1409 LCS_DBF_TEXT_(5, trace, "Rint%s", dev_name(&cdev->dev));
1410 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.cstat,
1411 irb->scsw.cmd.dstat);
1412 LCS_DBF_TEXT_(5, trace, "%4x%4x", irb->scsw.cmd.fctl,
1413 irb->scsw.cmd.actl);
1415 /* Check for channel and device errors presented */
1416 rc = lcs_get_problem(cdev, irb);
1417 if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
1418 dev_warn(&cdev->dev,
1419 "The LCS device stopped because of an error,"
1420 " dstat=0x%X, cstat=0x%X \n",
1423 channel->state = LCS_CH_STATE_ERROR;
1426 if (channel->state == LCS_CH_STATE_ERROR) {
1427 lcs_schedule_recovery(card);
1428 wake_up(&card->wait_q);
1431 /* How far in the ccw chain have we processed? */
1432 if ((channel->state != LCS_CH_STATE_INIT) &&
1433 (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) &&
1434 (irb->scsw.cmd.cpa != 0)) {
1435 index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa)
1437 if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) ||
1438 (irb->scsw.cmd.cstat & SCHN_STAT_PCI))
1439 /* Bloody io subsystem tells us lies about cpa... */
1440 index = (index - 1) & (LCS_NUM_BUFFS - 1);
1441 while (channel->io_idx != index) {
1442 __lcs_processed_buffer(channel,
1443 channel->iob + channel->io_idx);
1445 (channel->io_idx + 1) & (LCS_NUM_BUFFS - 1);
1449 if ((irb->scsw.cmd.dstat & DEV_STAT_DEV_END) ||
1450 (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) ||
1451 (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK))
1452 /* Mark channel as stopped. */
1453 channel->state = LCS_CH_STATE_STOPPED;
1454 else if (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)
1455 /* CCW execution stopped on a suspend bit. */
1456 channel->state = LCS_CH_STATE_SUSPENDED;
1457 if (irb->scsw.cmd.fctl & SCSW_FCTL_HALT_FUNC) {
1458 if (irb->scsw.cmd.cc != 0) {
1459 ccw_device_halt(channel->ccwdev, (addr_t) channel);
1462 /* The channel has been stopped by halt_IO. */
1463 channel->state = LCS_CH_STATE_HALTED;
1465 if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC)
1466 channel->state = LCS_CH_STATE_CLEARED;
1467 /* Do the rest in the tasklet. */
1468 tasklet_schedule(&channel->irq_tasklet);
1472 * Tasklet for IRQ handler
1475 lcs_tasklet(unsigned long data)
1477 unsigned long flags;
1478 struct lcs_channel *channel;
1479 struct lcs_buffer *iob;
1483 channel = (struct lcs_channel *) data;
1484 LCS_DBF_TEXT_(5, trace, "tlet%s", dev_name(&channel->ccwdev->dev));
1486 /* Check for processed buffers. */
1488 buf_idx = channel->buf_idx;
1489 while (iob[buf_idx].state == LCS_BUF_STATE_PROCESSED) {
1490 /* Do the callback thing. */
1491 if (iob[buf_idx].callback != NULL)
1492 iob[buf_idx].callback(channel, iob + buf_idx);
1493 buf_idx = (buf_idx + 1) & (LCS_NUM_BUFFS - 1);
1495 channel->buf_idx = buf_idx;
1497 if (channel->state == LCS_CH_STATE_STOPPED)
1498 // FIXME: what if rc != 0 ??
1499 rc = lcs_start_channel(channel);
1500 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1501 if (channel->state == LCS_CH_STATE_SUSPENDED &&
1502 channel->iob[channel->io_idx].state == LCS_BUF_STATE_READY) {
1503 // FIXME: what if rc != 0 ??
1504 rc = __lcs_resume_channel(channel);
1506 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
1508 /* Something happened on the channel. Wake up waiters. */
1509 wake_up(&channel->wait_q);
1513 * Finish current tx buffer and make it ready for transmit.
1516 __lcs_emit_txbuffer(struct lcs_card *card)
1518 LCS_DBF_TEXT(5, trace, "emittx");
1519 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0;
1520 card->tx_buffer->count += 2;
1521 lcs_ready_buffer(&card->write, card->tx_buffer);
1522 card->tx_buffer = NULL;
1527 * Callback for finished tx buffers.
1530 lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1532 struct lcs_card *card;
1534 LCS_DBF_TEXT(5, trace, "txbuffcb");
1535 /* Put buffer back to pool. */
1536 lcs_release_buffer(channel, buffer);
1537 card = container_of(channel, struct lcs_card, write);
1538 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1539 netif_wake_queue(card->dev);
1540 spin_lock(&card->lock);
1542 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1544 * Last running tx buffer has finished. Submit partially
1545 * filled current buffer.
1547 __lcs_emit_txbuffer(card);
1548 spin_unlock(&card->lock);
1552 * Packet transmit function called by network stack
1555 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
1556 struct net_device *dev)
1558 struct lcs_header *header;
1561 LCS_DBF_TEXT(5, trace, "hardxmit");
1563 card->stats.tx_dropped++;
1564 card->stats.tx_errors++;
1567 if (card->state != DEV_STATE_UP) {
1569 card->stats.tx_dropped++;
1570 card->stats.tx_errors++;
1571 card->stats.tx_carrier_errors++;
1574 if (skb->protocol == htons(ETH_P_IPV6)) {
1578 netif_stop_queue(card->dev);
1579 spin_lock(&card->lock);
1580 if (card->tx_buffer != NULL &&
1581 card->tx_buffer->count + sizeof(struct lcs_header) +
1582 skb->len + sizeof(u16) > LCS_IOBUFFERSIZE)
1583 /* skb too big for current tx buffer. */
1584 __lcs_emit_txbuffer(card);
1585 if (card->tx_buffer == NULL) {
1586 /* Get new tx buffer */
1587 card->tx_buffer = lcs_get_buffer(&card->write);
1588 if (card->tx_buffer == NULL) {
1589 card->stats.tx_dropped++;
1593 card->tx_buffer->callback = lcs_txbuffer_cb;
1594 card->tx_buffer->count = 0;
1596 header = (struct lcs_header *)
1597 (card->tx_buffer->data + card->tx_buffer->count);
1598 card->tx_buffer->count += skb->len + sizeof(struct lcs_header);
1599 header->offset = card->tx_buffer->count;
1600 header->type = card->lan_type;
1601 header->slot = card->portno;
1602 skb_copy_from_linear_data(skb, header + 1, skb->len);
1603 spin_unlock(&card->lock);
1604 card->stats.tx_bytes += skb->len;
1605 card->stats.tx_packets++;
1607 netif_wake_queue(card->dev);
1608 spin_lock(&card->lock);
1609 if (card->tx_emitted <= 0 && card->tx_buffer != NULL)
1610 /* If this is the first tx buffer emit it immediately. */
1611 __lcs_emit_txbuffer(card);
1613 spin_unlock(&card->lock);
1618 lcs_start_xmit(struct sk_buff *skb, struct net_device *dev)
1620 struct lcs_card *card;
1623 LCS_DBF_TEXT(5, trace, "pktxmit");
1624 card = (struct lcs_card *) dev->ml_priv;
1625 rc = __lcs_start_xmit(card, skb, dev);
1630 * send startlan and lanstat command to make LCS device ready
1633 lcs_startlan_auto(struct lcs_card *card)
1637 LCS_DBF_TEXT(2, trace, "strtauto");
1638 #ifdef CONFIG_NET_ETHERNET
1639 card->lan_type = LCS_FRAME_TYPE_ENET;
1640 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1646 card->lan_type = LCS_FRAME_TYPE_TR;
1647 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1652 card->lan_type = LCS_FRAME_TYPE_FDDI;
1653 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1661 lcs_startlan(struct lcs_card *card)
1665 LCS_DBF_TEXT(2, trace, "startlan");
1667 if (card->portno != LCS_INVALID_PORT_NO) {
1668 if (card->lan_type == LCS_FRAME_TYPE_AUTO)
1669 rc = lcs_startlan_auto(card);
1671 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
1673 for (i = 0; i <= 16; i++) {
1675 if (card->lan_type != LCS_FRAME_TYPE_AUTO)
1676 rc = lcs_send_startlan(card,
1677 LCS_INITIATOR_TCPIP);
1679 /* autodetecting lan type */
1680 rc = lcs_startlan_auto(card);
1686 return lcs_send_lanstat(card);
1691 * LCS detect function
1692 * setup channels and make them I/O ready
1695 lcs_detect(struct lcs_card *card)
1699 LCS_DBF_TEXT(2, setup, "lcsdetct");
1700 /* start/reset card */
1702 netif_stop_queue(card->dev);
1703 rc = lcs_stop_channels(card);
1705 rc = lcs_start_channels(card);
1707 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP);
1709 rc = lcs_startlan(card);
1713 card->state = DEV_STATE_UP;
1715 card->state = DEV_STATE_DOWN;
1716 card->write.state = LCS_CH_STATE_INIT;
1717 card->read.state = LCS_CH_STATE_INIT;
1726 lcs_stopcard(struct lcs_card *card)
1730 LCS_DBF_TEXT(3, setup, "stopcard");
1732 if (card->read.state != LCS_CH_STATE_STOPPED &&
1733 card->write.state != LCS_CH_STATE_STOPPED &&
1734 card->read.state != LCS_CH_STATE_ERROR &&
1735 card->write.state != LCS_CH_STATE_ERROR &&
1736 card->state == DEV_STATE_UP) {
1737 lcs_clear_multicast_list(card);
1738 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
1739 rc = lcs_send_shutdown(card);
1741 rc = lcs_stop_channels(card);
1742 card->state = DEV_STATE_DOWN;
1748 * Kernel Thread helper functions for LGW initiated commands
1751 lcs_start_kernel_thread(struct work_struct *work)
1753 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1754 LCS_DBF_TEXT(5, trace, "krnthrd");
1755 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1756 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
1757 #ifdef CONFIG_IP_MULTICAST
1758 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
1759 kernel_thread(lcs_register_mc_addresses,
1760 (void *) card, SIGCHLD);
1765 * Process control frames.
1768 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
1770 LCS_DBF_TEXT(5, trace, "getctrl");
1771 if (cmd->initiator == LCS_INITIATOR_LGW) {
1772 switch(cmd->cmd_code) {
1773 case LCS_CMD_STARTUP:
1774 case LCS_CMD_STARTLAN:
1775 lcs_schedule_recovery(card);
1777 case LCS_CMD_STOPLAN:
1778 pr_warning("Stoplan for %s initiated by LGW.\n",
1781 netif_carrier_off(card->dev);
1784 LCS_DBF_TEXT(5, trace, "noLGWcmd");
1788 lcs_notify_lancmd_waiters(card, cmd);
1792 * Unpack network packet.
1795 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
1797 struct sk_buff *skb;
1799 LCS_DBF_TEXT(5, trace, "getskb");
1800 if (card->dev == NULL ||
1801 card->state != DEV_STATE_UP)
1802 /* The card isn't up. Ignore the packet. */
1805 skb = dev_alloc_skb(skb_len);
1807 dev_err(&card->dev->dev,
1808 " Allocating a socket buffer to interface %s failed\n",
1810 card->stats.rx_dropped++;
1813 memcpy(skb_put(skb, skb_len), skb_data, skb_len);
1814 skb->protocol = card->lan_type_trans(skb, card->dev);
1815 card->stats.rx_bytes += skb_len;
1816 card->stats.rx_packets++;
1817 if (skb->protocol == htons(ETH_P_802_2))
1818 *((__u32 *)skb->cb) = ++card->pkt_seq;
1823 * LCS main routine to get packets and lancmd replies from the buffers
1826 lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1828 struct lcs_card *card;
1829 struct lcs_header *lcs_hdr;
1832 LCS_DBF_TEXT(5, trace, "lcsgtpkt");
1833 lcs_hdr = (struct lcs_header *) buffer->data;
1834 if (lcs_hdr->offset == LCS_ILLEGAL_OFFSET) {
1835 LCS_DBF_TEXT(4, trace, "-eiogpkt");
1838 card = container_of(channel, struct lcs_card, read);
1840 while (lcs_hdr->offset != 0) {
1841 if (lcs_hdr->offset <= 0 ||
1842 lcs_hdr->offset > LCS_IOBUFFERSIZE ||
1843 lcs_hdr->offset < offset) {
1844 /* Offset invalid. */
1845 card->stats.rx_length_errors++;
1846 card->stats.rx_errors++;
1849 /* What kind of frame is it? */
1850 if (lcs_hdr->type == LCS_FRAME_TYPE_CONTROL)
1851 /* Control frame. */
1852 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr);
1853 else if (lcs_hdr->type == LCS_FRAME_TYPE_ENET ||
1854 lcs_hdr->type == LCS_FRAME_TYPE_TR ||
1855 lcs_hdr->type == LCS_FRAME_TYPE_FDDI)
1856 /* Normal network packet. */
1857 lcs_get_skb(card, (char *)(lcs_hdr + 1),
1858 lcs_hdr->offset - offset -
1859 sizeof(struct lcs_header));
1861 /* Unknown frame type. */
1862 ; // FIXME: error message ?
1863 /* Proceed to next frame. */
1864 offset = lcs_hdr->offset;
1865 lcs_hdr->offset = LCS_ILLEGAL_OFFSET;
1866 lcs_hdr = (struct lcs_header *) (buffer->data + offset);
1868 /* The buffer is now empty. Make it ready again. */
1869 lcs_ready_buffer(&card->read, buffer);
1873 * get network statistics for ifconfig and other user programs
1875 static struct net_device_stats *
1876 lcs_getstats(struct net_device *dev)
1878 struct lcs_card *card;
1880 LCS_DBF_TEXT(4, trace, "netstats");
1881 card = (struct lcs_card *) dev->ml_priv;
1882 return &card->stats;
1887 * This function will be called by user doing ifconfig xxx down
1890 lcs_stop_device(struct net_device *dev)
1892 struct lcs_card *card;
1895 LCS_DBF_TEXT(2, trace, "stopdev");
1896 card = (struct lcs_card *) dev->ml_priv;
1897 netif_carrier_off(dev);
1898 netif_tx_disable(dev);
1899 dev->flags &= ~IFF_UP;
1900 wait_event(card->write.wait_q,
1901 (card->write.state != LCS_CH_STATE_RUNNING));
1902 rc = lcs_stopcard(card);
1904 dev_err(&card->dev->dev,
1905 " Shutting down the LCS device failed\n ");
1910 * start lcs device and make it runnable
1911 * This function will be called by user doing ifconfig xxx up
1914 lcs_open_device(struct net_device *dev)
1916 struct lcs_card *card;
1919 LCS_DBF_TEXT(2, trace, "opendev");
1920 card = (struct lcs_card *) dev->ml_priv;
1921 /* initialize statistics */
1922 rc = lcs_detect(card);
1924 pr_err("Error in opening device!\n");
1927 dev->flags |= IFF_UP;
1928 netif_carrier_on(dev);
1929 netif_wake_queue(dev);
1930 card->state = DEV_STATE_UP;
1936 * show function for portno called by cat or similar things
1939 lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
1941 struct lcs_card *card;
1943 card = (struct lcs_card *)dev->driver_data;
1948 return sprintf(buf, "%d\n", card->portno);
1952 * store the value which is piped to file portno
1955 lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1957 struct lcs_card *card;
1960 card = (struct lcs_card *)dev->driver_data;
1965 sscanf(buf, "%u", &value);
1966 /* TODO: sanity checks */
1967 card->portno = value;
1973 static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
1976 lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1978 struct ccwgroup_device *cgdev;
1980 cgdev = to_ccwgroupdev(dev);
1984 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
1987 static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
1990 lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
1992 struct lcs_card *card;
1994 card = (struct lcs_card *)dev->driver_data;
1996 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
2000 lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2002 struct lcs_card *card;
2005 card = (struct lcs_card *)dev->driver_data;
2010 sscanf(buf, "%u", &value);
2011 /* TODO: sanity checks */
2012 card->lancmd_timeout = value;
2018 static DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
2021 lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
2022 const char *buf, size_t count)
2024 struct lcs_card *card = dev->driver_data;
2030 if (card->state != DEV_STATE_UP)
2032 i = simple_strtoul(buf, &tmp, 16);
2034 lcs_schedule_recovery(card);
2038 static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store);
2040 static struct attribute * lcs_attrs[] = {
2041 &dev_attr_portno.attr,
2042 &dev_attr_type.attr,
2043 &dev_attr_lancmd_timeout.attr,
2044 &dev_attr_recover.attr,
2048 static struct attribute_group lcs_attr_group = {
2053 * lcs_probe_device is called on establishing a new ccwgroup_device.
2056 lcs_probe_device(struct ccwgroup_device *ccwgdev)
2058 struct lcs_card *card;
2061 if (!get_device(&ccwgdev->dev))
2064 LCS_DBF_TEXT(2, setup, "add_dev");
2065 card = lcs_alloc_card();
2067 LCS_DBF_TEXT_(2, setup, " rc%d", -ENOMEM);
2068 put_device(&ccwgdev->dev);
2071 ret = sysfs_create_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2073 lcs_free_card(card);
2074 put_device(&ccwgdev->dev);
2077 ccwgdev->dev.driver_data = card;
2078 ccwgdev->cdev[0]->handler = lcs_irq;
2079 ccwgdev->cdev[1]->handler = lcs_irq;
2080 card->gdev = ccwgdev;
2081 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2082 card->thread_start_mask = 0;
2083 card->thread_allowed_mask = 0;
2084 card->thread_running_mask = 0;
2089 lcs_register_netdev(struct ccwgroup_device *ccwgdev)
2091 struct lcs_card *card;
2093 LCS_DBF_TEXT(2, setup, "regnetdv");
2094 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2095 if (card->dev->reg_state != NETREG_UNINITIALIZED)
2097 SET_NETDEV_DEV(card->dev, &ccwgdev->dev);
2098 return register_netdev(card->dev);
2102 * lcs_new_device will be called by setting the group device online.
2106 lcs_new_device(struct ccwgroup_device *ccwgdev)
2108 struct lcs_card *card;
2109 struct net_device *dev=NULL;
2110 enum lcs_dev_states recover_state;
2113 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2117 LCS_DBF_TEXT(2, setup, "newdev");
2118 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2119 card->read.ccwdev = ccwgdev->cdev[0];
2120 card->write.ccwdev = ccwgdev->cdev[1];
2122 recover_state = card->state;
2123 ccw_device_set_online(card->read.ccwdev);
2124 ccw_device_set_online(card->write.ccwdev);
2126 LCS_DBF_TEXT(3, setup, "lcsnewdv");
2128 lcs_setup_card(card);
2129 rc = lcs_detect(card);
2131 LCS_DBF_TEXT(2, setup, "dtctfail");
2132 dev_err(&card->dev->dev,
2133 "Detecting a network adapter for LCS devices"
2134 " failed with rc=%d (0x%x)\n", rc, rc);
2139 LCS_DBF_TEXT(2, setup, "samedev");
2140 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2143 switch (card->lan_type) {
2144 #ifdef CONFIG_NET_ETHERNET
2145 case LCS_FRAME_TYPE_ENET:
2146 card->lan_type_trans = eth_type_trans;
2147 dev = alloc_etherdev(0);
2151 case LCS_FRAME_TYPE_TR:
2152 card->lan_type_trans = tr_type_trans;
2153 dev = alloc_trdev(0);
2157 case LCS_FRAME_TYPE_FDDI:
2158 card->lan_type_trans = fddi_type_trans;
2159 dev = alloc_fddidev(0);
2163 LCS_DBF_TEXT(3, setup, "errinit");
2164 pr_err(" Initialization failed\n");
2170 card->dev->ml_priv = card;
2171 card->dev->open = lcs_open_device;
2172 card->dev->stop = lcs_stop_device;
2173 card->dev->hard_start_xmit = lcs_start_xmit;
2174 card->dev->get_stats = lcs_getstats;
2175 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
2176 #ifdef CONFIG_IP_MULTICAST
2177 if (!lcs_check_multicast_support(card))
2178 card->dev->set_multicast_list = lcs_set_multicast_list;
2181 lcs_set_allowed_threads(card,0xffffffff);
2182 if (recover_state == DEV_STATE_RECOVER) {
2183 lcs_set_multicast_list(card->dev);
2184 card->dev->flags |= IFF_UP;
2185 netif_carrier_on(card->dev);
2186 netif_wake_queue(card->dev);
2187 card->state = DEV_STATE_UP;
2192 if (lcs_register_netdev(ccwgdev) != 0)
2195 /* Print out supported assists: IPv6 */
2196 pr_info("LCS device %s %s IPv6 support\n", card->dev->name,
2197 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
2198 "with" : "without");
2199 /* Print out supported assist: Multicast */
2200 pr_info("LCS device %s %s Multicast support\n", card->dev->name,
2201 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
2202 "with" : "without");
2206 ccw_device_set_offline(card->read.ccwdev);
2207 ccw_device_set_offline(card->write.ccwdev);
2212 * lcs_shutdown_device, called when setting the group device offline.
2215 __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
2217 struct lcs_card *card;
2218 enum lcs_dev_states recover_state;
2221 LCS_DBF_TEXT(3, setup, "shtdndev");
2222 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2225 if (recovery_mode == 0) {
2226 lcs_set_allowed_threads(card, 0);
2227 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
2228 return -ERESTARTSYS;
2230 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2231 recover_state = card->state;
2233 ret = lcs_stop_device(card->dev);
2234 ret = ccw_device_set_offline(card->read.ccwdev);
2235 ret = ccw_device_set_offline(card->write.ccwdev);
2236 if (recover_state == DEV_STATE_UP) {
2237 card->state = DEV_STATE_RECOVER;
2245 lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2247 return __lcs_shutdown_device(ccwgdev, 0);
2251 * drive lcs recovery after startup and startlan initiated by Lan Gateway
2254 lcs_recovery(void *ptr)
2256 struct lcs_card *card;
2257 struct ccwgroup_device *gdev;
2260 card = (struct lcs_card *) ptr;
2261 daemonize("lcs_recover");
2263 LCS_DBF_TEXT(4, trace, "recover1");
2264 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD))
2266 LCS_DBF_TEXT(4, trace, "recover2");
2268 dev_warn(&gdev->dev,
2269 "A recovery process has been started for the LCS device\n");
2270 rc = __lcs_shutdown_device(gdev, 1);
2271 rc = lcs_new_device(gdev);
2273 pr_info("Device %s successfully recovered!\n",
2276 pr_info("Device %s could not be recovered!\n",
2278 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
2283 * lcs_remove_device, free buffers and card
2286 lcs_remove_device(struct ccwgroup_device *ccwgdev)
2288 struct lcs_card *card;
2290 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2294 LCS_DBF_TEXT(3, setup, "remdev");
2295 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2296 if (ccwgdev->state == CCWGROUP_ONLINE) {
2297 lcs_shutdown_device(ccwgdev);
2300 unregister_netdev(card->dev);
2301 sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
2302 lcs_cleanup_card(card);
2303 lcs_free_card(card);
2304 put_device(&ccwgdev->dev);
2308 * LCS ccwgroup driver registration
2310 static struct ccwgroup_driver lcs_group_driver = {
2311 .owner = THIS_MODULE,
2314 .driver_id = 0xD3C3E2,
2315 .probe = lcs_probe_device,
2316 .remove = lcs_remove_device,
2317 .set_online = lcs_new_device,
2318 .set_offline = lcs_shutdown_device,
2322 * LCS Module/Kernel initialization function
2325 __init lcs_init_module(void)
2329 pr_info("Loading %s\n", version);
2330 rc = lcs_register_debug_facility();
2331 LCS_DBF_TEXT(0, setup, "lcsinit");
2333 pr_err("Initialization failed\n");
2337 rc = register_cu3088_discipline(&lcs_group_driver);
2339 pr_err("Initialization failed\n");
2347 * LCS module cleanup function
2350 __exit lcs_cleanup_module(void)
2352 pr_info("Terminating lcs module.\n");
2353 LCS_DBF_TEXT(0, trace, "cleanup");
2354 unregister_cu3088_discipline(&lcs_group_driver);
2355 lcs_unregister_debug_facility();
2358 module_init(lcs_init_module);
2359 module_exit(lcs_cleanup_module);
2361 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
2362 MODULE_LICENSE("GPL");