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/bitops.h>
63 #include <asm/ccwdev.h>
64 #include <asm/ccwgroup.h>
65 #include <asm/debug.h>
66 #include <asm/idals.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 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 inline ccw_check_return_code (struct ccw_device *cdev,
228 static void inline ccw_check_unit_check (struct chbk * p_ch,
229 unsigned char sense );
230 static int find_link(struct net_device *dev, char *host_name, char *ws_name );
231 static int claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid);
232 static int init_ccw_bk(struct net_device *dev);
233 static void probe_error( struct ccwgroup_device *cgdev);
234 static struct net_device_stats *claw_stats(struct net_device *dev);
235 static int inline pages_to_order_of_mag(int num_of_pages);
236 static struct sk_buff *claw_pack_skb(struct claw_privbk *privptr);
238 static void dumpit (char *buf, int len);
240 /* sysfs Functions */
241 static ssize_t claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf);
242 static ssize_t claw_hname_write(struct device *dev, struct device_attribute *attr,
243 const char *buf, size_t count);
244 static ssize_t claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf);
245 static ssize_t claw_adname_write(struct device *dev, struct device_attribute *attr,
246 const char *buf, size_t count);
247 static ssize_t claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf);
248 static ssize_t claw_apname_write(struct device *dev, struct device_attribute *attr,
249 const char *buf, size_t count);
250 static ssize_t claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
251 static ssize_t claw_wbuff_write(struct device *dev, struct device_attribute *attr,
252 const char *buf, size_t count);
253 static ssize_t claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
254 static ssize_t claw_rbuff_write(struct device *dev, struct device_attribute *attr,
255 const char *buf, size_t count);
256 static int claw_add_files(struct device *dev);
257 static void claw_remove_files(struct device *dev);
259 /* Functions for System Validate */
260 static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw);
261 static int claw_send_control(struct net_device *dev, __u8 type, __u8 link,
262 __u8 correlator, __u8 rc , char *local_name, char *remote_name);
263 static int claw_snd_conn_req(struct net_device *dev, __u8 link);
264 static int claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl);
265 static int claw_snd_sys_validate_rsp(struct net_device *dev,
266 struct clawctl * p_ctl, __u32 return_code);
267 static int claw_strt_conn_req(struct net_device *dev );
268 static void claw_strt_read ( struct net_device *dev, int lock );
269 static void claw_strt_out_IO( struct net_device *dev );
270 static void claw_free_wrt_buf( struct net_device *dev );
272 /* Functions for unpack reads */
273 static void unpack_read (struct net_device *dev );
277 static struct ccwgroup_driver claw_group_driver = {
278 .owner = THIS_MODULE,
281 .driver_id = 0xC3D3C1E6,
283 .remove = claw_remove_device,
284 .set_online = claw_new_device,
285 .set_offline = claw_shutdown_device,
293 /*----------------------------------------------------------------*
295 * this function is called for each CLAW device. *
296 *----------------------------------------------------------------*/
298 claw_probe(struct ccwgroup_device *cgdev)
301 struct claw_privbk *privptr=NULL;
304 printk(KERN_INFO "%s Enter\n",__FUNCTION__);
306 CLAW_DBF_TEXT(2,setup,"probe");
307 if (!get_device(&cgdev->dev))
310 printk(KERN_INFO "claw: variable cgdev =\n");
311 dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
313 privptr = kmalloc(sizeof(struct claw_privbk), GFP_KERNEL);
314 if (privptr == NULL) {
316 put_device(&cgdev->dev);
317 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
318 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
319 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
322 memset(privptr,0x00,sizeof(struct claw_privbk));
323 privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
324 privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL);
325 if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
327 put_device(&cgdev->dev);
328 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
329 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
330 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
333 memset(privptr->p_mtc_envelope, 0x00, MAX_ENVELOPE_SIZE);
334 memset(privptr->p_env, 0x00, sizeof(struct claw_env));
335 memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
336 memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
337 memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
338 privptr->p_env->packing = 0;
339 privptr->p_env->write_buffers = 5;
340 privptr->p_env->read_buffers = 5;
341 privptr->p_env->read_size = CLAW_FRAME_SIZE;
342 privptr->p_env->write_size = CLAW_FRAME_SIZE;
343 rc = claw_add_files(&cgdev->dev);
346 put_device(&cgdev->dev);
347 printk(KERN_WARNING "add_files failed %s %s Exit Line %d \n",
348 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
349 CLAW_DBF_TEXT_(2,setup,"probex%d",rc);
352 printk(KERN_INFO "claw: sysfs files added for %s\n",cgdev->cdev[0]->dev.bus_id);
353 privptr->p_env->p_priv = privptr;
354 cgdev->cdev[0]->handler = claw_irq_handler;
355 cgdev->cdev[1]->handler = claw_irq_handler;
356 cgdev->dev.driver_data = privptr;
358 printk(KERN_INFO "claw:%s exit on line %d, "
359 "rc = 0\n",__FUNCTION__,__LINE__);
361 CLAW_DBF_TEXT(2,setup,"prbext 0");
364 } /* end of claw_probe */
366 /*-------------------------------------------------------------------*
368 *-------------------------------------------------------------------*/
371 claw_tx(struct sk_buff *skb, struct net_device *dev)
374 struct claw_privbk *privptr=dev->priv;
375 unsigned long saveflags;
379 printk(KERN_INFO "%s:%s enter\n",dev->name,__FUNCTION__);
381 CLAW_DBF_TEXT(4,trace,"claw_tx");
382 p_ch=&privptr->channel[WRITE];
384 printk(KERN_WARNING "%s: null pointer passed as sk_buffer\n",
386 privptr->stats.tx_dropped++;
388 printk(KERN_INFO "%s: %s() exit on line %d, rc = EIO\n",
389 dev->name,__FUNCTION__, __LINE__);
391 CLAW_DBF_TEXT_(2,trace,"clawtx%d",-EIO);
396 printk(KERN_INFO "%s: variable sk_buff=\n",dev->name);
397 dumpit((char *) skb, sizeof(struct sk_buff));
398 printk(KERN_INFO "%s: variable dev=\n",dev->name);
399 dumpit((char *) dev, sizeof(struct net_device));
401 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
402 rc=claw_hw_tx( skb, dev, 1 );
403 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
405 printk(KERN_INFO "%s:%s exit on line %d, rc = %d\n",
406 dev->name, __FUNCTION__, __LINE__, rc);
408 CLAW_DBF_TEXT_(4,trace,"clawtx%d",rc);
410 } /* end of claw_tx */
412 /*------------------------------------------------------------------*
413 * pack the collect queue into an skb and return it *
414 * If not packing just return the top skb from the queue *
415 *------------------------------------------------------------------*/
417 static struct sk_buff *
418 claw_pack_skb(struct claw_privbk *privptr)
420 struct sk_buff *new_skb,*held_skb;
421 struct chbk *p_ch = &privptr->channel[WRITE];
422 struct claw_env *p_env = privptr->p_env;
423 int pkt_cnt,pk_ind,so_far;
425 new_skb = NULL; /* assume no dice */
427 CLAW_DBF_TEXT(4,trace,"PackSKBe");
428 if (!skb_queue_empty(&p_ch->collect_queue)) {
430 held_skb = skb_dequeue(&p_ch->collect_queue);
432 dev_kfree_skb_any(held_skb);
435 if (p_env->packing != DO_PACKED)
437 /* get a new SKB we will pack at least one */
438 new_skb = dev_alloc_skb(p_env->write_size);
439 if (new_skb == NULL) {
440 atomic_inc(&held_skb->users);
441 skb_queue_head(&p_ch->collect_queue,held_skb);
444 /* we have packed packet and a place to put it */
447 new_skb->cb[1] = 'P'; /* every skb on queue has pack header */
448 while ((pk_ind) && (held_skb != NULL)) {
449 if (held_skb->len+so_far <= p_env->write_size-8) {
450 memcpy(skb_put(new_skb,held_skb->len),
451 held_skb->data,held_skb->len);
452 privptr->stats.tx_packets++;
453 so_far += held_skb->len;
455 dev_kfree_skb_any(held_skb);
456 held_skb = skb_dequeue(&p_ch->collect_queue);
458 atomic_dec(&held_skb->users);
461 atomic_inc(&held_skb->users);
462 skb_queue_head(&p_ch->collect_queue,held_skb);
466 printk(KERN_INFO "%s: %s() Packed %d len %d\n",
468 __FUNCTION__,pkt_cnt,new_skb->len);
471 CLAW_DBF_TEXT(4,trace,"PackSKBx");
475 /*-------------------------------------------------------------------*
478 *-------------------------------------------------------------------*/
481 claw_change_mtu(struct net_device *dev, int new_mtu)
483 struct claw_privbk *privptr=dev->priv;
486 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
489 printk(KERN_INFO "variable dev =\n");
490 dumpit((char *) dev, sizeof(struct net_device));
491 printk(KERN_INFO "variable new_mtu = %d\n", new_mtu);
493 CLAW_DBF_TEXT(4,trace,"setmtu");
494 buff_size = privptr->p_env->write_size;
495 if ((new_mtu < 60) || (new_mtu > buff_size)) {
497 printk(KERN_INFO "%s:%s Exit on line %d, rc=EINVAL\n",
499 __FUNCTION__, __LINE__);
505 printk(KERN_INFO "%s:%s Exit on line %d\n",dev->name,
506 __FUNCTION__, __LINE__);
509 } /* end of claw_change_mtu */
512 /*-------------------------------------------------------------------*
515 *-------------------------------------------------------------------*/
517 claw_open(struct net_device *dev)
522 unsigned long saveflags=0;
524 struct claw_privbk *privptr;
525 DECLARE_WAITQUEUE(wait, current);
526 struct timer_list timer;
530 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
532 CLAW_DBF_TEXT(4,trace,"open");
533 if (!dev | (dev->name[0] == 0x00)) {
534 CLAW_DBF_TEXT(2,trace,"BadDev");
535 printk(KERN_WARNING "claw: Bad device at open failing \n");
538 privptr = (struct claw_privbk *)dev->priv;
539 /* allocate and initialize CCW blocks */
540 if (privptr->buffs_alloc == 0) {
543 printk(KERN_INFO "%s:%s Exit on line %d, rc=ENOMEM\n",
545 __FUNCTION__, __LINE__);
546 CLAW_DBF_TEXT(2,trace,"openmem");
550 privptr->system_validate_comp=0;
551 privptr->release_pend=0;
552 if(strncmp(privptr->p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
553 privptr->p_env->read_size=DEF_PACK_BUFSIZE;
554 privptr->p_env->write_size=DEF_PACK_BUFSIZE;
555 privptr->p_env->packing=PACKING_ASK;
557 privptr->p_env->packing=0;
558 privptr->p_env->read_size=CLAW_FRAME_SIZE;
559 privptr->p_env->write_size=CLAW_FRAME_SIZE;
562 tasklet_init(&privptr->channel[READ].tasklet, claw_irq_tasklet,
563 (unsigned long) &privptr->channel[READ]);
564 for ( i = 0; i < 2; i++) {
565 CLAW_DBF_TEXT_(2,trace,"opn_ch%d",i);
566 init_waitqueue_head(&privptr->channel[i].wait);
567 /* skb_queue_head_init(&p_ch->io_queue); */
570 &privptr->channel[WRITE].collect_queue);
571 privptr->channel[i].flag_a = 0;
572 privptr->channel[i].IO_active = 0;
573 privptr->channel[i].flag &= ~CLAW_TIMER;
575 timer.function = (void *)claw_timer;
576 timer.data = (unsigned long)(&privptr->channel[i]);
577 timer.expires = jiffies + 15*HZ;
579 spin_lock_irqsave(get_ccwdev_lock(
580 privptr->channel[i].cdev), saveflags);
581 parm = (unsigned long) &privptr->channel[i];
582 privptr->channel[i].claw_state = CLAW_START_HALT_IO;
584 add_wait_queue(&privptr->channel[i].wait, &wait);
585 rc = ccw_device_halt(
586 (struct ccw_device *)privptr->channel[i].cdev,parm);
587 set_current_state(TASK_INTERRUPTIBLE);
588 spin_unlock_irqrestore(
589 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
591 set_current_state(TASK_RUNNING);
592 remove_wait_queue(&privptr->channel[i].wait, &wait);
594 ccw_check_return_code(privptr->channel[i].cdev, rc);
595 if((privptr->channel[i].flag & CLAW_TIMER) == 0x00)
598 if ((((privptr->channel[READ].last_dstat |
599 privptr->channel[WRITE].last_dstat) &
600 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) ||
601 (((privptr->channel[READ].flag |
602 privptr->channel[WRITE].flag) & CLAW_TIMER) != 0x00)) {
604 printk(KERN_INFO "%s: channel problems during open - read:"
605 " %02x - write: %02x\n",
607 privptr->channel[READ].last_dstat,
608 privptr->channel[WRITE].last_dstat);
610 printk(KERN_INFO "%s: remote side is not ready\n", dev->name);
611 CLAW_DBF_TEXT(2,trace,"notrdy");
613 for ( i = 0; i < 2; i++) {
615 get_ccwdev_lock(privptr->channel[i].cdev),
617 parm = (unsigned long) &privptr->channel[i];
618 privptr->channel[i].claw_state = CLAW_STOP;
619 rc = ccw_device_halt(
620 (struct ccw_device *)&privptr->channel[i].cdev,
622 spin_unlock_irqrestore(
623 get_ccwdev_lock(privptr->channel[i].cdev),
626 ccw_check_return_code(
627 privptr->channel[i].cdev, rc);
630 free_pages((unsigned long)privptr->p_buff_ccw,
631 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
632 if (privptr->p_env->read_size < PAGE_SIZE) {
633 free_pages((unsigned long)privptr->p_buff_read,
634 (int)pages_to_order_of_mag(
635 privptr->p_buff_read_num));
638 p_buf=privptr->p_read_active_first;
639 while (p_buf!=NULL) {
640 free_pages((unsigned long)p_buf->p_buffer,
641 (int)pages_to_order_of_mag(
642 privptr->p_buff_pages_perread ));
646 if (privptr->p_env->write_size < PAGE_SIZE ) {
647 free_pages((unsigned long)privptr->p_buff_write,
648 (int)pages_to_order_of_mag(
649 privptr->p_buff_write_num));
652 p_buf=privptr->p_write_active_first;
653 while (p_buf!=NULL) {
654 free_pages((unsigned long)p_buf->p_buffer,
655 (int)pages_to_order_of_mag(
656 privptr->p_buff_pages_perwrite ));
660 privptr->buffs_alloc = 0;
661 privptr->channel[READ].flag= 0x00;
662 privptr->channel[WRITE].flag = 0x00;
663 privptr->p_buff_ccw=NULL;
664 privptr->p_buff_read=NULL;
665 privptr->p_buff_write=NULL;
666 claw_clear_busy(dev);
668 printk(KERN_INFO "%s:%s Exit on line %d, rc=EIO\n",
669 dev->name,__FUNCTION__,__LINE__);
671 CLAW_DBF_TEXT(2,trace,"open EIO");
675 /* Send SystemValidate command */
677 claw_clear_busy(dev);
680 printk(KERN_INFO "%s:%s Exit on line %d, rc=0\n",
681 dev->name,__FUNCTION__,__LINE__);
683 CLAW_DBF_TEXT(4,trace,"openok");
685 } /* end of claw_open */
687 /*-------------------------------------------------------------------*
691 *--------------------------------------------------------------------*/
693 claw_irq_handler(struct ccw_device *cdev,
694 unsigned long intparm, struct irb *irb)
696 struct chbk *p_ch = NULL;
697 struct claw_privbk *privptr = NULL;
698 struct net_device *dev = NULL;
699 struct claw_env *p_env;
700 struct chbk *p_ch_r=NULL;
704 printk(KERN_INFO "%s enter \n",__FUNCTION__);
706 CLAW_DBF_TEXT(4,trace,"clawirq");
707 /* Bypass all 'unsolicited interrupts' */
708 if (!cdev->dev.driver_data) {
709 printk(KERN_WARNING "claw: unsolicited interrupt for device:"
710 "%s received c-%02x d-%02x\n",
711 cdev->dev.bus_id,irb->scsw.cstat, irb->scsw.dstat);
713 printk(KERN_INFO "claw: %s() "
714 "exit on line %d\n",__FUNCTION__,__LINE__);
716 CLAW_DBF_TEXT(2,trace,"badirq");
719 privptr = (struct claw_privbk *)cdev->dev.driver_data;
721 /* Try to extract channel from driver data. */
722 if (privptr->channel[READ].cdev == cdev)
723 p_ch = &privptr->channel[READ];
724 else if (privptr->channel[WRITE].cdev == cdev)
725 p_ch = &privptr->channel[WRITE];
727 printk(KERN_WARNING "claw: Can't determine channel for "
728 "interrupt, device %s\n", cdev->dev.bus_id);
729 CLAW_DBF_TEXT(2,trace,"badchan");
732 CLAW_DBF_TEXT_(4,trace,"IRQCH=%d",p_ch->flag);
734 dev = (struct net_device *) (p_ch->ndev);
735 p_env=privptr->p_env;
738 printk(KERN_INFO "%s: interrupt for device: %04x "
739 "received c-%02x d-%02x state-%02x\n",
740 dev->name, p_ch->devno, irb->scsw.cstat,
741 irb->scsw.dstat, p_ch->claw_state);
744 /* Copy interruption response block. */
745 memcpy(p_ch->irb, irb, sizeof(struct irb));
747 /* Check for good subchannel return code, otherwise error message */
748 if (irb->scsw.cstat && !(irb->scsw.cstat & SCHN_STAT_PCI)) {
749 printk(KERN_INFO "%s: subchannel check for device: %04x -"
750 " Sch Stat %02x Dev Stat %02x CPA - %04x\n",
751 dev->name, p_ch->devno,
752 irb->scsw.cstat, irb->scsw.dstat,irb->scsw.cpa);
754 dumpit((char *)irb,sizeof(struct irb));
755 dumpit((char *)(unsigned long)irb->scsw.cpa,
756 sizeof(struct ccw1));
759 printk(KERN_INFO "%s:%s Exit on line %d\n",
760 dev->name,__FUNCTION__,__LINE__);
762 CLAW_DBF_TEXT(2,trace,"chanchk");
766 /* Check the reason-code of a unit check */
767 if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
768 ccw_check_unit_check(p_ch, irb->ecw[0]);
771 /* State machine to bring the connection up, down and to restart */
772 p_ch->last_dstat = irb->scsw.dstat;
774 switch (p_ch->claw_state) {
775 case CLAW_STOP:/* HALT_IO by claw_release (halt sequence) */
777 printk(KERN_INFO "%s: CLAW_STOP enter\n", dev->name);
779 if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
780 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
781 (p_ch->irb->scsw.stctl ==
782 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
784 printk(KERN_INFO "%s:%s Exit on line %d\n",
785 dev->name,__FUNCTION__,__LINE__);
789 wake_up(&p_ch->wait); /* wake up claw_release */
792 printk(KERN_INFO "%s: CLAW_STOP exit\n", dev->name);
795 printk(KERN_INFO "%s:%s Exit on line %d\n",
796 dev->name,__FUNCTION__,__LINE__);
798 CLAW_DBF_TEXT(4,trace,"stop");
801 case CLAW_START_HALT_IO: /* HALT_IO issued by claw_open */
803 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO\n",
806 if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
807 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
808 (p_ch->irb->scsw.stctl ==
809 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
811 printk(KERN_INFO "%s:%s Exit on line %d\n",
812 dev->name,__FUNCTION__,__LINE__);
814 CLAW_DBF_TEXT(4,trace,"haltio");
817 if (p_ch->flag == CLAW_READ) {
818 p_ch->claw_state = CLAW_START_READ;
819 wake_up(&p_ch->wait); /* wake claw_open (READ)*/
822 if (p_ch->flag == CLAW_WRITE) {
823 p_ch->claw_state = CLAW_START_WRITE;
824 /* send SYSTEM_VALIDATE */
825 claw_strt_read(dev, LOCK_NO);
826 claw_send_control(dev,
827 SYSTEM_VALIDATE_REQUEST,
830 p_env->adapter_name );
832 printk(KERN_WARNING "claw: unsolicited "
833 "interrupt for device:"
834 "%s received c-%02x d-%02x\n",
841 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO exit\n",
845 printk(KERN_INFO "%s:%s Exit on line %d\n",
846 dev->name,__FUNCTION__,__LINE__);
848 CLAW_DBF_TEXT(4,trace,"haltio");
850 case CLAW_START_READ:
851 CLAW_DBF_TEXT(4,trace,"ReadIRQ");
852 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
853 clear_bit(0, (void *)&p_ch->IO_active);
854 if ((p_ch->irb->ecw[0] & 0x41) == 0x41 ||
855 (p_ch->irb->ecw[0] & 0x40) == 0x40 ||
856 (p_ch->irb->ecw[0]) == 0)
858 privptr->stats.rx_errors++;
859 printk(KERN_INFO "%s: Restart is "
860 "required after remote "
865 printk(KERN_INFO "%s:%s Exit on line %d\n",
866 dev->name,__FUNCTION__,__LINE__);
868 CLAW_DBF_TEXT(4,trace,"notrdy");
871 if ((p_ch->irb->scsw.cstat & SCHN_STAT_PCI) &&
872 (p_ch->irb->scsw.dstat==0)) {
873 if (test_and_set_bit(CLAW_BH_ACTIVE,
874 (void *)&p_ch->flag_a) == 0) {
875 tasklet_schedule(&p_ch->tasklet);
878 CLAW_DBF_TEXT(4,trace,"PCINoBH");
881 printk(KERN_INFO "%s:%s Exit on line %d\n",
882 dev->name,__FUNCTION__,__LINE__);
884 CLAW_DBF_TEXT(4,trace,"PCI_read");
887 if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
888 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
889 (p_ch->irb->scsw.stctl ==
890 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
892 printk(KERN_INFO "%s:%s Exit on line %d\n",
893 dev->name,__FUNCTION__,__LINE__);
895 CLAW_DBF_TEXT(4,trace,"SPend_rd");
898 clear_bit(0, (void *)&p_ch->IO_active);
899 claw_clearbit_busy(TB_RETRY,dev);
900 if (test_and_set_bit(CLAW_BH_ACTIVE,
901 (void *)&p_ch->flag_a) == 0) {
902 tasklet_schedule(&p_ch->tasklet);
905 CLAW_DBF_TEXT(4,trace,"RdBHAct");
909 printk(KERN_INFO "%s: process CLAW_START_READ exit\n",
913 printk(KERN_INFO "%s:%s Exit on line %d\n",
914 dev->name,__FUNCTION__,__LINE__);
916 CLAW_DBF_TEXT(4,trace,"RdIRQXit");
918 case CLAW_START_WRITE:
919 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
920 printk(KERN_INFO "%s: Unit Check Occured in "
921 "write channel\n",dev->name);
922 clear_bit(0, (void *)&p_ch->IO_active);
923 if (p_ch->irb->ecw[0] & 0x80 ) {
924 printk(KERN_INFO "%s: Resetting Event "
925 "occurred:\n",dev->name);
926 init_timer(&p_ch->timer);
927 p_ch->timer.function =
928 (void *)claw_write_retry;
929 p_ch->timer.data = (unsigned long)p_ch;
930 p_ch->timer.expires = jiffies + 10*HZ;
931 add_timer(&p_ch->timer);
932 printk(KERN_INFO "%s: write connection "
933 "restarting\n",dev->name);
936 printk(KERN_INFO "%s:%s Exit on line %d\n",
937 dev->name,__FUNCTION__,__LINE__);
939 CLAW_DBF_TEXT(4,trace,"rstrtwrt");
942 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) {
943 clear_bit(0, (void *)&p_ch->IO_active);
944 printk(KERN_INFO "%s: Unit Exception "
945 "Occured in write channel\n",
948 if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
949 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
950 (p_ch->irb->scsw.stctl ==
951 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
953 printk(KERN_INFO "%s:%s Exit on line %d\n",
954 dev->name,__FUNCTION__,__LINE__);
956 CLAW_DBF_TEXT(4,trace,"writeUE");
959 clear_bit(0, (void *)&p_ch->IO_active);
960 if (claw_test_and_setbit_busy(TB_TX,dev)==0) {
961 claw_write_next(p_ch);
962 claw_clearbit_busy(TB_TX,dev);
963 claw_clear_busy(dev);
965 p_ch_r=(struct chbk *)&privptr->channel[READ];
966 if (test_and_set_bit(CLAW_BH_ACTIVE,
967 (void *)&p_ch_r->flag_a) == 0) {
968 tasklet_schedule(&p_ch_r->tasklet);
972 printk(KERN_INFO "%s: process CLAW_START_WRITE exit\n",
976 printk(KERN_INFO "%s:%s Exit on line %d\n",
977 dev->name,__FUNCTION__,__LINE__);
979 CLAW_DBF_TEXT(4,trace,"StWtExit");
982 printk(KERN_WARNING "%s: wrong selection code - irq "
983 "state=%d\n",dev->name,p_ch->claw_state);
985 printk(KERN_INFO "%s:%s Exit on line %d\n",
986 dev->name,__FUNCTION__,__LINE__);
988 CLAW_DBF_TEXT(2,trace,"badIRQ");
992 } /* end of claw_irq_handler */
995 /*-------------------------------------------------------------------*
998 *--------------------------------------------------------------------*/
1000 claw_irq_tasklet ( unsigned long data )
1003 struct net_device *dev;
1004 struct claw_privbk * privptr;
1006 p_ch = (struct chbk *) data;
1007 dev = (struct net_device *)p_ch->ndev;
1009 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1012 printk(KERN_INFO "%s: variable p_ch =\n",dev->name);
1013 dumpit((char *) p_ch, sizeof(struct chbk));
1015 CLAW_DBF_TEXT(4,trace,"IRQtask");
1017 privptr = (struct claw_privbk *) dev->priv;
1020 printk(KERN_INFO "%s: bh routine - state-%02x\n" ,
1021 dev->name, p_ch->claw_state);
1025 clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a);
1026 CLAW_DBF_TEXT(4,trace,"TskletXt");
1028 printk(KERN_INFO "%s:%s Exit on line %d\n",
1029 dev->name,__FUNCTION__,__LINE__);
1032 } /* end of claw_irq_bh */
1034 /*-------------------------------------------------------------------*
1037 *--------------------------------------------------------------------*/
1039 claw_release(struct net_device *dev)
1043 unsigned long saveflags;
1045 struct claw_privbk *privptr;
1046 DECLARE_WAITQUEUE(wait, current);
1047 struct ccwbk* p_this_ccw;
1048 struct ccwbk* p_buf;
1052 privptr = (struct claw_privbk *) dev->priv;
1056 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1058 CLAW_DBF_TEXT(4,trace,"release");
1060 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1061 dumpit((char *) dev, sizeof(struct net_device));
1062 printk(KERN_INFO "Priv Buffalloc %d\n",privptr->buffs_alloc);
1063 printk(KERN_INFO "Priv p_buff_ccw = %p\n",&privptr->p_buff_ccw);
1065 privptr->release_pend=1;
1066 claw_setbit_busy(TB_STOP,dev);
1067 for ( i = 1; i >=0 ; i--) {
1069 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1070 /* del_timer(&privptr->channel[READ].timer); */
1071 privptr->channel[i].claw_state = CLAW_STOP;
1072 privptr->channel[i].IO_active = 0;
1073 parm = (unsigned long) &privptr->channel[i];
1075 claw_purge_skb_queue(
1076 &privptr->channel[WRITE].collect_queue);
1077 rc = ccw_device_halt (privptr->channel[i].cdev, parm);
1078 if (privptr->system_validate_comp==0x00) /* never opened? */
1079 init_waitqueue_head(&privptr->channel[i].wait);
1080 add_wait_queue(&privptr->channel[i].wait, &wait);
1081 set_current_state(TASK_INTERRUPTIBLE);
1082 spin_unlock_irqrestore(
1083 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1085 set_current_state(TASK_RUNNING);
1086 remove_wait_queue(&privptr->channel[i].wait, &wait);
1088 ccw_check_return_code(privptr->channel[i].cdev, rc);
1091 if (privptr->pk_skb != NULL) {
1092 dev_kfree_skb_any(privptr->pk_skb);
1093 privptr->pk_skb = NULL;
1095 if(privptr->buffs_alloc != 1) {
1097 printk(KERN_INFO "%s:%s Exit on line %d\n",
1098 dev->name,__FUNCTION__,__LINE__);
1100 CLAW_DBF_TEXT(4,trace,"none2fre");
1103 CLAW_DBF_TEXT(4,trace,"freebufs");
1104 if (privptr->p_buff_ccw != NULL) {
1105 free_pages((unsigned long)privptr->p_buff_ccw,
1106 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
1108 CLAW_DBF_TEXT(4,trace,"freeread");
1109 if (privptr->p_env->read_size < PAGE_SIZE) {
1110 if (privptr->p_buff_read != NULL) {
1111 free_pages((unsigned long)privptr->p_buff_read,
1112 (int)pages_to_order_of_mag(privptr->p_buff_read_num));
1116 p_buf=privptr->p_read_active_first;
1117 while (p_buf!=NULL) {
1118 free_pages((unsigned long)p_buf->p_buffer,
1119 (int)pages_to_order_of_mag(
1120 privptr->p_buff_pages_perread ));
1124 CLAW_DBF_TEXT(4,trace,"freewrit");
1125 if (privptr->p_env->write_size < PAGE_SIZE ) {
1126 free_pages((unsigned long)privptr->p_buff_write,
1127 (int)pages_to_order_of_mag(privptr->p_buff_write_num));
1130 p_buf=privptr->p_write_active_first;
1131 while (p_buf!=NULL) {
1132 free_pages((unsigned long)p_buf->p_buffer,
1133 (int)pages_to_order_of_mag(
1134 privptr->p_buff_pages_perwrite ));
1138 CLAW_DBF_TEXT(4,trace,"clearptr");
1139 privptr->buffs_alloc = 0;
1140 privptr->p_buff_ccw=NULL;
1141 privptr->p_buff_read=NULL;
1142 privptr->p_buff_write=NULL;
1143 privptr->system_validate_comp=0;
1144 privptr->release_pend=0;
1145 /* Remove any writes that were pending and reset all reads */
1146 p_this_ccw=privptr->p_read_active_first;
1147 while (p_this_ccw!=NULL) {
1148 p_this_ccw->header.length=0xffff;
1149 p_this_ccw->header.opcode=0xff;
1150 p_this_ccw->header.flag=0x00;
1151 p_this_ccw=p_this_ccw->next;
1154 while (privptr->p_write_active_first!=NULL) {
1155 p_this_ccw=privptr->p_write_active_first;
1156 p_this_ccw->header.flag=CLAW_PENDING;
1157 privptr->p_write_active_first=p_this_ccw->next;
1158 p_this_ccw->next=privptr->p_write_free_chain;
1159 privptr->p_write_free_chain=p_this_ccw;
1160 ++privptr->write_free_count;
1162 privptr->p_write_active_last=NULL;
1163 privptr->mtc_logical_link = -1;
1164 privptr->mtc_skipping = 1;
1165 privptr->mtc_offset=0;
1167 if (((privptr->channel[READ].last_dstat |
1168 privptr->channel[WRITE].last_dstat) &
1169 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) {
1170 printk(KERN_WARNING "%s: channel problems during close - "
1171 "read: %02x - write: %02x\n",
1173 privptr->channel[READ].last_dstat,
1174 privptr->channel[WRITE].last_dstat);
1175 CLAW_DBF_TEXT(2,trace,"badclose");
1178 printk(KERN_INFO "%s:%s Exit on line %d\n",
1179 dev->name,__FUNCTION__,__LINE__);
1181 CLAW_DBF_TEXT(4,trace,"rlsexit");
1183 } /* end of claw_release */
1187 /*-------------------------------------------------------------------*
1188 * claw_write_retry *
1190 *--------------------------------------------------------------------*/
1193 claw_write_retry ( struct chbk *p_ch )
1196 struct net_device *dev=p_ch->ndev;
1200 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
1201 printk(KERN_INFO "claw: variable p_ch =\n");
1202 dumpit((char *) p_ch, sizeof(struct chbk));
1204 CLAW_DBF_TEXT(4,trace,"w_retry");
1205 if (p_ch->claw_state == CLAW_STOP) {
1207 printk(KERN_INFO "%s:%s Exit on line %d\n",
1208 dev->name,__FUNCTION__,__LINE__);
1213 printk( KERN_INFO "%s:%s state-%02x\n" ,
1218 claw_strt_out_IO( dev );
1220 printk(KERN_INFO "%s:%s Exit on line %d\n",
1221 dev->name,__FUNCTION__,__LINE__);
1223 CLAW_DBF_TEXT(4,trace,"rtry_xit");
1225 } /* end of claw_write_retry */
1228 /*-------------------------------------------------------------------*
1231 *--------------------------------------------------------------------*/
1234 claw_write_next ( struct chbk * p_ch )
1237 struct net_device *dev;
1238 struct claw_privbk *privptr=NULL;
1239 struct sk_buff *pk_skb;
1243 printk(KERN_INFO "%s:%s Enter \n",p_ch->ndev->name,__FUNCTION__);
1244 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1245 dumpit((char *) p_ch, sizeof(struct chbk));
1247 CLAW_DBF_TEXT(4,trace,"claw_wrt");
1248 if (p_ch->claw_state == CLAW_STOP)
1250 dev = (struct net_device *) p_ch->ndev;
1251 privptr = (struct claw_privbk *) dev->priv;
1252 claw_free_wrt_buf( dev );
1253 if ((privptr->write_free_count > 0) &&
1254 !skb_queue_empty(&p_ch->collect_queue)) {
1255 pk_skb = claw_pack_skb(privptr);
1256 while (pk_skb != NULL) {
1257 rc = claw_hw_tx( pk_skb, dev,1);
1258 if (privptr->write_free_count > 0) {
1259 pk_skb = claw_pack_skb(privptr);
1264 if (privptr->p_write_active_first!=NULL) {
1265 claw_strt_out_IO(dev);
1269 printk(KERN_INFO "%s:%s Exit on line %d\n",
1270 dev->name,__FUNCTION__,__LINE__);
1273 } /* end of claw_write_next */
1275 /*-------------------------------------------------------------------*
1278 *--------------------------------------------------------------------*/
1281 claw_timer ( struct chbk * p_ch )
1284 printk(KERN_INFO "%s:%s Entry\n",p_ch->ndev->name,__FUNCTION__);
1285 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1286 dumpit((char *) p_ch, sizeof(struct chbk));
1288 CLAW_DBF_TEXT(4,trace,"timer");
1289 p_ch->flag |= CLAW_TIMER;
1290 wake_up(&p_ch->wait);
1292 printk(KERN_INFO "%s:%s Exit on line %d\n",
1293 p_ch->ndev->name,__FUNCTION__,__LINE__);
1296 } /* end of claw_timer */
1305 /*-------------------------------------------------------------------*
1307 * pages_to_order_of_mag *
1309 * takes a number of pages from 1 to 512 and returns the *
1310 * log(num_pages)/log(2) get_free_pages() needs a base 2 order *
1311 * of magnitude get_free_pages() has an upper order of 9 *
1312 *--------------------------------------------------------------------*/
1315 pages_to_order_of_mag(int num_of_pages)
1317 int order_of_mag=1; /* assume 2 pages */
1320 printk(KERN_INFO "%s Enter pages = %d \n",__FUNCTION__,num_of_pages);
1322 CLAW_DBF_TEXT_(5,trace,"pages%d",num_of_pages);
1323 if (num_of_pages == 1) {return 0; } /* magnitude of 0 = 1 page */
1324 /* 512 pages = 2Meg on 4k page systems */
1325 if (num_of_pages >= 512) {return 9; }
1326 /* we have two or more pages order is at least 1 */
1327 for (nump=2 ;nump <= 512;nump*=2) {
1328 if (num_of_pages <= nump)
1332 if (order_of_mag > 9) { order_of_mag = 9; } /* I know it's paranoid */
1334 printk(KERN_INFO "%s Exit on line %d, order = %d\n",
1335 __FUNCTION__,__LINE__, order_of_mag);
1337 CLAW_DBF_TEXT_(5,trace,"mag%d",order_of_mag);
1338 return order_of_mag;
1341 /*-------------------------------------------------------------------*
1345 *--------------------------------------------------------------------*/
1347 add_claw_reads(struct net_device *dev, struct ccwbk* p_first,
1348 struct ccwbk* p_last)
1350 struct claw_privbk *privptr;
1351 struct ccw1 temp_ccw;
1352 struct endccw * p_end;
1354 struct ccwbk* p_buf;
1357 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1360 printk(KERN_INFO "dev\n");
1361 dumpit((char *) dev, sizeof(struct net_device));
1362 printk(KERN_INFO "p_first\n");
1363 dumpit((char *) p_first, sizeof(struct ccwbk));
1364 printk(KERN_INFO "p_last\n");
1365 dumpit((char *) p_last, sizeof(struct ccwbk));
1367 CLAW_DBF_TEXT(4,trace,"addreads");
1368 privptr = dev->priv;
1369 p_end = privptr->p_end_ccw;
1371 /* first CCW and last CCW contains a new set of read channel programs
1372 * to apend the running channel programs
1374 if ( p_first==NULL) {
1376 printk(KERN_INFO "%s:%s Exit on line %d\n",
1377 dev->name,__FUNCTION__,__LINE__);
1379 CLAW_DBF_TEXT(4,trace,"addexit");
1383 /* set up ending CCW sequence for this segment */
1385 p_end->read1=0x00; /* second ending CCW is now active */
1386 /* reset ending CCWs and setup TIC CCWs */
1387 p_end->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1388 p_end->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1389 p_last->r_TIC_1.cda =(__u32)__pa(&p_end->read2_nop1);
1390 p_last->r_TIC_2.cda =(__u32)__pa(&p_end->read2_nop1);
1391 p_end->read2_nop2.cda=0;
1392 p_end->read2_nop2.count=1;
1395 p_end->read1=0x01; /* first ending CCW is now active */
1396 /* reset ending CCWs and setup TIC CCWs */
1397 p_end->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1398 p_end->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1399 p_last->r_TIC_1.cda = (__u32)__pa(&p_end->read1_nop1);
1400 p_last->r_TIC_2.cda = (__u32)__pa(&p_end->read1_nop1);
1401 p_end->read1_nop2.cda=0;
1402 p_end->read1_nop2.count=1;
1405 if ( privptr-> p_read_active_first ==NULL ) {
1407 printk(KERN_INFO "%s:%s p_read_active_frist == NULL \n",
1408 dev->name,__FUNCTION__);
1409 printk(KERN_INFO "%s:%s Read active first/last changed \n",
1410 dev->name,__FUNCTION__);
1412 privptr-> p_read_active_first= p_first; /* set new first */
1413 privptr-> p_read_active_last = p_last; /* set new last */
1418 printk(KERN_INFO "%s:%s Read in progress \n",
1419 dev->name,__FUNCTION__);
1421 /* set up TIC ccw */
1422 temp_ccw.cda= (__u32)__pa(&p_first->read);
1425 temp_ccw.cmd_code = CCW_CLAW_CMD_TIC;
1430 /* first set of CCW's is chained to the new read */
1431 /* chain, so the second set is chained to the active chain. */
1432 /* Therefore modify the second set to point to the new */
1433 /* read chain set up TIC CCWs */
1434 /* make sure we update the CCW so channel doesn't fetch it */
1435 /* when it's only half done */
1436 memcpy( &p_end->read2_nop2, &temp_ccw ,
1437 sizeof(struct ccw1));
1438 privptr->p_read_active_last->r_TIC_1.cda=
1439 (__u32)__pa(&p_first->read);
1440 privptr->p_read_active_last->r_TIC_2.cda=
1441 (__u32)__pa(&p_first->read);
1444 /* make sure we update the CCW so channel doesn't */
1445 /* fetch it when it is only half done */
1446 memcpy( &p_end->read1_nop2, &temp_ccw ,
1447 sizeof(struct ccw1));
1448 privptr->p_read_active_last->r_TIC_1.cda=
1449 (__u32)__pa(&p_first->read);
1450 privptr->p_read_active_last->r_TIC_2.cda=
1451 (__u32)__pa(&p_first->read);
1453 /* chain in new set of blocks */
1454 privptr->p_read_active_last->next = p_first;
1455 privptr->p_read_active_last=p_last;
1456 } /* end of if ( privptr-> p_read_active_first ==NULL) */
1458 printk(KERN_INFO "%s:%s dump p_last CCW BK \n",dev->name,__FUNCTION__);
1459 dumpit((char *)p_last, sizeof(struct ccwbk));
1460 printk(KERN_INFO "%s:%s dump p_end CCW BK \n",dev->name,__FUNCTION__);
1461 dumpit((char *)p_end, sizeof(struct endccw));
1463 printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__FUNCTION__);
1464 dumpit((char *)p_first, sizeof(struct ccwbk));
1465 printk(KERN_INFO "%s:%s Dump Active CCW chain \n",
1466 dev->name,__FUNCTION__);
1467 p_buf=privptr->p_read_active_first;
1468 while (p_buf!=NULL) {
1469 dumpit((char *)p_buf, sizeof(struct ccwbk));
1474 printk(KERN_INFO "%s:%s Exit on line %d\n",
1475 dev->name,__FUNCTION__,__LINE__);
1477 CLAW_DBF_TEXT(4,trace,"addexit");
1479 } /* end of add_claw_reads */
1481 /*-------------------------------------------------------------------*
1482 * ccw_check_return_code *
1484 *-------------------------------------------------------------------*/
1487 ccw_check_return_code(struct ccw_device *cdev, int return_code)
1490 printk(KERN_INFO "%s: %s() > enter \n",
1491 cdev->dev.bus_id,__FUNCTION__);
1493 CLAW_DBF_TEXT(4,trace,"ccwret");
1495 printk(KERN_INFO "variable cdev =\n");
1496 dumpit((char *) cdev, sizeof(struct ccw_device));
1497 printk(KERN_INFO "variable return_code = %d\n",return_code);
1499 if (return_code != 0) {
1500 switch (return_code) {
1502 printk(KERN_INFO "%s: Busy !\n",
1506 printk(KERN_EMERG "%s: Missing device called "
1507 "for IO ENODEV\n", cdev->dev.bus_id);
1510 printk(KERN_EMERG "%s: Status pending... EIO \n",
1514 printk(KERN_EMERG "%s: Invalid Dev State EINVAL \n",
1518 printk(KERN_EMERG "%s: Unknown error in "
1519 "Do_IO %d\n",cdev->dev.bus_id, return_code);
1523 printk(KERN_INFO "%s: %s() > exit on line %d\n",
1524 cdev->dev.bus_id,__FUNCTION__,__LINE__);
1526 CLAW_DBF_TEXT(4,trace,"ccwret");
1527 } /* end of ccw_check_return_code */
1529 /*-------------------------------------------------------------------*
1530 * ccw_check_unit_check *
1531 *--------------------------------------------------------------------*/
1534 ccw_check_unit_check(struct chbk * p_ch, unsigned char sense )
1536 struct net_device *dev = p_ch->ndev;
1539 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__FUNCTION__);
1542 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1543 dumpit((char *)dev, sizeof(struct net_device));
1544 printk(KERN_INFO "%s: variable sense =\n",dev->name);
1545 dumpit((char *)&sense, 2);
1547 CLAW_DBF_TEXT(4,trace,"unitchek");
1549 printk(KERN_INFO "%s: Unit Check with sense byte:0x%04x\n",
1554 printk(KERN_WARNING "%s: Interface disconnect or "
1556 "occurred (remote side)\n", dev->name);
1559 printk(KERN_WARNING "%s: System reset occured"
1560 " (remote side)\n", dev->name);
1563 else if (sense & 0x20) {
1565 printk(KERN_WARNING "%s: Data-streaming "
1566 "timeout)\n", dev->name);
1569 printk(KERN_WARNING "%s: Data-transfer parity"
1570 " error\n", dev->name);
1573 else if (sense & 0x10) {
1575 printk(KERN_WARNING "%s: Hardware malfunction "
1576 "(remote side)\n", dev->name);
1579 printk(KERN_WARNING "%s: read-data parity error "
1580 "(remote side)\n", dev->name);
1585 printk(KERN_INFO "%s: %s() exit on line %d\n",
1586 dev->name,__FUNCTION__,__LINE__);
1588 } /* end of ccw_check_unit_check */
1592 /*-------------------------------------------------------------------*
1593 * Dump buffer format *
1595 *--------------------------------------------------------------------*/
1598 dumpit(char* buf, int len)
1601 __u32 ct, sw, rm, dup;
1603 char tbuf[82], tdup[82];
1610 char bhex[82], duphex[82];
1618 for ( ct=0; ct < len; ct++, ptr++, rptr++ ) {
1621 sprintf(addr, "%16.16lX",(unsigned long)rptr);
1623 sprintf(addr, "%8.8X",(__u32)rptr);
1625 sprintf(boff, "%4.4X", (__u32)ct);
1629 if ((sw == 4) || (sw == 12)) {
1636 sprintf(tbuf,"%2.2lX", (unsigned long)*ptr);
1638 sprintf(tbuf,"%2.2X", (__u32)*ptr);
1642 if ((0!=isprint(*ptr)) && (*ptr >= 0x20)) {
1652 if ((strcmp(duphex, bhex)) !=0) {
1654 sprintf(tdup,"Duplicate as above to"
1656 printk( KERN_INFO " "
1657 " --- %s ---\n",tdup);
1659 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1660 addr, boff, bhex, basc);
1662 strcpy(duphex, bhex);
1673 for ( ; rm > 0; rm--, sw++ ) {
1674 if ((sw==4) || (sw==12)) strcat(bhex, " ");
1675 if (sw==8) strcat(bhex, " ");
1680 sprintf(tdup,"Duplicate as above to %s", addr);
1681 printk( KERN_INFO " --- %s ---\n",
1684 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1685 addr, boff, bhex, basc);
1689 sprintf(tdup,"Duplicate as above to %s", addr);
1690 printk( KERN_INFO " --- %s ---\n",
1694 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1695 addr, boff, bhex, basc);
1700 } /* end of dumpit */
1703 /*-------------------------------------------------------------------*
1705 *--------------------------------------------------------------------*/
1707 find_link(struct net_device *dev, char *host_name, char *ws_name )
1709 struct claw_privbk *privptr;
1710 struct claw_env *p_env;
1714 printk(KERN_INFO "%s:%s > enter \n",dev->name,__FUNCTION__);
1716 CLAW_DBF_TEXT(2,setup,"findlink");
1718 printk(KERN_INFO "%s: variable dev = \n",dev->name);
1719 dumpit((char *) dev, sizeof(struct net_device));
1720 printk(KERN_INFO "%s: variable host_name = %s\n",dev->name, host_name);
1721 printk(KERN_INFO "%s: variable ws_name = %s\n",dev->name, ws_name);
1724 p_env=privptr->p_env;
1725 switch (p_env->packing)
1728 if ((memcmp(WS_APPL_NAME_PACKED, host_name, 8)!=0) ||
1729 (memcmp(WS_APPL_NAME_PACKED, ws_name, 8)!=0 ))
1734 if ((memcmp(WS_APPL_NAME_IP_NAME, host_name, 8)!=0) ||
1735 (memcmp(WS_APPL_NAME_IP_NAME, ws_name, 8)!=0 ))
1739 if ((memcmp(HOST_APPL_NAME, host_name, 8)!=0) ||
1740 (memcmp(p_env->api_type , ws_name, 8)!=0))
1746 printk(KERN_INFO "%s:%s Exit on line %d\n",
1747 dev->name,__FUNCTION__,__LINE__);
1750 } /* end of find_link */
1752 /*-------------------------------------------------------------------*
1756 *-------------------------------------------------------------------*/
1759 claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid)
1762 struct claw_privbk *privptr;
1763 struct ccwbk *p_this_ccw;
1764 struct ccwbk *p_first_ccw;
1765 struct ccwbk *p_last_ccw;
1767 signed long len_of_data;
1768 unsigned long bytesInThisBuffer;
1769 unsigned char *pDataAddress;
1770 struct endccw *pEnd;
1771 struct ccw1 tempCCW;
1773 struct claw_env *p_env;
1775 struct clawph *pk_head;
1778 struct ccwbk *p_buf;
1781 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__FUNCTION__);
1783 CLAW_DBF_TEXT(4,trace,"hw_tx");
1785 printk(KERN_INFO "%s: variable dev skb =\n",dev->name);
1786 dumpit((char *) skb, sizeof(struct sk_buff));
1787 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1788 dumpit((char *) dev, sizeof(struct net_device));
1789 printk(KERN_INFO "%s: variable linkid = %ld\n",dev->name,linkid);
1791 privptr = (struct claw_privbk *) (dev->priv);
1792 p_ch=(struct chbk *)&privptr->channel[WRITE];
1793 p_env =privptr->p_env;
1795 printk(KERN_INFO "%s: %s() dump sk_buff \n",dev->name,__FUNCTION__);
1796 dumpit((char *)skb ,sizeof(struct sk_buff));
1798 claw_free_wrt_buf(dev); /* Clean up free chain if posible */
1799 /* scan the write queue to free any completed write packets */
1802 if ((p_env->packing >= PACK_SEND) &&
1803 (skb->cb[1] != 'P')) {
1804 skb_push(skb,sizeof(struct clawph));
1805 pk_head=(struct clawph *)skb->data;
1806 pk_head->len=skb->len-sizeof(struct clawph);
1807 if (pk_head->len%4) {
1808 pk_head->len+= 4-(pk_head->len%4);
1809 skb_pad(skb,4-(pk_head->len%4));
1810 skb_put(skb,4-(pk_head->len%4));
1812 if (p_env->packing == DO_PACKED)
1813 pk_head->link_num = linkid;
1815 pk_head->link_num = 0;
1816 pk_head->flag = 0x00;
1821 if (claw_check_busy(dev)) {
1822 if (privptr->write_free_count!=0) {
1823 claw_clear_busy(dev);
1826 claw_strt_out_IO(dev );
1827 claw_free_wrt_buf( dev );
1828 if (privptr->write_free_count==0) {
1830 printk(KERN_INFO "%s: "
1831 "(claw_check_busy) no free write "
1832 "buffers\n", dev->name);
1834 ch = &privptr->channel[WRITE];
1835 atomic_inc(&skb->users);
1836 skb_queue_tail(&ch->collect_queue, skb);
1840 claw_clear_busy(dev);
1845 if (claw_test_and_setbit_busy(TB_TX,dev)) { /* set to busy */
1847 printk(KERN_INFO "%s: busy (claw_test_and_setbit_"
1848 "busy)\n", dev->name);
1850 ch = &privptr->channel[WRITE];
1851 atomic_inc(&skb->users);
1852 skb_queue_tail(&ch->collect_queue, skb);
1853 claw_strt_out_IO(dev );
1858 /* See how many write buffers are required to hold this data */
1859 numBuffers= ( skb->len + privptr->p_env->write_size - 1) /
1860 ( privptr->p_env->write_size);
1862 /* If that number of buffers isn't available, give up for now */
1863 if (privptr->write_free_count < numBuffers ||
1864 privptr->p_write_free_chain == NULL ) {
1866 claw_setbit_busy(TB_NOBUFFER,dev);
1869 printk(KERN_INFO "%s: busy (claw_setbit_busy"
1870 "(TB_NOBUFFER))\n", dev->name);
1871 printk(KERN_INFO " free_count: %d, numBuffers : %d\n",
1872 (int)privptr->write_free_count,(int) numBuffers );
1874 ch = &privptr->channel[WRITE];
1875 atomic_inc(&skb->users);
1876 skb_queue_tail(&ch->collect_queue, skb);
1877 CLAW_DBF_TEXT(2,trace,"clawbusy");
1880 pDataAddress=skb->data;
1881 len_of_data=skb->len;
1883 while (len_of_data > 0) {
1885 printk(KERN_INFO "%s: %s() length-of-data is %ld \n",
1886 dev->name ,__FUNCTION__,len_of_data);
1887 dumpit((char *)pDataAddress ,64);
1889 p_this_ccw=privptr->p_write_free_chain; /* get a block */
1890 if (p_this_ccw == NULL) { /* lost the race */
1891 ch = &privptr->channel[WRITE];
1892 atomic_inc(&skb->users);
1893 skb_queue_tail(&ch->collect_queue, skb);
1896 privptr->p_write_free_chain=p_this_ccw->next;
1897 p_this_ccw->next=NULL;
1898 --privptr->write_free_count; /* -1 */
1899 bytesInThisBuffer=len_of_data;
1900 memcpy( p_this_ccw->p_buffer,pDataAddress, bytesInThisBuffer);
1901 len_of_data-=bytesInThisBuffer;
1902 pDataAddress+=(unsigned long)bytesInThisBuffer;
1903 /* setup write CCW */
1904 p_this_ccw->write.cmd_code = (linkid * 8) +1;
1905 if (len_of_data>0) {
1906 p_this_ccw->write.cmd_code+=MORE_to_COME_FLAG;
1908 p_this_ccw->write.count=bytesInThisBuffer;
1909 /* now add to end of this chain */
1910 if (p_first_ccw==NULL) {
1911 p_first_ccw=p_this_ccw;
1913 if (p_last_ccw!=NULL) {
1914 p_last_ccw->next=p_this_ccw;
1915 /* set up TIC ccws */
1916 p_last_ccw->w_TIC_1.cda=
1917 (__u32)__pa(&p_this_ccw->write);
1919 p_last_ccw=p_this_ccw; /* save new last block */
1921 printk(KERN_INFO "%s: %s() > CCW and Buffer %ld bytes long \n",
1922 dev->name,__FUNCTION__,bytesInThisBuffer);
1923 dumpit((char *)p_this_ccw, sizeof(struct ccwbk));
1924 dumpit((char *)p_this_ccw->p_buffer, 64);
1928 /* FirstCCW and LastCCW now contain a new set of write channel
1929 * programs to append to the running channel program
1932 if (p_first_ccw!=NULL) {
1933 /* setup ending ccw sequence for this segment */
1934 pEnd=privptr->p_end_ccw;
1936 pEnd->write1=0x00; /* second end ccw is now active */
1937 /* set up Tic CCWs */
1938 p_last_ccw->w_TIC_1.cda=
1939 (__u32)__pa(&pEnd->write2_nop1);
1940 pEnd->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1941 pEnd->write2_nop2.flags =
1942 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1943 pEnd->write2_nop2.cda=0;
1944 pEnd->write2_nop2.count=1;
1946 else { /* end of if (pEnd->write1)*/
1947 pEnd->write1=0x01; /* first end ccw is now active */
1948 /* set up Tic CCWs */
1949 p_last_ccw->w_TIC_1.cda=
1950 (__u32)__pa(&pEnd->write1_nop1);
1951 pEnd->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1952 pEnd->write1_nop2.flags =
1953 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1954 pEnd->write1_nop2.cda=0;
1955 pEnd->write1_nop2.count=1;
1956 } /* end if if (pEnd->write1) */
1959 if (privptr->p_write_active_first==NULL ) {
1960 privptr->p_write_active_first=p_first_ccw;
1961 privptr->p_write_active_last=p_last_ccw;
1965 /* set up Tic CCWs */
1967 tempCCW.cda=(__u32)__pa(&p_first_ccw->write);
1970 tempCCW.cmd_code=CCW_CLAW_CMD_TIC;
1975 * first set of ending CCW's is chained to the new write
1976 * chain, so the second set is chained to the active chain
1977 * Therefore modify the second set to point the new write chain.
1978 * make sure we update the CCW atomically
1979 * so channel does not fetch it when it's only half done
1981 memcpy( &pEnd->write2_nop2, &tempCCW ,
1982 sizeof(struct ccw1));
1983 privptr->p_write_active_last->w_TIC_1.cda=
1984 (__u32)__pa(&p_first_ccw->write);
1988 /*make sure we update the CCW atomically
1989 *so channel does not fetch it when it's only half done
1991 memcpy(&pEnd->write1_nop2, &tempCCW ,
1992 sizeof(struct ccw1));
1993 privptr->p_write_active_last->w_TIC_1.cda=
1994 (__u32)__pa(&p_first_ccw->write);
1996 } /* end if if (pEnd->write1) */
1998 privptr->p_write_active_last->next=p_first_ccw;
1999 privptr->p_write_active_last=p_last_ccw;
2002 } /* endif (p_first_ccw!=NULL) */
2006 printk(KERN_INFO "%s: %s() > Dump Active CCW chain \n",
2007 dev->name,__FUNCTION__);
2008 p_buf=privptr->p_write_active_first;
2009 while (p_buf!=NULL) {
2010 dumpit((char *)p_buf, sizeof(struct ccwbk));
2013 p_buf=(struct ccwbk*)privptr->p_end_ccw;
2014 dumpit((char *)p_buf, sizeof(struct endccw));
2016 dev_kfree_skb_any(skb);
2023 claw_strt_out_IO(dev );
2024 /* if write free count is zero , set NOBUFFER */
2026 printk(KERN_INFO "%s: %s() > free_count is %d\n",
2027 dev->name,__FUNCTION__,
2028 (int) privptr->write_free_count );
2030 if (privptr->write_free_count==0) {
2031 claw_setbit_busy(TB_NOBUFFER,dev);
2034 claw_clearbit_busy(TB_TX,dev);
2037 printk(KERN_INFO "%s: %s() > exit on line %d, rc = %d \n",
2038 dev->name,__FUNCTION__,__LINE__, rc);
2041 } /* end of claw_hw_tx */
2043 /*-------------------------------------------------------------------*
2047 *--------------------------------------------------------------------*/
2050 init_ccw_bk(struct net_device *dev)
2053 __u32 ccw_blocks_required;
2054 __u32 ccw_blocks_perpage;
2055 __u32 ccw_pages_required;
2056 __u32 claw_reads_perpage=1;
2057 __u32 claw_read_pages;
2058 __u32 claw_writes_perpage=1;
2059 __u32 claw_write_pages;
2061 struct ccwbk*p_free_chain;
2063 struct ccwbk*p_last_CCWB;
2064 struct ccwbk*p_first_CCWB;
2065 struct endccw *p_endccw=NULL;
2066 addr_t real_address;
2067 struct claw_privbk *privptr=dev->priv;
2068 struct clawh *pClawH=NULL;
2069 addr_t real_TIC_address;
2072 printk(KERN_INFO "%s: %s() enter \n",dev->name,__FUNCTION__);
2074 CLAW_DBF_TEXT(4,trace,"init_ccw");
2076 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2077 dumpit((char *) dev, sizeof(struct net_device));
2080 /* initialize statistics field */
2081 privptr->active_link_ID=0;
2082 /* initialize ccwbk pointers */
2083 privptr->p_write_free_chain=NULL; /* pointer to free ccw chain*/
2084 privptr->p_write_active_first=NULL; /* pointer to the first write ccw*/
2085 privptr->p_write_active_last=NULL; /* pointer to the last write ccw*/
2086 privptr->p_read_active_first=NULL; /* pointer to the first read ccw*/
2087 privptr->p_read_active_last=NULL; /* pointer to the last read ccw */
2088 privptr->p_end_ccw=NULL; /* pointer to ending ccw */
2089 privptr->p_claw_signal_blk=NULL; /* pointer to signal block */
2090 privptr->buffs_alloc = 0;
2091 memset(&privptr->end_ccw, 0x00, sizeof(struct endccw));
2092 memset(&privptr->ctl_bk, 0x00, sizeof(struct clawctl));
2093 /* initialize free write ccwbk counter */
2094 privptr->write_free_count=0; /* number of free bufs on write chain */
2098 * We need 1 CCW block for each read buffer, 1 for each
2099 * write buffer, plus 1 for ClawSignalBlock
2101 ccw_blocks_required =
2102 privptr->p_env->read_buffers+privptr->p_env->write_buffers+1;
2104 printk(KERN_INFO "%s: %s() "
2105 "ccw_blocks_required=%d\n",
2106 dev->name,__FUNCTION__,
2107 ccw_blocks_required);
2108 printk(KERN_INFO "%s: %s() "
2110 dev->name,__FUNCTION__,
2111 (unsigned int)PAGE_SIZE);
2112 printk(KERN_INFO "%s: %s() > "
2114 dev->name,__FUNCTION__,
2115 (unsigned int)PAGE_MASK);
2118 * compute number of CCW blocks that will fit in a page
2120 ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE;
2122 (ccw_blocks_required+ccw_blocks_perpage -1) /
2126 printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
2127 dev->name,__FUNCTION__,
2128 ccw_blocks_perpage);
2129 printk(KERN_INFO "%s: %s() > ccw_pages_required=%d\n",
2130 dev->name,__FUNCTION__,
2131 ccw_pages_required);
2134 * read and write sizes are set by 2 constants in claw.h
2135 * 4k and 32k. Unpacked values other than 4k are not going to
2136 * provide good performance. With packing buffers support 32k
2139 if (privptr->p_env->read_size < PAGE_SIZE) {
2140 claw_reads_perpage= PAGE_SIZE / privptr->p_env->read_size;
2141 claw_read_pages= (privptr->p_env->read_buffers +
2142 claw_reads_perpage -1) / claw_reads_perpage;
2144 else { /* > or equal */
2145 privptr->p_buff_pages_perread=
2146 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
2148 privptr->p_env->read_buffers * privptr->p_buff_pages_perread;
2150 if (privptr->p_env->write_size < PAGE_SIZE) {
2151 claw_writes_perpage=
2152 PAGE_SIZE / privptr->p_env->write_size;
2154 (privptr->p_env->write_buffers + claw_writes_perpage -1) /
2155 claw_writes_perpage;
2158 else { /* > or equal */
2159 privptr->p_buff_pages_perwrite=
2160 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
2162 privptr->p_env->write_buffers * privptr->p_buff_pages_perwrite;
2165 if (privptr->p_env->read_size < PAGE_SIZE) {
2166 printk(KERN_INFO "%s: %s() reads_perpage=%d\n",
2167 dev->name,__FUNCTION__,
2168 claw_reads_perpage);
2171 printk(KERN_INFO "%s: %s() pages_perread=%d\n",
2172 dev->name,__FUNCTION__,
2173 privptr->p_buff_pages_perread);
2175 printk(KERN_INFO "%s: %s() read_pages=%d\n",
2176 dev->name,__FUNCTION__,
2178 if (privptr->p_env->write_size < PAGE_SIZE) {
2179 printk(KERN_INFO "%s: %s() writes_perpage=%d\n",
2180 dev->name,__FUNCTION__,
2181 claw_writes_perpage);
2184 printk(KERN_INFO "%s: %s() pages_perwrite=%d\n",
2185 dev->name,__FUNCTION__,
2186 privptr->p_buff_pages_perwrite);
2188 printk(KERN_INFO "%s: %s() write_pages=%d\n",
2189 dev->name,__FUNCTION__,
2195 * allocate ccw_pages_required
2197 if (privptr->p_buff_ccw==NULL) {
2198 privptr->p_buff_ccw=
2199 (void *)__get_free_pages(__GFP_DMA,
2200 (int)pages_to_order_of_mag(ccw_pages_required ));
2201 if (privptr->p_buff_ccw==NULL) {
2202 printk(KERN_INFO "%s: %s() "
2203 "__get_free_pages for CCWs failed : "
2205 dev->name,__FUNCTION__,
2206 ccw_pages_required );
2208 printk(KERN_INFO "%s: %s() > "
2209 "exit on line %d, rc = ENOMEM\n",
2210 dev->name,__FUNCTION__,
2215 privptr->p_buff_ccw_num=ccw_pages_required;
2217 memset(privptr->p_buff_ccw, 0x00,
2218 privptr->p_buff_ccw_num * PAGE_SIZE);
2221 * obtain ending ccw block address
2224 privptr->p_end_ccw = (struct endccw *)&privptr->end_ccw;
2225 real_address = (__u32)__pa(privptr->p_end_ccw);
2226 /* Initialize ending CCW block */
2228 printk(KERN_INFO "%s: %s() begin initialize ending CCW blocks\n",
2229 dev->name,__FUNCTION__);
2232 p_endccw=privptr->p_end_ccw;
2233 p_endccw->real=real_address;
2234 p_endccw->write1=0x00;
2235 p_endccw->read1=0x00;
2238 p_endccw->write1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2239 p_endccw->write1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2240 p_endccw->write1_nop1.count = 1;
2241 p_endccw->write1_nop1.cda = 0;
2244 p_endccw->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2245 p_endccw->write1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2246 p_endccw->write1_nop2.count = 1;
2247 p_endccw->write1_nop2.cda = 0;
2250 p_endccw->write2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2251 p_endccw->write2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2252 p_endccw->write2_nop1.count = 1;
2253 p_endccw->write2_nop1.cda = 0;
2256 p_endccw->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2257 p_endccw->write2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2258 p_endccw->write2_nop2.count = 1;
2259 p_endccw->write2_nop2.cda = 0;
2262 p_endccw->read1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2263 p_endccw->read1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2264 p_endccw->read1_nop1.count = 1;
2265 p_endccw->read1_nop1.cda = 0;
2268 p_endccw->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2269 p_endccw->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2270 p_endccw->read1_nop2.count = 1;
2271 p_endccw->read1_nop2.cda = 0;
2274 p_endccw->read2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2275 p_endccw->read2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2276 p_endccw->read2_nop1.count = 1;
2277 p_endccw->read2_nop1.cda = 0;
2280 p_endccw->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2281 p_endccw->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2282 p_endccw->read2_nop2.count = 1;
2283 p_endccw->read2_nop2.cda = 0;
2286 printk(KERN_INFO "%s: %s() dump claw ending CCW BK \n",
2287 dev->name,__FUNCTION__);
2288 dumpit((char *)p_endccw, sizeof(struct endccw));
2292 * Build a chain of CCWs
2297 printk(KERN_INFO "%s: %s() Begin build a chain of CCW buffer \n",
2298 dev->name,__FUNCTION__);
2300 p_buff=privptr->p_buff_ccw;
2303 for (i=0 ; i < ccw_pages_required; i++ ) {
2304 real_address = (__u32)__pa(p_buff);
2306 for (j=0 ; j < ccw_blocks_perpage ; j++) {
2307 p_buf->next = p_free_chain;
2308 p_free_chain = p_buf;
2309 p_buf->real=(__u32)__pa(p_buf);
2315 printk(KERN_INFO "%s: %s() "
2316 "End build a chain of CCW buffer \n",
2317 dev->name,__FUNCTION__);
2319 while (p_buf!=NULL) {
2320 dumpit((char *)p_buf, sizeof(struct ccwbk));
2326 * Initialize ClawSignalBlock
2330 printk(KERN_INFO "%s: %s() "
2331 "Begin initialize ClawSignalBlock \n",
2332 dev->name,__FUNCTION__);
2334 if (privptr->p_claw_signal_blk==NULL) {
2335 privptr->p_claw_signal_blk=p_free_chain;
2336 p_free_chain=p_free_chain->next;
2337 pClawH=(struct clawh *)privptr->p_claw_signal_blk;
2338 pClawH->length=0xffff;
2339 pClawH->opcode=0xff;
2340 pClawH->flag=CLAW_BUSY;
2343 printk(KERN_INFO "%s: %s() > End initialize "
2344 "ClawSignalBlock\n",
2345 dev->name,__FUNCTION__);
2346 dumpit((char *)privptr->p_claw_signal_blk, sizeof(struct ccwbk));
2350 * allocate write_pages_required and add to free chain
2352 if (privptr->p_buff_write==NULL) {
2353 if (privptr->p_env->write_size < PAGE_SIZE) {
2354 privptr->p_buff_write=
2355 (void *)__get_free_pages(__GFP_DMA,
2356 (int)pages_to_order_of_mag(claw_write_pages ));
2357 if (privptr->p_buff_write==NULL) {
2358 printk(KERN_INFO "%s: %s() __get_free_pages for write"
2359 " bufs failed : get is for %d pages\n",
2360 dev->name,__FUNCTION__,claw_write_pages );
2361 free_pages((unsigned long)privptr->p_buff_ccw,
2362 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2363 privptr->p_buff_ccw=NULL;
2365 printk(KERN_INFO "%s: %s() > exit on line %d,"
2367 dev->name,__FUNCTION__,__LINE__);
2372 * Build CLAW write free chain
2376 memset(privptr->p_buff_write, 0x00,
2377 ccw_pages_required * PAGE_SIZE);
2379 printk(KERN_INFO "%s: %s() Begin build claw write free "
2380 "chain \n",dev->name,__FUNCTION__);
2382 privptr->p_write_free_chain=NULL;
2384 p_buff=privptr->p_buff_write;
2386 for (i=0 ; i< privptr->p_env->write_buffers ; i++) {
2387 p_buf = p_free_chain; /* get a CCW */
2388 p_free_chain = p_buf->next;
2389 p_buf->next =privptr->p_write_free_chain;
2390 privptr->p_write_free_chain = p_buf;
2391 p_buf-> p_buffer = (struct clawbuf *)p_buff;
2392 p_buf-> write.cda = (__u32)__pa(p_buff);
2393 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2394 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2395 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2396 p_buf-> w_read_FF.count = 1;
2397 p_buf-> w_read_FF.cda =
2398 (__u32)__pa(&p_buf-> header.flag);
2399 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2400 p_buf-> w_TIC_1.flags = 0;
2401 p_buf-> w_TIC_1.count = 0;
2403 if (((unsigned long)p_buff+privptr->p_env->write_size) >=
2404 ((unsigned long)(p_buff+2*
2405 (privptr->p_env->write_size) -1) & PAGE_MASK)) {
2406 p_buff= p_buff+privptr->p_env->write_size;
2410 else /* Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
2412 privptr->p_write_free_chain=NULL;
2413 for (i = 0; i< privptr->p_env->write_buffers ; i++) {
2414 p_buff=(void *)__get_free_pages(__GFP_DMA,
2415 (int)pages_to_order_of_mag(
2416 privptr->p_buff_pages_perwrite) );
2418 printk(KERN_INFO "%s:%s __get_free_pages "
2419 "for writes buf: get for %d pages\n",
2420 dev->name,__FUNCTION__,
2421 privptr->p_buff_pages_perwrite);
2424 printk(KERN_INFO "%s:%s __get_free_pages"
2425 "for writes buf failed : get is for %d pages\n",
2428 privptr->p_buff_pages_perwrite );
2429 free_pages((unsigned long)privptr->p_buff_ccw,
2430 (int)pages_to_order_of_mag(
2431 privptr->p_buff_ccw_num));
2432 privptr->p_buff_ccw=NULL;
2433 p_buf=privptr->p_buff_write;
2434 while (p_buf!=NULL) {
2435 free_pages((unsigned long)
2437 (int)pages_to_order_of_mag(
2438 privptr->p_buff_pages_perwrite));
2442 printk(KERN_INFO "%s: %s exit on line %d, rc = ENOMEM\n",
2448 } /* Error on get_pages */
2449 memset(p_buff, 0x00, privptr->p_env->write_size );
2450 p_buf = p_free_chain;
2451 p_free_chain = p_buf->next;
2452 p_buf->next = privptr->p_write_free_chain;
2453 privptr->p_write_free_chain = p_buf;
2454 privptr->p_buff_write = p_buf;
2455 p_buf->p_buffer=(struct clawbuf *)p_buff;
2456 p_buf-> write.cda = (__u32)__pa(p_buff);
2457 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2458 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2459 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2460 p_buf-> w_read_FF.count = 1;
2461 p_buf-> w_read_FF.cda =
2462 (__u32)__pa(&p_buf-> header.flag);
2463 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2464 p_buf-> w_TIC_1.flags = 0;
2465 p_buf-> w_TIC_1.count = 0;
2466 } /* for all write_buffers */
2468 } /* else buffers are PAGE_SIZE or bigger */
2471 privptr->p_buff_write_num=claw_write_pages;
2472 privptr->write_free_count=privptr->p_env->write_buffers;
2476 printk(KERN_INFO "%s:%s End build claw write free chain \n",
2477 dev->name,__FUNCTION__);
2478 p_buf=privptr->p_write_free_chain;
2479 while (p_buf!=NULL) {
2480 dumpit((char *)p_buf, sizeof(struct ccwbk));
2485 * allocate read_pages_required and chain to free chain
2487 if (privptr->p_buff_read==NULL) {
2488 if (privptr->p_env->read_size < PAGE_SIZE) {
2489 privptr->p_buff_read=
2490 (void *)__get_free_pages(__GFP_DMA,
2491 (int)pages_to_order_of_mag(claw_read_pages) );
2492 if (privptr->p_buff_read==NULL) {
2493 printk(KERN_INFO "%s: %s() "
2494 "__get_free_pages for read buf failed : "
2495 "get is for %d pages\n",
2496 dev->name,__FUNCTION__,claw_read_pages );
2497 free_pages((unsigned long)privptr->p_buff_ccw,
2498 (int)pages_to_order_of_mag(
2499 privptr->p_buff_ccw_num));
2500 /* free the write pages size is < page size */
2501 free_pages((unsigned long)privptr->p_buff_write,
2502 (int)pages_to_order_of_mag(
2503 privptr->p_buff_write_num));
2504 privptr->p_buff_ccw=NULL;
2505 privptr->p_buff_write=NULL;
2507 printk(KERN_INFO "%s: %s() > exit on line %d, rc ="
2508 " ENOMEM\n",dev->name,__FUNCTION__,__LINE__);
2512 memset(privptr->p_buff_read, 0x00, claw_read_pages * PAGE_SIZE);
2513 privptr->p_buff_read_num=claw_read_pages;
2515 * Build CLAW read free chain
2519 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2520 dev->name,__FUNCTION__);
2522 p_buff=privptr->p_buff_read;
2523 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2524 p_buf = p_free_chain;
2525 p_free_chain = p_buf->next;
2527 if (p_last_CCWB==NULL) {
2533 p_buf->next=p_first_CCWB;
2535 (__u32)__pa(&p_first_CCWB -> read );
2540 p_buf->p_buffer=(struct clawbuf *)p_buff;
2541 /* initialize read command */
2542 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2543 p_buf-> read.cda = (__u32)__pa(p_buff);
2544 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2545 p_buf-> read.count = privptr->p_env->read_size;
2547 /* initialize read_h command */
2548 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2549 p_buf-> read_h.cda =
2550 (__u32)__pa(&(p_buf->header));
2551 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2552 p_buf-> read_h.count = sizeof(struct clawh);
2554 /* initialize Signal command */
2555 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2556 p_buf-> signal.cda =
2557 (__u32)__pa(&(pClawH->flag));
2558 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2559 p_buf-> signal.count = 1;
2561 /* initialize r_TIC_1 command */
2562 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2563 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2564 p_buf-> r_TIC_1.flags = 0;
2565 p_buf-> r_TIC_1.count = 0;
2567 /* initialize r_read_FF command */
2568 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2569 p_buf-> r_read_FF.cda =
2570 (__u32)__pa(&(pClawH->flag));
2571 p_buf-> r_read_FF.flags =
2572 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2573 p_buf-> r_read_FF.count = 1;
2575 /* initialize r_TIC_2 */
2576 memcpy(&p_buf->r_TIC_2,
2577 &p_buf->r_TIC_1, sizeof(struct ccw1));
2579 /* initialize Header */
2580 p_buf->header.length=0xffff;
2581 p_buf->header.opcode=0xff;
2582 p_buf->header.flag=CLAW_PENDING;
2584 if (((unsigned long)p_buff+privptr->p_env->read_size) >=
2585 ((unsigned long)(p_buff+2*(privptr->p_env->read_size) -1)
2587 p_buff= p_buff+privptr->p_env->read_size;
2591 (void *)((unsigned long)
2592 (p_buff+2*(privptr->p_env->read_size) -1)
2595 } /* for read_buffers */
2596 } /* read_size < PAGE_SIZE */
2597 else { /* read Size >= PAGE_SIZE */
2600 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2601 dev->name,__FUNCTION__);
2603 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2604 p_buff = (void *)__get_free_pages(__GFP_DMA,
2605 (int)pages_to_order_of_mag(privptr->p_buff_pages_perread) );
2607 printk(KERN_INFO "%s: %s() __get_free_pages for read "
2608 "buf failed : get is for %d pages\n",
2609 dev->name,__FUNCTION__,
2610 privptr->p_buff_pages_perread );
2611 free_pages((unsigned long)privptr->p_buff_ccw,
2612 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2613 /* free the write pages */
2614 p_buf=privptr->p_buff_write;
2615 while (p_buf!=NULL) {
2616 free_pages((unsigned long)p_buf->p_buffer,
2617 (int)pages_to_order_of_mag(
2618 privptr->p_buff_pages_perwrite ));
2621 /* free any read pages already alloc */
2622 p_buf=privptr->p_buff_read;
2623 while (p_buf!=NULL) {
2624 free_pages((unsigned long)p_buf->p_buffer,
2625 (int)pages_to_order_of_mag(
2626 privptr->p_buff_pages_perread ));
2629 privptr->p_buff_ccw=NULL;
2630 privptr->p_buff_write=NULL;
2632 printk(KERN_INFO "%s: %s() exit on line %d, rc = ENOMEM\n",
2633 dev->name,__FUNCTION__,
2638 memset(p_buff, 0x00, privptr->p_env->read_size);
2639 p_buf = p_free_chain;
2640 privptr->p_buff_read = p_buf;
2641 p_free_chain = p_buf->next;
2643 if (p_last_CCWB==NULL) {
2649 p_buf->next=p_first_CCWB;
2652 &p_first_CCWB -> read );
2656 /* save buff address */
2657 p_buf->p_buffer=(struct clawbuf *)p_buff;
2658 /* initialize read command */
2659 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2660 p_buf-> read.cda = (__u32)__pa(p_buff);
2661 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2662 p_buf-> read.count = privptr->p_env->read_size;
2664 /* initialize read_h command */
2665 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2666 p_buf-> read_h.cda =
2667 (__u32)__pa(&(p_buf->header));
2668 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2669 p_buf-> read_h.count = sizeof(struct clawh);
2671 /* initialize Signal command */
2672 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2673 p_buf-> signal.cda =
2674 (__u32)__pa(&(pClawH->flag));
2675 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2676 p_buf-> signal.count = 1;
2678 /* initialize r_TIC_1 command */
2679 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2680 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2681 p_buf-> r_TIC_1.flags = 0;
2682 p_buf-> r_TIC_1.count = 0;
2684 /* initialize r_read_FF command */
2685 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2686 p_buf-> r_read_FF.cda =
2687 (__u32)__pa(&(pClawH->flag));
2688 p_buf-> r_read_FF.flags =
2689 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2690 p_buf-> r_read_FF.count = 1;
2692 /* initialize r_TIC_2 */
2693 memcpy(&p_buf->r_TIC_2, &p_buf->r_TIC_1,
2694 sizeof(struct ccw1));
2696 /* initialize Header */
2697 p_buf->header.length=0xffff;
2698 p_buf->header.opcode=0xff;
2699 p_buf->header.flag=CLAW_PENDING;
2701 } /* For read_buffers */
2702 } /* read_size >= PAGE_SIZE */
2703 } /* pBuffread = NULL */
2705 printk(KERN_INFO "%s: %s() > End build claw read free chain \n",
2706 dev->name,__FUNCTION__);
2708 while (p_buf!=NULL) {
2709 dumpit((char *)p_buf, sizeof(struct ccwbk));
2714 add_claw_reads( dev ,p_first_CCWB , p_last_CCWB);
2715 privptr->buffs_alloc = 1;
2717 printk(KERN_INFO "%s: %s() exit on line %d\n",
2718 dev->name,__FUNCTION__,__LINE__);
2721 } /* end of init_ccw_bk */
2723 /*-------------------------------------------------------------------*
2727 *--------------------------------------------------------------------*/
2730 probe_error( struct ccwgroup_device *cgdev)
2732 struct claw_privbk *privptr;
2734 printk(KERN_INFO "%s enter \n",__FUNCTION__);
2736 CLAW_DBF_TEXT(4,trace,"proberr");
2738 printk(KERN_INFO "%s variable cgdev =\n",__FUNCTION__);
2739 dumpit((char *) cgdev, sizeof(struct ccwgroup_device));
2741 privptr=(struct claw_privbk *)cgdev->dev.driver_data;
2742 if (privptr!=NULL) {
2743 kfree(privptr->p_env);
2744 privptr->p_env=NULL;
2745 kfree(privptr->p_mtc_envelope);
2746 privptr->p_mtc_envelope=NULL;
2751 printk(KERN_INFO "%s > exit on line %d\n",
2752 __FUNCTION__,__LINE__);
2760 /*-------------------------------------------------------------------*
2761 * claw_process_control *
2764 *--------------------------------------------------------------------*/
2767 claw_process_control( struct net_device *dev, struct ccwbk * p_ccw)
2770 struct clawbuf *p_buf;
2771 struct clawctl ctlbk;
2772 struct clawctl *p_ctlbk;
2773 char temp_host_name[8];
2774 char temp_ws_name[8];
2775 struct claw_privbk *privptr;
2776 struct claw_env *p_env;
2777 struct sysval *p_sysval;
2778 struct conncmd *p_connect=NULL;
2780 struct chbk *p_ch = NULL;
2782 printk(KERN_INFO "%s: %s() > enter \n",
2783 dev->name,__FUNCTION__);
2785 CLAW_DBF_TEXT(2,setup,"clw_cntl");
2787 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2788 dumpit((char *) dev, sizeof(struct net_device));
2789 printk(KERN_INFO "%s: variable p_ccw =\n",dev->name);
2790 dumpit((char *) p_ccw, sizeof(struct ccwbk *));
2792 udelay(1000); /* Wait a ms for the control packets to
2793 *catch up to each other */
2795 p_env=privptr->p_env;
2796 memcpy( &temp_host_name, p_env->host_name, 8);
2797 memcpy( &temp_ws_name, p_env->adapter_name , 8);
2798 printk(KERN_INFO "%s: CLAW device %.8s: "
2799 "Received Control Packet\n",
2800 dev->name, temp_ws_name);
2801 if (privptr->release_pend==1) {
2803 printk(KERN_INFO "%s: %s() > "
2804 "exit on line %d, rc=0\n",
2805 dev->name,__FUNCTION__,__LINE__);
2809 p_buf=p_ccw->p_buffer;
2811 if (p_env->packing == DO_PACKED) { /* packing in progress?*/
2812 memcpy(p_ctlbk, &p_buf->buffer[4], sizeof(struct clawctl));
2814 memcpy(p_ctlbk, p_buf, sizeof(struct clawctl));
2817 printk(KERN_INFO "%s: dump claw control data inbound\n",dev->name);
2818 dumpit((char *)p_ctlbk, sizeof(struct clawctl));
2820 switch (p_ctlbk->command)
2822 case SYSTEM_VALIDATE_REQUEST:
2823 if (p_ctlbk->version!=CLAW_VERSION_ID) {
2824 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2825 CLAW_RC_WRONG_VERSION );
2826 printk("%s: %d is wrong version id. "
2828 dev->name, p_ctlbk->version,
2831 p_sysval=(struct sysval *)&(p_ctlbk->data);
2832 printk( "%s: Recv Sys Validate Request: "
2833 "Vers=%d,link_id=%d,Corr=%d,WS name=%."
2834 "8s,Host name=%.8s\n",
2835 dev->name, p_ctlbk->version,
2837 p_ctlbk->correlator,
2839 p_sysval->host_name);
2840 if (0!=memcmp(temp_host_name,p_sysval->host_name,8)) {
2841 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2842 CLAW_RC_NAME_MISMATCH );
2843 CLAW_DBF_TEXT(2,setup,"HSTBAD");
2844 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->host_name);
2845 CLAW_DBF_TEXT_(2,setup,"%s",temp_host_name);
2846 printk(KERN_INFO "%s: Host name mismatch\n",
2848 printk(KERN_INFO "%s: Received :%s: "
2851 p_sysval->host_name,
2854 if (0!=memcmp(temp_ws_name,p_sysval->WS_name,8)) {
2855 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2856 CLAW_RC_NAME_MISMATCH );
2857 CLAW_DBF_TEXT(2,setup,"WSNBAD");
2858 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->WS_name);
2859 CLAW_DBF_TEXT_(2,setup,"%s",temp_ws_name);
2860 printk(KERN_INFO "%s: WS name mismatch\n",
2862 printk(KERN_INFO "%s: Received :%s: "
2868 if (( p_sysval->write_frame_size < p_env->write_size) &&
2869 ( p_env->packing == 0)) {
2870 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2871 CLAW_RC_HOST_RCV_TOO_SMALL );
2872 printk(KERN_INFO "%s: host write size is too "
2873 "small\n", dev->name);
2874 CLAW_DBF_TEXT(2,setup,"wrtszbad");
2876 if (( p_sysval->read_frame_size < p_env->read_size) &&
2877 ( p_env->packing == 0)) {
2878 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2879 CLAW_RC_HOST_RCV_TOO_SMALL );
2880 printk(KERN_INFO "%s: host read size is too "
2881 "small\n", dev->name);
2882 CLAW_DBF_TEXT(2,setup,"rdsizbad");
2884 claw_snd_sys_validate_rsp(dev, p_ctlbk, 0 );
2885 printk("%s: CLAW device %.8s: System validate"
2886 " completed.\n",dev->name, temp_ws_name);
2887 printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev->name,
2888 p_sysval->read_frame_size,p_sysval->write_frame_size);
2889 privptr->system_validate_comp=1;
2890 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
2891 p_env->packing = PACKING_ASK;
2893 claw_strt_conn_req(dev);
2896 case SYSTEM_VALIDATE_RESPONSE:
2897 p_sysval=(struct sysval *)&(p_ctlbk->data);
2898 printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
2899 "WS name=%.8s,Host name=%.8s\n",
2902 p_ctlbk->correlator,
2905 p_sysval->host_name);
2906 switch (p_ctlbk->rc)
2909 printk(KERN_INFO "%s: CLAW device "
2910 "%.8s: System validate "
2912 dev->name, temp_ws_name);
2913 if (privptr->system_validate_comp == 0)
2914 claw_strt_conn_req(dev);
2915 privptr->system_validate_comp=1;
2917 case CLAW_RC_NAME_MISMATCH:
2918 printk(KERN_INFO "%s: Sys Validate "
2919 "Resp : Host, WS name is "
2923 case CLAW_RC_WRONG_VERSION:
2924 printk(KERN_INFO "%s: Sys Validate "
2925 "Resp : Wrong version\n",
2928 case CLAW_RC_HOST_RCV_TOO_SMALL:
2929 printk(KERN_INFO "%s: Sys Validate "
2930 "Resp : bad frame size\n",
2934 printk(KERN_INFO "%s: Sys Validate "
2936 dev->name, p_ctlbk->rc );
2941 case CONNECTION_REQUEST:
2942 p_connect=(struct conncmd *)&(p_ctlbk->data);
2943 printk(KERN_INFO "%s: Recv Conn Req: Vers=%d,link_id=%d,"
2944 "Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
2948 p_ctlbk->correlator,
2949 p_connect->host_name,
2950 p_connect->WS_name);
2951 if (privptr->active_link_ID!=0 ) {
2952 claw_snd_disc(dev, p_ctlbk);
2953 printk(KERN_INFO "%s: Conn Req error : "
2954 "already logical link is active \n",
2957 if (p_ctlbk->linkid!=1 ) {
2958 claw_snd_disc(dev, p_ctlbk);
2959 printk(KERN_INFO "%s: Conn Req error : "
2960 "req logical link id is not 1\n",
2964 p_connect->host_name, p_connect->WS_name);
2966 claw_snd_disc(dev, p_ctlbk);
2967 printk(KERN_INFO "%s: Conn Req error : "
2968 "req appl name does not match\n",
2971 claw_send_control(dev,
2972 CONNECTION_CONFIRM, p_ctlbk->linkid,
2973 p_ctlbk->correlator,
2974 0, p_connect->host_name,
2975 p_connect->WS_name);
2976 if (p_env->packing == PACKING_ASK) {
2977 printk("%s: Now Pack ask\n",dev->name);
2978 p_env->packing = PACK_SEND;
2979 claw_snd_conn_req(dev,0);
2981 printk(KERN_INFO "%s: CLAW device %.8s: Connection "
2982 "completed link_id=%d.\n",
2983 dev->name, temp_ws_name,
2985 privptr->active_link_ID=p_ctlbk->linkid;
2986 p_ch=&privptr->channel[WRITE];
2987 wake_up(&p_ch->wait); /* wake up claw_open ( WRITE) */
2989 case CONNECTION_RESPONSE:
2990 p_connect=(struct conncmd *)&(p_ctlbk->data);
2991 printk(KERN_INFO "%s: Revc Conn Resp: Vers=%d,link_id=%d,"
2992 "Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
2996 p_ctlbk->correlator,
2998 p_connect->host_name,
2999 p_connect->WS_name);
3001 if (p_ctlbk->rc !=0 ) {
3002 printk(KERN_INFO "%s: Conn Resp error: rc=%d \n",
3003 dev->name, p_ctlbk->rc);
3007 p_connect->host_name, p_connect->WS_name);
3009 claw_snd_disc(dev, p_ctlbk);
3010 printk(KERN_INFO "%s: Conn Resp error: "
3011 "req appl name does not match\n",
3014 /* should be until CONNECTION_CONFIRM */
3015 privptr->active_link_ID = - (p_ctlbk->linkid);
3017 case CONNECTION_CONFIRM:
3018 p_connect=(struct conncmd *)&(p_ctlbk->data);
3019 printk(KERN_INFO "%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
3020 "Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
3024 p_ctlbk->correlator,
3025 p_connect->host_name,
3026 p_connect->WS_name);
3027 if (p_ctlbk->linkid== -(privptr->active_link_ID)) {
3028 privptr->active_link_ID=p_ctlbk->linkid;
3029 if (p_env->packing > PACKING_ASK) {
3030 printk(KERN_INFO "%s: Confirmed Now packing\n",dev->name);
3031 p_env->packing = DO_PACKED;
3033 p_ch=&privptr->channel[WRITE];
3034 wake_up(&p_ch->wait);
3037 printk(KERN_INFO "%s: Conn confirm: "
3038 "unexpected linkid=%d \n",
3039 dev->name, p_ctlbk->linkid);
3040 claw_snd_disc(dev, p_ctlbk);
3044 printk(KERN_INFO "%s: Disconnect: "
3045 "Vers=%d,link_id=%d,Corr=%d\n",
3046 dev->name, p_ctlbk->version,
3047 p_ctlbk->linkid, p_ctlbk->correlator);
3048 if ((p_ctlbk->linkid == 2) &&
3049 (p_env->packing == PACK_SEND)) {
3050 privptr->active_link_ID = 1;
3051 p_env->packing = DO_PACKED;
3054 privptr->active_link_ID=0;
3057 printk(KERN_INFO "%s: CLAW ERROR detected\n",
3061 printk(KERN_INFO "%s: Unexpected command code=%d \n",
3062 dev->name, p_ctlbk->command);
3067 printk(KERN_INFO "%s: %s() exit on line %d, rc = 0\n",
3068 dev->name,__FUNCTION__,__LINE__);
3072 } /* end of claw_process_control */
3075 /*-------------------------------------------------------------------*
3076 * claw_send_control *
3078 *--------------------------------------------------------------------*/
3081 claw_send_control(struct net_device *dev, __u8 type, __u8 link,
3082 __u8 correlator, __u8 rc, char *local_name, char *remote_name)
3084 struct claw_privbk *privptr;
3085 struct clawctl *p_ctl;
3086 struct sysval *p_sysval;
3087 struct conncmd *p_connect;
3088 struct sk_buff *skb;
3091 printk(KERN_INFO "%s:%s > enter \n",dev->name,__FUNCTION__);
3093 CLAW_DBF_TEXT(2,setup,"sndcntl");
3095 printk(KERN_INFO "%s: Sending Control Packet \n",dev->name);
3096 printk(KERN_INFO "%s: variable type = 0x%X, link = "
3097 "%d, correlator = %d, rc = %d\n",
3098 dev->name,type, link, correlator, rc);
3099 printk(KERN_INFO "%s: variable local_name = %s, "
3100 "remote_name = %s\n",dev->name, local_name, remote_name);
3103 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3105 p_ctl->command=type;
3106 p_ctl->version=CLAW_VERSION_ID;
3108 p_ctl->correlator=correlator;
3111 p_sysval=(struct sysval *)&p_ctl->data;
3112 p_connect=(struct conncmd *)&p_ctl->data;
3114 switch (p_ctl->command) {
3115 case SYSTEM_VALIDATE_REQUEST:
3116 case SYSTEM_VALIDATE_RESPONSE:
3117 memcpy(&p_sysval->host_name, local_name, 8);
3118 memcpy(&p_sysval->WS_name, remote_name, 8);
3119 if (privptr->p_env->packing > 0) {
3120 p_sysval->read_frame_size=DEF_PACK_BUFSIZE;
3121 p_sysval->write_frame_size=DEF_PACK_BUFSIZE;
3123 /* how big is the piggest group of packets */
3124 p_sysval->read_frame_size=privptr->p_env->read_size;
3125 p_sysval->write_frame_size=privptr->p_env->write_size;
3127 memset(&p_sysval->reserved, 0x00, 4);
3129 case CONNECTION_REQUEST:
3130 case CONNECTION_RESPONSE:
3131 case CONNECTION_CONFIRM:
3133 memcpy(&p_sysval->host_name, local_name, 8);
3134 memcpy(&p_sysval->WS_name, remote_name, 8);
3135 if (privptr->p_env->packing > 0) {
3136 /* How big is the biggest packet */
3137 p_connect->reserved1[0]=CLAW_FRAME_SIZE;
3138 p_connect->reserved1[1]=CLAW_FRAME_SIZE;
3140 memset(&p_connect->reserved1, 0x00, 4);
3141 memset(&p_connect->reserved2, 0x00, 4);
3148 /* write Control Record to the device */
3151 skb = dev_alloc_skb(sizeof(struct clawctl));
3153 printk( "%s:%s low on mem, returning...\n",
3154 dev->name,__FUNCTION__);
3156 printk(KERN_INFO "%s:%s Exit, rc = ENOMEM\n",
3157 dev->name,__FUNCTION__);
3161 memcpy(skb_put(skb, sizeof(struct clawctl)),
3162 p_ctl, sizeof(struct clawctl));
3164 printk(KERN_INFO "%s: outbnd claw cntl data \n",dev->name);
3165 dumpit((char *)p_ctl,sizeof(struct clawctl));
3167 if (privptr->p_env->packing >= PACK_SEND)
3168 claw_hw_tx(skb, dev, 1);
3170 claw_hw_tx(skb, dev, 0);
3172 printk(KERN_INFO "%s:%s Exit on line %d\n",
3173 dev->name,__FUNCTION__,__LINE__);
3177 } /* end of claw_send_control */
3179 /*-------------------------------------------------------------------*
3180 * claw_snd_conn_req *
3182 *--------------------------------------------------------------------*/
3184 claw_snd_conn_req(struct net_device *dev, __u8 link)
3187 struct claw_privbk *privptr=dev->priv;
3188 struct clawctl *p_ctl;
3191 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
3193 CLAW_DBF_TEXT(2,setup,"snd_conn");
3195 printk(KERN_INFO "%s: variable link = %X, dev =\n",dev->name, link);
3196 dumpit((char *) dev, sizeof(struct net_device));
3199 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3200 p_ctl->linkid = link;
3201 if ( privptr->system_validate_comp==0x00 ) {
3203 printk(KERN_INFO "%s:%s Exit on line %d, rc = 1\n",
3204 dev->name,__FUNCTION__,__LINE__);
3208 if (privptr->p_env->packing == PACKING_ASK )
3209 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3210 WS_APPL_NAME_PACKED, WS_APPL_NAME_PACKED);
3211 if (privptr->p_env->packing == PACK_SEND) {
3212 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3213 WS_APPL_NAME_IP_NAME, WS_APPL_NAME_IP_NAME);
3215 if (privptr->p_env->packing == 0)
3216 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3217 HOST_APPL_NAME, privptr->p_env->api_type);
3219 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3220 dev->name,__FUNCTION__,__LINE__, rc);
3224 } /* end of claw_snd_conn_req */
3227 /*-------------------------------------------------------------------*
3230 *--------------------------------------------------------------------*/
3233 claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl)
3236 struct conncmd * p_connect;
3239 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3241 CLAW_DBF_TEXT(2,setup,"snd_dsc");
3243 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3244 dumpit((char *) dev, sizeof(struct net_device));
3245 printk(KERN_INFO "%s: variable p_ctl",dev->name);
3246 dumpit((char *) p_ctl, sizeof(struct clawctl));
3248 p_connect=(struct conncmd *)&p_ctl->data;
3250 rc=claw_send_control(dev, DISCONNECT, p_ctl->linkid,
3251 p_ctl->correlator, 0,
3252 p_connect->host_name, p_connect->WS_name);
3254 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3255 dev->name,__FUNCTION__, __LINE__, rc);
3258 } /* end of claw_snd_disc */
3261 /*-------------------------------------------------------------------*
3262 * claw_snd_sys_validate_rsp *
3264 *--------------------------------------------------------------------*/
3267 claw_snd_sys_validate_rsp(struct net_device *dev,
3268 struct clawctl *p_ctl, __u32 return_code)
3270 struct claw_env * p_env;
3271 struct claw_privbk *privptr;
3275 printk(KERN_INFO "%s:%s Enter\n",
3276 dev->name,__FUNCTION__);
3278 CLAW_DBF_TEXT(2,setup,"chkresp");
3280 printk(KERN_INFO "%s: variable return_code = %d, dev =\n",
3281 dev->name, return_code);
3282 dumpit((char *) dev, sizeof(struct net_device));
3283 printk(KERN_INFO "%s: variable p_ctl =\n",dev->name);
3284 dumpit((char *) p_ctl, sizeof(struct clawctl));
3286 privptr = dev->priv;
3287 p_env=privptr->p_env;
3288 rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE,
3293 p_env->adapter_name );
3295 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3296 dev->name,__FUNCTION__,__LINE__, rc);
3299 } /* end of claw_snd_sys_validate_rsp */
3301 /*-------------------------------------------------------------------*
3302 * claw_strt_conn_req *
3304 *--------------------------------------------------------------------*/
3307 claw_strt_conn_req(struct net_device *dev )
3312 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3314 CLAW_DBF_TEXT(2,setup,"conn_req");
3316 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3317 dumpit((char *) dev, sizeof(struct net_device));
3319 rc=claw_snd_conn_req(dev, 1);
3321 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3322 dev->name,__FUNCTION__,__LINE__, rc);
3325 } /* end of claw_strt_conn_req */
3329 /*-------------------------------------------------------------------*
3331 *-------------------------------------------------------------------*/
3334 net_device_stats *claw_stats(struct net_device *dev)
3336 struct claw_privbk *privptr;
3338 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3340 CLAW_DBF_TEXT(4,trace,"stats");
3341 privptr = dev->priv;
3343 printk(KERN_INFO "%s:%s Exit on line %d\n",
3344 dev->name,__FUNCTION__,__LINE__);
3346 return &privptr->stats;
3347 } /* end of claw_stats */
3350 /*-------------------------------------------------------------------*
3353 *--------------------------------------------------------------------*/
3355 unpack_read(struct net_device *dev )
3357 struct sk_buff *skb;
3358 struct claw_privbk *privptr;
3359 struct claw_env *p_env;
3360 struct ccwbk *p_this_ccw;
3361 struct ccwbk *p_first_ccw;
3362 struct ccwbk *p_last_ccw;
3363 struct clawph *p_packh;
3365 struct clawctl *p_ctlrec=NULL;
3370 __u8 mtc_this_frm=0;
3372 struct chbk *p_ch = NULL;
3377 printk(KERN_INFO "%s:%s enter \n",dev->name,__FUNCTION__);
3379 CLAW_DBF_TEXT(4,trace,"unpkread");
3385 p_env = privptr->p_env;
3386 p_this_ccw=privptr->p_read_active_first;
3388 while (p_this_ccw!=NULL && p_this_ccw->header.flag!=CLAW_PENDING) {
3390 printk(KERN_INFO "%s p_this_ccw \n",dev->name);
3391 dumpit((char*)p_this_ccw, sizeof(struct ccwbk));
3392 printk(KERN_INFO "%s Inbound p_this_ccw->p_buffer(64)"
3393 " pk=%d \n",dev->name,p_env->packing);
3394 dumpit((char *)p_this_ccw->p_buffer, 64 );
3398 p_this_ccw->header.flag=CLAW_PENDING;
3399 privptr->p_read_active_first=p_this_ccw->next;
3400 p_this_ccw->next=NULL;
3401 p_packh = (struct clawph *)p_this_ccw->p_buffer;
3402 if ((p_env->packing == PACK_SEND) &&
3403 (p_packh->len == 32) &&
3404 (p_packh->link_num == 0)) { /* is it a packed ctl rec? */
3405 p_packh++; /* peek past pack header */
3406 p_ctlrec = (struct clawctl *)p_packh;
3407 p_packh--; /* un peek */
3408 if ((p_ctlrec->command == CONNECTION_RESPONSE) ||
3409 (p_ctlrec->command == CONNECTION_CONFIRM))
3410 p_env->packing = DO_PACKED;
3412 if (p_env->packing == DO_PACKED)
3413 link_num=p_packh->link_num;
3415 link_num=p_this_ccw->header.opcode / 8;
3416 if ((p_this_ccw->header.opcode & MORE_to_COME_FLAG)!=0) {
3418 printk(KERN_INFO "%s: %s > More_to_come is ON\n",
3419 dev->name,__FUNCTION__);
3422 if (p_this_ccw->header.length!=
3423 privptr->p_env->read_size ) {
3424 printk(KERN_INFO " %s: Invalid frame detected "
3425 "length is %02x\n" ,
3426 dev->name, p_this_ccw->header.length);
3430 if (privptr->mtc_skipping) {
3432 * We're in the mode of skipping past a
3433 * multi-frame message
3434 * that we can't process for some reason or other.
3435 * The first frame without the More-To-Come flag is
3436 * the last frame of the skipped message.
3438 /* in case of More-To-Come not set in this frame */
3439 if (mtc_this_frm==0) {
3440 privptr->mtc_skipping=0; /* Ok, the end */
3441 privptr->mtc_logical_link=-1;
3444 printk(KERN_INFO "%s:%s goto next "
3445 "frame from MoretoComeSkip \n",
3446 dev->name,__FUNCTION__);
3452 claw_process_control(dev, p_this_ccw);
3454 printk(KERN_INFO "%s:%s goto next "
3455 "frame from claw_process_control \n",
3456 dev->name,__FUNCTION__);
3458 CLAW_DBF_TEXT(4,trace,"UnpkCntl");
3462 if (p_env->packing == DO_PACKED) {
3463 if (pack_off > p_env->read_size)
3465 p_packd = p_this_ccw->p_buffer+pack_off;
3466 p_packh = (struct clawph *) p_packd;
3467 if ((p_packh->len == 0) || /* all done with this frame? */
3468 (p_packh->flag != 0))
3470 bytes_to_mov = p_packh->len;
3471 pack_off += bytes_to_mov+sizeof(struct clawph);
3474 bytes_to_mov=p_this_ccw->header.length;
3476 if (privptr->mtc_logical_link<0) {
3478 printk(KERN_INFO "%s: %s mtc_logical_link < 0 \n",
3479 dev->name,__FUNCTION__);
3483 * if More-To-Come is set in this frame then we don't know
3484 * length of entire message, and hence have to allocate
3487 /* We are starting a new envelope */
3488 privptr->mtc_offset=0;
3489 privptr->mtc_logical_link=link_num;
3492 if (bytes_to_mov > (MAX_ENVELOPE_SIZE- privptr->mtc_offset) ) {
3495 printk(KERN_INFO "%s: %s > goto next "
3496 "frame from MoretoComeSkip \n",
3499 printk(KERN_INFO " bytes_to_mov %d > (MAX_ENVELOPE_"
3500 "SIZE-privptr->mtc_offset %d)\n",
3501 bytes_to_mov,(MAX_ENVELOPE_SIZE- privptr->mtc_offset));
3503 privptr->stats.rx_frame_errors++;
3506 if (p_env->packing == DO_PACKED) {
3507 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3508 p_packd+sizeof(struct clawph), bytes_to_mov);
3511 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3512 p_this_ccw->p_buffer, bytes_to_mov);
3515 printk(KERN_INFO "%s: %s() received data \n",
3516 dev->name,__FUNCTION__);
3517 if (p_env->packing == DO_PACKED)
3518 dumpit((char *)p_packd+sizeof(struct clawph),32);
3520 dumpit((char *)p_this_ccw->p_buffer, 32);
3521 printk(KERN_INFO "%s: %s() bytelength %d \n",
3522 dev->name,__FUNCTION__,bytes_to_mov);
3524 if (mtc_this_frm==0) {
3525 len_of_data=privptr->mtc_offset+bytes_to_mov;
3526 skb=dev_alloc_skb(len_of_data);
3528 memcpy(skb_put(skb,len_of_data),
3529 privptr->p_mtc_envelope,
3531 skb->mac.raw=skb->data;
3533 skb->protocol=htons(ETH_P_IP);
3534 skb->ip_summed=CHECKSUM_UNNECESSARY;
3535 privptr->stats.rx_packets++;
3536 privptr->stats.rx_bytes+=len_of_data;
3539 printk(KERN_INFO "%s: %s() netif_"
3540 "rx(skb) completed \n",
3541 dev->name,__FUNCTION__);
3545 privptr->stats.rx_dropped++;
3546 printk(KERN_WARNING "%s: %s() low on memory\n",
3547 dev->name,__FUNCTION__);
3549 privptr->mtc_offset=0;
3550 privptr->mtc_logical_link=-1;
3553 privptr->mtc_offset+=bytes_to_mov;
3555 if (p_env->packing == DO_PACKED)
3559 * Remove ThisCCWblock from active read queue, and add it
3560 * to queue of free blocks to be reused.
3563 p_this_ccw->header.length=0xffff;
3564 p_this_ccw->header.opcode=0xff;
3566 * add this one to the free queue for later reuse
3568 if (p_first_ccw==NULL) {
3569 p_first_ccw = p_this_ccw;
3572 p_last_ccw->next = p_this_ccw;
3574 p_last_ccw = p_this_ccw;
3576 * chain to next block on active read queue
3578 p_this_ccw = privptr->p_read_active_first;
3579 CLAW_DBF_TEXT_(4,trace,"rxpkt %d",p);
3580 } /* end of while */
3582 /* check validity */
3585 printk(KERN_INFO "%s:%s processed frame is %d \n",
3586 dev->name,__FUNCTION__,i);
3587 printk(KERN_INFO "%s:%s F:%lx L:%lx\n",
3590 (unsigned long)p_first_ccw,
3591 (unsigned long)p_last_ccw);
3593 CLAW_DBF_TEXT_(4,trace,"rxfrm %d",i);
3594 add_claw_reads(dev, p_first_ccw, p_last_ccw);
3595 p_ch=&privptr->channel[READ];
3596 claw_strt_read(dev, LOCK_YES);
3598 printk(KERN_INFO "%s: %s exit on line %d\n",
3599 dev->name, __FUNCTION__, __LINE__);
3602 } /* end of unpack_read */
3604 /*-------------------------------------------------------------------*
3607 *--------------------------------------------------------------------*/
3609 claw_strt_read (struct net_device *dev, int lock )
3613 unsigned long saveflags = 0;
3614 struct claw_privbk *privptr=dev->priv;
3615 struct ccwbk*p_ccwbk;
3617 struct clawh *p_clawh;
3618 p_ch=&privptr->channel[READ];
3621 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
3622 printk(KERN_INFO "%s: variable lock = %d, dev =\n",dev->name, lock);
3623 dumpit((char *) dev, sizeof(struct net_device));
3625 CLAW_DBF_TEXT(4,trace,"StRdNter");
3626 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3627 p_clawh->flag=CLAW_IDLE; /* 0x00 */
3629 if ((privptr->p_write_active_first!=NULL &&
3630 privptr->p_write_active_first->header.flag!=CLAW_PENDING) ||
3631 (privptr->p_read_active_first!=NULL &&
3632 privptr->p_read_active_first->header.flag!=CLAW_PENDING )) {
3633 p_clawh->flag=CLAW_BUSY; /* 0xff */
3636 printk(KERN_INFO "%s:%s state-%02x\n" ,
3637 dev->name,__FUNCTION__, p_ch->claw_state);
3639 if (lock==LOCK_YES) {
3640 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
3642 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3644 printk(KERN_INFO "%s: HOT READ started in %s\n" ,
3645 dev->name,__FUNCTION__);
3646 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3647 dumpit((char *)&p_clawh->flag , 1);
3649 CLAW_DBF_TEXT(4,trace,"HotRead");
3650 p_ccwbk=privptr->p_read_active_first;
3651 parm = (unsigned long) p_ch;
3652 rc = ccw_device_start (p_ch->cdev, &p_ccwbk->read, parm,
3655 ccw_check_return_code(p_ch->cdev, rc);
3660 printk(KERN_INFO "%s: No READ started by %s() In progress\n" ,
3661 dev->name,__FUNCTION__);
3663 CLAW_DBF_TEXT(2,trace,"ReadAct");
3666 if (lock==LOCK_YES) {
3667 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
3670 printk(KERN_INFO "%s:%s Exit on line %d\n",
3671 dev->name,__FUNCTION__,__LINE__);
3673 CLAW_DBF_TEXT(4,trace,"StRdExit");
3675 } /* end of claw_strt_read */
3677 /*-------------------------------------------------------------------*
3678 * claw_strt_out_IO *
3680 *--------------------------------------------------------------------*/
3683 claw_strt_out_IO( struct net_device *dev )
3687 struct claw_privbk *privptr;
3689 struct ccwbk *p_first_ccw;
3692 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3697 privptr=(struct claw_privbk *)dev->priv;
3698 p_ch=&privptr->channel[WRITE];
3701 printk(KERN_INFO "%s:%s state-%02x\n" ,
3702 dev->name,__FUNCTION__,p_ch->claw_state);
3704 CLAW_DBF_TEXT(4,trace,"strt_io");
3705 p_first_ccw=privptr->p_write_active_first;
3707 if (p_ch->claw_state == CLAW_STOP)
3709 if (p_first_ccw == NULL) {
3711 printk(KERN_INFO "%s:%s Exit on line %d\n",
3712 dev->name,__FUNCTION__,__LINE__);
3716 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3717 parm = (unsigned long) p_ch;
3719 printk(KERN_INFO "%s:%s do_io \n" ,dev->name,__FUNCTION__);
3720 dumpit((char *)p_first_ccw, sizeof(struct ccwbk));
3722 CLAW_DBF_TEXT(2,trace,"StWrtIO");
3723 rc = ccw_device_start (p_ch->cdev,&p_first_ccw->write, parm,
3726 ccw_check_return_code(p_ch->cdev, rc);
3729 dev->trans_start = jiffies;
3731 printk(KERN_INFO "%s:%s Exit on line %d\n",
3732 dev->name,__FUNCTION__,__LINE__);
3736 } /* end of claw_strt_out_IO */
3738 /*-------------------------------------------------------------------*
3739 * Free write buffers *
3741 *--------------------------------------------------------------------*/
3744 claw_free_wrt_buf( struct net_device *dev )
3747 struct claw_privbk *privptr=(struct claw_privbk *)dev->priv;
3748 struct ccwbk*p_first_ccw;
3749 struct ccwbk*p_last_ccw;
3750 struct ccwbk*p_this_ccw;
3751 struct ccwbk*p_next_ccw;
3756 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3757 printk(KERN_INFO "%s: free count = %d variable dev =\n",
3758 dev->name,privptr->write_free_count);
3760 CLAW_DBF_TEXT(4,trace,"freewrtb");
3761 /* scan the write queue to free any completed write packets */
3765 printk(KERN_INFO "%s: Dump current CCW chain \n",dev->name );
3766 p_buf=privptr->p_write_active_first;
3767 while (p_buf!=NULL) {
3768 dumpit((char *)p_buf, sizeof(struct ccwbk));
3772 printk(KERN_INFO "%s: privptr->p_write_"
3773 "active_first==NULL\n",dev->name );
3775 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3776 dumpit((char *)p_buf, sizeof(struct endccw));
3778 p_this_ccw=privptr->p_write_active_first;
3779 while ( (p_this_ccw!=NULL) && (p_this_ccw->header.flag!=CLAW_PENDING))
3781 p_next_ccw = p_this_ccw->next;
3782 if (((p_next_ccw!=NULL) &&
3783 (p_next_ccw->header.flag!=CLAW_PENDING)) ||
3784 ((p_this_ccw == privptr->p_write_active_last) &&
3785 (p_this_ccw->header.flag!=CLAW_PENDING))) {
3786 /* The next CCW is OK or this is */
3787 /* the last CCW...free it @A1A */
3788 privptr->p_write_active_first=p_this_ccw->next;
3789 p_this_ccw->header.flag=CLAW_PENDING;
3790 p_this_ccw->next=privptr->p_write_free_chain;
3791 privptr->p_write_free_chain=p_this_ccw;
3792 ++privptr->write_free_count;
3793 privptr->stats.tx_bytes+= p_this_ccw->write.count;
3794 p_this_ccw=privptr->p_write_active_first;
3795 privptr->stats.tx_packets++;
3801 if (privptr->write_free_count!=0) {
3802 claw_clearbit_busy(TB_NOBUFFER,dev);
3804 /* whole chain removed? */
3805 if (privptr->p_write_active_first==NULL) {
3806 privptr->p_write_active_last=NULL;
3808 printk(KERN_INFO "%s:%s p_write_"
3809 "active_first==NULL\n",dev->name,__FUNCTION__);
3813 printk(KERN_INFO "%s: Dump arranged CCW chain \n",dev->name );
3814 p_buf=privptr->p_write_active_first;
3815 while (p_buf!=NULL) {
3816 dumpit((char *)p_buf, sizeof(struct ccwbk));
3820 printk(KERN_INFO "%s: privptr->p_write_active_"
3821 "first==NULL\n",dev->name );
3823 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3824 dumpit((char *)p_buf, sizeof(struct endccw));
3827 CLAW_DBF_TEXT_(4,trace,"FWC=%d",privptr->write_free_count);
3829 printk(KERN_INFO "%s:%s Exit on line %d free_count =%d\n",
3830 dev->name,__FUNCTION__, __LINE__,privptr->write_free_count);
3835 /*-------------------------------------------------------------------*
3836 * claw free netdevice *
3838 *--------------------------------------------------------------------*/
3840 claw_free_netdevice(struct net_device * dev, int free_dev)
3842 struct claw_privbk *privptr;
3844 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3846 CLAW_DBF_TEXT(2,setup,"free_dev");
3850 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3851 privptr = dev->priv;
3852 if (dev->flags & IFF_RUNNING)
3855 privptr->channel[READ].ndev = NULL; /* say it's free */
3863 CLAW_DBF_TEXT(2,setup,"feee_ok");
3865 printk(KERN_INFO "%s:%s Exit\n",dev->name,__FUNCTION__);
3870 * Claw init netdevice
3871 * Initialize everything of the net device except the name and the
3875 claw_init_netdevice(struct net_device * dev)
3878 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3880 CLAW_DBF_TEXT(2,setup,"init_dev");
3881 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3883 printk(KERN_WARNING "claw:%s BAD Device exit line %d\n",
3884 __FUNCTION__,__LINE__);
3885 CLAW_DBF_TEXT(2,setup,"baddev");
3888 dev->mtu = CLAW_DEFAULT_MTU_SIZE;
3889 dev->hard_start_xmit = claw_tx;
3890 dev->open = claw_open;
3891 dev->stop = claw_release;
3892 dev->get_stats = claw_stats;
3893 dev->change_mtu = claw_change_mtu;
3894 dev->hard_header_len = 0;
3896 dev->type = ARPHRD_SLIP;
3897 dev->tx_queue_len = 1300;
3898 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
3899 SET_MODULE_OWNER(dev);
3901 printk(KERN_INFO "%s:%s Exit\n",dev->name,__FUNCTION__);
3903 CLAW_DBF_TEXT(2,setup,"initok");
3908 * Init a new channel in the privptr->channel[i].
3910 * @param cdev The ccw_device to be added.
3912 * @return 0 on success, !0 on error.
3915 add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
3920 printk(KERN_INFO "%s:%s Enter\n",cdev->dev.bus_id,__FUNCTION__);
3922 CLAW_DBF_TEXT_(2,setup,"%s",cdev->dev.bus_id);
3923 privptr->channel[i].flag = i+1; /* Read is 1 Write is 2 */
3924 p_ch = &privptr->channel[i];
3926 snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id);
3927 sscanf(cdev->dev.bus_id+4,"%x",&p_ch->devno);
3928 if ((p_ch->irb = kmalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) {
3929 printk(KERN_WARNING "%s Out of memory in %s for irb\n",
3930 p_ch->id,__FUNCTION__);
3932 printk(KERN_INFO "%s:%s Exit on line %d\n",
3933 p_ch->id,__FUNCTION__,__LINE__);
3937 memset(p_ch->irb, 0, sizeof (struct irb));
3939 printk(KERN_INFO "%s:%s Exit on line %d\n",
3940 cdev->dev.bus_id,__FUNCTION__,__LINE__);
3948 * Setup an interface.
3950 * @param cgdev Device to be setup.
3952 * @returns 0 on success, !0 on failure.
3955 claw_new_device(struct ccwgroup_device *cgdev)
3957 struct claw_privbk *privptr;
3958 struct claw_env *p_env;
3959 struct net_device *dev;
3962 pr_debug("%s() called\n", __FUNCTION__);
3963 printk(KERN_INFO "claw: add for %s\n",cgdev->cdev[READ]->dev.bus_id);
3964 CLAW_DBF_TEXT(2,setup,"new_dev");
3965 privptr = cgdev->dev.driver_data;
3966 cgdev->cdev[READ]->dev.driver_data = privptr;
3967 cgdev->cdev[WRITE]->dev.driver_data = privptr;
3970 p_env = privptr->p_env;
3971 sscanf(cgdev->cdev[READ]->dev.bus_id+4,"%x",
3972 &p_env->devno[READ]);
3973 sscanf(cgdev->cdev[WRITE]->dev.bus_id+4,"%x",
3974 &p_env->devno[WRITE]);
3975 ret = add_channel(cgdev->cdev[0],0,privptr);
3977 ret = add_channel(cgdev->cdev[1],1,privptr);
3980 "add channel failed "
3981 "with ret = %d\n", ret);
3984 ret = ccw_device_set_online(cgdev->cdev[READ]);
3987 "claw: ccw_device_set_online %s READ failed "
3988 "with ret = %d\n",cgdev->cdev[READ]->dev.bus_id,ret);
3991 ret = ccw_device_set_online(cgdev->cdev[WRITE]);
3994 "claw: ccw_device_set_online %s WRITE failed "
3995 "with ret = %d\n",cgdev->cdev[WRITE]->dev.bus_id, ret);
3998 dev = alloc_netdev(0,"claw%d",claw_init_netdevice);
4000 printk(KERN_WARNING "%s:alloc_netdev failed\n",__FUNCTION__);
4003 dev->priv = privptr;
4004 cgdev->dev.driver_data = privptr;
4005 cgdev->cdev[READ]->dev.driver_data = privptr;
4006 cgdev->cdev[WRITE]->dev.driver_data = privptr;
4008 SET_NETDEV_DEV(dev, &cgdev->dev);
4009 if (register_netdev(dev) != 0) {
4010 claw_free_netdevice(dev, 1);
4011 CLAW_DBF_TEXT(2,trace,"regfail");
4014 dev->flags &=~IFF_RUNNING;
4015 if (privptr->buffs_alloc == 0) {
4016 ret=init_ccw_bk(dev);
4019 "claw: init_ccw_bk failed with ret=%d\n", ret);
4020 unregister_netdev(dev);
4021 claw_free_netdevice(dev,1);
4022 CLAW_DBF_TEXT(2,trace,"ccwmem");
4026 privptr->channel[READ].ndev = dev;
4027 privptr->channel[WRITE].ndev = dev;
4028 privptr->p_env->ndev = dev;
4030 printk(KERN_INFO "%s:readsize=%d writesize=%d "
4031 "readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
4032 dev->name, p_env->read_size,
4033 p_env->write_size, p_env->read_buffers,
4034 p_env->write_buffers, p_env->devno[READ],
4035 p_env->devno[WRITE]);
4036 printk(KERN_INFO "%s:host_name:%.8s, adapter_name "
4037 ":%.8s api_type: %.8s\n",
4038 dev->name, p_env->host_name,
4039 p_env->adapter_name , p_env->api_type);
4042 ccw_device_set_offline(cgdev->cdev[1]);
4043 ccw_device_set_offline(cgdev->cdev[0]);
4049 claw_purge_skb_queue(struct sk_buff_head *q)
4051 struct sk_buff *skb;
4053 CLAW_DBF_TEXT(4,trace,"purgque");
4055 while ((skb = skb_dequeue(q))) {
4056 atomic_dec(&skb->users);
4057 dev_kfree_skb_any(skb);
4062 * Shutdown an interface.
4064 * @param cgdev Device to be shut down.
4066 * @returns 0 on success, !0 on failure.
4069 claw_shutdown_device(struct ccwgroup_device *cgdev)
4071 struct claw_privbk *priv;
4072 struct net_device *ndev;
4075 pr_debug("%s() called\n", __FUNCTION__);
4076 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4077 priv = cgdev->dev.driver_data;
4080 ndev = priv->channel[READ].ndev;
4082 /* Close the device */
4084 "%s: shuting down \n",ndev->name);
4085 if (ndev->flags & IFF_RUNNING)
4086 ret = claw_release(ndev);
4087 ndev->flags &=~IFF_RUNNING;
4088 unregister_netdev(ndev);
4089 ndev->priv = NULL; /* cgdev data, not ndev's to free */
4090 claw_free_netdevice(ndev, 1);
4091 priv->channel[READ].ndev = NULL;
4092 priv->channel[WRITE].ndev = NULL;
4093 priv->p_env->ndev = NULL;
4095 ccw_device_set_offline(cgdev->cdev[1]);
4096 ccw_device_set_offline(cgdev->cdev[0]);
4101 claw_remove_device(struct ccwgroup_device *cgdev)
4103 struct claw_privbk *priv;
4105 pr_debug("%s() called\n", __FUNCTION__);
4106 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4107 priv = cgdev->dev.driver_data;
4109 printk(KERN_WARNING "claw: %s() no Priv exiting\n",__FUNCTION__);
4112 printk(KERN_INFO "claw: %s() called %s will be removed.\n",
4113 __FUNCTION__,cgdev->cdev[0]->dev.bus_id);
4114 if (cgdev->state == CCWGROUP_ONLINE)
4115 claw_shutdown_device(cgdev);
4116 claw_remove_files(&cgdev->dev);
4117 kfree(priv->p_mtc_envelope);
4118 priv->p_mtc_envelope=NULL;
4121 kfree(priv->channel[0].irb);
4122 priv->channel[0].irb=NULL;
4123 kfree(priv->channel[1].irb);
4124 priv->channel[1].irb=NULL;
4126 cgdev->dev.driver_data=NULL;
4127 cgdev->cdev[READ]->dev.driver_data = NULL;
4128 cgdev->cdev[WRITE]->dev.driver_data = NULL;
4129 put_device(&cgdev->dev);
4137 claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
4139 struct claw_privbk *priv;
4140 struct claw_env * p_env;
4142 priv = dev->driver_data;
4145 p_env = priv->p_env;
4146 return sprintf(buf, "%s\n",p_env->host_name);
4150 claw_hname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4152 struct claw_privbk *priv;
4153 struct claw_env * p_env;
4155 priv = dev->driver_data;
4158 p_env = priv->p_env;
4159 if (count > MAX_NAME_LEN+1)
4161 memset(p_env->host_name, 0x20, MAX_NAME_LEN);
4162 strncpy(p_env->host_name,buf, count);
4163 p_env->host_name[count-1] = 0x20; /* clear extra 0x0a */
4164 p_env->host_name[MAX_NAME_LEN] = 0x00;
4165 CLAW_DBF_TEXT(2,setup,"HstnSet");
4166 CLAW_DBF_TEXT_(2,setup,"%s",p_env->host_name);
4171 static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write);
4174 claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
4176 struct claw_privbk *priv;
4177 struct claw_env * p_env;
4179 priv = dev->driver_data;
4182 p_env = priv->p_env;
4183 return sprintf(buf, "%s\n",p_env->adapter_name);
4187 claw_adname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4189 struct claw_privbk *priv;
4190 struct claw_env * p_env;
4192 priv = dev->driver_data;
4195 p_env = priv->p_env;
4196 if (count > MAX_NAME_LEN+1)
4198 memset(p_env->adapter_name, 0x20, MAX_NAME_LEN);
4199 strncpy(p_env->adapter_name,buf, count);
4200 p_env->adapter_name[count-1] = 0x20; /* clear extra 0x0a */
4201 p_env->adapter_name[MAX_NAME_LEN] = 0x00;
4202 CLAW_DBF_TEXT(2,setup,"AdnSet");
4203 CLAW_DBF_TEXT_(2,setup,"%s",p_env->adapter_name);
4208 static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write);
4211 claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
4213 struct claw_privbk *priv;
4214 struct claw_env * p_env;
4216 priv = dev->driver_data;
4219 p_env = priv->p_env;
4220 return sprintf(buf, "%s\n",
4225 claw_apname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4227 struct claw_privbk *priv;
4228 struct claw_env * p_env;
4230 priv = dev->driver_data;
4233 p_env = priv->p_env;
4234 if (count > MAX_NAME_LEN+1)
4236 memset(p_env->api_type, 0x20, MAX_NAME_LEN);
4237 strncpy(p_env->api_type,buf, count);
4238 p_env->api_type[count-1] = 0x20; /* we get a loose 0x0a */
4239 p_env->api_type[MAX_NAME_LEN] = 0x00;
4240 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
4241 p_env->read_size=DEF_PACK_BUFSIZE;
4242 p_env->write_size=DEF_PACK_BUFSIZE;
4243 p_env->packing=PACKING_ASK;
4244 CLAW_DBF_TEXT(2,setup,"PACKING");
4248 p_env->read_size=CLAW_FRAME_SIZE;
4249 p_env->write_size=CLAW_FRAME_SIZE;
4250 CLAW_DBF_TEXT(2,setup,"ApiSet");
4252 CLAW_DBF_TEXT_(2,setup,"%s",p_env->api_type);
4256 static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write);
4259 claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4261 struct claw_privbk *priv;
4262 struct claw_env * p_env;
4264 priv = dev->driver_data;
4267 p_env = priv->p_env;
4268 return sprintf(buf, "%d\n", p_env->write_buffers);
4272 claw_wbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4274 struct claw_privbk *priv;
4275 struct claw_env * p_env;
4278 priv = dev->driver_data;
4281 p_env = priv->p_env;
4282 sscanf(buf, "%i", &nnn);
4283 if (p_env->packing) {
4289 if ((nnn > max ) || (nnn < 2))
4291 p_env->write_buffers = nnn;
4292 CLAW_DBF_TEXT(2,setup,"Wbufset");
4293 CLAW_DBF_TEXT_(2,setup,"WB=%d",p_env->write_buffers);
4297 static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write);
4300 claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4302 struct claw_privbk *priv;
4303 struct claw_env * p_env;
4305 priv = dev->driver_data;
4308 p_env = priv->p_env;
4309 return sprintf(buf, "%d\n", p_env->read_buffers);
4313 claw_rbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4315 struct claw_privbk *priv;
4316 struct claw_env *p_env;
4319 priv = dev->driver_data;
4322 p_env = priv->p_env;
4323 sscanf(buf, "%i", &nnn);
4324 if (p_env->packing) {
4330 if ((nnn > max ) || (nnn < 2))
4332 p_env->read_buffers = nnn;
4333 CLAW_DBF_TEXT(2,setup,"Rbufset");
4334 CLAW_DBF_TEXT_(2,setup,"RB=%d",p_env->read_buffers);
4338 static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write);
4340 static struct attribute *claw_attr[] = {
4341 &dev_attr_read_buffer.attr,
4342 &dev_attr_write_buffer.attr,
4343 &dev_attr_adapter_name.attr,
4344 &dev_attr_api_type.attr,
4345 &dev_attr_host_name.attr,
4349 static struct attribute_group claw_attr_group = {
4354 claw_add_files(struct device *dev)
4356 pr_debug("%s() called\n", __FUNCTION__);
4357 CLAW_DBF_TEXT(2,setup,"add_file");
4358 return sysfs_create_group(&dev->kobj, &claw_attr_group);
4362 claw_remove_files(struct device *dev)
4364 pr_debug("%s() called\n", __FUNCTION__);
4365 CLAW_DBF_TEXT(2,setup,"rem_file");
4366 sysfs_remove_group(&dev->kobj, &claw_attr_group);
4369 /*--------------------------------------------------------------------*
4370 * claw_init and cleanup *
4371 *---------------------------------------------------------------------*/
4376 unregister_cu3088_discipline(&claw_group_driver);
4377 claw_unregister_debug_facility();
4378 printk(KERN_INFO "claw: Driver unloaded\n");
4383 * Initialize module.
4384 * This is called just after the module is loaded.
4386 * @return 0 on success, !0 on error.
4392 printk(KERN_INFO "claw: starting driver\n");
4395 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__);
4397 ret = claw_register_debug_facility();
4399 printk(KERN_WARNING "claw: %s() debug_register failed %d\n",
4403 CLAW_DBF_TEXT(2,setup,"init_mod");
4404 ret = register_cu3088_discipline(&claw_group_driver);
4406 claw_unregister_debug_facility();
4407 printk(KERN_WARNING "claw; %s() cu3088 register failed %d\n",
4411 printk(KERN_INFO "claw: %s() exit \n",__FUNCTION__);
4416 module_init(claw_init);
4417 module_exit(claw_cleanup);
4421 /*--------------------------------------------------------------------*
4423 *---------------------------------------------------------------------*/