2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver
5 * Linux for zSeries version
6 * Copyright (C) 2002,2005 IBM Corporation
7 * Author(s) Original code written by:
8 * Kazuo Iimura (iimura@jp.ibm.com)
10 * Andy Richter (richtera@us.ibm.com)
11 * Marc Price (mwprice@us.ibm.com)
14 * group x.x.rrrr,x.x.wwww
18 * adapter_name aaaaaaaa
22 * group 0.0.0200 0.0.0201
31 * The device id is decided by the order entries
32 * are added to the group the first is claw0 the second claw1
35 * rrrr - the first of 2 consecutive device addresses used for the
37 * The specified address is always used as the input (Read)
38 * channel and the next address is used as the output channel.
40 * wwww - the second of 2 consecutive device addresses used for
42 * The specified address is always used as the output
43 * channel and the previous address is used as the input channel.
45 * read_buffer - specifies number of input buffers to allocate.
46 * write_buffer - specifies number of output buffers to allocate.
47 * host_name - host name
48 * adaptor_name - adaptor name
49 * api_type - API type TCPIP or API will be sent and expected
52 * Note the following requirements:
53 * 1) host_name must match the configured adapter_name on the remote side
54 * 2) adaptor_name must match the configured host name on the remote side
57 * 1.00 Initial release shipped
58 * 1.10 Changes for Buffer allocation
59 * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower
60 * 1.25 Added Packing support
62 #include <asm/ccwdev.h>
63 #include <asm/ccwgroup.h>
64 #include <asm/debug.h>
65 #include <asm/idals.h>
68 #include <linux/bitops.h>
69 #include <linux/ctype.h>
70 #include <linux/delay.h>
71 #include <linux/errno.h>
72 #include <linux/if_arp.h>
73 #include <linux/init.h>
74 #include <linux/interrupt.h>
76 #include <linux/kernel.h>
77 #include <linux/module.h>
78 #include <linux/netdevice.h>
79 #include <linux/etherdevice.h>
80 #include <linux/proc_fs.h>
81 #include <linux/sched.h>
82 #include <linux/signal.h>
83 #include <linux/skbuff.h>
84 #include <linux/slab.h>
85 #include <linux/string.h>
86 #include <linux/tcp.h>
87 #include <linux/timer.h>
88 #include <linux/types.h>
93 MODULE_AUTHOR("Andy Richter <richtera@us.ibm.com>");
94 MODULE_DESCRIPTION("Linux for zSeries CLAW Driver\n" \
95 "Copyright 2000,2005 IBM Corporation\n");
96 MODULE_LICENSE("GPL");
98 /* Debugging is based on DEBUGMSG, IOTRACE, or FUNCTRACE options:
99 DEBUGMSG - Enables output of various debug messages in the code
100 IOTRACE - Enables output of CCW and other IO related traces
101 FUNCTRACE - Enables output of function entry/exit trace
102 Define any combination of above options to enable tracing
104 CLAW also uses the s390dbf file system see claw_trace and claw_setup
107 /* following enables tracing */
124 static char debug_buffer[255];
126 * Debug Facility Stuff
128 static debug_info_t *claw_dbf_setup;
129 static debug_info_t *claw_dbf_trace;
132 * CLAW Debug Facility functions
135 claw_unregister_debug_facility(void)
138 debug_unregister(claw_dbf_setup);
140 debug_unregister(claw_dbf_trace);
144 claw_register_debug_facility(void)
146 claw_dbf_setup = debug_register("claw_setup", 2, 1, 8);
147 claw_dbf_trace = debug_register("claw_trace", 2, 2, 8);
148 if (claw_dbf_setup == NULL || claw_dbf_trace == NULL) {
149 printk(KERN_WARNING "Not enough memory for debug facility.\n");
150 claw_unregister_debug_facility();
153 debug_register_view(claw_dbf_setup, &debug_hex_ascii_view);
154 debug_set_level(claw_dbf_setup, 2);
155 debug_register_view(claw_dbf_trace, &debug_hex_ascii_view);
156 debug_set_level(claw_dbf_trace, 2);
161 claw_set_busy(struct net_device *dev)
163 ((struct claw_privbk *) dev->priv)->tbusy=1;
168 claw_clear_busy(struct net_device *dev)
170 clear_bit(0, &(((struct claw_privbk *) dev->priv)->tbusy));
171 netif_wake_queue(dev);
176 claw_check_busy(struct net_device *dev)
179 return ((struct claw_privbk *) dev->priv)->tbusy;
183 claw_setbit_busy(int nr,struct net_device *dev)
185 netif_stop_queue(dev);
186 set_bit(nr, (void *)&(((struct claw_privbk *)dev->priv)->tbusy));
190 claw_clearbit_busy(int nr,struct net_device *dev)
192 clear_bit(nr,(void *)&(((struct claw_privbk *)dev->priv)->tbusy));
193 netif_wake_queue(dev);
197 claw_test_and_setbit_busy(int nr,struct net_device *dev)
199 netif_stop_queue(dev);
200 return test_and_set_bit(nr,
201 (void *)&(((struct claw_privbk *) dev->priv)->tbusy));
205 /* Functions for the DEV methods */
207 static int claw_probe(struct ccwgroup_device *cgdev);
208 static void claw_remove_device(struct ccwgroup_device *cgdev);
209 static void claw_purge_skb_queue(struct sk_buff_head *q);
210 static int claw_new_device(struct ccwgroup_device *cgdev);
211 static int claw_shutdown_device(struct ccwgroup_device *cgdev);
212 static int claw_tx(struct sk_buff *skb, struct net_device *dev);
213 static int claw_change_mtu( struct net_device *dev, int new_mtu);
214 static int claw_open(struct net_device *dev);
215 static void claw_irq_handler(struct ccw_device *cdev,
216 unsigned long intparm, struct irb *irb);
217 static void claw_irq_tasklet ( unsigned long data );
218 static int claw_release(struct net_device *dev);
219 static void claw_write_retry ( struct chbk * p_ch );
220 static void claw_write_next ( struct chbk * p_ch );
221 static void claw_timer ( struct chbk * p_ch );
224 static int add_claw_reads(struct net_device *dev,
225 struct ccwbk* p_first, struct ccwbk* p_last);
226 static void ccw_check_return_code (struct ccw_device *cdev, int return_code);
227 static void ccw_check_unit_check (struct chbk * p_ch, unsigned char sense );
228 static int find_link(struct net_device *dev, char *host_name, char *ws_name );
229 static int claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid);
230 static int init_ccw_bk(struct net_device *dev);
231 static void probe_error( struct ccwgroup_device *cgdev);
232 static struct net_device_stats *claw_stats(struct net_device *dev);
233 static int pages_to_order_of_mag(int num_of_pages);
234 static struct sk_buff *claw_pack_skb(struct claw_privbk *privptr);
236 static void dumpit (char *buf, int len);
238 /* sysfs Functions */
239 static ssize_t claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf);
240 static ssize_t claw_hname_write(struct device *dev, struct device_attribute *attr,
241 const char *buf, size_t count);
242 static ssize_t claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf);
243 static ssize_t claw_adname_write(struct device *dev, struct device_attribute *attr,
244 const char *buf, size_t count);
245 static ssize_t claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf);
246 static ssize_t claw_apname_write(struct device *dev, struct device_attribute *attr,
247 const char *buf, size_t count);
248 static ssize_t claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
249 static ssize_t claw_wbuff_write(struct device *dev, struct device_attribute *attr,
250 const char *buf, size_t count);
251 static ssize_t claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
252 static ssize_t claw_rbuff_write(struct device *dev, struct device_attribute *attr,
253 const char *buf, size_t count);
254 static int claw_add_files(struct device *dev);
255 static void claw_remove_files(struct device *dev);
257 /* Functions for System Validate */
258 static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw);
259 static int claw_send_control(struct net_device *dev, __u8 type, __u8 link,
260 __u8 correlator, __u8 rc , char *local_name, char *remote_name);
261 static int claw_snd_conn_req(struct net_device *dev, __u8 link);
262 static int claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl);
263 static int claw_snd_sys_validate_rsp(struct net_device *dev,
264 struct clawctl * p_ctl, __u32 return_code);
265 static int claw_strt_conn_req(struct net_device *dev );
266 static void claw_strt_read ( struct net_device *dev, int lock );
267 static void claw_strt_out_IO( struct net_device *dev );
268 static void claw_free_wrt_buf( struct net_device *dev );
270 /* Functions for unpack reads */
271 static void unpack_read (struct net_device *dev );
275 static struct ccwgroup_driver claw_group_driver = {
276 .owner = THIS_MODULE,
279 .driver_id = 0xC3D3C1E6,
281 .remove = claw_remove_device,
282 .set_online = claw_new_device,
283 .set_offline = claw_shutdown_device,
291 /*----------------------------------------------------------------*
293 * this function is called for each CLAW device. *
294 *----------------------------------------------------------------*/
296 claw_probe(struct ccwgroup_device *cgdev)
299 struct claw_privbk *privptr=NULL;
302 printk(KERN_INFO "%s Enter\n",__func__);
304 CLAW_DBF_TEXT(2,setup,"probe");
305 if (!get_device(&cgdev->dev))
308 printk(KERN_INFO "claw: variable cgdev =\n");
309 dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
311 privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
312 if (privptr == NULL) {
314 put_device(&cgdev->dev);
315 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
316 cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
317 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
320 privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
321 privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL);
322 if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
324 put_device(&cgdev->dev);
325 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
326 cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
327 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
330 memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
331 memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
332 memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
333 privptr->p_env->packing = 0;
334 privptr->p_env->write_buffers = 5;
335 privptr->p_env->read_buffers = 5;
336 privptr->p_env->read_size = CLAW_FRAME_SIZE;
337 privptr->p_env->write_size = CLAW_FRAME_SIZE;
338 rc = claw_add_files(&cgdev->dev);
341 put_device(&cgdev->dev);
342 printk(KERN_WARNING "add_files failed %s %s Exit Line %d \n",
343 cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
344 CLAW_DBF_TEXT_(2,setup,"probex%d",rc);
347 printk(KERN_INFO "claw: sysfs files added for %s\n",cgdev->cdev[0]->dev.bus_id);
348 privptr->p_env->p_priv = privptr;
349 cgdev->cdev[0]->handler = claw_irq_handler;
350 cgdev->cdev[1]->handler = claw_irq_handler;
351 cgdev->dev.driver_data = privptr;
353 printk(KERN_INFO "claw:%s exit on line %d, "
354 "rc = 0\n",__func__,__LINE__);
356 CLAW_DBF_TEXT(2,setup,"prbext 0");
359 } /* end of claw_probe */
361 /*-------------------------------------------------------------------*
363 *-------------------------------------------------------------------*/
366 claw_tx(struct sk_buff *skb, struct net_device *dev)
369 struct claw_privbk *privptr=dev->priv;
370 unsigned long saveflags;
374 printk(KERN_INFO "%s:%s enter\n",dev->name,__func__);
376 CLAW_DBF_TEXT(4,trace,"claw_tx");
377 p_ch=&privptr->channel[WRITE];
379 printk(KERN_WARNING "%s: null pointer passed as sk_buffer\n",
381 privptr->stats.tx_dropped++;
383 printk(KERN_INFO "%s: %s() exit on line %d, rc = EIO\n",
384 dev->name,__func__, __LINE__);
386 CLAW_DBF_TEXT_(2,trace,"clawtx%d",-EIO);
391 printk(KERN_INFO "%s: variable sk_buff=\n",dev->name);
392 dumpit((char *) skb, sizeof(struct sk_buff));
393 printk(KERN_INFO "%s: variable dev=\n",dev->name);
394 dumpit((char *) dev, sizeof(struct net_device));
396 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
397 rc=claw_hw_tx( skb, dev, 1 );
398 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
400 printk(KERN_INFO "%s:%s exit on line %d, rc = %d\n",
401 dev->name, __func__, __LINE__, rc);
403 CLAW_DBF_TEXT_(4,trace,"clawtx%d",rc);
405 } /* end of claw_tx */
407 /*------------------------------------------------------------------*
408 * pack the collect queue into an skb and return it *
409 * If not packing just return the top skb from the queue *
410 *------------------------------------------------------------------*/
412 static struct sk_buff *
413 claw_pack_skb(struct claw_privbk *privptr)
415 struct sk_buff *new_skb,*held_skb;
416 struct chbk *p_ch = &privptr->channel[WRITE];
417 struct claw_env *p_env = privptr->p_env;
418 int pkt_cnt,pk_ind,so_far;
420 new_skb = NULL; /* assume no dice */
422 CLAW_DBF_TEXT(4,trace,"PackSKBe");
423 if (!skb_queue_empty(&p_ch->collect_queue)) {
425 held_skb = skb_dequeue(&p_ch->collect_queue);
427 dev_kfree_skb_any(held_skb);
430 if (p_env->packing != DO_PACKED)
432 /* get a new SKB we will pack at least one */
433 new_skb = dev_alloc_skb(p_env->write_size);
434 if (new_skb == NULL) {
435 atomic_inc(&held_skb->users);
436 skb_queue_head(&p_ch->collect_queue,held_skb);
439 /* we have packed packet and a place to put it */
442 new_skb->cb[1] = 'P'; /* every skb on queue has pack header */
443 while ((pk_ind) && (held_skb != NULL)) {
444 if (held_skb->len+so_far <= p_env->write_size-8) {
445 memcpy(skb_put(new_skb,held_skb->len),
446 held_skb->data,held_skb->len);
447 privptr->stats.tx_packets++;
448 so_far += held_skb->len;
450 dev_kfree_skb_any(held_skb);
451 held_skb = skb_dequeue(&p_ch->collect_queue);
453 atomic_dec(&held_skb->users);
456 atomic_inc(&held_skb->users);
457 skb_queue_head(&p_ch->collect_queue,held_skb);
461 printk(KERN_INFO "%s: %s() Packed %d len %d\n",
463 __func__,pkt_cnt,new_skb->len);
466 CLAW_DBF_TEXT(4,trace,"PackSKBx");
470 /*-------------------------------------------------------------------*
473 *-------------------------------------------------------------------*/
476 claw_change_mtu(struct net_device *dev, int new_mtu)
478 struct claw_privbk *privptr=dev->priv;
481 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
484 printk(KERN_INFO "variable dev =\n");
485 dumpit((char *) dev, sizeof(struct net_device));
486 printk(KERN_INFO "variable new_mtu = %d\n", new_mtu);
488 CLAW_DBF_TEXT(4,trace,"setmtu");
489 buff_size = privptr->p_env->write_size;
490 if ((new_mtu < 60) || (new_mtu > buff_size)) {
492 printk(KERN_INFO "%s:%s Exit on line %d, rc=EINVAL\n",
500 printk(KERN_INFO "%s:%s Exit on line %d\n",dev->name,
504 } /* end of claw_change_mtu */
507 /*-------------------------------------------------------------------*
510 *-------------------------------------------------------------------*/
512 claw_open(struct net_device *dev)
517 unsigned long saveflags=0;
519 struct claw_privbk *privptr;
520 DECLARE_WAITQUEUE(wait, current);
521 struct timer_list timer;
525 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
527 CLAW_DBF_TEXT(4,trace,"open");
528 if (!dev || (dev->name[0] == 0x00)) {
529 CLAW_DBF_TEXT(2,trace,"BadDev");
530 printk(KERN_WARNING "claw: Bad device at open failing \n");
533 privptr = (struct claw_privbk *)dev->priv;
534 /* allocate and initialize CCW blocks */
535 if (privptr->buffs_alloc == 0) {
538 printk(KERN_INFO "%s:%s Exit on line %d, rc=ENOMEM\n",
541 CLAW_DBF_TEXT(2,trace,"openmem");
545 privptr->system_validate_comp=0;
546 privptr->release_pend=0;
547 if(strncmp(privptr->p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
548 privptr->p_env->read_size=DEF_PACK_BUFSIZE;
549 privptr->p_env->write_size=DEF_PACK_BUFSIZE;
550 privptr->p_env->packing=PACKING_ASK;
552 privptr->p_env->packing=0;
553 privptr->p_env->read_size=CLAW_FRAME_SIZE;
554 privptr->p_env->write_size=CLAW_FRAME_SIZE;
557 tasklet_init(&privptr->channel[READ].tasklet, claw_irq_tasklet,
558 (unsigned long) &privptr->channel[READ]);
559 for ( i = 0; i < 2; i++) {
560 CLAW_DBF_TEXT_(2,trace,"opn_ch%d",i);
561 init_waitqueue_head(&privptr->channel[i].wait);
562 /* skb_queue_head_init(&p_ch->io_queue); */
565 &privptr->channel[WRITE].collect_queue);
566 privptr->channel[i].flag_a = 0;
567 privptr->channel[i].IO_active = 0;
568 privptr->channel[i].flag &= ~CLAW_TIMER;
570 timer.function = (void *)claw_timer;
571 timer.data = (unsigned long)(&privptr->channel[i]);
572 timer.expires = jiffies + 15*HZ;
574 spin_lock_irqsave(get_ccwdev_lock(
575 privptr->channel[i].cdev), saveflags);
576 parm = (unsigned long) &privptr->channel[i];
577 privptr->channel[i].claw_state = CLAW_START_HALT_IO;
579 add_wait_queue(&privptr->channel[i].wait, &wait);
580 rc = ccw_device_halt(
581 (struct ccw_device *)privptr->channel[i].cdev,parm);
582 set_current_state(TASK_INTERRUPTIBLE);
583 spin_unlock_irqrestore(
584 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
586 set_current_state(TASK_RUNNING);
587 remove_wait_queue(&privptr->channel[i].wait, &wait);
589 ccw_check_return_code(privptr->channel[i].cdev, rc);
590 if((privptr->channel[i].flag & CLAW_TIMER) == 0x00)
593 if ((((privptr->channel[READ].last_dstat |
594 privptr->channel[WRITE].last_dstat) &
595 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) ||
596 (((privptr->channel[READ].flag |
597 privptr->channel[WRITE].flag) & CLAW_TIMER) != 0x00)) {
599 printk(KERN_INFO "%s: channel problems during open - read:"
600 " %02x - write: %02x\n",
602 privptr->channel[READ].last_dstat,
603 privptr->channel[WRITE].last_dstat);
605 printk(KERN_INFO "%s: remote side is not ready\n", dev->name);
606 CLAW_DBF_TEXT(2,trace,"notrdy");
608 for ( i = 0; i < 2; i++) {
610 get_ccwdev_lock(privptr->channel[i].cdev),
612 parm = (unsigned long) &privptr->channel[i];
613 privptr->channel[i].claw_state = CLAW_STOP;
614 rc = ccw_device_halt(
615 (struct ccw_device *)&privptr->channel[i].cdev,
617 spin_unlock_irqrestore(
618 get_ccwdev_lock(privptr->channel[i].cdev),
621 ccw_check_return_code(
622 privptr->channel[i].cdev, rc);
625 free_pages((unsigned long)privptr->p_buff_ccw,
626 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
627 if (privptr->p_env->read_size < PAGE_SIZE) {
628 free_pages((unsigned long)privptr->p_buff_read,
629 (int)pages_to_order_of_mag(
630 privptr->p_buff_read_num));
633 p_buf=privptr->p_read_active_first;
634 while (p_buf!=NULL) {
635 free_pages((unsigned long)p_buf->p_buffer,
636 (int)pages_to_order_of_mag(
637 privptr->p_buff_pages_perread ));
641 if (privptr->p_env->write_size < PAGE_SIZE ) {
642 free_pages((unsigned long)privptr->p_buff_write,
643 (int)pages_to_order_of_mag(
644 privptr->p_buff_write_num));
647 p_buf=privptr->p_write_active_first;
648 while (p_buf!=NULL) {
649 free_pages((unsigned long)p_buf->p_buffer,
650 (int)pages_to_order_of_mag(
651 privptr->p_buff_pages_perwrite ));
655 privptr->buffs_alloc = 0;
656 privptr->channel[READ].flag= 0x00;
657 privptr->channel[WRITE].flag = 0x00;
658 privptr->p_buff_ccw=NULL;
659 privptr->p_buff_read=NULL;
660 privptr->p_buff_write=NULL;
661 claw_clear_busy(dev);
663 printk(KERN_INFO "%s:%s Exit on line %d, rc=EIO\n",
664 dev->name,__func__,__LINE__);
666 CLAW_DBF_TEXT(2,trace,"open EIO");
670 /* Send SystemValidate command */
672 claw_clear_busy(dev);
675 printk(KERN_INFO "%s:%s Exit on line %d, rc=0\n",
676 dev->name,__func__,__LINE__);
678 CLAW_DBF_TEXT(4,trace,"openok");
680 } /* end of claw_open */
682 /*-------------------------------------------------------------------*
686 *--------------------------------------------------------------------*/
688 claw_irq_handler(struct ccw_device *cdev,
689 unsigned long intparm, struct irb *irb)
691 struct chbk *p_ch = NULL;
692 struct claw_privbk *privptr = NULL;
693 struct net_device *dev = NULL;
694 struct claw_env *p_env;
695 struct chbk *p_ch_r=NULL;
699 printk(KERN_INFO "%s enter \n",__func__);
701 CLAW_DBF_TEXT(4,trace,"clawirq");
702 /* Bypass all 'unsolicited interrupts' */
703 if (!cdev->dev.driver_data) {
704 printk(KERN_WARNING "claw: unsolicited interrupt for device:"
705 "%s received c-%02x d-%02x\n",
706 cdev->dev.bus_id, irb->scsw.cmd.cstat,
707 irb->scsw.cmd.dstat);
709 printk(KERN_INFO "claw: %s() "
710 "exit on line %d\n",__func__,__LINE__);
712 CLAW_DBF_TEXT(2,trace,"badirq");
715 privptr = (struct claw_privbk *)cdev->dev.driver_data;
717 /* Try to extract channel from driver data. */
718 if (privptr->channel[READ].cdev == cdev)
719 p_ch = &privptr->channel[READ];
720 else if (privptr->channel[WRITE].cdev == cdev)
721 p_ch = &privptr->channel[WRITE];
723 printk(KERN_WARNING "claw: Can't determine channel for "
724 "interrupt, device %s\n", cdev->dev.bus_id);
725 CLAW_DBF_TEXT(2,trace,"badchan");
728 CLAW_DBF_TEXT_(4,trace,"IRQCH=%d",p_ch->flag);
730 dev = (struct net_device *) (p_ch->ndev);
731 p_env=privptr->p_env;
734 printk(KERN_INFO "%s: interrupt for device: %04x "
735 "received c-%02x d-%02x state-%02x\n",
736 dev->name, p_ch->devno, irb->scsw.cmd.cstat,
737 irb->scsw.cmd.dstat, p_ch->claw_state);
740 /* Copy interruption response block. */
741 memcpy(p_ch->irb, irb, sizeof(struct irb));
743 /* Check for good subchannel return code, otherwise error message */
744 if (irb->scsw.cmd.cstat && !(irb->scsw.cmd.cstat & SCHN_STAT_PCI)) {
745 printk(KERN_INFO "%s: subchannel check for device: %04x -"
746 " Sch Stat %02x Dev Stat %02x CPA - %04x\n",
747 dev->name, p_ch->devno,
748 irb->scsw.cmd.cstat, irb->scsw.cmd.dstat,
751 dumpit((char *)irb,sizeof(struct irb));
752 dumpit((char *)(unsigned long)irb->scsw.cmd.cpa,
753 sizeof(struct ccw1));
756 printk(KERN_INFO "%s:%s Exit on line %d\n",
757 dev->name,__func__,__LINE__);
759 CLAW_DBF_TEXT(2,trace,"chanchk");
763 /* Check the reason-code of a unit check */
764 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
765 ccw_check_unit_check(p_ch, irb->ecw[0]);
767 /* State machine to bring the connection up, down and to restart */
768 p_ch->last_dstat = irb->scsw.cmd.dstat;
770 switch (p_ch->claw_state) {
771 case CLAW_STOP:/* HALT_IO by claw_release (halt sequence) */
773 printk(KERN_INFO "%s: CLAW_STOP enter\n", dev->name);
775 if (!((p_ch->irb->scsw.cmd.stctl &
776 SCSW_STCTL_SEC_STATUS) ||
777 (p_ch->irb->scsw.cmd.stctl ==
778 SCSW_STCTL_STATUS_PEND) ||
779 (p_ch->irb->scsw.cmd.stctl ==
780 (SCSW_STCTL_ALERT_STATUS |
781 SCSW_STCTL_STATUS_PEND)))) {
783 printk(KERN_INFO "%s:%s Exit on line %d\n",
784 dev->name,__func__,__LINE__);
788 wake_up(&p_ch->wait); /* wake up claw_release */
791 printk(KERN_INFO "%s: CLAW_STOP exit\n", dev->name);
794 printk(KERN_INFO "%s:%s Exit on line %d\n",
795 dev->name,__func__,__LINE__);
797 CLAW_DBF_TEXT(4,trace,"stop");
800 case CLAW_START_HALT_IO: /* HALT_IO issued by claw_open */
802 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO\n",
805 if (!((p_ch->irb->scsw.cmd.stctl &
806 SCSW_STCTL_SEC_STATUS) ||
807 (p_ch->irb->scsw.cmd.stctl ==
808 SCSW_STCTL_STATUS_PEND) ||
809 (p_ch->irb->scsw.cmd.stctl ==
810 (SCSW_STCTL_ALERT_STATUS |
811 SCSW_STCTL_STATUS_PEND)))) {
813 printk(KERN_INFO "%s:%s Exit on line %d\n",
814 dev->name,__func__,__LINE__);
816 CLAW_DBF_TEXT(4,trace,"haltio");
819 if (p_ch->flag == CLAW_READ) {
820 p_ch->claw_state = CLAW_START_READ;
821 wake_up(&p_ch->wait); /* wake claw_open (READ)*/
824 if (p_ch->flag == CLAW_WRITE) {
825 p_ch->claw_state = CLAW_START_WRITE;
826 /* send SYSTEM_VALIDATE */
827 claw_strt_read(dev, LOCK_NO);
828 claw_send_control(dev,
829 SYSTEM_VALIDATE_REQUEST,
832 p_env->adapter_name );
834 printk(KERN_WARNING "claw: unsolicited "
835 "interrupt for device:"
836 "%s received c-%02x d-%02x\n",
839 irb->scsw.cmd.dstat);
843 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO exit\n",
847 printk(KERN_INFO "%s:%s Exit on line %d\n",
848 dev->name,__func__,__LINE__);
850 CLAW_DBF_TEXT(4,trace,"haltio");
852 case CLAW_START_READ:
853 CLAW_DBF_TEXT(4,trace,"ReadIRQ");
854 if (p_ch->irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) {
855 clear_bit(0, (void *)&p_ch->IO_active);
856 if ((p_ch->irb->ecw[0] & 0x41) == 0x41 ||
857 (p_ch->irb->ecw[0] & 0x40) == 0x40 ||
858 (p_ch->irb->ecw[0]) == 0)
860 privptr->stats.rx_errors++;
861 printk(KERN_INFO "%s: Restart is "
862 "required after remote "
867 printk(KERN_INFO "%s:%s Exit on line %d\n",
868 dev->name,__func__,__LINE__);
870 CLAW_DBF_TEXT(4,trace,"notrdy");
873 if ((p_ch->irb->scsw.cmd.cstat & SCHN_STAT_PCI) &&
874 (p_ch->irb->scsw.cmd.dstat == 0)) {
875 if (test_and_set_bit(CLAW_BH_ACTIVE,
876 (void *)&p_ch->flag_a) == 0) {
877 tasklet_schedule(&p_ch->tasklet);
880 CLAW_DBF_TEXT(4,trace,"PCINoBH");
883 printk(KERN_INFO "%s:%s Exit on line %d\n",
884 dev->name,__func__,__LINE__);
886 CLAW_DBF_TEXT(4,trace,"PCI_read");
889 if (!((p_ch->irb->scsw.cmd.stctl &
890 SCSW_STCTL_SEC_STATUS) ||
891 (p_ch->irb->scsw.cmd.stctl ==
892 SCSW_STCTL_STATUS_PEND) ||
893 (p_ch->irb->scsw.cmd.stctl ==
894 (SCSW_STCTL_ALERT_STATUS |
895 SCSW_STCTL_STATUS_PEND)))) {
897 printk(KERN_INFO "%s:%s Exit on line %d\n",
898 dev->name,__func__,__LINE__);
900 CLAW_DBF_TEXT(4,trace,"SPend_rd");
903 clear_bit(0, (void *)&p_ch->IO_active);
904 claw_clearbit_busy(TB_RETRY,dev);
905 if (test_and_set_bit(CLAW_BH_ACTIVE,
906 (void *)&p_ch->flag_a) == 0) {
907 tasklet_schedule(&p_ch->tasklet);
910 CLAW_DBF_TEXT(4,trace,"RdBHAct");
914 printk(KERN_INFO "%s: process CLAW_START_READ exit\n",
918 printk(KERN_INFO "%s:%s Exit on line %d\n",
919 dev->name,__func__,__LINE__);
921 CLAW_DBF_TEXT(4,trace,"RdIRQXit");
923 case CLAW_START_WRITE:
924 if (p_ch->irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) {
925 printk(KERN_INFO "%s: Unit Check Occured in "
926 "write channel\n",dev->name);
927 clear_bit(0, (void *)&p_ch->IO_active);
928 if (p_ch->irb->ecw[0] & 0x80 ) {
929 printk(KERN_INFO "%s: Resetting Event "
930 "occurred:\n",dev->name);
931 init_timer(&p_ch->timer);
932 p_ch->timer.function =
933 (void *)claw_write_retry;
934 p_ch->timer.data = (unsigned long)p_ch;
935 p_ch->timer.expires = jiffies + 10*HZ;
936 add_timer(&p_ch->timer);
937 printk(KERN_INFO "%s: write connection "
938 "restarting\n",dev->name);
941 printk(KERN_INFO "%s:%s Exit on line %d\n",
942 dev->name,__func__,__LINE__);
944 CLAW_DBF_TEXT(4,trace,"rstrtwrt");
947 if (p_ch->irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) {
948 clear_bit(0, (void *)&p_ch->IO_active);
949 printk(KERN_INFO "%s: Unit Exception "
950 "Occured in write channel\n",
953 if (!((p_ch->irb->scsw.cmd.stctl &
954 SCSW_STCTL_SEC_STATUS) ||
955 (p_ch->irb->scsw.cmd.stctl ==
956 SCSW_STCTL_STATUS_PEND) ||
957 (p_ch->irb->scsw.cmd.stctl ==
958 (SCSW_STCTL_ALERT_STATUS |
959 SCSW_STCTL_STATUS_PEND)))) {
961 printk(KERN_INFO "%s:%s Exit on line %d\n",
962 dev->name,__func__,__LINE__);
964 CLAW_DBF_TEXT(4,trace,"writeUE");
967 clear_bit(0, (void *)&p_ch->IO_active);
968 if (claw_test_and_setbit_busy(TB_TX,dev)==0) {
969 claw_write_next(p_ch);
970 claw_clearbit_busy(TB_TX,dev);
971 claw_clear_busy(dev);
973 p_ch_r=(struct chbk *)&privptr->channel[READ];
974 if (test_and_set_bit(CLAW_BH_ACTIVE,
975 (void *)&p_ch_r->flag_a) == 0) {
976 tasklet_schedule(&p_ch_r->tasklet);
980 printk(KERN_INFO "%s: process CLAW_START_WRITE exit\n",
984 printk(KERN_INFO "%s:%s Exit on line %d\n",
985 dev->name,__func__,__LINE__);
987 CLAW_DBF_TEXT(4,trace,"StWtExit");
990 printk(KERN_WARNING "%s: wrong selection code - irq "
991 "state=%d\n",dev->name,p_ch->claw_state);
993 printk(KERN_INFO "%s:%s Exit on line %d\n",
994 dev->name,__func__,__LINE__);
996 CLAW_DBF_TEXT(2,trace,"badIRQ");
1000 } /* end of claw_irq_handler */
1003 /*-------------------------------------------------------------------*
1004 * claw_irq_tasklet *
1006 *--------------------------------------------------------------------*/
1008 claw_irq_tasklet ( unsigned long data )
1011 struct net_device *dev;
1012 struct claw_privbk * privptr;
1014 p_ch = (struct chbk *) data;
1015 dev = (struct net_device *)p_ch->ndev;
1017 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
1020 printk(KERN_INFO "%s: variable p_ch =\n",dev->name);
1021 dumpit((char *) p_ch, sizeof(struct chbk));
1023 CLAW_DBF_TEXT(4,trace,"IRQtask");
1025 privptr = (struct claw_privbk *) dev->priv;
1028 printk(KERN_INFO "%s: bh routine - state-%02x\n" ,
1029 dev->name, p_ch->claw_state);
1033 clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a);
1034 CLAW_DBF_TEXT(4,trace,"TskletXt");
1036 printk(KERN_INFO "%s:%s Exit on line %d\n",
1037 dev->name,__func__,__LINE__);
1040 } /* end of claw_irq_bh */
1042 /*-------------------------------------------------------------------*
1045 *--------------------------------------------------------------------*/
1047 claw_release(struct net_device *dev)
1051 unsigned long saveflags;
1053 struct claw_privbk *privptr;
1054 DECLARE_WAITQUEUE(wait, current);
1055 struct ccwbk* p_this_ccw;
1056 struct ccwbk* p_buf;
1060 privptr = (struct claw_privbk *) dev->priv;
1064 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
1066 CLAW_DBF_TEXT(4,trace,"release");
1068 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1069 dumpit((char *) dev, sizeof(struct net_device));
1070 printk(KERN_INFO "Priv Buffalloc %d\n",privptr->buffs_alloc);
1071 printk(KERN_INFO "Priv p_buff_ccw = %p\n",&privptr->p_buff_ccw);
1073 privptr->release_pend=1;
1074 claw_setbit_busy(TB_STOP,dev);
1075 for ( i = 1; i >=0 ; i--) {
1077 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1078 /* del_timer(&privptr->channel[READ].timer); */
1079 privptr->channel[i].claw_state = CLAW_STOP;
1080 privptr->channel[i].IO_active = 0;
1081 parm = (unsigned long) &privptr->channel[i];
1083 claw_purge_skb_queue(
1084 &privptr->channel[WRITE].collect_queue);
1085 rc = ccw_device_halt (privptr->channel[i].cdev, parm);
1086 if (privptr->system_validate_comp==0x00) /* never opened? */
1087 init_waitqueue_head(&privptr->channel[i].wait);
1088 add_wait_queue(&privptr->channel[i].wait, &wait);
1089 set_current_state(TASK_INTERRUPTIBLE);
1090 spin_unlock_irqrestore(
1091 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1093 set_current_state(TASK_RUNNING);
1094 remove_wait_queue(&privptr->channel[i].wait, &wait);
1096 ccw_check_return_code(privptr->channel[i].cdev, rc);
1099 if (privptr->pk_skb != NULL) {
1100 dev_kfree_skb_any(privptr->pk_skb);
1101 privptr->pk_skb = NULL;
1103 if(privptr->buffs_alloc != 1) {
1105 printk(KERN_INFO "%s:%s Exit on line %d\n",
1106 dev->name,__func__,__LINE__);
1108 CLAW_DBF_TEXT(4,trace,"none2fre");
1111 CLAW_DBF_TEXT(4,trace,"freebufs");
1112 if (privptr->p_buff_ccw != NULL) {
1113 free_pages((unsigned long)privptr->p_buff_ccw,
1114 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
1116 CLAW_DBF_TEXT(4,trace,"freeread");
1117 if (privptr->p_env->read_size < PAGE_SIZE) {
1118 if (privptr->p_buff_read != NULL) {
1119 free_pages((unsigned long)privptr->p_buff_read,
1120 (int)pages_to_order_of_mag(privptr->p_buff_read_num));
1124 p_buf=privptr->p_read_active_first;
1125 while (p_buf!=NULL) {
1126 free_pages((unsigned long)p_buf->p_buffer,
1127 (int)pages_to_order_of_mag(
1128 privptr->p_buff_pages_perread ));
1132 CLAW_DBF_TEXT(4,trace,"freewrit");
1133 if (privptr->p_env->write_size < PAGE_SIZE ) {
1134 free_pages((unsigned long)privptr->p_buff_write,
1135 (int)pages_to_order_of_mag(privptr->p_buff_write_num));
1138 p_buf=privptr->p_write_active_first;
1139 while (p_buf!=NULL) {
1140 free_pages((unsigned long)p_buf->p_buffer,
1141 (int)pages_to_order_of_mag(
1142 privptr->p_buff_pages_perwrite ));
1146 CLAW_DBF_TEXT(4,trace,"clearptr");
1147 privptr->buffs_alloc = 0;
1148 privptr->p_buff_ccw=NULL;
1149 privptr->p_buff_read=NULL;
1150 privptr->p_buff_write=NULL;
1151 privptr->system_validate_comp=0;
1152 privptr->release_pend=0;
1153 /* Remove any writes that were pending and reset all reads */
1154 p_this_ccw=privptr->p_read_active_first;
1155 while (p_this_ccw!=NULL) {
1156 p_this_ccw->header.length=0xffff;
1157 p_this_ccw->header.opcode=0xff;
1158 p_this_ccw->header.flag=0x00;
1159 p_this_ccw=p_this_ccw->next;
1162 while (privptr->p_write_active_first!=NULL) {
1163 p_this_ccw=privptr->p_write_active_first;
1164 p_this_ccw->header.flag=CLAW_PENDING;
1165 privptr->p_write_active_first=p_this_ccw->next;
1166 p_this_ccw->next=privptr->p_write_free_chain;
1167 privptr->p_write_free_chain=p_this_ccw;
1168 ++privptr->write_free_count;
1170 privptr->p_write_active_last=NULL;
1171 privptr->mtc_logical_link = -1;
1172 privptr->mtc_skipping = 1;
1173 privptr->mtc_offset=0;
1175 if (((privptr->channel[READ].last_dstat |
1176 privptr->channel[WRITE].last_dstat) &
1177 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) {
1178 printk(KERN_WARNING "%s: channel problems during close - "
1179 "read: %02x - write: %02x\n",
1181 privptr->channel[READ].last_dstat,
1182 privptr->channel[WRITE].last_dstat);
1183 CLAW_DBF_TEXT(2,trace,"badclose");
1186 printk(KERN_INFO "%s:%s Exit on line %d\n",
1187 dev->name,__func__,__LINE__);
1189 CLAW_DBF_TEXT(4,trace,"rlsexit");
1191 } /* end of claw_release */
1195 /*-------------------------------------------------------------------*
1196 * claw_write_retry *
1198 *--------------------------------------------------------------------*/
1201 claw_write_retry ( struct chbk *p_ch )
1204 struct net_device *dev=p_ch->ndev;
1208 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
1209 printk(KERN_INFO "claw: variable p_ch =\n");
1210 dumpit((char *) p_ch, sizeof(struct chbk));
1212 CLAW_DBF_TEXT(4,trace,"w_retry");
1213 if (p_ch->claw_state == CLAW_STOP) {
1215 printk(KERN_INFO "%s:%s Exit on line %d\n",
1216 dev->name,__func__,__LINE__);
1221 printk( KERN_INFO "%s:%s state-%02x\n" ,
1226 claw_strt_out_IO( dev );
1228 printk(KERN_INFO "%s:%s Exit on line %d\n",
1229 dev->name,__func__,__LINE__);
1231 CLAW_DBF_TEXT(4,trace,"rtry_xit");
1233 } /* end of claw_write_retry */
1236 /*-------------------------------------------------------------------*
1239 *--------------------------------------------------------------------*/
1242 claw_write_next ( struct chbk * p_ch )
1245 struct net_device *dev;
1246 struct claw_privbk *privptr=NULL;
1247 struct sk_buff *pk_skb;
1251 printk(KERN_INFO "%s:%s Enter \n",p_ch->ndev->name,__func__);
1252 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1253 dumpit((char *) p_ch, sizeof(struct chbk));
1255 CLAW_DBF_TEXT(4,trace,"claw_wrt");
1256 if (p_ch->claw_state == CLAW_STOP)
1258 dev = (struct net_device *) p_ch->ndev;
1259 privptr = (struct claw_privbk *) dev->priv;
1260 claw_free_wrt_buf( dev );
1261 if ((privptr->write_free_count > 0) &&
1262 !skb_queue_empty(&p_ch->collect_queue)) {
1263 pk_skb = claw_pack_skb(privptr);
1264 while (pk_skb != NULL) {
1265 rc = claw_hw_tx( pk_skb, dev,1);
1266 if (privptr->write_free_count > 0) {
1267 pk_skb = claw_pack_skb(privptr);
1272 if (privptr->p_write_active_first!=NULL) {
1273 claw_strt_out_IO(dev);
1277 printk(KERN_INFO "%s:%s Exit on line %d\n",
1278 dev->name,__func__,__LINE__);
1281 } /* end of claw_write_next */
1283 /*-------------------------------------------------------------------*
1286 *--------------------------------------------------------------------*/
1289 claw_timer ( struct chbk * p_ch )
1292 printk(KERN_INFO "%s:%s Entry\n",p_ch->ndev->name,__func__);
1293 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1294 dumpit((char *) p_ch, sizeof(struct chbk));
1296 CLAW_DBF_TEXT(4,trace,"timer");
1297 p_ch->flag |= CLAW_TIMER;
1298 wake_up(&p_ch->wait);
1300 printk(KERN_INFO "%s:%s Exit on line %d\n",
1301 p_ch->ndev->name,__func__,__LINE__);
1304 } /* end of claw_timer */
1313 /*-------------------------------------------------------------------*
1315 * pages_to_order_of_mag *
1317 * takes a number of pages from 1 to 512 and returns the *
1318 * log(num_pages)/log(2) get_free_pages() needs a base 2 order *
1319 * of magnitude get_free_pages() has an upper order of 9 *
1320 *--------------------------------------------------------------------*/
1323 pages_to_order_of_mag(int num_of_pages)
1325 int order_of_mag=1; /* assume 2 pages */
1328 printk(KERN_INFO "%s Enter pages = %d \n",__func__,num_of_pages);
1330 CLAW_DBF_TEXT_(5,trace,"pages%d",num_of_pages);
1331 if (num_of_pages == 1) {return 0; } /* magnitude of 0 = 1 page */
1332 /* 512 pages = 2Meg on 4k page systems */
1333 if (num_of_pages >= 512) {return 9; }
1334 /* we have two or more pages order is at least 1 */
1335 for (nump=2 ;nump <= 512;nump*=2) {
1336 if (num_of_pages <= nump)
1340 if (order_of_mag > 9) { order_of_mag = 9; } /* I know it's paranoid */
1342 printk(KERN_INFO "%s Exit on line %d, order = %d\n",
1343 __func__,__LINE__, order_of_mag);
1345 CLAW_DBF_TEXT_(5,trace,"mag%d",order_of_mag);
1346 return order_of_mag;
1349 /*-------------------------------------------------------------------*
1353 *--------------------------------------------------------------------*/
1355 add_claw_reads(struct net_device *dev, struct ccwbk* p_first,
1356 struct ccwbk* p_last)
1358 struct claw_privbk *privptr;
1359 struct ccw1 temp_ccw;
1360 struct endccw * p_end;
1362 struct ccwbk* p_buf;
1365 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
1368 printk(KERN_INFO "dev\n");
1369 dumpit((char *) dev, sizeof(struct net_device));
1370 printk(KERN_INFO "p_first\n");
1371 dumpit((char *) p_first, sizeof(struct ccwbk));
1372 printk(KERN_INFO "p_last\n");
1373 dumpit((char *) p_last, sizeof(struct ccwbk));
1375 CLAW_DBF_TEXT(4,trace,"addreads");
1376 privptr = dev->priv;
1377 p_end = privptr->p_end_ccw;
1379 /* first CCW and last CCW contains a new set of read channel programs
1380 * to apend the running channel programs
1382 if ( p_first==NULL) {
1384 printk(KERN_INFO "%s:%s Exit on line %d\n",
1385 dev->name,__func__,__LINE__);
1387 CLAW_DBF_TEXT(4,trace,"addexit");
1391 /* set up ending CCW sequence for this segment */
1393 p_end->read1=0x00; /* second ending CCW is now active */
1394 /* reset ending CCWs and setup TIC CCWs */
1395 p_end->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1396 p_end->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1397 p_last->r_TIC_1.cda =(__u32)__pa(&p_end->read2_nop1);
1398 p_last->r_TIC_2.cda =(__u32)__pa(&p_end->read2_nop1);
1399 p_end->read2_nop2.cda=0;
1400 p_end->read2_nop2.count=1;
1403 p_end->read1=0x01; /* first ending CCW is now active */
1404 /* reset ending CCWs and setup TIC CCWs */
1405 p_end->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1406 p_end->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1407 p_last->r_TIC_1.cda = (__u32)__pa(&p_end->read1_nop1);
1408 p_last->r_TIC_2.cda = (__u32)__pa(&p_end->read1_nop1);
1409 p_end->read1_nop2.cda=0;
1410 p_end->read1_nop2.count=1;
1413 if ( privptr-> p_read_active_first ==NULL ) {
1415 printk(KERN_INFO "%s:%s p_read_active_first == NULL \n",
1416 dev->name,__func__);
1417 printk(KERN_INFO "%s:%s Read active first/last changed \n",
1418 dev->name,__func__);
1420 privptr-> p_read_active_first= p_first; /* set new first */
1421 privptr-> p_read_active_last = p_last; /* set new last */
1426 printk(KERN_INFO "%s:%s Read in progress \n",
1427 dev->name,__func__);
1429 /* set up TIC ccw */
1430 temp_ccw.cda= (__u32)__pa(&p_first->read);
1433 temp_ccw.cmd_code = CCW_CLAW_CMD_TIC;
1438 /* first set of CCW's is chained to the new read */
1439 /* chain, so the second set is chained to the active chain. */
1440 /* Therefore modify the second set to point to the new */
1441 /* read chain set up TIC CCWs */
1442 /* make sure we update the CCW so channel doesn't fetch it */
1443 /* when it's only half done */
1444 memcpy( &p_end->read2_nop2, &temp_ccw ,
1445 sizeof(struct ccw1));
1446 privptr->p_read_active_last->r_TIC_1.cda=
1447 (__u32)__pa(&p_first->read);
1448 privptr->p_read_active_last->r_TIC_2.cda=
1449 (__u32)__pa(&p_first->read);
1452 /* make sure we update the CCW so channel doesn't */
1453 /* fetch it when it is only half done */
1454 memcpy( &p_end->read1_nop2, &temp_ccw ,
1455 sizeof(struct ccw1));
1456 privptr->p_read_active_last->r_TIC_1.cda=
1457 (__u32)__pa(&p_first->read);
1458 privptr->p_read_active_last->r_TIC_2.cda=
1459 (__u32)__pa(&p_first->read);
1461 /* chain in new set of blocks */
1462 privptr->p_read_active_last->next = p_first;
1463 privptr->p_read_active_last=p_last;
1464 } /* end of if ( privptr-> p_read_active_first ==NULL) */
1466 printk(KERN_INFO "%s:%s dump p_last CCW BK \n",dev->name,__func__);
1467 dumpit((char *)p_last, sizeof(struct ccwbk));
1468 printk(KERN_INFO "%s:%s dump p_end CCW BK \n",dev->name,__func__);
1469 dumpit((char *)p_end, sizeof(struct endccw));
1471 printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__func__);
1472 dumpit((char *)p_first, sizeof(struct ccwbk));
1473 printk(KERN_INFO "%s:%s Dump Active CCW chain \n",
1474 dev->name,__func__);
1475 p_buf=privptr->p_read_active_first;
1476 while (p_buf!=NULL) {
1477 dumpit((char *)p_buf, sizeof(struct ccwbk));
1482 printk(KERN_INFO "%s:%s Exit on line %d\n",
1483 dev->name,__func__,__LINE__);
1485 CLAW_DBF_TEXT(4,trace,"addexit");
1487 } /* end of add_claw_reads */
1489 /*-------------------------------------------------------------------*
1490 * ccw_check_return_code *
1492 *-------------------------------------------------------------------*/
1495 ccw_check_return_code(struct ccw_device *cdev, int return_code)
1498 printk(KERN_INFO "%s: %s() > enter \n",
1499 cdev->dev.bus_id,__func__);
1501 CLAW_DBF_TEXT(4,trace,"ccwret");
1503 printk(KERN_INFO "variable cdev =\n");
1504 dumpit((char *) cdev, sizeof(struct ccw_device));
1505 printk(KERN_INFO "variable return_code = %d\n",return_code);
1507 if (return_code != 0) {
1508 switch (return_code) {
1510 printk(KERN_INFO "%s: Busy !\n",
1514 printk(KERN_EMERG "%s: Missing device called "
1515 "for IO ENODEV\n", cdev->dev.bus_id);
1518 printk(KERN_EMERG "%s: Status pending... EIO \n",
1522 printk(KERN_EMERG "%s: Invalid Dev State EINVAL \n",
1526 printk(KERN_EMERG "%s: Unknown error in "
1527 "Do_IO %d\n",cdev->dev.bus_id, return_code);
1531 printk(KERN_INFO "%s: %s() > exit on line %d\n",
1532 cdev->dev.bus_id,__func__,__LINE__);
1534 CLAW_DBF_TEXT(4,trace,"ccwret");
1535 } /* end of ccw_check_return_code */
1537 /*-------------------------------------------------------------------*
1538 * ccw_check_unit_check *
1539 *--------------------------------------------------------------------*/
1542 ccw_check_unit_check(struct chbk * p_ch, unsigned char sense )
1544 struct net_device *dev = p_ch->ndev;
1547 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__func__);
1550 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1551 dumpit((char *)dev, sizeof(struct net_device));
1552 printk(KERN_INFO "%s: variable sense =\n",dev->name);
1553 dumpit((char *)&sense, 2);
1555 CLAW_DBF_TEXT(4,trace,"unitchek");
1557 printk(KERN_INFO "%s: Unit Check with sense byte:0x%04x\n",
1562 printk(KERN_WARNING "%s: Interface disconnect or "
1564 "occurred (remote side)\n", dev->name);
1567 printk(KERN_WARNING "%s: System reset occured"
1568 " (remote side)\n", dev->name);
1571 else if (sense & 0x20) {
1573 printk(KERN_WARNING "%s: Data-streaming "
1574 "timeout)\n", dev->name);
1577 printk(KERN_WARNING "%s: Data-transfer parity"
1578 " error\n", dev->name);
1581 else if (sense & 0x10) {
1583 printk(KERN_WARNING "%s: Hardware malfunction "
1584 "(remote side)\n", dev->name);
1587 printk(KERN_WARNING "%s: read-data parity error "
1588 "(remote side)\n", dev->name);
1593 printk(KERN_INFO "%s: %s() exit on line %d\n",
1594 dev->name,__func__,__LINE__);
1596 } /* end of ccw_check_unit_check */
1600 /*-------------------------------------------------------------------*
1601 * Dump buffer format *
1603 *--------------------------------------------------------------------*/
1606 dumpit(char* buf, int len)
1609 __u32 ct, sw, rm, dup;
1611 char tbuf[82], tdup[82];
1618 char bhex[82], duphex[82];
1626 for ( ct=0; ct < len; ct++, ptr++, rptr++ ) {
1629 sprintf(addr, "%16.16lX",(unsigned long)rptr);
1631 sprintf(addr, "%8.8X",(__u32)rptr);
1633 sprintf(boff, "%4.4X", (__u32)ct);
1637 if ((sw == 4) || (sw == 12)) {
1644 sprintf(tbuf,"%2.2lX", (unsigned long)*ptr);
1646 sprintf(tbuf,"%2.2X", (__u32)*ptr);
1650 if ((0!=isprint(*ptr)) && (*ptr >= 0x20)) {
1660 if ((strcmp(duphex, bhex)) !=0) {
1662 sprintf(tdup,"Duplicate as above to"
1664 printk( KERN_INFO " "
1665 " --- %s ---\n",tdup);
1667 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1668 addr, boff, bhex, basc);
1670 strcpy(duphex, bhex);
1681 for ( ; rm > 0; rm--, sw++ ) {
1682 if ((sw==4) || (sw==12)) strcat(bhex, " ");
1683 if (sw==8) strcat(bhex, " ");
1688 sprintf(tdup,"Duplicate as above to %s", addr);
1689 printk( KERN_INFO " --- %s ---\n",
1692 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1693 addr, boff, bhex, basc);
1697 sprintf(tdup,"Duplicate as above to %s", addr);
1698 printk( KERN_INFO " --- %s ---\n",
1702 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1703 addr, boff, bhex, basc);
1708 } /* end of dumpit */
1711 /*-------------------------------------------------------------------*
1713 *--------------------------------------------------------------------*/
1715 find_link(struct net_device *dev, char *host_name, char *ws_name )
1717 struct claw_privbk *privptr;
1718 struct claw_env *p_env;
1722 printk(KERN_INFO "%s:%s > enter \n",dev->name,__func__);
1724 CLAW_DBF_TEXT(2,setup,"findlink");
1726 printk(KERN_INFO "%s: variable dev = \n",dev->name);
1727 dumpit((char *) dev, sizeof(struct net_device));
1728 printk(KERN_INFO "%s: variable host_name = %s\n",dev->name, host_name);
1729 printk(KERN_INFO "%s: variable ws_name = %s\n",dev->name, ws_name);
1732 p_env=privptr->p_env;
1733 switch (p_env->packing)
1736 if ((memcmp(WS_APPL_NAME_PACKED, host_name, 8)!=0) ||
1737 (memcmp(WS_APPL_NAME_PACKED, ws_name, 8)!=0 ))
1742 if ((memcmp(WS_APPL_NAME_IP_NAME, host_name, 8)!=0) ||
1743 (memcmp(WS_APPL_NAME_IP_NAME, ws_name, 8)!=0 ))
1747 if ((memcmp(HOST_APPL_NAME, host_name, 8)!=0) ||
1748 (memcmp(p_env->api_type , ws_name, 8)!=0))
1754 printk(KERN_INFO "%s:%s Exit on line %d\n",
1755 dev->name,__func__,__LINE__);
1758 } /* end of find_link */
1760 /*-------------------------------------------------------------------*
1764 *-------------------------------------------------------------------*/
1767 claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid)
1770 struct claw_privbk *privptr;
1771 struct ccwbk *p_this_ccw;
1772 struct ccwbk *p_first_ccw;
1773 struct ccwbk *p_last_ccw;
1775 signed long len_of_data;
1776 unsigned long bytesInThisBuffer;
1777 unsigned char *pDataAddress;
1778 struct endccw *pEnd;
1779 struct ccw1 tempCCW;
1781 struct claw_env *p_env;
1783 struct clawph *pk_head;
1786 struct ccwbk *p_buf;
1789 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__func__);
1791 CLAW_DBF_TEXT(4,trace,"hw_tx");
1793 printk(KERN_INFO "%s: variable dev skb =\n",dev->name);
1794 dumpit((char *) skb, sizeof(struct sk_buff));
1795 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1796 dumpit((char *) dev, sizeof(struct net_device));
1797 printk(KERN_INFO "%s: variable linkid = %ld\n",dev->name,linkid);
1799 privptr = (struct claw_privbk *) (dev->priv);
1800 p_ch=(struct chbk *)&privptr->channel[WRITE];
1801 p_env =privptr->p_env;
1803 printk(KERN_INFO "%s: %s() dump sk_buff \n",dev->name,__func__);
1804 dumpit((char *)skb ,sizeof(struct sk_buff));
1806 claw_free_wrt_buf(dev); /* Clean up free chain if posible */
1807 /* scan the write queue to free any completed write packets */
1810 if ((p_env->packing >= PACK_SEND) &&
1811 (skb->cb[1] != 'P')) {
1812 skb_push(skb,sizeof(struct clawph));
1813 pk_head=(struct clawph *)skb->data;
1814 pk_head->len=skb->len-sizeof(struct clawph);
1815 if (pk_head->len%4) {
1816 pk_head->len+= 4-(pk_head->len%4);
1817 skb_pad(skb,4-(pk_head->len%4));
1818 skb_put(skb,4-(pk_head->len%4));
1820 if (p_env->packing == DO_PACKED)
1821 pk_head->link_num = linkid;
1823 pk_head->link_num = 0;
1824 pk_head->flag = 0x00;
1829 if (claw_check_busy(dev)) {
1830 if (privptr->write_free_count!=0) {
1831 claw_clear_busy(dev);
1834 claw_strt_out_IO(dev );
1835 claw_free_wrt_buf( dev );
1836 if (privptr->write_free_count==0) {
1838 printk(KERN_INFO "%s: "
1839 "(claw_check_busy) no free write "
1840 "buffers\n", dev->name);
1842 ch = &privptr->channel[WRITE];
1843 atomic_inc(&skb->users);
1844 skb_queue_tail(&ch->collect_queue, skb);
1848 claw_clear_busy(dev);
1853 if (claw_test_and_setbit_busy(TB_TX,dev)) { /* set to busy */
1855 printk(KERN_INFO "%s: busy (claw_test_and_setbit_"
1856 "busy)\n", dev->name);
1858 ch = &privptr->channel[WRITE];
1859 atomic_inc(&skb->users);
1860 skb_queue_tail(&ch->collect_queue, skb);
1861 claw_strt_out_IO(dev );
1866 /* See how many write buffers are required to hold this data */
1867 numBuffers = DIV_ROUND_UP(skb->len, privptr->p_env->write_size);
1869 /* If that number of buffers isn't available, give up for now */
1870 if (privptr->write_free_count < numBuffers ||
1871 privptr->p_write_free_chain == NULL ) {
1873 claw_setbit_busy(TB_NOBUFFER,dev);
1876 printk(KERN_INFO "%s: busy (claw_setbit_busy"
1877 "(TB_NOBUFFER))\n", dev->name);
1878 printk(KERN_INFO " free_count: %d, numBuffers : %d\n",
1879 (int)privptr->write_free_count,(int) numBuffers );
1881 ch = &privptr->channel[WRITE];
1882 atomic_inc(&skb->users);
1883 skb_queue_tail(&ch->collect_queue, skb);
1884 CLAW_DBF_TEXT(2,trace,"clawbusy");
1887 pDataAddress=skb->data;
1888 len_of_data=skb->len;
1890 while (len_of_data > 0) {
1892 printk(KERN_INFO "%s: %s() length-of-data is %ld \n",
1893 dev->name ,__func__,len_of_data);
1894 dumpit((char *)pDataAddress ,64);
1896 p_this_ccw=privptr->p_write_free_chain; /* get a block */
1897 if (p_this_ccw == NULL) { /* lost the race */
1898 ch = &privptr->channel[WRITE];
1899 atomic_inc(&skb->users);
1900 skb_queue_tail(&ch->collect_queue, skb);
1903 privptr->p_write_free_chain=p_this_ccw->next;
1904 p_this_ccw->next=NULL;
1905 --privptr->write_free_count; /* -1 */
1906 bytesInThisBuffer=len_of_data;
1907 memcpy( p_this_ccw->p_buffer,pDataAddress, bytesInThisBuffer);
1908 len_of_data-=bytesInThisBuffer;
1909 pDataAddress+=(unsigned long)bytesInThisBuffer;
1910 /* setup write CCW */
1911 p_this_ccw->write.cmd_code = (linkid * 8) +1;
1912 if (len_of_data>0) {
1913 p_this_ccw->write.cmd_code+=MORE_to_COME_FLAG;
1915 p_this_ccw->write.count=bytesInThisBuffer;
1916 /* now add to end of this chain */
1917 if (p_first_ccw==NULL) {
1918 p_first_ccw=p_this_ccw;
1920 if (p_last_ccw!=NULL) {
1921 p_last_ccw->next=p_this_ccw;
1922 /* set up TIC ccws */
1923 p_last_ccw->w_TIC_1.cda=
1924 (__u32)__pa(&p_this_ccw->write);
1926 p_last_ccw=p_this_ccw; /* save new last block */
1928 printk(KERN_INFO "%s: %s() > CCW and Buffer %ld bytes long \n",
1929 dev->name,__func__,bytesInThisBuffer);
1930 dumpit((char *)p_this_ccw, sizeof(struct ccwbk));
1931 dumpit((char *)p_this_ccw->p_buffer, 64);
1935 /* FirstCCW and LastCCW now contain a new set of write channel
1936 * programs to append to the running channel program
1939 if (p_first_ccw!=NULL) {
1940 /* setup ending ccw sequence for this segment */
1941 pEnd=privptr->p_end_ccw;
1943 pEnd->write1=0x00; /* second end ccw is now active */
1944 /* set up Tic CCWs */
1945 p_last_ccw->w_TIC_1.cda=
1946 (__u32)__pa(&pEnd->write2_nop1);
1947 pEnd->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1948 pEnd->write2_nop2.flags =
1949 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1950 pEnd->write2_nop2.cda=0;
1951 pEnd->write2_nop2.count=1;
1953 else { /* end of if (pEnd->write1)*/
1954 pEnd->write1=0x01; /* first end ccw is now active */
1955 /* set up Tic CCWs */
1956 p_last_ccw->w_TIC_1.cda=
1957 (__u32)__pa(&pEnd->write1_nop1);
1958 pEnd->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1959 pEnd->write1_nop2.flags =
1960 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1961 pEnd->write1_nop2.cda=0;
1962 pEnd->write1_nop2.count=1;
1963 } /* end if if (pEnd->write1) */
1966 if (privptr->p_write_active_first==NULL ) {
1967 privptr->p_write_active_first=p_first_ccw;
1968 privptr->p_write_active_last=p_last_ccw;
1972 /* set up Tic CCWs */
1974 tempCCW.cda=(__u32)__pa(&p_first_ccw->write);
1977 tempCCW.cmd_code=CCW_CLAW_CMD_TIC;
1982 * first set of ending CCW's is chained to the new write
1983 * chain, so the second set is chained to the active chain
1984 * Therefore modify the second set to point the new write chain.
1985 * make sure we update the CCW atomically
1986 * so channel does not fetch it when it's only half done
1988 memcpy( &pEnd->write2_nop2, &tempCCW ,
1989 sizeof(struct ccw1));
1990 privptr->p_write_active_last->w_TIC_1.cda=
1991 (__u32)__pa(&p_first_ccw->write);
1995 /*make sure we update the CCW atomically
1996 *so channel does not fetch it when it's only half done
1998 memcpy(&pEnd->write1_nop2, &tempCCW ,
1999 sizeof(struct ccw1));
2000 privptr->p_write_active_last->w_TIC_1.cda=
2001 (__u32)__pa(&p_first_ccw->write);
2003 } /* end if if (pEnd->write1) */
2005 privptr->p_write_active_last->next=p_first_ccw;
2006 privptr->p_write_active_last=p_last_ccw;
2009 } /* endif (p_first_ccw!=NULL) */
2013 printk(KERN_INFO "%s: %s() > Dump Active CCW chain \n",
2014 dev->name,__func__);
2015 p_buf=privptr->p_write_active_first;
2016 while (p_buf!=NULL) {
2017 dumpit((char *)p_buf, sizeof(struct ccwbk));
2020 p_buf=(struct ccwbk*)privptr->p_end_ccw;
2021 dumpit((char *)p_buf, sizeof(struct endccw));
2023 dev_kfree_skb_any(skb);
2030 claw_strt_out_IO(dev );
2031 /* if write free count is zero , set NOBUFFER */
2033 printk(KERN_INFO "%s: %s() > free_count is %d\n",
2035 (int) privptr->write_free_count );
2037 if (privptr->write_free_count==0) {
2038 claw_setbit_busy(TB_NOBUFFER,dev);
2041 claw_clearbit_busy(TB_TX,dev);
2044 printk(KERN_INFO "%s: %s() > exit on line %d, rc = %d \n",
2045 dev->name,__func__,__LINE__, rc);
2048 } /* end of claw_hw_tx */
2050 /*-------------------------------------------------------------------*
2054 *--------------------------------------------------------------------*/
2057 init_ccw_bk(struct net_device *dev)
2060 __u32 ccw_blocks_required;
2061 __u32 ccw_blocks_perpage;
2062 __u32 ccw_pages_required;
2063 __u32 claw_reads_perpage=1;
2064 __u32 claw_read_pages;
2065 __u32 claw_writes_perpage=1;
2066 __u32 claw_write_pages;
2068 struct ccwbk*p_free_chain;
2070 struct ccwbk*p_last_CCWB;
2071 struct ccwbk*p_first_CCWB;
2072 struct endccw *p_endccw=NULL;
2073 addr_t real_address;
2074 struct claw_privbk *privptr=dev->priv;
2075 struct clawh *pClawH=NULL;
2076 addr_t real_TIC_address;
2079 printk(KERN_INFO "%s: %s() enter \n",dev->name,__func__);
2081 CLAW_DBF_TEXT(4,trace,"init_ccw");
2083 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2084 dumpit((char *) dev, sizeof(struct net_device));
2087 /* initialize statistics field */
2088 privptr->active_link_ID=0;
2089 /* initialize ccwbk pointers */
2090 privptr->p_write_free_chain=NULL; /* pointer to free ccw chain*/
2091 privptr->p_write_active_first=NULL; /* pointer to the first write ccw*/
2092 privptr->p_write_active_last=NULL; /* pointer to the last write ccw*/
2093 privptr->p_read_active_first=NULL; /* pointer to the first read ccw*/
2094 privptr->p_read_active_last=NULL; /* pointer to the last read ccw */
2095 privptr->p_end_ccw=NULL; /* pointer to ending ccw */
2096 privptr->p_claw_signal_blk=NULL; /* pointer to signal block */
2097 privptr->buffs_alloc = 0;
2098 memset(&privptr->end_ccw, 0x00, sizeof(struct endccw));
2099 memset(&privptr->ctl_bk, 0x00, sizeof(struct clawctl));
2100 /* initialize free write ccwbk counter */
2101 privptr->write_free_count=0; /* number of free bufs on write chain */
2105 * We need 1 CCW block for each read buffer, 1 for each
2106 * write buffer, plus 1 for ClawSignalBlock
2108 ccw_blocks_required =
2109 privptr->p_env->read_buffers+privptr->p_env->write_buffers+1;
2111 printk(KERN_INFO "%s: %s() "
2112 "ccw_blocks_required=%d\n",
2114 ccw_blocks_required);
2115 printk(KERN_INFO "%s: %s() "
2118 (unsigned int)PAGE_SIZE);
2119 printk(KERN_INFO "%s: %s() > "
2122 (unsigned int)PAGE_MASK);
2125 * compute number of CCW blocks that will fit in a page
2127 ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE;
2129 DIV_ROUND_UP(ccw_blocks_required, ccw_blocks_perpage);
2132 printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
2134 ccw_blocks_perpage);
2135 printk(KERN_INFO "%s: %s() > ccw_pages_required=%d\n",
2137 ccw_pages_required);
2140 * read and write sizes are set by 2 constants in claw.h
2141 * 4k and 32k. Unpacked values other than 4k are not going to
2142 * provide good performance. With packing buffers support 32k
2145 if (privptr->p_env->read_size < PAGE_SIZE) {
2146 claw_reads_perpage = PAGE_SIZE / privptr->p_env->read_size;
2147 claw_read_pages = DIV_ROUND_UP(privptr->p_env->read_buffers,
2148 claw_reads_perpage);
2150 else { /* > or equal */
2151 privptr->p_buff_pages_perread =
2152 DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
2153 claw_read_pages = privptr->p_env->read_buffers *
2154 privptr->p_buff_pages_perread;
2156 if (privptr->p_env->write_size < PAGE_SIZE) {
2157 claw_writes_perpage =
2158 PAGE_SIZE / privptr->p_env->write_size;
2159 claw_write_pages = DIV_ROUND_UP(privptr->p_env->write_buffers,
2160 claw_writes_perpage);
2163 else { /* > or equal */
2164 privptr->p_buff_pages_perwrite =
2165 DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
2166 claw_write_pages = privptr->p_env->write_buffers *
2167 privptr->p_buff_pages_perwrite;
2170 if (privptr->p_env->read_size < PAGE_SIZE) {
2171 printk(KERN_INFO "%s: %s() reads_perpage=%d\n",
2173 claw_reads_perpage);
2176 printk(KERN_INFO "%s: %s() pages_perread=%d\n",
2178 privptr->p_buff_pages_perread);
2180 printk(KERN_INFO "%s: %s() read_pages=%d\n",
2183 if (privptr->p_env->write_size < PAGE_SIZE) {
2184 printk(KERN_INFO "%s: %s() writes_perpage=%d\n",
2186 claw_writes_perpage);
2189 printk(KERN_INFO "%s: %s() pages_perwrite=%d\n",
2191 privptr->p_buff_pages_perwrite);
2193 printk(KERN_INFO "%s: %s() write_pages=%d\n",
2200 * allocate ccw_pages_required
2202 if (privptr->p_buff_ccw==NULL) {
2203 privptr->p_buff_ccw=
2204 (void *)__get_free_pages(__GFP_DMA,
2205 (int)pages_to_order_of_mag(ccw_pages_required ));
2206 if (privptr->p_buff_ccw==NULL) {
2207 printk(KERN_INFO "%s: %s() "
2208 "__get_free_pages for CCWs failed : "
2211 ccw_pages_required );
2213 printk(KERN_INFO "%s: %s() > "
2214 "exit on line %d, rc = ENOMEM\n",
2220 privptr->p_buff_ccw_num=ccw_pages_required;
2222 memset(privptr->p_buff_ccw, 0x00,
2223 privptr->p_buff_ccw_num * PAGE_SIZE);
2226 * obtain ending ccw block address
2229 privptr->p_end_ccw = (struct endccw *)&privptr->end_ccw;
2230 real_address = (__u32)__pa(privptr->p_end_ccw);
2231 /* Initialize ending CCW block */
2233 printk(KERN_INFO "%s: %s() begin initialize ending CCW blocks\n",
2234 dev->name,__func__);
2237 p_endccw=privptr->p_end_ccw;
2238 p_endccw->real=real_address;
2239 p_endccw->write1=0x00;
2240 p_endccw->read1=0x00;
2243 p_endccw->write1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2244 p_endccw->write1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2245 p_endccw->write1_nop1.count = 1;
2246 p_endccw->write1_nop1.cda = 0;
2249 p_endccw->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2250 p_endccw->write1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2251 p_endccw->write1_nop2.count = 1;
2252 p_endccw->write1_nop2.cda = 0;
2255 p_endccw->write2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2256 p_endccw->write2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2257 p_endccw->write2_nop1.count = 1;
2258 p_endccw->write2_nop1.cda = 0;
2261 p_endccw->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2262 p_endccw->write2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2263 p_endccw->write2_nop2.count = 1;
2264 p_endccw->write2_nop2.cda = 0;
2267 p_endccw->read1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2268 p_endccw->read1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2269 p_endccw->read1_nop1.count = 1;
2270 p_endccw->read1_nop1.cda = 0;
2273 p_endccw->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2274 p_endccw->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2275 p_endccw->read1_nop2.count = 1;
2276 p_endccw->read1_nop2.cda = 0;
2279 p_endccw->read2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2280 p_endccw->read2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2281 p_endccw->read2_nop1.count = 1;
2282 p_endccw->read2_nop1.cda = 0;
2285 p_endccw->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2286 p_endccw->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2287 p_endccw->read2_nop2.count = 1;
2288 p_endccw->read2_nop2.cda = 0;
2291 printk(KERN_INFO "%s: %s() dump claw ending CCW BK \n",
2292 dev->name,__func__);
2293 dumpit((char *)p_endccw, sizeof(struct endccw));
2297 * Build a chain of CCWs
2302 printk(KERN_INFO "%s: %s() Begin build a chain of CCW buffer \n",
2303 dev->name,__func__);
2305 p_buff=privptr->p_buff_ccw;
2308 for (i=0 ; i < ccw_pages_required; i++ ) {
2309 real_address = (__u32)__pa(p_buff);
2311 for (j=0 ; j < ccw_blocks_perpage ; j++) {
2312 p_buf->next = p_free_chain;
2313 p_free_chain = p_buf;
2314 p_buf->real=(__u32)__pa(p_buf);
2320 printk(KERN_INFO "%s: %s() "
2321 "End build a chain of CCW buffer \n",
2322 dev->name,__func__);
2324 while (p_buf!=NULL) {
2325 dumpit((char *)p_buf, sizeof(struct ccwbk));
2331 * Initialize ClawSignalBlock
2335 printk(KERN_INFO "%s: %s() "
2336 "Begin initialize ClawSignalBlock \n",
2337 dev->name,__func__);
2339 if (privptr->p_claw_signal_blk==NULL) {
2340 privptr->p_claw_signal_blk=p_free_chain;
2341 p_free_chain=p_free_chain->next;
2342 pClawH=(struct clawh *)privptr->p_claw_signal_blk;
2343 pClawH->length=0xffff;
2344 pClawH->opcode=0xff;
2345 pClawH->flag=CLAW_BUSY;
2348 printk(KERN_INFO "%s: %s() > End initialize "
2349 "ClawSignalBlock\n",
2350 dev->name,__func__);
2351 dumpit((char *)privptr->p_claw_signal_blk, sizeof(struct ccwbk));
2355 * allocate write_pages_required and add to free chain
2357 if (privptr->p_buff_write==NULL) {
2358 if (privptr->p_env->write_size < PAGE_SIZE) {
2359 privptr->p_buff_write=
2360 (void *)__get_free_pages(__GFP_DMA,
2361 (int)pages_to_order_of_mag(claw_write_pages ));
2362 if (privptr->p_buff_write==NULL) {
2363 printk(KERN_INFO "%s: %s() __get_free_pages for write"
2364 " bufs failed : get is for %d pages\n",
2365 dev->name,__func__,claw_write_pages );
2366 free_pages((unsigned long)privptr->p_buff_ccw,
2367 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2368 privptr->p_buff_ccw=NULL;
2370 printk(KERN_INFO "%s: %s() > exit on line %d,"
2372 dev->name,__func__,__LINE__);
2377 * Build CLAW write free chain
2381 memset(privptr->p_buff_write, 0x00,
2382 ccw_pages_required * PAGE_SIZE);
2384 printk(KERN_INFO "%s: %s() Begin build claw write free "
2385 "chain \n",dev->name,__func__);
2387 privptr->p_write_free_chain=NULL;
2389 p_buff=privptr->p_buff_write;
2391 for (i=0 ; i< privptr->p_env->write_buffers ; i++) {
2392 p_buf = p_free_chain; /* get a CCW */
2393 p_free_chain = p_buf->next;
2394 p_buf->next =privptr->p_write_free_chain;
2395 privptr->p_write_free_chain = p_buf;
2396 p_buf-> p_buffer = (struct clawbuf *)p_buff;
2397 p_buf-> write.cda = (__u32)__pa(p_buff);
2398 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2399 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2400 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2401 p_buf-> w_read_FF.count = 1;
2402 p_buf-> w_read_FF.cda =
2403 (__u32)__pa(&p_buf-> header.flag);
2404 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2405 p_buf-> w_TIC_1.flags = 0;
2406 p_buf-> w_TIC_1.count = 0;
2408 if (((unsigned long)p_buff+privptr->p_env->write_size) >=
2409 ((unsigned long)(p_buff+2*
2410 (privptr->p_env->write_size) -1) & PAGE_MASK)) {
2411 p_buff= p_buff+privptr->p_env->write_size;
2415 else /* Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
2417 privptr->p_write_free_chain=NULL;
2418 for (i = 0; i< privptr->p_env->write_buffers ; i++) {
2419 p_buff=(void *)__get_free_pages(__GFP_DMA,
2420 (int)pages_to_order_of_mag(
2421 privptr->p_buff_pages_perwrite) );
2423 printk(KERN_INFO "%s:%s __get_free_pages "
2424 "for writes buf: get for %d pages\n",
2426 privptr->p_buff_pages_perwrite);
2429 printk(KERN_INFO "%s:%s __get_free_pages "
2430 "for writes buf failed : get is for %d pages\n",
2433 privptr->p_buff_pages_perwrite );
2434 free_pages((unsigned long)privptr->p_buff_ccw,
2435 (int)pages_to_order_of_mag(
2436 privptr->p_buff_ccw_num));
2437 privptr->p_buff_ccw=NULL;
2438 p_buf=privptr->p_buff_write;
2439 while (p_buf!=NULL) {
2440 free_pages((unsigned long)
2442 (int)pages_to_order_of_mag(
2443 privptr->p_buff_pages_perwrite));
2447 printk(KERN_INFO "%s: %s exit on line %d, rc = ENOMEM\n",
2453 } /* Error on get_pages */
2454 memset(p_buff, 0x00, privptr->p_env->write_size );
2455 p_buf = p_free_chain;
2456 p_free_chain = p_buf->next;
2457 p_buf->next = privptr->p_write_free_chain;
2458 privptr->p_write_free_chain = p_buf;
2459 privptr->p_buff_write = p_buf;
2460 p_buf->p_buffer=(struct clawbuf *)p_buff;
2461 p_buf-> write.cda = (__u32)__pa(p_buff);
2462 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2463 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2464 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2465 p_buf-> w_read_FF.count = 1;
2466 p_buf-> w_read_FF.cda =
2467 (__u32)__pa(&p_buf-> header.flag);
2468 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2469 p_buf-> w_TIC_1.flags = 0;
2470 p_buf-> w_TIC_1.count = 0;
2471 } /* for all write_buffers */
2473 } /* else buffers are PAGE_SIZE or bigger */
2476 privptr->p_buff_write_num=claw_write_pages;
2477 privptr->write_free_count=privptr->p_env->write_buffers;
2481 printk(KERN_INFO "%s:%s End build claw write free chain \n",
2482 dev->name,__func__);
2483 p_buf=privptr->p_write_free_chain;
2484 while (p_buf!=NULL) {
2485 dumpit((char *)p_buf, sizeof(struct ccwbk));
2490 * allocate read_pages_required and chain to free chain
2492 if (privptr->p_buff_read==NULL) {
2493 if (privptr->p_env->read_size < PAGE_SIZE) {
2494 privptr->p_buff_read=
2495 (void *)__get_free_pages(__GFP_DMA,
2496 (int)pages_to_order_of_mag(claw_read_pages) );
2497 if (privptr->p_buff_read==NULL) {
2498 printk(KERN_INFO "%s: %s() "
2499 "__get_free_pages for read buf failed : "
2500 "get is for %d pages\n",
2501 dev->name,__func__,claw_read_pages );
2502 free_pages((unsigned long)privptr->p_buff_ccw,
2503 (int)pages_to_order_of_mag(
2504 privptr->p_buff_ccw_num));
2505 /* free the write pages size is < page size */
2506 free_pages((unsigned long)privptr->p_buff_write,
2507 (int)pages_to_order_of_mag(
2508 privptr->p_buff_write_num));
2509 privptr->p_buff_ccw=NULL;
2510 privptr->p_buff_write=NULL;
2512 printk(KERN_INFO "%s: %s() > exit on line %d, rc ="
2513 " ENOMEM\n",dev->name,__func__,__LINE__);
2517 memset(privptr->p_buff_read, 0x00, claw_read_pages * PAGE_SIZE);
2518 privptr->p_buff_read_num=claw_read_pages;
2520 * Build CLAW read free chain
2524 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2525 dev->name,__func__);
2527 p_buff=privptr->p_buff_read;
2528 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2529 p_buf = p_free_chain;
2530 p_free_chain = p_buf->next;
2532 if (p_last_CCWB==NULL) {
2538 p_buf->next=p_first_CCWB;
2540 (__u32)__pa(&p_first_CCWB -> read );
2545 p_buf->p_buffer=(struct clawbuf *)p_buff;
2546 /* initialize read command */
2547 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2548 p_buf-> read.cda = (__u32)__pa(p_buff);
2549 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2550 p_buf-> read.count = privptr->p_env->read_size;
2552 /* initialize read_h command */
2553 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2554 p_buf-> read_h.cda =
2555 (__u32)__pa(&(p_buf->header));
2556 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2557 p_buf-> read_h.count = sizeof(struct clawh);
2559 /* initialize Signal command */
2560 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2561 p_buf-> signal.cda =
2562 (__u32)__pa(&(pClawH->flag));
2563 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2564 p_buf-> signal.count = 1;
2566 /* initialize r_TIC_1 command */
2567 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2568 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2569 p_buf-> r_TIC_1.flags = 0;
2570 p_buf-> r_TIC_1.count = 0;
2572 /* initialize r_read_FF command */
2573 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2574 p_buf-> r_read_FF.cda =
2575 (__u32)__pa(&(pClawH->flag));
2576 p_buf-> r_read_FF.flags =
2577 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2578 p_buf-> r_read_FF.count = 1;
2580 /* initialize r_TIC_2 */
2581 memcpy(&p_buf->r_TIC_2,
2582 &p_buf->r_TIC_1, sizeof(struct ccw1));
2584 /* initialize Header */
2585 p_buf->header.length=0xffff;
2586 p_buf->header.opcode=0xff;
2587 p_buf->header.flag=CLAW_PENDING;
2589 if (((unsigned long)p_buff+privptr->p_env->read_size) >=
2590 ((unsigned long)(p_buff+2*(privptr->p_env->read_size) -1)
2592 p_buff= p_buff+privptr->p_env->read_size;
2596 (void *)((unsigned long)
2597 (p_buff+2*(privptr->p_env->read_size) -1)
2600 } /* for read_buffers */
2601 } /* read_size < PAGE_SIZE */
2602 else { /* read Size >= PAGE_SIZE */
2605 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2606 dev->name,__func__);
2608 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2609 p_buff = (void *)__get_free_pages(__GFP_DMA,
2610 (int)pages_to_order_of_mag(privptr->p_buff_pages_perread) );
2612 printk(KERN_INFO "%s: %s() __get_free_pages for read "
2613 "buf failed : get is for %d pages\n",
2615 privptr->p_buff_pages_perread );
2616 free_pages((unsigned long)privptr->p_buff_ccw,
2617 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2618 /* free the write pages */
2619 p_buf=privptr->p_buff_write;
2620 while (p_buf!=NULL) {
2621 free_pages((unsigned long)p_buf->p_buffer,
2622 (int)pages_to_order_of_mag(
2623 privptr->p_buff_pages_perwrite ));
2626 /* free any read pages already alloc */
2627 p_buf=privptr->p_buff_read;
2628 while (p_buf!=NULL) {
2629 free_pages((unsigned long)p_buf->p_buffer,
2630 (int)pages_to_order_of_mag(
2631 privptr->p_buff_pages_perread ));
2634 privptr->p_buff_ccw=NULL;
2635 privptr->p_buff_write=NULL;
2637 printk(KERN_INFO "%s: %s() exit on line %d, rc = ENOMEM\n",
2643 memset(p_buff, 0x00, privptr->p_env->read_size);
2644 p_buf = p_free_chain;
2645 privptr->p_buff_read = p_buf;
2646 p_free_chain = p_buf->next;
2648 if (p_last_CCWB==NULL) {
2654 p_buf->next=p_first_CCWB;
2657 &p_first_CCWB -> read );
2661 /* save buff address */
2662 p_buf->p_buffer=(struct clawbuf *)p_buff;
2663 /* initialize read command */
2664 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2665 p_buf-> read.cda = (__u32)__pa(p_buff);
2666 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2667 p_buf-> read.count = privptr->p_env->read_size;
2669 /* initialize read_h command */
2670 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2671 p_buf-> read_h.cda =
2672 (__u32)__pa(&(p_buf->header));
2673 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2674 p_buf-> read_h.count = sizeof(struct clawh);
2676 /* initialize Signal command */
2677 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2678 p_buf-> signal.cda =
2679 (__u32)__pa(&(pClawH->flag));
2680 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2681 p_buf-> signal.count = 1;
2683 /* initialize r_TIC_1 command */
2684 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2685 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2686 p_buf-> r_TIC_1.flags = 0;
2687 p_buf-> r_TIC_1.count = 0;
2689 /* initialize r_read_FF command */
2690 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2691 p_buf-> r_read_FF.cda =
2692 (__u32)__pa(&(pClawH->flag));
2693 p_buf-> r_read_FF.flags =
2694 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2695 p_buf-> r_read_FF.count = 1;
2697 /* initialize r_TIC_2 */
2698 memcpy(&p_buf->r_TIC_2, &p_buf->r_TIC_1,
2699 sizeof(struct ccw1));
2701 /* initialize Header */
2702 p_buf->header.length=0xffff;
2703 p_buf->header.opcode=0xff;
2704 p_buf->header.flag=CLAW_PENDING;
2706 } /* For read_buffers */
2707 } /* read_size >= PAGE_SIZE */
2708 } /* pBuffread = NULL */
2710 printk(KERN_INFO "%s: %s() > End build claw read free chain \n",
2711 dev->name,__func__);
2713 while (p_buf!=NULL) {
2714 dumpit((char *)p_buf, sizeof(struct ccwbk));
2719 add_claw_reads( dev ,p_first_CCWB , p_last_CCWB);
2720 privptr->buffs_alloc = 1;
2722 printk(KERN_INFO "%s: %s() exit on line %d\n",
2723 dev->name,__func__,__LINE__);
2726 } /* end of init_ccw_bk */
2728 /*-------------------------------------------------------------------*
2732 *--------------------------------------------------------------------*/
2735 probe_error( struct ccwgroup_device *cgdev)
2737 struct claw_privbk *privptr;
2739 printk(KERN_INFO "%s enter \n",__func__);
2741 CLAW_DBF_TEXT(4,trace,"proberr");
2743 printk(KERN_INFO "%s variable cgdev =\n",__func__);
2744 dumpit((char *) cgdev, sizeof(struct ccwgroup_device));
2746 privptr=(struct claw_privbk *)cgdev->dev.driver_data;
2747 if (privptr!=NULL) {
2748 kfree(privptr->p_env);
2749 privptr->p_env=NULL;
2750 kfree(privptr->p_mtc_envelope);
2751 privptr->p_mtc_envelope=NULL;
2756 printk(KERN_INFO "%s > exit on line %d\n",
2765 /*-------------------------------------------------------------------*
2766 * claw_process_control *
2769 *--------------------------------------------------------------------*/
2772 claw_process_control( struct net_device *dev, struct ccwbk * p_ccw)
2775 struct clawbuf *p_buf;
2776 struct clawctl ctlbk;
2777 struct clawctl *p_ctlbk;
2778 char temp_host_name[8];
2779 char temp_ws_name[8];
2780 struct claw_privbk *privptr;
2781 struct claw_env *p_env;
2782 struct sysval *p_sysval;
2783 struct conncmd *p_connect=NULL;
2785 struct chbk *p_ch = NULL;
2787 printk(KERN_INFO "%s: %s() > enter \n",
2788 dev->name,__func__);
2790 CLAW_DBF_TEXT(2,setup,"clw_cntl");
2792 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2793 dumpit((char *) dev, sizeof(struct net_device));
2794 printk(KERN_INFO "%s: variable p_ccw =\n",dev->name);
2795 dumpit((char *) p_ccw, sizeof(struct ccwbk *));
2797 udelay(1000); /* Wait a ms for the control packets to
2798 *catch up to each other */
2800 p_env=privptr->p_env;
2801 memcpy( &temp_host_name, p_env->host_name, 8);
2802 memcpy( &temp_ws_name, p_env->adapter_name , 8);
2803 printk(KERN_INFO "%s: CLAW device %.8s: "
2804 "Received Control Packet\n",
2805 dev->name, temp_ws_name);
2806 if (privptr->release_pend==1) {
2808 printk(KERN_INFO "%s: %s() > "
2809 "exit on line %d, rc=0\n",
2810 dev->name,__func__,__LINE__);
2814 p_buf=p_ccw->p_buffer;
2816 if (p_env->packing == DO_PACKED) { /* packing in progress?*/
2817 memcpy(p_ctlbk, &p_buf->buffer[4], sizeof(struct clawctl));
2819 memcpy(p_ctlbk, p_buf, sizeof(struct clawctl));
2822 printk(KERN_INFO "%s: dump claw control data inbound\n",dev->name);
2823 dumpit((char *)p_ctlbk, sizeof(struct clawctl));
2825 switch (p_ctlbk->command)
2827 case SYSTEM_VALIDATE_REQUEST:
2828 if (p_ctlbk->version!=CLAW_VERSION_ID) {
2829 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2830 CLAW_RC_WRONG_VERSION );
2831 printk("%s: %d is wrong version id. "
2833 dev->name, p_ctlbk->version,
2836 p_sysval=(struct sysval *)&(p_ctlbk->data);
2837 printk( "%s: Recv Sys Validate Request: "
2838 "Vers=%d,link_id=%d,Corr=%d,WS name=%."
2839 "8s,Host name=%.8s\n",
2840 dev->name, p_ctlbk->version,
2842 p_ctlbk->correlator,
2844 p_sysval->host_name);
2845 if (0!=memcmp(temp_host_name,p_sysval->host_name,8)) {
2846 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2847 CLAW_RC_NAME_MISMATCH );
2848 CLAW_DBF_TEXT(2,setup,"HSTBAD");
2849 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->host_name);
2850 CLAW_DBF_TEXT_(2,setup,"%s",temp_host_name);
2851 printk(KERN_INFO "%s: Host name mismatch\n",
2853 printk(KERN_INFO "%s: Received :%s: "
2856 p_sysval->host_name,
2859 if (0!=memcmp(temp_ws_name,p_sysval->WS_name,8)) {
2860 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2861 CLAW_RC_NAME_MISMATCH );
2862 CLAW_DBF_TEXT(2,setup,"WSNBAD");
2863 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->WS_name);
2864 CLAW_DBF_TEXT_(2,setup,"%s",temp_ws_name);
2865 printk(KERN_INFO "%s: WS name mismatch\n",
2867 printk(KERN_INFO "%s: Received :%s: "
2873 if (( p_sysval->write_frame_size < p_env->write_size) &&
2874 ( p_env->packing == 0)) {
2875 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2876 CLAW_RC_HOST_RCV_TOO_SMALL );
2877 printk(KERN_INFO "%s: host write size is too "
2878 "small\n", dev->name);
2879 CLAW_DBF_TEXT(2,setup,"wrtszbad");
2881 if (( p_sysval->read_frame_size < p_env->read_size) &&
2882 ( p_env->packing == 0)) {
2883 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2884 CLAW_RC_HOST_RCV_TOO_SMALL );
2885 printk(KERN_INFO "%s: host read size is too "
2886 "small\n", dev->name);
2887 CLAW_DBF_TEXT(2,setup,"rdsizbad");
2889 claw_snd_sys_validate_rsp(dev, p_ctlbk, 0 );
2890 printk("%s: CLAW device %.8s: System validate"
2891 " completed.\n",dev->name, temp_ws_name);
2892 printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev->name,
2893 p_sysval->read_frame_size,p_sysval->write_frame_size);
2894 privptr->system_validate_comp=1;
2895 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
2896 p_env->packing = PACKING_ASK;
2898 claw_strt_conn_req(dev);
2901 case SYSTEM_VALIDATE_RESPONSE:
2902 p_sysval=(struct sysval *)&(p_ctlbk->data);
2903 printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
2904 "WS name=%.8s,Host name=%.8s\n",
2907 p_ctlbk->correlator,
2910 p_sysval->host_name);
2911 switch (p_ctlbk->rc)
2914 printk(KERN_INFO "%s: CLAW device "
2915 "%.8s: System validate "
2917 dev->name, temp_ws_name);
2918 if (privptr->system_validate_comp == 0)
2919 claw_strt_conn_req(dev);
2920 privptr->system_validate_comp=1;
2922 case CLAW_RC_NAME_MISMATCH:
2923 printk(KERN_INFO "%s: Sys Validate "
2924 "Resp : Host, WS name is "
2928 case CLAW_RC_WRONG_VERSION:
2929 printk(KERN_INFO "%s: Sys Validate "
2930 "Resp : Wrong version\n",
2933 case CLAW_RC_HOST_RCV_TOO_SMALL:
2934 printk(KERN_INFO "%s: Sys Validate "
2935 "Resp : bad frame size\n",
2939 printk(KERN_INFO "%s: Sys Validate "
2941 dev->name, p_ctlbk->rc );
2946 case CONNECTION_REQUEST:
2947 p_connect=(struct conncmd *)&(p_ctlbk->data);
2948 printk(KERN_INFO "%s: Recv Conn Req: Vers=%d,link_id=%d,"
2949 "Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
2953 p_ctlbk->correlator,
2954 p_connect->host_name,
2955 p_connect->WS_name);
2956 if (privptr->active_link_ID!=0 ) {
2957 claw_snd_disc(dev, p_ctlbk);
2958 printk(KERN_INFO "%s: Conn Req error : "
2959 "already logical link is active \n",
2962 if (p_ctlbk->linkid!=1 ) {
2963 claw_snd_disc(dev, p_ctlbk);
2964 printk(KERN_INFO "%s: Conn Req error : "
2965 "req logical link id is not 1\n",
2969 p_connect->host_name, p_connect->WS_name);
2971 claw_snd_disc(dev, p_ctlbk);
2972 printk(KERN_INFO "%s: Conn Req error : "
2973 "req appl name does not match\n",
2976 claw_send_control(dev,
2977 CONNECTION_CONFIRM, p_ctlbk->linkid,
2978 p_ctlbk->correlator,
2979 0, p_connect->host_name,
2980 p_connect->WS_name);
2981 if (p_env->packing == PACKING_ASK) {
2982 printk("%s: Now Pack ask\n",dev->name);
2983 p_env->packing = PACK_SEND;
2984 claw_snd_conn_req(dev,0);
2986 printk(KERN_INFO "%s: CLAW device %.8s: Connection "
2987 "completed link_id=%d.\n",
2988 dev->name, temp_ws_name,
2990 privptr->active_link_ID=p_ctlbk->linkid;
2991 p_ch=&privptr->channel[WRITE];
2992 wake_up(&p_ch->wait); /* wake up claw_open ( WRITE) */
2994 case CONNECTION_RESPONSE:
2995 p_connect=(struct conncmd *)&(p_ctlbk->data);
2996 printk(KERN_INFO "%s: Revc Conn Resp: Vers=%d,link_id=%d,"
2997 "Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
3001 p_ctlbk->correlator,
3003 p_connect->host_name,
3004 p_connect->WS_name);
3006 if (p_ctlbk->rc !=0 ) {
3007 printk(KERN_INFO "%s: Conn Resp error: rc=%d \n",
3008 dev->name, p_ctlbk->rc);
3012 p_connect->host_name, p_connect->WS_name);
3014 claw_snd_disc(dev, p_ctlbk);
3015 printk(KERN_INFO "%s: Conn Resp error: "
3016 "req appl name does not match\n",
3019 /* should be until CONNECTION_CONFIRM */
3020 privptr->active_link_ID = - (p_ctlbk->linkid);
3022 case CONNECTION_CONFIRM:
3023 p_connect=(struct conncmd *)&(p_ctlbk->data);
3024 printk(KERN_INFO "%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
3025 "Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
3029 p_ctlbk->correlator,
3030 p_connect->host_name,
3031 p_connect->WS_name);
3032 if (p_ctlbk->linkid== -(privptr->active_link_ID)) {
3033 privptr->active_link_ID=p_ctlbk->linkid;
3034 if (p_env->packing > PACKING_ASK) {
3035 printk(KERN_INFO "%s: Confirmed Now packing\n",dev->name);
3036 p_env->packing = DO_PACKED;
3038 p_ch=&privptr->channel[WRITE];
3039 wake_up(&p_ch->wait);
3042 printk(KERN_INFO "%s: Conn confirm: "
3043 "unexpected linkid=%d \n",
3044 dev->name, p_ctlbk->linkid);
3045 claw_snd_disc(dev, p_ctlbk);
3049 printk(KERN_INFO "%s: Disconnect: "
3050 "Vers=%d,link_id=%d,Corr=%d\n",
3051 dev->name, p_ctlbk->version,
3052 p_ctlbk->linkid, p_ctlbk->correlator);
3053 if ((p_ctlbk->linkid == 2) &&
3054 (p_env->packing == PACK_SEND)) {
3055 privptr->active_link_ID = 1;
3056 p_env->packing = DO_PACKED;
3059 privptr->active_link_ID=0;
3062 printk(KERN_INFO "%s: CLAW ERROR detected\n",
3066 printk(KERN_INFO "%s: Unexpected command code=%d \n",
3067 dev->name, p_ctlbk->command);
3072 printk(KERN_INFO "%s: %s() exit on line %d, rc = 0\n",
3073 dev->name,__func__,__LINE__);
3077 } /* end of claw_process_control */
3080 /*-------------------------------------------------------------------*
3081 * claw_send_control *
3083 *--------------------------------------------------------------------*/
3086 claw_send_control(struct net_device *dev, __u8 type, __u8 link,
3087 __u8 correlator, __u8 rc, char *local_name, char *remote_name)
3089 struct claw_privbk *privptr;
3090 struct clawctl *p_ctl;
3091 struct sysval *p_sysval;
3092 struct conncmd *p_connect;
3093 struct sk_buff *skb;
3096 printk(KERN_INFO "%s:%s > enter \n",dev->name,__func__);
3098 CLAW_DBF_TEXT(2,setup,"sndcntl");
3100 printk(KERN_INFO "%s: Sending Control Packet \n",dev->name);
3101 printk(KERN_INFO "%s: variable type = 0x%X, link = "
3102 "%d, correlator = %d, rc = %d\n",
3103 dev->name,type, link, correlator, rc);
3104 printk(KERN_INFO "%s: variable local_name = %s, "
3105 "remote_name = %s\n",dev->name, local_name, remote_name);
3108 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3110 p_ctl->command=type;
3111 p_ctl->version=CLAW_VERSION_ID;
3113 p_ctl->correlator=correlator;
3116 p_sysval=(struct sysval *)&p_ctl->data;
3117 p_connect=(struct conncmd *)&p_ctl->data;
3119 switch (p_ctl->command) {
3120 case SYSTEM_VALIDATE_REQUEST:
3121 case SYSTEM_VALIDATE_RESPONSE:
3122 memcpy(&p_sysval->host_name, local_name, 8);
3123 memcpy(&p_sysval->WS_name, remote_name, 8);
3124 if (privptr->p_env->packing > 0) {
3125 p_sysval->read_frame_size=DEF_PACK_BUFSIZE;
3126 p_sysval->write_frame_size=DEF_PACK_BUFSIZE;
3128 /* how big is the piggest group of packets */
3129 p_sysval->read_frame_size=privptr->p_env->read_size;
3130 p_sysval->write_frame_size=privptr->p_env->write_size;
3132 memset(&p_sysval->reserved, 0x00, 4);
3134 case CONNECTION_REQUEST:
3135 case CONNECTION_RESPONSE:
3136 case CONNECTION_CONFIRM:
3138 memcpy(&p_sysval->host_name, local_name, 8);
3139 memcpy(&p_sysval->WS_name, remote_name, 8);
3140 if (privptr->p_env->packing > 0) {
3141 /* How big is the biggest packet */
3142 p_connect->reserved1[0]=CLAW_FRAME_SIZE;
3143 p_connect->reserved1[1]=CLAW_FRAME_SIZE;
3145 memset(&p_connect->reserved1, 0x00, 4);
3146 memset(&p_connect->reserved2, 0x00, 4);
3153 /* write Control Record to the device */
3156 skb = dev_alloc_skb(sizeof(struct clawctl));
3158 printk( "%s:%s low on mem, returning...\n",
3159 dev->name,__func__);
3161 printk(KERN_INFO "%s:%s Exit, rc = ENOMEM\n",
3162 dev->name,__func__);
3166 memcpy(skb_put(skb, sizeof(struct clawctl)),
3167 p_ctl, sizeof(struct clawctl));
3169 printk(KERN_INFO "%s: outbnd claw cntl data \n",dev->name);
3170 dumpit((char *)p_ctl,sizeof(struct clawctl));
3172 if (privptr->p_env->packing >= PACK_SEND)
3173 claw_hw_tx(skb, dev, 1);
3175 claw_hw_tx(skb, dev, 0);
3177 printk(KERN_INFO "%s:%s Exit on line %d\n",
3178 dev->name,__func__,__LINE__);
3182 } /* end of claw_send_control */
3184 /*-------------------------------------------------------------------*
3185 * claw_snd_conn_req *
3187 *--------------------------------------------------------------------*/
3189 claw_snd_conn_req(struct net_device *dev, __u8 link)
3192 struct claw_privbk *privptr=dev->priv;
3193 struct clawctl *p_ctl;
3196 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
3198 CLAW_DBF_TEXT(2,setup,"snd_conn");
3200 printk(KERN_INFO "%s: variable link = %X, dev =\n",dev->name, link);
3201 dumpit((char *) dev, sizeof(struct net_device));
3204 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3205 p_ctl->linkid = link;
3206 if ( privptr->system_validate_comp==0x00 ) {
3208 printk(KERN_INFO "%s:%s Exit on line %d, rc = 1\n",
3209 dev->name,__func__,__LINE__);
3213 if (privptr->p_env->packing == PACKING_ASK )
3214 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3215 WS_APPL_NAME_PACKED, WS_APPL_NAME_PACKED);
3216 if (privptr->p_env->packing == PACK_SEND) {
3217 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3218 WS_APPL_NAME_IP_NAME, WS_APPL_NAME_IP_NAME);
3220 if (privptr->p_env->packing == 0)
3221 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3222 HOST_APPL_NAME, privptr->p_env->api_type);
3224 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3225 dev->name,__func__,__LINE__, rc);
3229 } /* end of claw_snd_conn_req */
3232 /*-------------------------------------------------------------------*
3235 *--------------------------------------------------------------------*/
3238 claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl)
3241 struct conncmd * p_connect;
3244 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3246 CLAW_DBF_TEXT(2,setup,"snd_dsc");
3248 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3249 dumpit((char *) dev, sizeof(struct net_device));
3250 printk(KERN_INFO "%s: variable p_ctl",dev->name);
3251 dumpit((char *) p_ctl, sizeof(struct clawctl));
3253 p_connect=(struct conncmd *)&p_ctl->data;
3255 rc=claw_send_control(dev, DISCONNECT, p_ctl->linkid,
3256 p_ctl->correlator, 0,
3257 p_connect->host_name, p_connect->WS_name);
3259 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3260 dev->name,__func__, __LINE__, rc);
3263 } /* end of claw_snd_disc */
3266 /*-------------------------------------------------------------------*
3267 * claw_snd_sys_validate_rsp *
3269 *--------------------------------------------------------------------*/
3272 claw_snd_sys_validate_rsp(struct net_device *dev,
3273 struct clawctl *p_ctl, __u32 return_code)
3275 struct claw_env * p_env;
3276 struct claw_privbk *privptr;
3280 printk(KERN_INFO "%s:%s Enter\n",
3281 dev->name,__func__);
3283 CLAW_DBF_TEXT(2,setup,"chkresp");
3285 printk(KERN_INFO "%s: variable return_code = %d, dev =\n",
3286 dev->name, return_code);
3287 dumpit((char *) dev, sizeof(struct net_device));
3288 printk(KERN_INFO "%s: variable p_ctl =\n",dev->name);
3289 dumpit((char *) p_ctl, sizeof(struct clawctl));
3291 privptr = dev->priv;
3292 p_env=privptr->p_env;
3293 rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE,
3298 p_env->adapter_name );
3300 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3301 dev->name,__func__,__LINE__, rc);
3304 } /* end of claw_snd_sys_validate_rsp */
3306 /*-------------------------------------------------------------------*
3307 * claw_strt_conn_req *
3309 *--------------------------------------------------------------------*/
3312 claw_strt_conn_req(struct net_device *dev )
3317 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3319 CLAW_DBF_TEXT(2,setup,"conn_req");
3321 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3322 dumpit((char *) dev, sizeof(struct net_device));
3324 rc=claw_snd_conn_req(dev, 1);
3326 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3327 dev->name,__func__,__LINE__, rc);
3330 } /* end of claw_strt_conn_req */
3334 /*-------------------------------------------------------------------*
3336 *-------------------------------------------------------------------*/
3339 net_device_stats *claw_stats(struct net_device *dev)
3341 struct claw_privbk *privptr;
3343 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3345 CLAW_DBF_TEXT(4,trace,"stats");
3346 privptr = dev->priv;
3348 printk(KERN_INFO "%s:%s Exit on line %d\n",
3349 dev->name,__func__,__LINE__);
3351 return &privptr->stats;
3352 } /* end of claw_stats */
3355 /*-------------------------------------------------------------------*
3358 *--------------------------------------------------------------------*/
3360 unpack_read(struct net_device *dev )
3362 struct sk_buff *skb;
3363 struct claw_privbk *privptr;
3364 struct claw_env *p_env;
3365 struct ccwbk *p_this_ccw;
3366 struct ccwbk *p_first_ccw;
3367 struct ccwbk *p_last_ccw;
3368 struct clawph *p_packh;
3370 struct clawctl *p_ctlrec=NULL;
3375 __u8 mtc_this_frm=0;
3377 struct chbk *p_ch = NULL;
3382 printk(KERN_INFO "%s:%s enter \n",dev->name,__func__);
3384 CLAW_DBF_TEXT(4,trace,"unpkread");
3390 p_env = privptr->p_env;
3391 p_this_ccw=privptr->p_read_active_first;
3393 while (p_this_ccw!=NULL && p_this_ccw->header.flag!=CLAW_PENDING) {
3395 printk(KERN_INFO "%s p_this_ccw \n",dev->name);
3396 dumpit((char*)p_this_ccw, sizeof(struct ccwbk));
3397 printk(KERN_INFO "%s Inbound p_this_ccw->p_buffer(64)"
3398 " pk=%d \n",dev->name,p_env->packing);
3399 dumpit((char *)p_this_ccw->p_buffer, 64 );
3403 p_this_ccw->header.flag=CLAW_PENDING;
3404 privptr->p_read_active_first=p_this_ccw->next;
3405 p_this_ccw->next=NULL;
3406 p_packh = (struct clawph *)p_this_ccw->p_buffer;
3407 if ((p_env->packing == PACK_SEND) &&
3408 (p_packh->len == 32) &&
3409 (p_packh->link_num == 0)) { /* is it a packed ctl rec? */
3410 p_packh++; /* peek past pack header */
3411 p_ctlrec = (struct clawctl *)p_packh;
3412 p_packh--; /* un peek */
3413 if ((p_ctlrec->command == CONNECTION_RESPONSE) ||
3414 (p_ctlrec->command == CONNECTION_CONFIRM))
3415 p_env->packing = DO_PACKED;
3417 if (p_env->packing == DO_PACKED)
3418 link_num=p_packh->link_num;
3420 link_num=p_this_ccw->header.opcode / 8;
3421 if ((p_this_ccw->header.opcode & MORE_to_COME_FLAG)!=0) {
3423 printk(KERN_INFO "%s: %s > More_to_come is ON\n",
3424 dev->name,__func__);
3427 if (p_this_ccw->header.length!=
3428 privptr->p_env->read_size ) {
3429 printk(KERN_INFO " %s: Invalid frame detected "
3430 "length is %02x\n" ,
3431 dev->name, p_this_ccw->header.length);
3435 if (privptr->mtc_skipping) {
3437 * We're in the mode of skipping past a
3438 * multi-frame message
3439 * that we can't process for some reason or other.
3440 * The first frame without the More-To-Come flag is
3441 * the last frame of the skipped message.
3443 /* in case of More-To-Come not set in this frame */
3444 if (mtc_this_frm==0) {
3445 privptr->mtc_skipping=0; /* Ok, the end */
3446 privptr->mtc_logical_link=-1;
3449 printk(KERN_INFO "%s:%s goto next "
3450 "frame from MoretoComeSkip \n",
3451 dev->name,__func__);
3457 claw_process_control(dev, p_this_ccw);
3459 printk(KERN_INFO "%s:%s goto next "
3460 "frame from claw_process_control \n",
3461 dev->name,__func__);
3463 CLAW_DBF_TEXT(4,trace,"UnpkCntl");
3467 if (p_env->packing == DO_PACKED) {
3468 if (pack_off > p_env->read_size)
3470 p_packd = p_this_ccw->p_buffer+pack_off;
3471 p_packh = (struct clawph *) p_packd;
3472 if ((p_packh->len == 0) || /* all done with this frame? */
3473 (p_packh->flag != 0))
3475 bytes_to_mov = p_packh->len;
3476 pack_off += bytes_to_mov+sizeof(struct clawph);
3479 bytes_to_mov=p_this_ccw->header.length;
3481 if (privptr->mtc_logical_link<0) {
3483 printk(KERN_INFO "%s: %s mtc_logical_link < 0 \n",
3484 dev->name,__func__);
3488 * if More-To-Come is set in this frame then we don't know
3489 * length of entire message, and hence have to allocate
3492 /* We are starting a new envelope */
3493 privptr->mtc_offset=0;
3494 privptr->mtc_logical_link=link_num;
3497 if (bytes_to_mov > (MAX_ENVELOPE_SIZE- privptr->mtc_offset) ) {
3500 printk(KERN_INFO "%s: %s > goto next "
3501 "frame from MoretoComeSkip \n",
3504 printk(KERN_INFO " bytes_to_mov %d > (MAX_ENVELOPE_"
3505 "SIZE-privptr->mtc_offset %d)\n",
3506 bytes_to_mov,(MAX_ENVELOPE_SIZE- privptr->mtc_offset));
3508 privptr->stats.rx_frame_errors++;
3511 if (p_env->packing == DO_PACKED) {
3512 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3513 p_packd+sizeof(struct clawph), bytes_to_mov);
3516 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3517 p_this_ccw->p_buffer, bytes_to_mov);
3520 printk(KERN_INFO "%s: %s() received data \n",
3521 dev->name,__func__);
3522 if (p_env->packing == DO_PACKED)
3523 dumpit((char *)p_packd+sizeof(struct clawph),32);
3525 dumpit((char *)p_this_ccw->p_buffer, 32);
3526 printk(KERN_INFO "%s: %s() bytelength %d \n",
3527 dev->name,__func__,bytes_to_mov);
3529 if (mtc_this_frm==0) {
3530 len_of_data=privptr->mtc_offset+bytes_to_mov;
3531 skb=dev_alloc_skb(len_of_data);
3533 memcpy(skb_put(skb,len_of_data),
3534 privptr->p_mtc_envelope,
3537 skb_reset_mac_header(skb);
3538 skb->protocol=htons(ETH_P_IP);
3539 skb->ip_summed=CHECKSUM_UNNECESSARY;
3540 privptr->stats.rx_packets++;
3541 privptr->stats.rx_bytes+=len_of_data;
3544 printk(KERN_INFO "%s: %s() netif_"
3545 "rx(skb) completed \n",
3546 dev->name,__func__);
3550 privptr->stats.rx_dropped++;
3551 printk(KERN_WARNING "%s: %s() low on memory\n",
3552 dev->name,__func__);
3554 privptr->mtc_offset=0;
3555 privptr->mtc_logical_link=-1;
3558 privptr->mtc_offset+=bytes_to_mov;
3560 if (p_env->packing == DO_PACKED)
3564 * Remove ThisCCWblock from active read queue, and add it
3565 * to queue of free blocks to be reused.
3568 p_this_ccw->header.length=0xffff;
3569 p_this_ccw->header.opcode=0xff;
3571 * add this one to the free queue for later reuse
3573 if (p_first_ccw==NULL) {
3574 p_first_ccw = p_this_ccw;
3577 p_last_ccw->next = p_this_ccw;
3579 p_last_ccw = p_this_ccw;
3581 * chain to next block on active read queue
3583 p_this_ccw = privptr->p_read_active_first;
3584 CLAW_DBF_TEXT_(4,trace,"rxpkt %d",p);
3585 } /* end of while */
3587 /* check validity */
3590 printk(KERN_INFO "%s:%s processed frame is %d \n",
3591 dev->name,__func__,i);
3592 printk(KERN_INFO "%s:%s F:%lx L:%lx\n",
3595 (unsigned long)p_first_ccw,
3596 (unsigned long)p_last_ccw);
3598 CLAW_DBF_TEXT_(4,trace,"rxfrm %d",i);
3599 add_claw_reads(dev, p_first_ccw, p_last_ccw);
3600 p_ch=&privptr->channel[READ];
3601 claw_strt_read(dev, LOCK_YES);
3603 printk(KERN_INFO "%s: %s exit on line %d\n",
3604 dev->name, __func__, __LINE__);
3607 } /* end of unpack_read */
3609 /*-------------------------------------------------------------------*
3612 *--------------------------------------------------------------------*/
3614 claw_strt_read (struct net_device *dev, int lock )
3618 unsigned long saveflags = 0;
3619 struct claw_privbk *privptr=dev->priv;
3620 struct ccwbk*p_ccwbk;
3622 struct clawh *p_clawh;
3623 p_ch=&privptr->channel[READ];
3626 printk(KERN_INFO "%s:%s Enter \n",dev->name,__func__);
3627 printk(KERN_INFO "%s: variable lock = %d, dev =\n",dev->name, lock);
3628 dumpit((char *) dev, sizeof(struct net_device));
3630 CLAW_DBF_TEXT(4,trace,"StRdNter");
3631 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3632 p_clawh->flag=CLAW_IDLE; /* 0x00 */
3634 if ((privptr->p_write_active_first!=NULL &&
3635 privptr->p_write_active_first->header.flag!=CLAW_PENDING) ||
3636 (privptr->p_read_active_first!=NULL &&
3637 privptr->p_read_active_first->header.flag!=CLAW_PENDING )) {
3638 p_clawh->flag=CLAW_BUSY; /* 0xff */
3641 printk(KERN_INFO "%s:%s state-%02x\n" ,
3642 dev->name,__func__, p_ch->claw_state);
3644 if (lock==LOCK_YES) {
3645 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
3647 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3649 printk(KERN_INFO "%s: HOT READ started in %s\n" ,
3650 dev->name,__func__);
3651 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3652 dumpit((char *)&p_clawh->flag , 1);
3654 CLAW_DBF_TEXT(4,trace,"HotRead");
3655 p_ccwbk=privptr->p_read_active_first;
3656 parm = (unsigned long) p_ch;
3657 rc = ccw_device_start (p_ch->cdev, &p_ccwbk->read, parm,
3660 ccw_check_return_code(p_ch->cdev, rc);
3665 printk(KERN_INFO "%s: No READ started by %s() In progress\n" ,
3666 dev->name,__func__);
3668 CLAW_DBF_TEXT(2,trace,"ReadAct");
3671 if (lock==LOCK_YES) {
3672 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
3675 printk(KERN_INFO "%s:%s Exit on line %d\n",
3676 dev->name,__func__,__LINE__);
3678 CLAW_DBF_TEXT(4,trace,"StRdExit");
3680 } /* end of claw_strt_read */
3682 /*-------------------------------------------------------------------*
3683 * claw_strt_out_IO *
3685 *--------------------------------------------------------------------*/
3688 claw_strt_out_IO( struct net_device *dev )
3692 struct claw_privbk *privptr;
3694 struct ccwbk *p_first_ccw;
3697 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3702 privptr=(struct claw_privbk *)dev->priv;
3703 p_ch=&privptr->channel[WRITE];
3706 printk(KERN_INFO "%s:%s state-%02x\n" ,
3707 dev->name,__func__,p_ch->claw_state);
3709 CLAW_DBF_TEXT(4,trace,"strt_io");
3710 p_first_ccw=privptr->p_write_active_first;
3712 if (p_ch->claw_state == CLAW_STOP)
3714 if (p_first_ccw == NULL) {
3716 printk(KERN_INFO "%s:%s Exit on line %d\n",
3717 dev->name,__func__,__LINE__);
3721 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3722 parm = (unsigned long) p_ch;
3724 printk(KERN_INFO "%s:%s do_io \n" ,dev->name,__func__);
3725 dumpit((char *)p_first_ccw, sizeof(struct ccwbk));
3727 CLAW_DBF_TEXT(2,trace,"StWrtIO");
3728 rc = ccw_device_start (p_ch->cdev,&p_first_ccw->write, parm,
3731 ccw_check_return_code(p_ch->cdev, rc);
3734 dev->trans_start = jiffies;
3736 printk(KERN_INFO "%s:%s Exit on line %d\n",
3737 dev->name,__func__,__LINE__);
3741 } /* end of claw_strt_out_IO */
3743 /*-------------------------------------------------------------------*
3744 * Free write buffers *
3746 *--------------------------------------------------------------------*/
3749 claw_free_wrt_buf( struct net_device *dev )
3752 struct claw_privbk *privptr=(struct claw_privbk *)dev->priv;
3753 struct ccwbk*p_first_ccw;
3754 struct ccwbk*p_last_ccw;
3755 struct ccwbk*p_this_ccw;
3756 struct ccwbk*p_next_ccw;
3761 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3762 printk(KERN_INFO "%s: free count = %d variable dev =\n",
3763 dev->name,privptr->write_free_count);
3765 CLAW_DBF_TEXT(4,trace,"freewrtb");
3766 /* scan the write queue to free any completed write packets */
3770 printk(KERN_INFO "%s: Dump current CCW chain \n",dev->name );
3771 p_buf=privptr->p_write_active_first;
3772 while (p_buf!=NULL) {
3773 dumpit((char *)p_buf, sizeof(struct ccwbk));
3777 printk(KERN_INFO "%s: privptr->p_write_"
3778 "active_first==NULL\n",dev->name );
3780 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3781 dumpit((char *)p_buf, sizeof(struct endccw));
3783 p_this_ccw=privptr->p_write_active_first;
3784 while ( (p_this_ccw!=NULL) && (p_this_ccw->header.flag!=CLAW_PENDING))
3786 p_next_ccw = p_this_ccw->next;
3787 if (((p_next_ccw!=NULL) &&
3788 (p_next_ccw->header.flag!=CLAW_PENDING)) ||
3789 ((p_this_ccw == privptr->p_write_active_last) &&
3790 (p_this_ccw->header.flag!=CLAW_PENDING))) {
3791 /* The next CCW is OK or this is */
3792 /* the last CCW...free it @A1A */
3793 privptr->p_write_active_first=p_this_ccw->next;
3794 p_this_ccw->header.flag=CLAW_PENDING;
3795 p_this_ccw->next=privptr->p_write_free_chain;
3796 privptr->p_write_free_chain=p_this_ccw;
3797 ++privptr->write_free_count;
3798 privptr->stats.tx_bytes+= p_this_ccw->write.count;
3799 p_this_ccw=privptr->p_write_active_first;
3800 privptr->stats.tx_packets++;
3806 if (privptr->write_free_count!=0) {
3807 claw_clearbit_busy(TB_NOBUFFER,dev);
3809 /* whole chain removed? */
3810 if (privptr->p_write_active_first==NULL) {
3811 privptr->p_write_active_last=NULL;
3813 printk(KERN_INFO "%s:%s p_write_"
3814 "active_first==NULL\n",dev->name,__func__);
3818 printk(KERN_INFO "%s: Dump arranged CCW chain \n",dev->name );
3819 p_buf=privptr->p_write_active_first;
3820 while (p_buf!=NULL) {
3821 dumpit((char *)p_buf, sizeof(struct ccwbk));
3825 printk(KERN_INFO "%s: privptr->p_write_active_"
3826 "first==NULL\n",dev->name );
3828 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3829 dumpit((char *)p_buf, sizeof(struct endccw));
3832 CLAW_DBF_TEXT_(4,trace,"FWC=%d",privptr->write_free_count);
3834 printk(KERN_INFO "%s:%s Exit on line %d free_count =%d\n",
3835 dev->name,__func__, __LINE__,privptr->write_free_count);
3840 /*-------------------------------------------------------------------*
3841 * claw free netdevice *
3843 *--------------------------------------------------------------------*/
3845 claw_free_netdevice(struct net_device * dev, int free_dev)
3847 struct claw_privbk *privptr;
3849 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3851 CLAW_DBF_TEXT(2,setup,"free_dev");
3855 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3856 privptr = dev->priv;
3857 if (dev->flags & IFF_RUNNING)
3860 privptr->channel[READ].ndev = NULL; /* say it's free */
3868 CLAW_DBF_TEXT(2,setup,"feee_ok");
3870 printk(KERN_INFO "%s:%s Exit\n",dev->name,__func__);
3875 * Claw init netdevice
3876 * Initialize everything of the net device except the name and the
3880 claw_init_netdevice(struct net_device * dev)
3883 printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
3885 CLAW_DBF_TEXT(2,setup,"init_dev");
3886 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3888 printk(KERN_WARNING "claw:%s BAD Device exit line %d\n",
3890 CLAW_DBF_TEXT(2,setup,"baddev");
3893 dev->mtu = CLAW_DEFAULT_MTU_SIZE;
3894 dev->hard_start_xmit = claw_tx;
3895 dev->open = claw_open;
3896 dev->stop = claw_release;
3897 dev->get_stats = claw_stats;
3898 dev->change_mtu = claw_change_mtu;
3899 dev->hard_header_len = 0;
3901 dev->type = ARPHRD_SLIP;
3902 dev->tx_queue_len = 1300;
3903 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
3905 printk(KERN_INFO "%s:%s Exit\n",dev->name,__func__);
3907 CLAW_DBF_TEXT(2,setup,"initok");
3912 * Init a new channel in the privptr->channel[i].
3914 * @param cdev The ccw_device to be added.
3916 * @return 0 on success, !0 on error.
3919 add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
3922 struct ccw_dev_id dev_id;
3925 printk(KERN_INFO "%s:%s Enter\n",cdev->dev.bus_id,__func__);
3927 CLAW_DBF_TEXT_(2,setup,"%s",cdev->dev.bus_id);
3928 privptr->channel[i].flag = i+1; /* Read is 1 Write is 2 */
3929 p_ch = &privptr->channel[i];
3931 snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id);
3932 ccw_device_get_id(cdev, &dev_id);
3933 p_ch->devno = dev_id.devno;
3934 if ((p_ch->irb = kzalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) {
3935 printk(KERN_WARNING "%s Out of memory in %s for irb\n",
3938 printk(KERN_INFO "%s:%s Exit on line %d\n",
3939 p_ch->id,__func__,__LINE__);
3944 printk(KERN_INFO "%s:%s Exit on line %d\n",
3945 cdev->dev.bus_id,__func__,__LINE__);
3953 * Setup an interface.
3955 * @param cgdev Device to be setup.
3957 * @returns 0 on success, !0 on failure.
3960 claw_new_device(struct ccwgroup_device *cgdev)
3962 struct claw_privbk *privptr;
3963 struct claw_env *p_env;
3964 struct net_device *dev;
3966 struct ccw_dev_id dev_id;
3968 pr_debug("%s() called\n", __func__);
3969 printk(KERN_INFO "claw: add for %s\n",cgdev->cdev[READ]->dev.bus_id);
3970 CLAW_DBF_TEXT(2,setup,"new_dev");
3971 privptr = cgdev->dev.driver_data;
3972 cgdev->cdev[READ]->dev.driver_data = privptr;
3973 cgdev->cdev[WRITE]->dev.driver_data = privptr;
3976 p_env = privptr->p_env;
3977 ccw_device_get_id(cgdev->cdev[READ], &dev_id);
3978 p_env->devno[READ] = dev_id.devno;
3979 ccw_device_get_id(cgdev->cdev[WRITE], &dev_id);
3980 p_env->devno[WRITE] = dev_id.devno;
3981 ret = add_channel(cgdev->cdev[0],0,privptr);
3983 ret = add_channel(cgdev->cdev[1],1,privptr);
3986 "add channel failed "
3987 "with ret = %d\n", ret);
3990 ret = ccw_device_set_online(cgdev->cdev[READ]);
3993 "claw: ccw_device_set_online %s READ failed "
3994 "with ret = %d\n",cgdev->cdev[READ]->dev.bus_id,ret);
3997 ret = ccw_device_set_online(cgdev->cdev[WRITE]);
4000 "claw: ccw_device_set_online %s WRITE failed "
4001 "with ret = %d\n",cgdev->cdev[WRITE]->dev.bus_id, ret);
4004 dev = alloc_netdev(0,"claw%d",claw_init_netdevice);
4006 printk(KERN_WARNING "%s:alloc_netdev failed\n",__func__);
4009 dev->priv = privptr;
4010 cgdev->dev.driver_data = privptr;
4011 cgdev->cdev[READ]->dev.driver_data = privptr;
4012 cgdev->cdev[WRITE]->dev.driver_data = privptr;
4014 SET_NETDEV_DEV(dev, &cgdev->dev);
4015 if (register_netdev(dev) != 0) {
4016 claw_free_netdevice(dev, 1);
4017 CLAW_DBF_TEXT(2,trace,"regfail");
4020 dev->flags &=~IFF_RUNNING;
4021 if (privptr->buffs_alloc == 0) {
4022 ret=init_ccw_bk(dev);
4025 "claw: init_ccw_bk failed with ret=%d\n", ret);
4026 unregister_netdev(dev);
4027 claw_free_netdevice(dev,1);
4028 CLAW_DBF_TEXT(2,trace,"ccwmem");
4032 privptr->channel[READ].ndev = dev;
4033 privptr->channel[WRITE].ndev = dev;
4034 privptr->p_env->ndev = dev;
4036 printk(KERN_INFO "%s:readsize=%d writesize=%d "
4037 "readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
4038 dev->name, p_env->read_size,
4039 p_env->write_size, p_env->read_buffers,
4040 p_env->write_buffers, p_env->devno[READ],
4041 p_env->devno[WRITE]);
4042 printk(KERN_INFO "%s:host_name:%.8s, adapter_name "
4043 ":%.8s api_type: %.8s\n",
4044 dev->name, p_env->host_name,
4045 p_env->adapter_name , p_env->api_type);
4048 ccw_device_set_offline(cgdev->cdev[1]);
4049 ccw_device_set_offline(cgdev->cdev[0]);
4055 claw_purge_skb_queue(struct sk_buff_head *q)
4057 struct sk_buff *skb;
4059 CLAW_DBF_TEXT(4,trace,"purgque");
4061 while ((skb = skb_dequeue(q))) {
4062 atomic_dec(&skb->users);
4063 dev_kfree_skb_any(skb);
4068 * Shutdown an interface.
4070 * @param cgdev Device to be shut down.
4072 * @returns 0 on success, !0 on failure.
4075 claw_shutdown_device(struct ccwgroup_device *cgdev)
4077 struct claw_privbk *priv;
4078 struct net_device *ndev;
4081 pr_debug("%s() called\n", __func__);
4082 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4083 priv = cgdev->dev.driver_data;
4086 ndev = priv->channel[READ].ndev;
4088 /* Close the device */
4090 "%s: shuting down \n",ndev->name);
4091 if (ndev->flags & IFF_RUNNING)
4092 ret = claw_release(ndev);
4093 ndev->flags &=~IFF_RUNNING;
4094 unregister_netdev(ndev);
4095 ndev->priv = NULL; /* cgdev data, not ndev's to free */
4096 claw_free_netdevice(ndev, 1);
4097 priv->channel[READ].ndev = NULL;
4098 priv->channel[WRITE].ndev = NULL;
4099 priv->p_env->ndev = NULL;
4101 ccw_device_set_offline(cgdev->cdev[1]);
4102 ccw_device_set_offline(cgdev->cdev[0]);
4107 claw_remove_device(struct ccwgroup_device *cgdev)
4109 struct claw_privbk *priv;
4111 pr_debug("%s() called\n", __func__);
4112 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4113 priv = cgdev->dev.driver_data;
4115 printk(KERN_WARNING "claw: %s() no Priv exiting\n",__func__);
4118 printk(KERN_INFO "claw: %s() called %s will be removed.\n",
4119 __func__,cgdev->cdev[0]->dev.bus_id);
4120 if (cgdev->state == CCWGROUP_ONLINE)
4121 claw_shutdown_device(cgdev);
4122 claw_remove_files(&cgdev->dev);
4123 kfree(priv->p_mtc_envelope);
4124 priv->p_mtc_envelope=NULL;
4127 kfree(priv->channel[0].irb);
4128 priv->channel[0].irb=NULL;
4129 kfree(priv->channel[1].irb);
4130 priv->channel[1].irb=NULL;
4132 cgdev->dev.driver_data=NULL;
4133 cgdev->cdev[READ]->dev.driver_data = NULL;
4134 cgdev->cdev[WRITE]->dev.driver_data = NULL;
4135 put_device(&cgdev->dev);
4143 claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
4145 struct claw_privbk *priv;
4146 struct claw_env * p_env;
4148 priv = dev->driver_data;
4151 p_env = priv->p_env;
4152 return sprintf(buf, "%s\n",p_env->host_name);
4156 claw_hname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4158 struct claw_privbk *priv;
4159 struct claw_env * p_env;
4161 priv = dev->driver_data;
4164 p_env = priv->p_env;
4165 if (count > MAX_NAME_LEN+1)
4167 memset(p_env->host_name, 0x20, MAX_NAME_LEN);
4168 strncpy(p_env->host_name,buf, count);
4169 p_env->host_name[count-1] = 0x20; /* clear extra 0x0a */
4170 p_env->host_name[MAX_NAME_LEN] = 0x00;
4171 CLAW_DBF_TEXT(2,setup,"HstnSet");
4172 CLAW_DBF_TEXT_(2,setup,"%s",p_env->host_name);
4177 static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write);
4180 claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
4182 struct claw_privbk *priv;
4183 struct claw_env * p_env;
4185 priv = dev->driver_data;
4188 p_env = priv->p_env;
4189 return sprintf(buf, "%s\n",p_env->adapter_name);
4193 claw_adname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4195 struct claw_privbk *priv;
4196 struct claw_env * p_env;
4198 priv = dev->driver_data;
4201 p_env = priv->p_env;
4202 if (count > MAX_NAME_LEN+1)
4204 memset(p_env->adapter_name, 0x20, MAX_NAME_LEN);
4205 strncpy(p_env->adapter_name,buf, count);
4206 p_env->adapter_name[count-1] = 0x20; /* clear extra 0x0a */
4207 p_env->adapter_name[MAX_NAME_LEN] = 0x00;
4208 CLAW_DBF_TEXT(2,setup,"AdnSet");
4209 CLAW_DBF_TEXT_(2,setup,"%s",p_env->adapter_name);
4214 static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write);
4217 claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
4219 struct claw_privbk *priv;
4220 struct claw_env * p_env;
4222 priv = dev->driver_data;
4225 p_env = priv->p_env;
4226 return sprintf(buf, "%s\n",
4231 claw_apname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4233 struct claw_privbk *priv;
4234 struct claw_env * p_env;
4236 priv = dev->driver_data;
4239 p_env = priv->p_env;
4240 if (count > MAX_NAME_LEN+1)
4242 memset(p_env->api_type, 0x20, MAX_NAME_LEN);
4243 strncpy(p_env->api_type,buf, count);
4244 p_env->api_type[count-1] = 0x20; /* we get a loose 0x0a */
4245 p_env->api_type[MAX_NAME_LEN] = 0x00;
4246 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
4247 p_env->read_size=DEF_PACK_BUFSIZE;
4248 p_env->write_size=DEF_PACK_BUFSIZE;
4249 p_env->packing=PACKING_ASK;
4250 CLAW_DBF_TEXT(2,setup,"PACKING");
4254 p_env->read_size=CLAW_FRAME_SIZE;
4255 p_env->write_size=CLAW_FRAME_SIZE;
4256 CLAW_DBF_TEXT(2,setup,"ApiSet");
4258 CLAW_DBF_TEXT_(2,setup,"%s",p_env->api_type);
4262 static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write);
4265 claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4267 struct claw_privbk *priv;
4268 struct claw_env * p_env;
4270 priv = dev->driver_data;
4273 p_env = priv->p_env;
4274 return sprintf(buf, "%d\n", p_env->write_buffers);
4278 claw_wbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4280 struct claw_privbk *priv;
4281 struct claw_env * p_env;
4284 priv = dev->driver_data;
4287 p_env = priv->p_env;
4288 sscanf(buf, "%i", &nnn);
4289 if (p_env->packing) {
4295 if ((nnn > max ) || (nnn < 2))
4297 p_env->write_buffers = nnn;
4298 CLAW_DBF_TEXT(2,setup,"Wbufset");
4299 CLAW_DBF_TEXT_(2,setup,"WB=%d",p_env->write_buffers);
4303 static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write);
4306 claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4308 struct claw_privbk *priv;
4309 struct claw_env * p_env;
4311 priv = dev->driver_data;
4314 p_env = priv->p_env;
4315 return sprintf(buf, "%d\n", p_env->read_buffers);
4319 claw_rbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4321 struct claw_privbk *priv;
4322 struct claw_env *p_env;
4325 priv = dev->driver_data;
4328 p_env = priv->p_env;
4329 sscanf(buf, "%i", &nnn);
4330 if (p_env->packing) {
4336 if ((nnn > max ) || (nnn < 2))
4338 p_env->read_buffers = nnn;
4339 CLAW_DBF_TEXT(2,setup,"Rbufset");
4340 CLAW_DBF_TEXT_(2,setup,"RB=%d",p_env->read_buffers);
4344 static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write);
4346 static struct attribute *claw_attr[] = {
4347 &dev_attr_read_buffer.attr,
4348 &dev_attr_write_buffer.attr,
4349 &dev_attr_adapter_name.attr,
4350 &dev_attr_api_type.attr,
4351 &dev_attr_host_name.attr,
4355 static struct attribute_group claw_attr_group = {
4360 claw_add_files(struct device *dev)
4362 pr_debug("%s() called\n", __func__);
4363 CLAW_DBF_TEXT(2,setup,"add_file");
4364 return sysfs_create_group(&dev->kobj, &claw_attr_group);
4368 claw_remove_files(struct device *dev)
4370 pr_debug("%s() called\n", __func__);
4371 CLAW_DBF_TEXT(2,setup,"rem_file");
4372 sysfs_remove_group(&dev->kobj, &claw_attr_group);
4375 /*--------------------------------------------------------------------*
4376 * claw_init and cleanup *
4377 *---------------------------------------------------------------------*/
4382 unregister_cu3088_discipline(&claw_group_driver);
4383 claw_unregister_debug_facility();
4384 printk(KERN_INFO "claw: Driver unloaded\n");
4389 * Initialize module.
4390 * This is called just after the module is loaded.
4392 * @return 0 on success, !0 on error.
4398 printk(KERN_INFO "claw: starting driver\n");
4401 printk(KERN_INFO "claw: %s() enter \n",__func__);
4403 ret = claw_register_debug_facility();
4405 printk(KERN_WARNING "claw: %s() debug_register failed %d\n",
4409 CLAW_DBF_TEXT(2,setup,"init_mod");
4410 ret = register_cu3088_discipline(&claw_group_driver);
4412 claw_unregister_debug_facility();
4413 printk(KERN_WARNING "claw; %s() cu3088 register failed %d\n",
4417 printk(KERN_INFO "claw: %s() exit \n",__func__);
4422 module_init(claw_init);
4423 module_exit(claw_cleanup);
4427 /*--------------------------------------------------------------------*
4429 *---------------------------------------------------------------------*/