2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver
5 * $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $
7 * Linux for zSeries version
8 * Copyright (C) 2002,2005 IBM Corporation
9 * Author(s) Original code written by:
10 * Kazuo Iimura (iimura@jp.ibm.com)
12 * Andy Richter (richtera@us.ibm.com)
13 * Marc Price (mwprice@us.ibm.com)
16 * group x.x.rrrr,x.x.wwww
20 * adapter_name aaaaaaaa
24 * group 0.0.0200 0.0.0201
33 * The device id is decided by the order entries
34 * are added to the group the first is claw0 the second claw1
37 * rrrr - the first of 2 consecutive device addresses used for the
39 * The specified address is always used as the input (Read)
40 * channel and the next address is used as the output channel.
42 * wwww - the second of 2 consecutive device addresses used for
44 * The specified address is always used as the output
45 * channel and the previous address is used as the input channel.
47 * read_buffer - specifies number of input buffers to allocate.
48 * write_buffer - specifies number of output buffers to allocate.
49 * host_name - host name
50 * adaptor_name - adaptor name
51 * api_type - API type TCPIP or API will be sent and expected
54 * Note the following requirements:
55 * 1) host_name must match the configured adapter_name on the remote side
56 * 2) adaptor_name must match the configured host name on the remote side
59 * 1.00 Initial release shipped
60 * 1.10 Changes for Buffer allocation
61 * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower
62 * 1.25 Added Packing support
64 #include <asm/bitops.h>
65 #include <asm/ccwdev.h>
66 #include <asm/ccwgroup.h>
67 #include <asm/debug.h>
68 #include <asm/idals.h>
71 #include <linux/ctype.h>
72 #include <linux/delay.h>
73 #include <linux/errno.h>
74 #include <linux/if_arp.h>
75 #include <linux/init.h>
76 #include <linux/interrupt.h>
78 #include <linux/kernel.h>
79 #include <linux/module.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/proc_fs.h>
83 #include <linux/sched.h>
84 #include <linux/signal.h>
85 #include <linux/skbuff.h>
86 #include <linux/slab.h>
87 #include <linux/string.h>
88 #include <linux/tcp.h>
89 #include <linux/timer.h>
90 #include <linux/types.h>
95 MODULE_AUTHOR("Andy Richter <richtera@us.ibm.com>");
96 MODULE_DESCRIPTION("Linux for zSeries CLAW Driver\n" \
97 "Copyright 2000,2005 IBM Corporation\n");
98 MODULE_LICENSE("GPL");
100 /* Debugging is based on DEBUGMSG, IOTRACE, or FUNCTRACE options:
101 DEBUGMSG - Enables output of various debug messages in the code
102 IOTRACE - Enables output of CCW and other IO related traces
103 FUNCTRACE - Enables output of function entry/exit trace
104 Define any combination of above options to enable tracing
106 CLAW also uses the s390dbf file system see claw_trace and claw_setup
109 /* following enables tracing */
126 char debug_buffer[255];
128 * Debug Facility Stuff
130 static debug_info_t *claw_dbf_setup;
131 static debug_info_t *claw_dbf_trace;
134 * CLAW Debug Facility functions
137 claw_unregister_debug_facility(void)
140 debug_unregister(claw_dbf_setup);
142 debug_unregister(claw_dbf_trace);
146 claw_register_debug_facility(void)
148 claw_dbf_setup = debug_register("claw_setup", 2, 1, 8);
149 claw_dbf_trace = debug_register("claw_trace", 2, 2, 8);
150 if (claw_dbf_setup == NULL || claw_dbf_trace == NULL) {
151 printk(KERN_WARNING "Not enough memory for debug facility.\n");
152 claw_unregister_debug_facility();
155 debug_register_view(claw_dbf_setup, &debug_hex_ascii_view);
156 debug_set_level(claw_dbf_setup, 2);
157 debug_register_view(claw_dbf_trace, &debug_hex_ascii_view);
158 debug_set_level(claw_dbf_trace, 2);
163 claw_set_busy(struct net_device *dev)
165 ((struct claw_privbk *) dev->priv)->tbusy=1;
170 claw_clear_busy(struct net_device *dev)
172 clear_bit(0, &(((struct claw_privbk *) dev->priv)->tbusy));
173 netif_wake_queue(dev);
178 claw_check_busy(struct net_device *dev)
181 return ((struct claw_privbk *) dev->priv)->tbusy;
185 claw_setbit_busy(int nr,struct net_device *dev)
187 netif_stop_queue(dev);
188 set_bit(nr, (void *)&(((struct claw_privbk *)dev->priv)->tbusy));
192 claw_clearbit_busy(int nr,struct net_device *dev)
194 clear_bit(nr,(void *)&(((struct claw_privbk *)dev->priv)->tbusy));
195 netif_wake_queue(dev);
199 claw_test_and_setbit_busy(int nr,struct net_device *dev)
201 netif_stop_queue(dev);
202 return test_and_set_bit(nr,
203 (void *)&(((struct claw_privbk *) dev->priv)->tbusy));
207 /* Functions for the DEV methods */
209 static int claw_probe(struct ccwgroup_device *cgdev);
210 static void claw_remove_device(struct ccwgroup_device *cgdev);
211 static void claw_purge_skb_queue(struct sk_buff_head *q);
212 static int claw_new_device(struct ccwgroup_device *cgdev);
213 static int claw_shutdown_device(struct ccwgroup_device *cgdev);
214 static int claw_tx(struct sk_buff *skb, struct net_device *dev);
215 static int claw_change_mtu( struct net_device *dev, int new_mtu);
216 static int claw_open(struct net_device *dev);
217 static void claw_irq_handler(struct ccw_device *cdev,
218 unsigned long intparm, struct irb *irb);
219 static void claw_irq_tasklet ( unsigned long data );
220 static int claw_release(struct net_device *dev);
221 static void claw_write_retry ( struct chbk * p_ch );
222 static void claw_write_next ( struct chbk * p_ch );
223 static void claw_timer ( struct chbk * p_ch );
226 static int add_claw_reads(struct net_device *dev,
227 struct ccwbk* p_first, struct ccwbk* p_last);
228 static void inline ccw_check_return_code (struct ccw_device *cdev,
230 static void inline ccw_check_unit_check (struct chbk * p_ch,
231 unsigned char sense );
232 static int find_link(struct net_device *dev, char *host_name, char *ws_name );
233 static int claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid);
234 static int init_ccw_bk(struct net_device *dev);
235 static void probe_error( struct ccwgroup_device *cgdev);
236 static struct net_device_stats *claw_stats(struct net_device *dev);
237 static int inline pages_to_order_of_mag(int num_of_pages);
238 static struct sk_buff *claw_pack_skb(struct claw_privbk *privptr);
240 static void dumpit (char *buf, int len);
242 /* sysfs Functions */
243 static ssize_t claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf);
244 static ssize_t claw_hname_write(struct device *dev, struct device_attribute *attr,
245 const char *buf, size_t count);
246 static ssize_t claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf);
247 static ssize_t claw_adname_write(struct device *dev, struct device_attribute *attr,
248 const char *buf, size_t count);
249 static ssize_t claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf);
250 static ssize_t claw_apname_write(struct device *dev, struct device_attribute *attr,
251 const char *buf, size_t count);
252 static ssize_t claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
253 static ssize_t claw_wbuff_write(struct device *dev, struct device_attribute *attr,
254 const char *buf, size_t count);
255 static ssize_t claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
256 static ssize_t claw_rbuff_write(struct device *dev, struct device_attribute *attr,
257 const char *buf, size_t count);
258 static int claw_add_files(struct device *dev);
259 static void claw_remove_files(struct device *dev);
261 /* Functions for System Validate */
262 static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw);
263 static int claw_send_control(struct net_device *dev, __u8 type, __u8 link,
264 __u8 correlator, __u8 rc , char *local_name, char *remote_name);
265 static int claw_snd_conn_req(struct net_device *dev, __u8 link);
266 static int claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl);
267 static int claw_snd_sys_validate_rsp(struct net_device *dev,
268 struct clawctl * p_ctl, __u32 return_code);
269 static int claw_strt_conn_req(struct net_device *dev );
270 static void claw_strt_read ( struct net_device *dev, int lock );
271 static void claw_strt_out_IO( struct net_device *dev );
272 static void claw_free_wrt_buf( struct net_device *dev );
274 /* Functions for unpack reads */
275 static void unpack_read (struct net_device *dev );
279 static struct ccwgroup_driver claw_group_driver = {
280 .owner = THIS_MODULE,
283 .driver_id = 0xC3D3C1E6,
285 .remove = claw_remove_device,
286 .set_online = claw_new_device,
287 .set_offline = claw_shutdown_device,
295 /*----------------------------------------------------------------*
297 * this function is called for each CLAW device. *
298 *----------------------------------------------------------------*/
300 claw_probe(struct ccwgroup_device *cgdev)
303 struct claw_privbk *privptr=NULL;
306 printk(KERN_INFO "%s Enter\n",__FUNCTION__);
308 CLAW_DBF_TEXT(2,setup,"probe");
309 if (!get_device(&cgdev->dev))
312 printk(KERN_INFO "claw: variable cgdev =\n");
313 dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
315 privptr = kmalloc(sizeof(struct claw_privbk), GFP_KERNEL);
316 if (privptr == NULL) {
318 put_device(&cgdev->dev);
319 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
320 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
321 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
324 memset(privptr,0x00,sizeof(struct claw_privbk));
325 privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
326 privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL);
327 if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
329 put_device(&cgdev->dev);
330 printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
331 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
332 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
335 memset(privptr->p_mtc_envelope, 0x00, MAX_ENVELOPE_SIZE);
336 memset(privptr->p_env, 0x00, sizeof(struct claw_env));
337 memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
338 memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
339 memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
340 privptr->p_env->packing = 0;
341 privptr->p_env->write_buffers = 5;
342 privptr->p_env->read_buffers = 5;
343 privptr->p_env->read_size = CLAW_FRAME_SIZE;
344 privptr->p_env->write_size = CLAW_FRAME_SIZE;
345 rc = claw_add_files(&cgdev->dev);
348 put_device(&cgdev->dev);
349 printk(KERN_WARNING "add_files failed %s %s Exit Line %d \n",
350 cgdev->cdev[0]->dev.bus_id,__FUNCTION__,__LINE__);
351 CLAW_DBF_TEXT_(2,setup,"probex%d",rc);
354 printk(KERN_INFO "claw: sysfs files added for %s\n",cgdev->cdev[0]->dev.bus_id);
355 privptr->p_env->p_priv = privptr;
356 cgdev->cdev[0]->handler = claw_irq_handler;
357 cgdev->cdev[1]->handler = claw_irq_handler;
358 cgdev->dev.driver_data = privptr;
360 printk(KERN_INFO "claw:%s exit on line %d, "
361 "rc = 0\n",__FUNCTION__,__LINE__);
363 CLAW_DBF_TEXT(2,setup,"prbext 0");
366 } /* end of claw_probe */
368 /*-------------------------------------------------------------------*
370 *-------------------------------------------------------------------*/
373 claw_tx(struct sk_buff *skb, struct net_device *dev)
376 struct claw_privbk *privptr=dev->priv;
377 unsigned long saveflags;
381 printk(KERN_INFO "%s:%s enter\n",dev->name,__FUNCTION__);
383 CLAW_DBF_TEXT(4,trace,"claw_tx");
384 p_ch=&privptr->channel[WRITE];
386 printk(KERN_WARNING "%s: null pointer passed as sk_buffer\n",
388 privptr->stats.tx_dropped++;
390 printk(KERN_INFO "%s: %s() exit on line %d, rc = EIO\n",
391 dev->name,__FUNCTION__, __LINE__);
393 CLAW_DBF_TEXT_(2,trace,"clawtx%d",-EIO);
398 printk(KERN_INFO "%s: variable sk_buff=\n",dev->name);
399 dumpit((char *) skb, sizeof(struct sk_buff));
400 printk(KERN_INFO "%s: variable dev=\n",dev->name);
401 dumpit((char *) dev, sizeof(struct net_device));
403 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
404 rc=claw_hw_tx( skb, dev, 1 );
405 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
407 printk(KERN_INFO "%s:%s exit on line %d, rc = %d\n",
408 dev->name, __FUNCTION__, __LINE__, rc);
410 CLAW_DBF_TEXT_(4,trace,"clawtx%d",rc);
412 } /* end of claw_tx */
414 /*------------------------------------------------------------------*
415 * pack the collect queue into an skb and return it *
416 * If not packing just return the top skb from the queue *
417 *------------------------------------------------------------------*/
419 static struct sk_buff *
420 claw_pack_skb(struct claw_privbk *privptr)
422 struct sk_buff *new_skb,*held_skb;
423 struct chbk *p_ch = &privptr->channel[WRITE];
424 struct claw_env *p_env = privptr->p_env;
425 int pkt_cnt,pk_ind,so_far;
427 new_skb = NULL; /* assume no dice */
429 CLAW_DBF_TEXT(4,trace,"PackSKBe");
430 if (!skb_queue_empty(&p_ch->collect_queue)) {
432 held_skb = skb_dequeue(&p_ch->collect_queue);
434 dev_kfree_skb_any(held_skb);
437 if (p_env->packing != DO_PACKED)
439 /* get a new SKB we will pack at least one */
440 new_skb = dev_alloc_skb(p_env->write_size);
441 if (new_skb == NULL) {
442 atomic_inc(&held_skb->users);
443 skb_queue_head(&p_ch->collect_queue,held_skb);
446 /* we have packed packet and a place to put it */
449 new_skb->cb[1] = 'P'; /* every skb on queue has pack header */
450 while ((pk_ind) && (held_skb != NULL)) {
451 if (held_skb->len+so_far <= p_env->write_size-8) {
452 memcpy(skb_put(new_skb,held_skb->len),
453 held_skb->data,held_skb->len);
454 privptr->stats.tx_packets++;
455 so_far += held_skb->len;
457 dev_kfree_skb_any(held_skb);
458 held_skb = skb_dequeue(&p_ch->collect_queue);
460 atomic_dec(&held_skb->users);
463 atomic_inc(&held_skb->users);
464 skb_queue_head(&p_ch->collect_queue,held_skb);
468 printk(KERN_INFO "%s: %s() Packed %d len %d\n",
470 __FUNCTION__,pkt_cnt,new_skb->len);
473 CLAW_DBF_TEXT(4,trace,"PackSKBx");
477 /*-------------------------------------------------------------------*
480 *-------------------------------------------------------------------*/
483 claw_change_mtu(struct net_device *dev, int new_mtu)
485 struct claw_privbk *privptr=dev->priv;
488 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
491 printk(KERN_INFO "variable dev =\n");
492 dumpit((char *) dev, sizeof(struct net_device));
493 printk(KERN_INFO "variable new_mtu = %d\n", new_mtu);
495 CLAW_DBF_TEXT(4,trace,"setmtu");
496 buff_size = privptr->p_env->write_size;
497 if ((new_mtu < 60) || (new_mtu > buff_size)) {
499 printk(KERN_INFO "%s:%s Exit on line %d, rc=EINVAL\n",
501 __FUNCTION__, __LINE__);
507 printk(KERN_INFO "%s:%s Exit on line %d\n",dev->name,
508 __FUNCTION__, __LINE__);
511 } /* end of claw_change_mtu */
514 /*-------------------------------------------------------------------*
517 *-------------------------------------------------------------------*/
519 claw_open(struct net_device *dev)
524 unsigned long saveflags=0;
526 struct claw_privbk *privptr;
527 DECLARE_WAITQUEUE(wait, current);
528 struct timer_list timer;
532 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
534 CLAW_DBF_TEXT(4,trace,"open");
535 if (!dev | (dev->name[0] == 0x00)) {
536 CLAW_DBF_TEXT(2,trace,"BadDev");
537 printk(KERN_WARNING "claw: Bad device at open failing \n");
540 privptr = (struct claw_privbk *)dev->priv;
541 /* allocate and initialize CCW blocks */
542 if (privptr->buffs_alloc == 0) {
545 printk(KERN_INFO "%s:%s Exit on line %d, rc=ENOMEM\n",
547 __FUNCTION__, __LINE__);
548 CLAW_DBF_TEXT(2,trace,"openmem");
552 privptr->system_validate_comp=0;
553 privptr->release_pend=0;
554 if(strncmp(privptr->p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
555 privptr->p_env->read_size=DEF_PACK_BUFSIZE;
556 privptr->p_env->write_size=DEF_PACK_BUFSIZE;
557 privptr->p_env->packing=PACKING_ASK;
559 privptr->p_env->packing=0;
560 privptr->p_env->read_size=CLAW_FRAME_SIZE;
561 privptr->p_env->write_size=CLAW_FRAME_SIZE;
564 tasklet_init(&privptr->channel[READ].tasklet, claw_irq_tasklet,
565 (unsigned long) &privptr->channel[READ]);
566 for ( i = 0; i < 2; i++) {
567 CLAW_DBF_TEXT_(2,trace,"opn_ch%d",i);
568 init_waitqueue_head(&privptr->channel[i].wait);
569 /* skb_queue_head_init(&p_ch->io_queue); */
572 &privptr->channel[WRITE].collect_queue);
573 privptr->channel[i].flag_a = 0;
574 privptr->channel[i].IO_active = 0;
575 privptr->channel[i].flag &= ~CLAW_TIMER;
577 timer.function = (void *)claw_timer;
578 timer.data = (unsigned long)(&privptr->channel[i]);
579 timer.expires = jiffies + 15*HZ;
581 spin_lock_irqsave(get_ccwdev_lock(
582 privptr->channel[i].cdev), saveflags);
583 parm = (unsigned long) &privptr->channel[i];
584 privptr->channel[i].claw_state = CLAW_START_HALT_IO;
586 add_wait_queue(&privptr->channel[i].wait, &wait);
587 rc = ccw_device_halt(
588 (struct ccw_device *)privptr->channel[i].cdev,parm);
589 set_current_state(TASK_INTERRUPTIBLE);
590 spin_unlock_irqrestore(
591 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
593 set_current_state(TASK_RUNNING);
594 remove_wait_queue(&privptr->channel[i].wait, &wait);
596 ccw_check_return_code(privptr->channel[i].cdev, rc);
597 if((privptr->channel[i].flag & CLAW_TIMER) == 0x00)
600 if ((((privptr->channel[READ].last_dstat |
601 privptr->channel[WRITE].last_dstat) &
602 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) ||
603 (((privptr->channel[READ].flag |
604 privptr->channel[WRITE].flag) & CLAW_TIMER) != 0x00)) {
606 printk(KERN_INFO "%s: channel problems during open - read:"
607 " %02x - write: %02x\n",
609 privptr->channel[READ].last_dstat,
610 privptr->channel[WRITE].last_dstat);
612 printk(KERN_INFO "%s: remote side is not ready\n", dev->name);
613 CLAW_DBF_TEXT(2,trace,"notrdy");
615 for ( i = 0; i < 2; i++) {
617 get_ccwdev_lock(privptr->channel[i].cdev),
619 parm = (unsigned long) &privptr->channel[i];
620 privptr->channel[i].claw_state = CLAW_STOP;
621 rc = ccw_device_halt(
622 (struct ccw_device *)&privptr->channel[i].cdev,
624 spin_unlock_irqrestore(
625 get_ccwdev_lock(privptr->channel[i].cdev),
628 ccw_check_return_code(
629 privptr->channel[i].cdev, rc);
632 free_pages((unsigned long)privptr->p_buff_ccw,
633 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
634 if (privptr->p_env->read_size < PAGE_SIZE) {
635 free_pages((unsigned long)privptr->p_buff_read,
636 (int)pages_to_order_of_mag(
637 privptr->p_buff_read_num));
640 p_buf=privptr->p_read_active_first;
641 while (p_buf!=NULL) {
642 free_pages((unsigned long)p_buf->p_buffer,
643 (int)pages_to_order_of_mag(
644 privptr->p_buff_pages_perread ));
648 if (privptr->p_env->write_size < PAGE_SIZE ) {
649 free_pages((unsigned long)privptr->p_buff_write,
650 (int)pages_to_order_of_mag(
651 privptr->p_buff_write_num));
654 p_buf=privptr->p_write_active_first;
655 while (p_buf!=NULL) {
656 free_pages((unsigned long)p_buf->p_buffer,
657 (int)pages_to_order_of_mag(
658 privptr->p_buff_pages_perwrite ));
662 privptr->buffs_alloc = 0;
663 privptr->channel[READ].flag= 0x00;
664 privptr->channel[WRITE].flag = 0x00;
665 privptr->p_buff_ccw=NULL;
666 privptr->p_buff_read=NULL;
667 privptr->p_buff_write=NULL;
668 claw_clear_busy(dev);
670 printk(KERN_INFO "%s:%s Exit on line %d, rc=EIO\n",
671 dev->name,__FUNCTION__,__LINE__);
673 CLAW_DBF_TEXT(2,trace,"open EIO");
677 /* Send SystemValidate command */
679 claw_clear_busy(dev);
682 printk(KERN_INFO "%s:%s Exit on line %d, rc=0\n",
683 dev->name,__FUNCTION__,__LINE__);
685 CLAW_DBF_TEXT(4,trace,"openok");
687 } /* end of claw_open */
689 /*-------------------------------------------------------------------*
693 *--------------------------------------------------------------------*/
695 claw_irq_handler(struct ccw_device *cdev,
696 unsigned long intparm, struct irb *irb)
698 struct chbk *p_ch = NULL;
699 struct claw_privbk *privptr = NULL;
700 struct net_device *dev = NULL;
701 struct claw_env *p_env;
702 struct chbk *p_ch_r=NULL;
706 printk(KERN_INFO "%s enter \n",__FUNCTION__);
708 CLAW_DBF_TEXT(4,trace,"clawirq");
709 /* Bypass all 'unsolicited interrupts' */
710 if (!cdev->dev.driver_data) {
711 printk(KERN_WARNING "claw: unsolicited interrupt for device:"
712 "%s received c-%02x d-%02x\n",
713 cdev->dev.bus_id,irb->scsw.cstat, irb->scsw.dstat);
715 printk(KERN_INFO "claw: %s() "
716 "exit on line %d\n",__FUNCTION__,__LINE__);
718 CLAW_DBF_TEXT(2,trace,"badirq");
721 privptr = (struct claw_privbk *)cdev->dev.driver_data;
723 /* Try to extract channel from driver data. */
724 if (privptr->channel[READ].cdev == cdev)
725 p_ch = &privptr->channel[READ];
726 else if (privptr->channel[WRITE].cdev == cdev)
727 p_ch = &privptr->channel[WRITE];
729 printk(KERN_WARNING "claw: Can't determine channel for "
730 "interrupt, device %s\n", cdev->dev.bus_id);
731 CLAW_DBF_TEXT(2,trace,"badchan");
734 CLAW_DBF_TEXT_(4,trace,"IRQCH=%d",p_ch->flag);
736 dev = (struct net_device *) (p_ch->ndev);
737 p_env=privptr->p_env;
740 printk(KERN_INFO "%s: interrupt for device: %04x "
741 "received c-%02x d-%02x state-%02x\n",
742 dev->name, p_ch->devno, irb->scsw.cstat,
743 irb->scsw.dstat, p_ch->claw_state);
746 /* Copy interruption response block. */
747 memcpy(p_ch->irb, irb, sizeof(struct irb));
749 /* Check for good subchannel return code, otherwise error message */
750 if (irb->scsw.cstat && !(irb->scsw.cstat & SCHN_STAT_PCI)) {
751 printk(KERN_INFO "%s: subchannel check for device: %04x -"
752 " Sch Stat %02x Dev Stat %02x CPA - %04x\n",
753 dev->name, p_ch->devno,
754 irb->scsw.cstat, irb->scsw.dstat,irb->scsw.cpa);
756 dumpit((char *)irb,sizeof(struct irb));
757 dumpit((char *)(unsigned long)irb->scsw.cpa,
758 sizeof(struct ccw1));
761 printk(KERN_INFO "%s:%s Exit on line %d\n",
762 dev->name,__FUNCTION__,__LINE__);
764 CLAW_DBF_TEXT(2,trace,"chanchk");
768 /* Check the reason-code of a unit check */
769 if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
770 ccw_check_unit_check(p_ch, irb->ecw[0]);
773 /* State machine to bring the connection up, down and to restart */
774 p_ch->last_dstat = irb->scsw.dstat;
776 switch (p_ch->claw_state) {
777 case CLAW_STOP:/* HALT_IO by claw_release (halt sequence) */
779 printk(KERN_INFO "%s: CLAW_STOP enter\n", dev->name);
781 if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
782 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
783 (p_ch->irb->scsw.stctl ==
784 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
786 printk(KERN_INFO "%s:%s Exit on line %d\n",
787 dev->name,__FUNCTION__,__LINE__);
791 wake_up(&p_ch->wait); /* wake up claw_release */
794 printk(KERN_INFO "%s: CLAW_STOP exit\n", dev->name);
797 printk(KERN_INFO "%s:%s Exit on line %d\n",
798 dev->name,__FUNCTION__,__LINE__);
800 CLAW_DBF_TEXT(4,trace,"stop");
803 case CLAW_START_HALT_IO: /* HALT_IO issued by claw_open */
805 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO\n",
808 if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
809 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
810 (p_ch->irb->scsw.stctl ==
811 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
813 printk(KERN_INFO "%s:%s Exit on line %d\n",
814 dev->name,__FUNCTION__,__LINE__);
816 CLAW_DBF_TEXT(4,trace,"haltio");
819 if (p_ch->flag == CLAW_READ) {
820 p_ch->claw_state = CLAW_START_READ;
821 wake_up(&p_ch->wait); /* wake claw_open (READ)*/
824 if (p_ch->flag == CLAW_WRITE) {
825 p_ch->claw_state = CLAW_START_WRITE;
826 /* send SYSTEM_VALIDATE */
827 claw_strt_read(dev, LOCK_NO);
828 claw_send_control(dev,
829 SYSTEM_VALIDATE_REQUEST,
832 p_env->adapter_name );
834 printk(KERN_WARNING "claw: unsolicited "
835 "interrupt for device:"
836 "%s received c-%02x d-%02x\n",
843 printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO exit\n",
847 printk(KERN_INFO "%s:%s Exit on line %d\n",
848 dev->name,__FUNCTION__,__LINE__);
850 CLAW_DBF_TEXT(4,trace,"haltio");
852 case CLAW_START_READ:
853 CLAW_DBF_TEXT(4,trace,"ReadIRQ");
854 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
855 clear_bit(0, (void *)&p_ch->IO_active);
856 if ((p_ch->irb->ecw[0] & 0x41) == 0x41 ||
857 (p_ch->irb->ecw[0] & 0x40) == 0x40 ||
858 (p_ch->irb->ecw[0]) == 0)
860 privptr->stats.rx_errors++;
861 printk(KERN_INFO "%s: Restart is "
862 "required after remote "
867 printk(KERN_INFO "%s:%s Exit on line %d\n",
868 dev->name,__FUNCTION__,__LINE__);
870 CLAW_DBF_TEXT(4,trace,"notrdy");
873 if ((p_ch->irb->scsw.cstat & SCHN_STAT_PCI) &&
874 (p_ch->irb->scsw.dstat==0)) {
875 if (test_and_set_bit(CLAW_BH_ACTIVE,
876 (void *)&p_ch->flag_a) == 0) {
877 tasklet_schedule(&p_ch->tasklet);
880 CLAW_DBF_TEXT(4,trace,"PCINoBH");
883 printk(KERN_INFO "%s:%s Exit on line %d\n",
884 dev->name,__FUNCTION__,__LINE__);
886 CLAW_DBF_TEXT(4,trace,"PCI_read");
889 if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
890 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
891 (p_ch->irb->scsw.stctl ==
892 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
894 printk(KERN_INFO "%s:%s Exit on line %d\n",
895 dev->name,__FUNCTION__,__LINE__);
897 CLAW_DBF_TEXT(4,trace,"SPend_rd");
900 clear_bit(0, (void *)&p_ch->IO_active);
901 claw_clearbit_busy(TB_RETRY,dev);
902 if (test_and_set_bit(CLAW_BH_ACTIVE,
903 (void *)&p_ch->flag_a) == 0) {
904 tasklet_schedule(&p_ch->tasklet);
907 CLAW_DBF_TEXT(4,trace,"RdBHAct");
911 printk(KERN_INFO "%s: process CLAW_START_READ exit\n",
915 printk(KERN_INFO "%s:%s Exit on line %d\n",
916 dev->name,__FUNCTION__,__LINE__);
918 CLAW_DBF_TEXT(4,trace,"RdIRQXit");
920 case CLAW_START_WRITE:
921 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
922 printk(KERN_INFO "%s: Unit Check Occured in "
923 "write channel\n",dev->name);
924 clear_bit(0, (void *)&p_ch->IO_active);
925 if (p_ch->irb->ecw[0] & 0x80 ) {
926 printk(KERN_INFO "%s: Resetting Event "
927 "occurred:\n",dev->name);
928 init_timer(&p_ch->timer);
929 p_ch->timer.function =
930 (void *)claw_write_retry;
931 p_ch->timer.data = (unsigned long)p_ch;
932 p_ch->timer.expires = jiffies + 10*HZ;
933 add_timer(&p_ch->timer);
934 printk(KERN_INFO "%s: write connection "
935 "restarting\n",dev->name);
938 printk(KERN_INFO "%s:%s Exit on line %d\n",
939 dev->name,__FUNCTION__,__LINE__);
941 CLAW_DBF_TEXT(4,trace,"rstrtwrt");
944 if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) {
945 clear_bit(0, (void *)&p_ch->IO_active);
946 printk(KERN_INFO "%s: Unit Exception "
947 "Occured in write channel\n",
950 if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
951 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
952 (p_ch->irb->scsw.stctl ==
953 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
955 printk(KERN_INFO "%s:%s Exit on line %d\n",
956 dev->name,__FUNCTION__,__LINE__);
958 CLAW_DBF_TEXT(4,trace,"writeUE");
961 clear_bit(0, (void *)&p_ch->IO_active);
962 if (claw_test_and_setbit_busy(TB_TX,dev)==0) {
963 claw_write_next(p_ch);
964 claw_clearbit_busy(TB_TX,dev);
965 claw_clear_busy(dev);
967 p_ch_r=(struct chbk *)&privptr->channel[READ];
968 if (test_and_set_bit(CLAW_BH_ACTIVE,
969 (void *)&p_ch_r->flag_a) == 0) {
970 tasklet_schedule(&p_ch_r->tasklet);
974 printk(KERN_INFO "%s: process CLAW_START_WRITE exit\n",
978 printk(KERN_INFO "%s:%s Exit on line %d\n",
979 dev->name,__FUNCTION__,__LINE__);
981 CLAW_DBF_TEXT(4,trace,"StWtExit");
984 printk(KERN_WARNING "%s: wrong selection code - irq "
985 "state=%d\n",dev->name,p_ch->claw_state);
987 printk(KERN_INFO "%s:%s Exit on line %d\n",
988 dev->name,__FUNCTION__,__LINE__);
990 CLAW_DBF_TEXT(2,trace,"badIRQ");
994 } /* end of claw_irq_handler */
997 /*-------------------------------------------------------------------*
1000 *--------------------------------------------------------------------*/
1002 claw_irq_tasklet ( unsigned long data )
1005 struct net_device *dev;
1006 struct claw_privbk * privptr;
1008 p_ch = (struct chbk *) data;
1009 dev = (struct net_device *)p_ch->ndev;
1011 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1014 printk(KERN_INFO "%s: variable p_ch =\n",dev->name);
1015 dumpit((char *) p_ch, sizeof(struct chbk));
1017 CLAW_DBF_TEXT(4,trace,"IRQtask");
1019 privptr = (struct claw_privbk *) dev->priv;
1022 printk(KERN_INFO "%s: bh routine - state-%02x\n" ,
1023 dev->name, p_ch->claw_state);
1027 clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a);
1028 CLAW_DBF_TEXT(4,trace,"TskletXt");
1030 printk(KERN_INFO "%s:%s Exit on line %d\n",
1031 dev->name,__FUNCTION__,__LINE__);
1034 } /* end of claw_irq_bh */
1036 /*-------------------------------------------------------------------*
1039 *--------------------------------------------------------------------*/
1041 claw_release(struct net_device *dev)
1045 unsigned long saveflags;
1047 struct claw_privbk *privptr;
1048 DECLARE_WAITQUEUE(wait, current);
1049 struct ccwbk* p_this_ccw;
1050 struct ccwbk* p_buf;
1054 privptr = (struct claw_privbk *) dev->priv;
1058 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1060 CLAW_DBF_TEXT(4,trace,"release");
1062 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1063 dumpit((char *) dev, sizeof(struct net_device));
1064 printk(KERN_INFO "Priv Buffalloc %d\n",privptr->buffs_alloc);
1065 printk(KERN_INFO "Priv p_buff_ccw = %p\n",&privptr->p_buff_ccw);
1067 privptr->release_pend=1;
1068 claw_setbit_busy(TB_STOP,dev);
1069 for ( i = 1; i >=0 ; i--) {
1071 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1072 /* del_timer(&privptr->channel[READ].timer); */
1073 privptr->channel[i].claw_state = CLAW_STOP;
1074 privptr->channel[i].IO_active = 0;
1075 parm = (unsigned long) &privptr->channel[i];
1077 claw_purge_skb_queue(
1078 &privptr->channel[WRITE].collect_queue);
1079 rc = ccw_device_halt (privptr->channel[i].cdev, parm);
1080 if (privptr->system_validate_comp==0x00) /* never opened? */
1081 init_waitqueue_head(&privptr->channel[i].wait);
1082 add_wait_queue(&privptr->channel[i].wait, &wait);
1083 set_current_state(TASK_INTERRUPTIBLE);
1084 spin_unlock_irqrestore(
1085 get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
1087 set_current_state(TASK_RUNNING);
1088 remove_wait_queue(&privptr->channel[i].wait, &wait);
1090 ccw_check_return_code(privptr->channel[i].cdev, rc);
1093 if (privptr->pk_skb != NULL) {
1094 dev_kfree_skb_any(privptr->pk_skb);
1095 privptr->pk_skb = NULL;
1097 if(privptr->buffs_alloc != 1) {
1099 printk(KERN_INFO "%s:%s Exit on line %d\n",
1100 dev->name,__FUNCTION__,__LINE__);
1102 CLAW_DBF_TEXT(4,trace,"none2fre");
1105 CLAW_DBF_TEXT(4,trace,"freebufs");
1106 if (privptr->p_buff_ccw != NULL) {
1107 free_pages((unsigned long)privptr->p_buff_ccw,
1108 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
1110 CLAW_DBF_TEXT(4,trace,"freeread");
1111 if (privptr->p_env->read_size < PAGE_SIZE) {
1112 if (privptr->p_buff_read != NULL) {
1113 free_pages((unsigned long)privptr->p_buff_read,
1114 (int)pages_to_order_of_mag(privptr->p_buff_read_num));
1118 p_buf=privptr->p_read_active_first;
1119 while (p_buf!=NULL) {
1120 free_pages((unsigned long)p_buf->p_buffer,
1121 (int)pages_to_order_of_mag(
1122 privptr->p_buff_pages_perread ));
1126 CLAW_DBF_TEXT(4,trace,"freewrit");
1127 if (privptr->p_env->write_size < PAGE_SIZE ) {
1128 free_pages((unsigned long)privptr->p_buff_write,
1129 (int)pages_to_order_of_mag(privptr->p_buff_write_num));
1132 p_buf=privptr->p_write_active_first;
1133 while (p_buf!=NULL) {
1134 free_pages((unsigned long)p_buf->p_buffer,
1135 (int)pages_to_order_of_mag(
1136 privptr->p_buff_pages_perwrite ));
1140 CLAW_DBF_TEXT(4,trace,"clearptr");
1141 privptr->buffs_alloc = 0;
1142 privptr->p_buff_ccw=NULL;
1143 privptr->p_buff_read=NULL;
1144 privptr->p_buff_write=NULL;
1145 privptr->system_validate_comp=0;
1146 privptr->release_pend=0;
1147 /* Remove any writes that were pending and reset all reads */
1148 p_this_ccw=privptr->p_read_active_first;
1149 while (p_this_ccw!=NULL) {
1150 p_this_ccw->header.length=0xffff;
1151 p_this_ccw->header.opcode=0xff;
1152 p_this_ccw->header.flag=0x00;
1153 p_this_ccw=p_this_ccw->next;
1156 while (privptr->p_write_active_first!=NULL) {
1157 p_this_ccw=privptr->p_write_active_first;
1158 p_this_ccw->header.flag=CLAW_PENDING;
1159 privptr->p_write_active_first=p_this_ccw->next;
1160 p_this_ccw->next=privptr->p_write_free_chain;
1161 privptr->p_write_free_chain=p_this_ccw;
1162 ++privptr->write_free_count;
1164 privptr->p_write_active_last=NULL;
1165 privptr->mtc_logical_link = -1;
1166 privptr->mtc_skipping = 1;
1167 privptr->mtc_offset=0;
1169 if (((privptr->channel[READ].last_dstat |
1170 privptr->channel[WRITE].last_dstat) &
1171 ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) {
1172 printk(KERN_WARNING "%s: channel problems during close - "
1173 "read: %02x - write: %02x\n",
1175 privptr->channel[READ].last_dstat,
1176 privptr->channel[WRITE].last_dstat);
1177 CLAW_DBF_TEXT(2,trace,"badclose");
1180 printk(KERN_INFO "%s:%s Exit on line %d\n",
1181 dev->name,__FUNCTION__,__LINE__);
1183 CLAW_DBF_TEXT(4,trace,"rlsexit");
1185 } /* end of claw_release */
1189 /*-------------------------------------------------------------------*
1190 * claw_write_retry *
1192 *--------------------------------------------------------------------*/
1195 claw_write_retry ( struct chbk *p_ch )
1198 struct net_device *dev=p_ch->ndev;
1202 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
1203 printk(KERN_INFO "claw: variable p_ch =\n");
1204 dumpit((char *) p_ch, sizeof(struct chbk));
1206 CLAW_DBF_TEXT(4,trace,"w_retry");
1207 if (p_ch->claw_state == CLAW_STOP) {
1209 printk(KERN_INFO "%s:%s Exit on line %d\n",
1210 dev->name,__FUNCTION__,__LINE__);
1215 printk( KERN_INFO "%s:%s state-%02x\n" ,
1220 claw_strt_out_IO( dev );
1222 printk(KERN_INFO "%s:%s Exit on line %d\n",
1223 dev->name,__FUNCTION__,__LINE__);
1225 CLAW_DBF_TEXT(4,trace,"rtry_xit");
1227 } /* end of claw_write_retry */
1230 /*-------------------------------------------------------------------*
1233 *--------------------------------------------------------------------*/
1236 claw_write_next ( struct chbk * p_ch )
1239 struct net_device *dev;
1240 struct claw_privbk *privptr=NULL;
1241 struct sk_buff *pk_skb;
1245 printk(KERN_INFO "%s:%s Enter \n",p_ch->ndev->name,__FUNCTION__);
1246 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1247 dumpit((char *) p_ch, sizeof(struct chbk));
1249 CLAW_DBF_TEXT(4,trace,"claw_wrt");
1250 if (p_ch->claw_state == CLAW_STOP)
1252 dev = (struct net_device *) p_ch->ndev;
1253 privptr = (struct claw_privbk *) dev->priv;
1254 claw_free_wrt_buf( dev );
1255 if ((privptr->write_free_count > 0) &&
1256 !skb_queue_empty(&p_ch->collect_queue)) {
1257 pk_skb = claw_pack_skb(privptr);
1258 while (pk_skb != NULL) {
1259 rc = claw_hw_tx( pk_skb, dev,1);
1260 if (privptr->write_free_count > 0) {
1261 pk_skb = claw_pack_skb(privptr);
1266 if (privptr->p_write_active_first!=NULL) {
1267 claw_strt_out_IO(dev);
1271 printk(KERN_INFO "%s:%s Exit on line %d\n",
1272 dev->name,__FUNCTION__,__LINE__);
1275 } /* end of claw_write_next */
1277 /*-------------------------------------------------------------------*
1280 *--------------------------------------------------------------------*/
1283 claw_timer ( struct chbk * p_ch )
1286 printk(KERN_INFO "%s:%s Entry\n",p_ch->ndev->name,__FUNCTION__);
1287 printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
1288 dumpit((char *) p_ch, sizeof(struct chbk));
1290 CLAW_DBF_TEXT(4,trace,"timer");
1291 p_ch->flag |= CLAW_TIMER;
1292 wake_up(&p_ch->wait);
1294 printk(KERN_INFO "%s:%s Exit on line %d\n",
1295 p_ch->ndev->name,__FUNCTION__,__LINE__);
1298 } /* end of claw_timer */
1307 /*-------------------------------------------------------------------*
1309 * pages_to_order_of_mag *
1311 * takes a number of pages from 1 to 512 and returns the *
1312 * log(num_pages)/log(2) get_free_pages() needs a base 2 order *
1313 * of magnitude get_free_pages() has an upper order of 9 *
1314 *--------------------------------------------------------------------*/
1317 pages_to_order_of_mag(int num_of_pages)
1319 int order_of_mag=1; /* assume 2 pages */
1322 printk(KERN_INFO "%s Enter pages = %d \n",__FUNCTION__,num_of_pages);
1324 CLAW_DBF_TEXT_(5,trace,"pages%d",num_of_pages);
1325 if (num_of_pages == 1) {return 0; } /* magnitude of 0 = 1 page */
1326 /* 512 pages = 2Meg on 4k page systems */
1327 if (num_of_pages >= 512) {return 9; }
1328 /* we have two or more pages order is at least 1 */
1329 for (nump=2 ;nump <= 512;nump*=2) {
1330 if (num_of_pages <= nump)
1334 if (order_of_mag > 9) { order_of_mag = 9; } /* I know it's paranoid */
1336 printk(KERN_INFO "%s Exit on line %d, order = %d\n",
1337 __FUNCTION__,__LINE__, order_of_mag);
1339 CLAW_DBF_TEXT_(5,trace,"mag%d",order_of_mag);
1340 return order_of_mag;
1343 /*-------------------------------------------------------------------*
1347 *--------------------------------------------------------------------*/
1349 add_claw_reads(struct net_device *dev, struct ccwbk* p_first,
1350 struct ccwbk* p_last)
1352 struct claw_privbk *privptr;
1353 struct ccw1 temp_ccw;
1354 struct endccw * p_end;
1356 struct ccwbk* p_buf;
1359 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
1362 printk(KERN_INFO "dev\n");
1363 dumpit((char *) dev, sizeof(struct net_device));
1364 printk(KERN_INFO "p_first\n");
1365 dumpit((char *) p_first, sizeof(struct ccwbk));
1366 printk(KERN_INFO "p_last\n");
1367 dumpit((char *) p_last, sizeof(struct ccwbk));
1369 CLAW_DBF_TEXT(4,trace,"addreads");
1370 privptr = dev->priv;
1371 p_end = privptr->p_end_ccw;
1373 /* first CCW and last CCW contains a new set of read channel programs
1374 * to apend the running channel programs
1376 if ( p_first==NULL) {
1378 printk(KERN_INFO "%s:%s Exit on line %d\n",
1379 dev->name,__FUNCTION__,__LINE__);
1381 CLAW_DBF_TEXT(4,trace,"addexit");
1385 /* set up ending CCW sequence for this segment */
1387 p_end->read1=0x00; /* second ending CCW is now active */
1388 /* reset ending CCWs and setup TIC CCWs */
1389 p_end->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1390 p_end->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1391 p_last->r_TIC_1.cda =(__u32)__pa(&p_end->read2_nop1);
1392 p_last->r_TIC_2.cda =(__u32)__pa(&p_end->read2_nop1);
1393 p_end->read2_nop2.cda=0;
1394 p_end->read2_nop2.count=1;
1397 p_end->read1=0x01; /* first ending CCW is now active */
1398 /* reset ending CCWs and setup TIC CCWs */
1399 p_end->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1400 p_end->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
1401 p_last->r_TIC_1.cda = (__u32)__pa(&p_end->read1_nop1);
1402 p_last->r_TIC_2.cda = (__u32)__pa(&p_end->read1_nop1);
1403 p_end->read1_nop2.cda=0;
1404 p_end->read1_nop2.count=1;
1407 if ( privptr-> p_read_active_first ==NULL ) {
1409 printk(KERN_INFO "%s:%s p_read_active_frist == NULL \n",
1410 dev->name,__FUNCTION__);
1411 printk(KERN_INFO "%s:%s Read active first/last changed \n",
1412 dev->name,__FUNCTION__);
1414 privptr-> p_read_active_first= p_first; /* set new first */
1415 privptr-> p_read_active_last = p_last; /* set new last */
1420 printk(KERN_INFO "%s:%s Read in progress \n",
1421 dev->name,__FUNCTION__);
1423 /* set up TIC ccw */
1424 temp_ccw.cda= (__u32)__pa(&p_first->read);
1427 temp_ccw.cmd_code = CCW_CLAW_CMD_TIC;
1432 /* first set of CCW's is chained to the new read */
1433 /* chain, so the second set is chained to the active chain. */
1434 /* Therefore modify the second set to point to the new */
1435 /* read chain set up TIC CCWs */
1436 /* make sure we update the CCW so channel doesn't fetch it */
1437 /* when it's only half done */
1438 memcpy( &p_end->read2_nop2, &temp_ccw ,
1439 sizeof(struct ccw1));
1440 privptr->p_read_active_last->r_TIC_1.cda=
1441 (__u32)__pa(&p_first->read);
1442 privptr->p_read_active_last->r_TIC_2.cda=
1443 (__u32)__pa(&p_first->read);
1446 /* make sure we update the CCW so channel doesn't */
1447 /* fetch it when it is only half done */
1448 memcpy( &p_end->read1_nop2, &temp_ccw ,
1449 sizeof(struct ccw1));
1450 privptr->p_read_active_last->r_TIC_1.cda=
1451 (__u32)__pa(&p_first->read);
1452 privptr->p_read_active_last->r_TIC_2.cda=
1453 (__u32)__pa(&p_first->read);
1455 /* chain in new set of blocks */
1456 privptr->p_read_active_last->next = p_first;
1457 privptr->p_read_active_last=p_last;
1458 } /* end of if ( privptr-> p_read_active_first ==NULL) */
1460 printk(KERN_INFO "%s:%s dump p_last CCW BK \n",dev->name,__FUNCTION__);
1461 dumpit((char *)p_last, sizeof(struct ccwbk));
1462 printk(KERN_INFO "%s:%s dump p_end CCW BK \n",dev->name,__FUNCTION__);
1463 dumpit((char *)p_end, sizeof(struct endccw));
1465 printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__FUNCTION__);
1466 dumpit((char *)p_first, sizeof(struct ccwbk));
1467 printk(KERN_INFO "%s:%s Dump Active CCW chain \n",
1468 dev->name,__FUNCTION__);
1469 p_buf=privptr->p_read_active_first;
1470 while (p_buf!=NULL) {
1471 dumpit((char *)p_buf, sizeof(struct ccwbk));
1476 printk(KERN_INFO "%s:%s Exit on line %d\n",
1477 dev->name,__FUNCTION__,__LINE__);
1479 CLAW_DBF_TEXT(4,trace,"addexit");
1481 } /* end of add_claw_reads */
1483 /*-------------------------------------------------------------------*
1484 * ccw_check_return_code *
1486 *-------------------------------------------------------------------*/
1489 ccw_check_return_code(struct ccw_device *cdev, int return_code)
1492 printk(KERN_INFO "%s: %s() > enter \n",
1493 cdev->dev.bus_id,__FUNCTION__);
1495 CLAW_DBF_TEXT(4,trace,"ccwret");
1497 printk(KERN_INFO "variable cdev =\n");
1498 dumpit((char *) cdev, sizeof(struct ccw_device));
1499 printk(KERN_INFO "variable return_code = %d\n",return_code);
1501 if (return_code != 0) {
1502 switch (return_code) {
1504 printk(KERN_INFO "%s: Busy !\n",
1508 printk(KERN_EMERG "%s: Missing device called "
1509 "for IO ENODEV\n", cdev->dev.bus_id);
1512 printk(KERN_EMERG "%s: Status pending... EIO \n",
1516 printk(KERN_EMERG "%s: Invalid Dev State EINVAL \n",
1520 printk(KERN_EMERG "%s: Unknown error in "
1521 "Do_IO %d\n",cdev->dev.bus_id, return_code);
1525 printk(KERN_INFO "%s: %s() > exit on line %d\n",
1526 cdev->dev.bus_id,__FUNCTION__,__LINE__);
1528 CLAW_DBF_TEXT(4,trace,"ccwret");
1529 } /* end of ccw_check_return_code */
1531 /*-------------------------------------------------------------------*
1532 * ccw_check_unit_check *
1533 *--------------------------------------------------------------------*/
1536 ccw_check_unit_check(struct chbk * p_ch, unsigned char sense )
1538 struct net_device *dev = p_ch->ndev;
1541 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__FUNCTION__);
1544 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1545 dumpit((char *)dev, sizeof(struct net_device));
1546 printk(KERN_INFO "%s: variable sense =\n",dev->name);
1547 dumpit((char *)&sense, 2);
1549 CLAW_DBF_TEXT(4,trace,"unitchek");
1551 printk(KERN_INFO "%s: Unit Check with sense byte:0x%04x\n",
1556 printk(KERN_WARNING "%s: Interface disconnect or "
1558 "occurred (remote side)\n", dev->name);
1561 printk(KERN_WARNING "%s: System reset occured"
1562 " (remote side)\n", dev->name);
1565 else if (sense & 0x20) {
1567 printk(KERN_WARNING "%s: Data-streaming "
1568 "timeout)\n", dev->name);
1571 printk(KERN_WARNING "%s: Data-transfer parity"
1572 " error\n", dev->name);
1575 else if (sense & 0x10) {
1577 printk(KERN_WARNING "%s: Hardware malfunction "
1578 "(remote side)\n", dev->name);
1581 printk(KERN_WARNING "%s: read-data parity error "
1582 "(remote side)\n", dev->name);
1587 printk(KERN_INFO "%s: %s() exit on line %d\n",
1588 dev->name,__FUNCTION__,__LINE__);
1590 } /* end of ccw_check_unit_check */
1594 /*-------------------------------------------------------------------*
1595 * Dump buffer format *
1597 *--------------------------------------------------------------------*/
1600 dumpit(char* buf, int len)
1603 __u32 ct, sw, rm, dup;
1605 char tbuf[82], tdup[82];
1612 char bhex[82], duphex[82];
1620 for ( ct=0; ct < len; ct++, ptr++, rptr++ ) {
1623 sprintf(addr, "%16.16lX",(unsigned long)rptr);
1625 sprintf(addr, "%8.8X",(__u32)rptr);
1627 sprintf(boff, "%4.4X", (__u32)ct);
1631 if ((sw == 4) || (sw == 12)) {
1638 sprintf(tbuf,"%2.2lX", (unsigned long)*ptr);
1640 sprintf(tbuf,"%2.2X", (__u32)*ptr);
1644 if ((0!=isprint(*ptr)) && (*ptr >= 0x20)) {
1654 if ((strcmp(duphex, bhex)) !=0) {
1656 sprintf(tdup,"Duplicate as above to"
1658 printk( KERN_INFO " "
1659 " --- %s ---\n",tdup);
1661 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1662 addr, boff, bhex, basc);
1664 strcpy(duphex, bhex);
1675 for ( ; rm > 0; rm--, sw++ ) {
1676 if ((sw==4) || (sw==12)) strcat(bhex, " ");
1677 if (sw==8) strcat(bhex, " ");
1682 sprintf(tdup,"Duplicate as above to %s", addr);
1683 printk( KERN_INFO " --- %s ---\n",
1686 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1687 addr, boff, bhex, basc);
1691 sprintf(tdup,"Duplicate as above to %s", addr);
1692 printk( KERN_INFO " --- %s ---\n",
1696 printk( KERN_INFO " %s (+%s) : %s [%s]\n",
1697 addr, boff, bhex, basc);
1702 } /* end of dumpit */
1705 /*-------------------------------------------------------------------*
1707 *--------------------------------------------------------------------*/
1709 find_link(struct net_device *dev, char *host_name, char *ws_name )
1711 struct claw_privbk *privptr;
1712 struct claw_env *p_env;
1716 printk(KERN_INFO "%s:%s > enter \n",dev->name,__FUNCTION__);
1718 CLAW_DBF_TEXT(2,setup,"findlink");
1720 printk(KERN_INFO "%s: variable dev = \n",dev->name);
1721 dumpit((char *) dev, sizeof(struct net_device));
1722 printk(KERN_INFO "%s: variable host_name = %s\n",dev->name, host_name);
1723 printk(KERN_INFO "%s: variable ws_name = %s\n",dev->name, ws_name);
1726 p_env=privptr->p_env;
1727 switch (p_env->packing)
1730 if ((memcmp(WS_APPL_NAME_PACKED, host_name, 8)!=0) ||
1731 (memcmp(WS_APPL_NAME_PACKED, ws_name, 8)!=0 ))
1736 if ((memcmp(WS_APPL_NAME_IP_NAME, host_name, 8)!=0) ||
1737 (memcmp(WS_APPL_NAME_IP_NAME, ws_name, 8)!=0 ))
1741 if ((memcmp(HOST_APPL_NAME, host_name, 8)!=0) ||
1742 (memcmp(p_env->api_type , ws_name, 8)!=0))
1748 printk(KERN_INFO "%s:%s Exit on line %d\n",
1749 dev->name,__FUNCTION__,__LINE__);
1752 } /* end of find_link */
1754 /*-------------------------------------------------------------------*
1758 *-------------------------------------------------------------------*/
1761 claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid)
1764 struct claw_privbk *privptr;
1765 struct ccwbk *p_this_ccw;
1766 struct ccwbk *p_first_ccw;
1767 struct ccwbk *p_last_ccw;
1769 signed long len_of_data;
1770 unsigned long bytesInThisBuffer;
1771 unsigned char *pDataAddress;
1772 struct endccw *pEnd;
1773 struct ccw1 tempCCW;
1775 struct claw_env *p_env;
1777 struct clawph *pk_head;
1780 struct ccwbk *p_buf;
1783 printk(KERN_INFO "%s: %s() > enter\n",dev->name,__FUNCTION__);
1785 CLAW_DBF_TEXT(4,trace,"hw_tx");
1787 printk(KERN_INFO "%s: variable dev skb =\n",dev->name);
1788 dumpit((char *) skb, sizeof(struct sk_buff));
1789 printk(KERN_INFO "%s: variable dev =\n",dev->name);
1790 dumpit((char *) dev, sizeof(struct net_device));
1791 printk(KERN_INFO "%s: variable linkid = %ld\n",dev->name,linkid);
1793 privptr = (struct claw_privbk *) (dev->priv);
1794 p_ch=(struct chbk *)&privptr->channel[WRITE];
1795 p_env =privptr->p_env;
1797 printk(KERN_INFO "%s: %s() dump sk_buff \n",dev->name,__FUNCTION__);
1798 dumpit((char *)skb ,sizeof(struct sk_buff));
1800 claw_free_wrt_buf(dev); /* Clean up free chain if posible */
1801 /* scan the write queue to free any completed write packets */
1804 if ((p_env->packing >= PACK_SEND) &&
1805 (skb->cb[1] != 'P')) {
1806 skb_push(skb,sizeof(struct clawph));
1807 pk_head=(struct clawph *)skb->data;
1808 pk_head->len=skb->len-sizeof(struct clawph);
1809 if (pk_head->len%4) {
1810 pk_head->len+= 4-(pk_head->len%4);
1811 skb_pad(skb,4-(pk_head->len%4));
1812 skb_put(skb,4-(pk_head->len%4));
1814 if (p_env->packing == DO_PACKED)
1815 pk_head->link_num = linkid;
1817 pk_head->link_num = 0;
1818 pk_head->flag = 0x00;
1823 if (claw_check_busy(dev)) {
1824 if (privptr->write_free_count!=0) {
1825 claw_clear_busy(dev);
1828 claw_strt_out_IO(dev );
1829 claw_free_wrt_buf( dev );
1830 if (privptr->write_free_count==0) {
1832 printk(KERN_INFO "%s: "
1833 "(claw_check_busy) no free write "
1834 "buffers\n", dev->name);
1836 ch = &privptr->channel[WRITE];
1837 atomic_inc(&skb->users);
1838 skb_queue_tail(&ch->collect_queue, skb);
1842 claw_clear_busy(dev);
1847 if (claw_test_and_setbit_busy(TB_TX,dev)) { /* set to busy */
1849 printk(KERN_INFO "%s: busy (claw_test_and_setbit_"
1850 "busy)\n", dev->name);
1852 ch = &privptr->channel[WRITE];
1853 atomic_inc(&skb->users);
1854 skb_queue_tail(&ch->collect_queue, skb);
1855 claw_strt_out_IO(dev );
1860 /* See how many write buffers are required to hold this data */
1861 numBuffers= ( skb->len + privptr->p_env->write_size - 1) /
1862 ( privptr->p_env->write_size);
1864 /* If that number of buffers isn't available, give up for now */
1865 if (privptr->write_free_count < numBuffers ||
1866 privptr->p_write_free_chain == NULL ) {
1868 claw_setbit_busy(TB_NOBUFFER,dev);
1871 printk(KERN_INFO "%s: busy (claw_setbit_busy"
1872 "(TB_NOBUFFER))\n", dev->name);
1873 printk(KERN_INFO " free_count: %d, numBuffers : %d\n",
1874 (int)privptr->write_free_count,(int) numBuffers );
1876 ch = &privptr->channel[WRITE];
1877 atomic_inc(&skb->users);
1878 skb_queue_tail(&ch->collect_queue, skb);
1879 CLAW_DBF_TEXT(2,trace,"clawbusy");
1882 pDataAddress=skb->data;
1883 len_of_data=skb->len;
1885 while (len_of_data > 0) {
1887 printk(KERN_INFO "%s: %s() length-of-data is %ld \n",
1888 dev->name ,__FUNCTION__,len_of_data);
1889 dumpit((char *)pDataAddress ,64);
1891 p_this_ccw=privptr->p_write_free_chain; /* get a block */
1892 if (p_this_ccw == NULL) { /* lost the race */
1893 ch = &privptr->channel[WRITE];
1894 atomic_inc(&skb->users);
1895 skb_queue_tail(&ch->collect_queue, skb);
1898 privptr->p_write_free_chain=p_this_ccw->next;
1899 p_this_ccw->next=NULL;
1900 --privptr->write_free_count; /* -1 */
1901 bytesInThisBuffer=len_of_data;
1902 memcpy( p_this_ccw->p_buffer,pDataAddress, bytesInThisBuffer);
1903 len_of_data-=bytesInThisBuffer;
1904 pDataAddress+=(unsigned long)bytesInThisBuffer;
1905 /* setup write CCW */
1906 p_this_ccw->write.cmd_code = (linkid * 8) +1;
1907 if (len_of_data>0) {
1908 p_this_ccw->write.cmd_code+=MORE_to_COME_FLAG;
1910 p_this_ccw->write.count=bytesInThisBuffer;
1911 /* now add to end of this chain */
1912 if (p_first_ccw==NULL) {
1913 p_first_ccw=p_this_ccw;
1915 if (p_last_ccw!=NULL) {
1916 p_last_ccw->next=p_this_ccw;
1917 /* set up TIC ccws */
1918 p_last_ccw->w_TIC_1.cda=
1919 (__u32)__pa(&p_this_ccw->write);
1921 p_last_ccw=p_this_ccw; /* save new last block */
1923 printk(KERN_INFO "%s: %s() > CCW and Buffer %ld bytes long \n",
1924 dev->name,__FUNCTION__,bytesInThisBuffer);
1925 dumpit((char *)p_this_ccw, sizeof(struct ccwbk));
1926 dumpit((char *)p_this_ccw->p_buffer, 64);
1930 /* FirstCCW and LastCCW now contain a new set of write channel
1931 * programs to append to the running channel program
1934 if (p_first_ccw!=NULL) {
1935 /* setup ending ccw sequence for this segment */
1936 pEnd=privptr->p_end_ccw;
1938 pEnd->write1=0x00; /* second end ccw is now active */
1939 /* set up Tic CCWs */
1940 p_last_ccw->w_TIC_1.cda=
1941 (__u32)__pa(&pEnd->write2_nop1);
1942 pEnd->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1943 pEnd->write2_nop2.flags =
1944 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1945 pEnd->write2_nop2.cda=0;
1946 pEnd->write2_nop2.count=1;
1948 else { /* end of if (pEnd->write1)*/
1949 pEnd->write1=0x01; /* first end ccw is now active */
1950 /* set up Tic CCWs */
1951 p_last_ccw->w_TIC_1.cda=
1952 (__u32)__pa(&pEnd->write1_nop1);
1953 pEnd->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
1954 pEnd->write1_nop2.flags =
1955 CCW_FLAG_SLI | CCW_FLAG_SKIP;
1956 pEnd->write1_nop2.cda=0;
1957 pEnd->write1_nop2.count=1;
1958 } /* end if if (pEnd->write1) */
1961 if (privptr->p_write_active_first==NULL ) {
1962 privptr->p_write_active_first=p_first_ccw;
1963 privptr->p_write_active_last=p_last_ccw;
1967 /* set up Tic CCWs */
1969 tempCCW.cda=(__u32)__pa(&p_first_ccw->write);
1972 tempCCW.cmd_code=CCW_CLAW_CMD_TIC;
1977 * first set of ending CCW's is chained to the new write
1978 * chain, so the second set is chained to the active chain
1979 * Therefore modify the second set to point the new write chain.
1980 * make sure we update the CCW atomically
1981 * so channel does not fetch it when it's only half done
1983 memcpy( &pEnd->write2_nop2, &tempCCW ,
1984 sizeof(struct ccw1));
1985 privptr->p_write_active_last->w_TIC_1.cda=
1986 (__u32)__pa(&p_first_ccw->write);
1990 /*make sure we update the CCW atomically
1991 *so channel does not fetch it when it's only half done
1993 memcpy(&pEnd->write1_nop2, &tempCCW ,
1994 sizeof(struct ccw1));
1995 privptr->p_write_active_last->w_TIC_1.cda=
1996 (__u32)__pa(&p_first_ccw->write);
1998 } /* end if if (pEnd->write1) */
2000 privptr->p_write_active_last->next=p_first_ccw;
2001 privptr->p_write_active_last=p_last_ccw;
2004 } /* endif (p_first_ccw!=NULL) */
2008 printk(KERN_INFO "%s: %s() > Dump Active CCW chain \n",
2009 dev->name,__FUNCTION__);
2010 p_buf=privptr->p_write_active_first;
2011 while (p_buf!=NULL) {
2012 dumpit((char *)p_buf, sizeof(struct ccwbk));
2015 p_buf=(struct ccwbk*)privptr->p_end_ccw;
2016 dumpit((char *)p_buf, sizeof(struct endccw));
2018 dev_kfree_skb_any(skb);
2025 claw_strt_out_IO(dev );
2026 /* if write free count is zero , set NOBUFFER */
2028 printk(KERN_INFO "%s: %s() > free_count is %d\n",
2029 dev->name,__FUNCTION__,
2030 (int) privptr->write_free_count );
2032 if (privptr->write_free_count==0) {
2033 claw_setbit_busy(TB_NOBUFFER,dev);
2036 claw_clearbit_busy(TB_TX,dev);
2039 printk(KERN_INFO "%s: %s() > exit on line %d, rc = %d \n",
2040 dev->name,__FUNCTION__,__LINE__, rc);
2043 } /* end of claw_hw_tx */
2045 /*-------------------------------------------------------------------*
2049 *--------------------------------------------------------------------*/
2052 init_ccw_bk(struct net_device *dev)
2055 __u32 ccw_blocks_required;
2056 __u32 ccw_blocks_perpage;
2057 __u32 ccw_pages_required;
2058 __u32 claw_reads_perpage=1;
2059 __u32 claw_read_pages;
2060 __u32 claw_writes_perpage=1;
2061 __u32 claw_write_pages;
2063 struct ccwbk*p_free_chain;
2065 struct ccwbk*p_last_CCWB;
2066 struct ccwbk*p_first_CCWB;
2067 struct endccw *p_endccw=NULL;
2068 addr_t real_address;
2069 struct claw_privbk *privptr=dev->priv;
2070 struct clawh *pClawH=NULL;
2071 addr_t real_TIC_address;
2074 printk(KERN_INFO "%s: %s() enter \n",dev->name,__FUNCTION__);
2076 CLAW_DBF_TEXT(4,trace,"init_ccw");
2078 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2079 dumpit((char *) dev, sizeof(struct net_device));
2082 /* initialize statistics field */
2083 privptr->active_link_ID=0;
2084 /* initialize ccwbk pointers */
2085 privptr->p_write_free_chain=NULL; /* pointer to free ccw chain*/
2086 privptr->p_write_active_first=NULL; /* pointer to the first write ccw*/
2087 privptr->p_write_active_last=NULL; /* pointer to the last write ccw*/
2088 privptr->p_read_active_first=NULL; /* pointer to the first read ccw*/
2089 privptr->p_read_active_last=NULL; /* pointer to the last read ccw */
2090 privptr->p_end_ccw=NULL; /* pointer to ending ccw */
2091 privptr->p_claw_signal_blk=NULL; /* pointer to signal block */
2092 privptr->buffs_alloc = 0;
2093 memset(&privptr->end_ccw, 0x00, sizeof(struct endccw));
2094 memset(&privptr->ctl_bk, 0x00, sizeof(struct clawctl));
2095 /* initialize free write ccwbk counter */
2096 privptr->write_free_count=0; /* number of free bufs on write chain */
2100 * We need 1 CCW block for each read buffer, 1 for each
2101 * write buffer, plus 1 for ClawSignalBlock
2103 ccw_blocks_required =
2104 privptr->p_env->read_buffers+privptr->p_env->write_buffers+1;
2106 printk(KERN_INFO "%s: %s() "
2107 "ccw_blocks_required=%d\n",
2108 dev->name,__FUNCTION__,
2109 ccw_blocks_required);
2110 printk(KERN_INFO "%s: %s() "
2112 dev->name,__FUNCTION__,
2113 (unsigned int)PAGE_SIZE);
2114 printk(KERN_INFO "%s: %s() > "
2116 dev->name,__FUNCTION__,
2117 (unsigned int)PAGE_MASK);
2120 * compute number of CCW blocks that will fit in a page
2122 ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE;
2124 (ccw_blocks_required+ccw_blocks_perpage -1) /
2128 printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
2129 dev->name,__FUNCTION__,
2130 ccw_blocks_perpage);
2131 printk(KERN_INFO "%s: %s() > ccw_pages_required=%d\n",
2132 dev->name,__FUNCTION__,
2133 ccw_pages_required);
2136 * read and write sizes are set by 2 constants in claw.h
2137 * 4k and 32k. Unpacked values other than 4k are not going to
2138 * provide good performance. With packing buffers support 32k
2141 if (privptr->p_env->read_size < PAGE_SIZE) {
2142 claw_reads_perpage= PAGE_SIZE / privptr->p_env->read_size;
2143 claw_read_pages= (privptr->p_env->read_buffers +
2144 claw_reads_perpage -1) / claw_reads_perpage;
2146 else { /* > or equal */
2147 privptr->p_buff_pages_perread=
2148 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
2150 privptr->p_env->read_buffers * privptr->p_buff_pages_perread;
2152 if (privptr->p_env->write_size < PAGE_SIZE) {
2153 claw_writes_perpage=
2154 PAGE_SIZE / privptr->p_env->write_size;
2156 (privptr->p_env->write_buffers + claw_writes_perpage -1) /
2157 claw_writes_perpage;
2160 else { /* > or equal */
2161 privptr->p_buff_pages_perwrite=
2162 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
2164 privptr->p_env->write_buffers * privptr->p_buff_pages_perwrite;
2167 if (privptr->p_env->read_size < PAGE_SIZE) {
2168 printk(KERN_INFO "%s: %s() reads_perpage=%d\n",
2169 dev->name,__FUNCTION__,
2170 claw_reads_perpage);
2173 printk(KERN_INFO "%s: %s() pages_perread=%d\n",
2174 dev->name,__FUNCTION__,
2175 privptr->p_buff_pages_perread);
2177 printk(KERN_INFO "%s: %s() read_pages=%d\n",
2178 dev->name,__FUNCTION__,
2180 if (privptr->p_env->write_size < PAGE_SIZE) {
2181 printk(KERN_INFO "%s: %s() writes_perpage=%d\n",
2182 dev->name,__FUNCTION__,
2183 claw_writes_perpage);
2186 printk(KERN_INFO "%s: %s() pages_perwrite=%d\n",
2187 dev->name,__FUNCTION__,
2188 privptr->p_buff_pages_perwrite);
2190 printk(KERN_INFO "%s: %s() write_pages=%d\n",
2191 dev->name,__FUNCTION__,
2197 * allocate ccw_pages_required
2199 if (privptr->p_buff_ccw==NULL) {
2200 privptr->p_buff_ccw=
2201 (void *)__get_free_pages(__GFP_DMA,
2202 (int)pages_to_order_of_mag(ccw_pages_required ));
2203 if (privptr->p_buff_ccw==NULL) {
2204 printk(KERN_INFO "%s: %s() "
2205 "__get_free_pages for CCWs failed : "
2207 dev->name,__FUNCTION__,
2208 ccw_pages_required );
2210 printk(KERN_INFO "%s: %s() > "
2211 "exit on line %d, rc = ENOMEM\n",
2212 dev->name,__FUNCTION__,
2217 privptr->p_buff_ccw_num=ccw_pages_required;
2219 memset(privptr->p_buff_ccw, 0x00,
2220 privptr->p_buff_ccw_num * PAGE_SIZE);
2223 * obtain ending ccw block address
2226 privptr->p_end_ccw = (struct endccw *)&privptr->end_ccw;
2227 real_address = (__u32)__pa(privptr->p_end_ccw);
2228 /* Initialize ending CCW block */
2230 printk(KERN_INFO "%s: %s() begin initialize ending CCW blocks\n",
2231 dev->name,__FUNCTION__);
2234 p_endccw=privptr->p_end_ccw;
2235 p_endccw->real=real_address;
2236 p_endccw->write1=0x00;
2237 p_endccw->read1=0x00;
2240 p_endccw->write1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2241 p_endccw->write1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2242 p_endccw->write1_nop1.count = 1;
2243 p_endccw->write1_nop1.cda = 0;
2246 p_endccw->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2247 p_endccw->write1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2248 p_endccw->write1_nop2.count = 1;
2249 p_endccw->write1_nop2.cda = 0;
2252 p_endccw->write2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2253 p_endccw->write2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2254 p_endccw->write2_nop1.count = 1;
2255 p_endccw->write2_nop1.cda = 0;
2258 p_endccw->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2259 p_endccw->write2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2260 p_endccw->write2_nop2.count = 1;
2261 p_endccw->write2_nop2.cda = 0;
2264 p_endccw->read1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2265 p_endccw->read1_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2266 p_endccw->read1_nop1.count = 1;
2267 p_endccw->read1_nop1.cda = 0;
2270 p_endccw->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2271 p_endccw->read1_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2272 p_endccw->read1_nop2.count = 1;
2273 p_endccw->read1_nop2.cda = 0;
2276 p_endccw->read2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
2277 p_endccw->read2_nop1.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2278 p_endccw->read2_nop1.count = 1;
2279 p_endccw->read2_nop1.cda = 0;
2282 p_endccw->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
2283 p_endccw->read2_nop2.flags = CCW_FLAG_SLI | CCW_FLAG_SKIP;
2284 p_endccw->read2_nop2.count = 1;
2285 p_endccw->read2_nop2.cda = 0;
2288 printk(KERN_INFO "%s: %s() dump claw ending CCW BK \n",
2289 dev->name,__FUNCTION__);
2290 dumpit((char *)p_endccw, sizeof(struct endccw));
2294 * Build a chain of CCWs
2299 printk(KERN_INFO "%s: %s() Begin build a chain of CCW buffer \n",
2300 dev->name,__FUNCTION__);
2302 p_buff=privptr->p_buff_ccw;
2305 for (i=0 ; i < ccw_pages_required; i++ ) {
2306 real_address = (__u32)__pa(p_buff);
2308 for (j=0 ; j < ccw_blocks_perpage ; j++) {
2309 p_buf->next = p_free_chain;
2310 p_free_chain = p_buf;
2311 p_buf->real=(__u32)__pa(p_buf);
2317 printk(KERN_INFO "%s: %s() "
2318 "End build a chain of CCW buffer \n",
2319 dev->name,__FUNCTION__);
2321 while (p_buf!=NULL) {
2322 dumpit((char *)p_buf, sizeof(struct ccwbk));
2328 * Initialize ClawSignalBlock
2332 printk(KERN_INFO "%s: %s() "
2333 "Begin initialize ClawSignalBlock \n",
2334 dev->name,__FUNCTION__);
2336 if (privptr->p_claw_signal_blk==NULL) {
2337 privptr->p_claw_signal_blk=p_free_chain;
2338 p_free_chain=p_free_chain->next;
2339 pClawH=(struct clawh *)privptr->p_claw_signal_blk;
2340 pClawH->length=0xffff;
2341 pClawH->opcode=0xff;
2342 pClawH->flag=CLAW_BUSY;
2345 printk(KERN_INFO "%s: %s() > End initialize "
2346 "ClawSignalBlock\n",
2347 dev->name,__FUNCTION__);
2348 dumpit((char *)privptr->p_claw_signal_blk, sizeof(struct ccwbk));
2352 * allocate write_pages_required and add to free chain
2354 if (privptr->p_buff_write==NULL) {
2355 if (privptr->p_env->write_size < PAGE_SIZE) {
2356 privptr->p_buff_write=
2357 (void *)__get_free_pages(__GFP_DMA,
2358 (int)pages_to_order_of_mag(claw_write_pages ));
2359 if (privptr->p_buff_write==NULL) {
2360 printk(KERN_INFO "%s: %s() __get_free_pages for write"
2361 " bufs failed : get is for %d pages\n",
2362 dev->name,__FUNCTION__,claw_write_pages );
2363 free_pages((unsigned long)privptr->p_buff_ccw,
2364 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2365 privptr->p_buff_ccw=NULL;
2367 printk(KERN_INFO "%s: %s() > exit on line %d,"
2369 dev->name,__FUNCTION__,__LINE__);
2374 * Build CLAW write free chain
2378 memset(privptr->p_buff_write, 0x00,
2379 ccw_pages_required * PAGE_SIZE);
2381 printk(KERN_INFO "%s: %s() Begin build claw write free "
2382 "chain \n",dev->name,__FUNCTION__);
2384 privptr->p_write_free_chain=NULL;
2386 p_buff=privptr->p_buff_write;
2388 for (i=0 ; i< privptr->p_env->write_buffers ; i++) {
2389 p_buf = p_free_chain; /* get a CCW */
2390 p_free_chain = p_buf->next;
2391 p_buf->next =privptr->p_write_free_chain;
2392 privptr->p_write_free_chain = p_buf;
2393 p_buf-> p_buffer = (struct clawbuf *)p_buff;
2394 p_buf-> write.cda = (__u32)__pa(p_buff);
2395 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2396 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2397 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2398 p_buf-> w_read_FF.count = 1;
2399 p_buf-> w_read_FF.cda =
2400 (__u32)__pa(&p_buf-> header.flag);
2401 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2402 p_buf-> w_TIC_1.flags = 0;
2403 p_buf-> w_TIC_1.count = 0;
2405 if (((unsigned long)p_buff+privptr->p_env->write_size) >=
2406 ((unsigned long)(p_buff+2*
2407 (privptr->p_env->write_size) -1) & PAGE_MASK)) {
2408 p_buff= p_buff+privptr->p_env->write_size;
2412 else /* Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
2414 privptr->p_write_free_chain=NULL;
2415 for (i = 0; i< privptr->p_env->write_buffers ; i++) {
2416 p_buff=(void *)__get_free_pages(__GFP_DMA,
2417 (int)pages_to_order_of_mag(
2418 privptr->p_buff_pages_perwrite) );
2420 printk(KERN_INFO "%s:%s __get_free_pages "
2421 "for writes buf: get for %d pages\n",
2422 dev->name,__FUNCTION__,
2423 privptr->p_buff_pages_perwrite);
2426 printk(KERN_INFO "%s:%s __get_free_pages"
2427 "for writes buf failed : get is for %d pages\n",
2430 privptr->p_buff_pages_perwrite );
2431 free_pages((unsigned long)privptr->p_buff_ccw,
2432 (int)pages_to_order_of_mag(
2433 privptr->p_buff_ccw_num));
2434 privptr->p_buff_ccw=NULL;
2435 p_buf=privptr->p_buff_write;
2436 while (p_buf!=NULL) {
2437 free_pages((unsigned long)
2439 (int)pages_to_order_of_mag(
2440 privptr->p_buff_pages_perwrite));
2444 printk(KERN_INFO "%s: %s exit on line %d, rc = ENOMEM\n",
2450 } /* Error on get_pages */
2451 memset(p_buff, 0x00, privptr->p_env->write_size );
2452 p_buf = p_free_chain;
2453 p_free_chain = p_buf->next;
2454 p_buf->next = privptr->p_write_free_chain;
2455 privptr->p_write_free_chain = p_buf;
2456 privptr->p_buff_write = p_buf;
2457 p_buf->p_buffer=(struct clawbuf *)p_buff;
2458 p_buf-> write.cda = (__u32)__pa(p_buff);
2459 p_buf-> write.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2460 p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2461 p_buf-> w_read_FF.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2462 p_buf-> w_read_FF.count = 1;
2463 p_buf-> w_read_FF.cda =
2464 (__u32)__pa(&p_buf-> header.flag);
2465 p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2466 p_buf-> w_TIC_1.flags = 0;
2467 p_buf-> w_TIC_1.count = 0;
2468 } /* for all write_buffers */
2470 } /* else buffers are PAGE_SIZE or bigger */
2473 privptr->p_buff_write_num=claw_write_pages;
2474 privptr->write_free_count=privptr->p_env->write_buffers;
2478 printk(KERN_INFO "%s:%s End build claw write free chain \n",
2479 dev->name,__FUNCTION__);
2480 p_buf=privptr->p_write_free_chain;
2481 while (p_buf!=NULL) {
2482 dumpit((char *)p_buf, sizeof(struct ccwbk));
2487 * allocate read_pages_required and chain to free chain
2489 if (privptr->p_buff_read==NULL) {
2490 if (privptr->p_env->read_size < PAGE_SIZE) {
2491 privptr->p_buff_read=
2492 (void *)__get_free_pages(__GFP_DMA,
2493 (int)pages_to_order_of_mag(claw_read_pages) );
2494 if (privptr->p_buff_read==NULL) {
2495 printk(KERN_INFO "%s: %s() "
2496 "__get_free_pages for read buf failed : "
2497 "get is for %d pages\n",
2498 dev->name,__FUNCTION__,claw_read_pages );
2499 free_pages((unsigned long)privptr->p_buff_ccw,
2500 (int)pages_to_order_of_mag(
2501 privptr->p_buff_ccw_num));
2502 /* free the write pages size is < page size */
2503 free_pages((unsigned long)privptr->p_buff_write,
2504 (int)pages_to_order_of_mag(
2505 privptr->p_buff_write_num));
2506 privptr->p_buff_ccw=NULL;
2507 privptr->p_buff_write=NULL;
2509 printk(KERN_INFO "%s: %s() > exit on line %d, rc ="
2510 " ENOMEM\n",dev->name,__FUNCTION__,__LINE__);
2514 memset(privptr->p_buff_read, 0x00, claw_read_pages * PAGE_SIZE);
2515 privptr->p_buff_read_num=claw_read_pages;
2517 * Build CLAW read free chain
2521 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2522 dev->name,__FUNCTION__);
2524 p_buff=privptr->p_buff_read;
2525 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2526 p_buf = p_free_chain;
2527 p_free_chain = p_buf->next;
2529 if (p_last_CCWB==NULL) {
2535 p_buf->next=p_first_CCWB;
2537 (__u32)__pa(&p_first_CCWB -> read );
2542 p_buf->p_buffer=(struct clawbuf *)p_buff;
2543 /* initialize read command */
2544 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2545 p_buf-> read.cda = (__u32)__pa(p_buff);
2546 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2547 p_buf-> read.count = privptr->p_env->read_size;
2549 /* initialize read_h command */
2550 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2551 p_buf-> read_h.cda =
2552 (__u32)__pa(&(p_buf->header));
2553 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2554 p_buf-> read_h.count = sizeof(struct clawh);
2556 /* initialize Signal command */
2557 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2558 p_buf-> signal.cda =
2559 (__u32)__pa(&(pClawH->flag));
2560 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2561 p_buf-> signal.count = 1;
2563 /* initialize r_TIC_1 command */
2564 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2565 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2566 p_buf-> r_TIC_1.flags = 0;
2567 p_buf-> r_TIC_1.count = 0;
2569 /* initialize r_read_FF command */
2570 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2571 p_buf-> r_read_FF.cda =
2572 (__u32)__pa(&(pClawH->flag));
2573 p_buf-> r_read_FF.flags =
2574 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2575 p_buf-> r_read_FF.count = 1;
2577 /* initialize r_TIC_2 */
2578 memcpy(&p_buf->r_TIC_2,
2579 &p_buf->r_TIC_1, sizeof(struct ccw1));
2581 /* initialize Header */
2582 p_buf->header.length=0xffff;
2583 p_buf->header.opcode=0xff;
2584 p_buf->header.flag=CLAW_PENDING;
2586 if (((unsigned long)p_buff+privptr->p_env->read_size) >=
2587 ((unsigned long)(p_buff+2*(privptr->p_env->read_size) -1)
2589 p_buff= p_buff+privptr->p_env->read_size;
2593 (void *)((unsigned long)
2594 (p_buff+2*(privptr->p_env->read_size) -1)
2597 } /* for read_buffers */
2598 } /* read_size < PAGE_SIZE */
2599 else { /* read Size >= PAGE_SIZE */
2602 printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
2603 dev->name,__FUNCTION__);
2605 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
2606 p_buff = (void *)__get_free_pages(__GFP_DMA,
2607 (int)pages_to_order_of_mag(privptr->p_buff_pages_perread) );
2609 printk(KERN_INFO "%s: %s() __get_free_pages for read "
2610 "buf failed : get is for %d pages\n",
2611 dev->name,__FUNCTION__,
2612 privptr->p_buff_pages_perread );
2613 free_pages((unsigned long)privptr->p_buff_ccw,
2614 (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
2615 /* free the write pages */
2616 p_buf=privptr->p_buff_write;
2617 while (p_buf!=NULL) {
2618 free_pages((unsigned long)p_buf->p_buffer,
2619 (int)pages_to_order_of_mag(
2620 privptr->p_buff_pages_perwrite ));
2623 /* free any read pages already alloc */
2624 p_buf=privptr->p_buff_read;
2625 while (p_buf!=NULL) {
2626 free_pages((unsigned long)p_buf->p_buffer,
2627 (int)pages_to_order_of_mag(
2628 privptr->p_buff_pages_perread ));
2631 privptr->p_buff_ccw=NULL;
2632 privptr->p_buff_write=NULL;
2634 printk(KERN_INFO "%s: %s() exit on line %d, rc = ENOMEM\n",
2635 dev->name,__FUNCTION__,
2640 memset(p_buff, 0x00, privptr->p_env->read_size);
2641 p_buf = p_free_chain;
2642 privptr->p_buff_read = p_buf;
2643 p_free_chain = p_buf->next;
2645 if (p_last_CCWB==NULL) {
2651 p_buf->next=p_first_CCWB;
2654 &p_first_CCWB -> read );
2658 /* save buff address */
2659 p_buf->p_buffer=(struct clawbuf *)p_buff;
2660 /* initialize read command */
2661 p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
2662 p_buf-> read.cda = (__u32)__pa(p_buff);
2663 p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2664 p_buf-> read.count = privptr->p_env->read_size;
2666 /* initialize read_h command */
2667 p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
2668 p_buf-> read_h.cda =
2669 (__u32)__pa(&(p_buf->header));
2670 p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2671 p_buf-> read_h.count = sizeof(struct clawh);
2673 /* initialize Signal command */
2674 p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
2675 p_buf-> signal.cda =
2676 (__u32)__pa(&(pClawH->flag));
2677 p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
2678 p_buf-> signal.count = 1;
2680 /* initialize r_TIC_1 command */
2681 p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
2682 p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
2683 p_buf-> r_TIC_1.flags = 0;
2684 p_buf-> r_TIC_1.count = 0;
2686 /* initialize r_read_FF command */
2687 p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
2688 p_buf-> r_read_FF.cda =
2689 (__u32)__pa(&(pClawH->flag));
2690 p_buf-> r_read_FF.flags =
2691 CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
2692 p_buf-> r_read_FF.count = 1;
2694 /* initialize r_TIC_2 */
2695 memcpy(&p_buf->r_TIC_2, &p_buf->r_TIC_1,
2696 sizeof(struct ccw1));
2698 /* initialize Header */
2699 p_buf->header.length=0xffff;
2700 p_buf->header.opcode=0xff;
2701 p_buf->header.flag=CLAW_PENDING;
2703 } /* For read_buffers */
2704 } /* read_size >= PAGE_SIZE */
2705 } /* pBuffread = NULL */
2707 printk(KERN_INFO "%s: %s() > End build claw read free chain \n",
2708 dev->name,__FUNCTION__);
2710 while (p_buf!=NULL) {
2711 dumpit((char *)p_buf, sizeof(struct ccwbk));
2716 add_claw_reads( dev ,p_first_CCWB , p_last_CCWB);
2717 privptr->buffs_alloc = 1;
2719 printk(KERN_INFO "%s: %s() exit on line %d\n",
2720 dev->name,__FUNCTION__,__LINE__);
2723 } /* end of init_ccw_bk */
2725 /*-------------------------------------------------------------------*
2729 *--------------------------------------------------------------------*/
2732 probe_error( struct ccwgroup_device *cgdev)
2734 struct claw_privbk *privptr;
2736 printk(KERN_INFO "%s enter \n",__FUNCTION__);
2738 CLAW_DBF_TEXT(4,trace,"proberr");
2740 printk(KERN_INFO "%s variable cgdev =\n",__FUNCTION__);
2741 dumpit((char *) cgdev, sizeof(struct ccwgroup_device));
2743 privptr=(struct claw_privbk *)cgdev->dev.driver_data;
2744 if (privptr!=NULL) {
2745 kfree(privptr->p_env);
2746 privptr->p_env=NULL;
2747 kfree(privptr->p_mtc_envelope);
2748 privptr->p_mtc_envelope=NULL;
2753 printk(KERN_INFO "%s > exit on line %d\n",
2754 __FUNCTION__,__LINE__);
2762 /*-------------------------------------------------------------------*
2763 * claw_process_control *
2766 *--------------------------------------------------------------------*/
2769 claw_process_control( struct net_device *dev, struct ccwbk * p_ccw)
2772 struct clawbuf *p_buf;
2773 struct clawctl ctlbk;
2774 struct clawctl *p_ctlbk;
2775 char temp_host_name[8];
2776 char temp_ws_name[8];
2777 struct claw_privbk *privptr;
2778 struct claw_env *p_env;
2779 struct sysval *p_sysval;
2780 struct conncmd *p_connect=NULL;
2782 struct chbk *p_ch = NULL;
2784 printk(KERN_INFO "%s: %s() > enter \n",
2785 dev->name,__FUNCTION__);
2787 CLAW_DBF_TEXT(2,setup,"clw_cntl");
2789 printk(KERN_INFO "%s: variable dev =\n",dev->name);
2790 dumpit((char *) dev, sizeof(struct net_device));
2791 printk(KERN_INFO "%s: variable p_ccw =\n",dev->name);
2792 dumpit((char *) p_ccw, sizeof(struct ccwbk *));
2794 udelay(1000); /* Wait a ms for the control packets to
2795 *catch up to each other */
2797 p_env=privptr->p_env;
2798 memcpy( &temp_host_name, p_env->host_name, 8);
2799 memcpy( &temp_ws_name, p_env->adapter_name , 8);
2800 printk(KERN_INFO "%s: CLAW device %.8s: "
2801 "Received Control Packet\n",
2802 dev->name, temp_ws_name);
2803 if (privptr->release_pend==1) {
2805 printk(KERN_INFO "%s: %s() > "
2806 "exit on line %d, rc=0\n",
2807 dev->name,__FUNCTION__,__LINE__);
2811 p_buf=p_ccw->p_buffer;
2813 if (p_env->packing == DO_PACKED) { /* packing in progress?*/
2814 memcpy(p_ctlbk, &p_buf->buffer[4], sizeof(struct clawctl));
2816 memcpy(p_ctlbk, p_buf, sizeof(struct clawctl));
2819 printk(KERN_INFO "%s: dump claw control data inbound\n",dev->name);
2820 dumpit((char *)p_ctlbk, sizeof(struct clawctl));
2822 switch (p_ctlbk->command)
2824 case SYSTEM_VALIDATE_REQUEST:
2825 if (p_ctlbk->version!=CLAW_VERSION_ID) {
2826 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2827 CLAW_RC_WRONG_VERSION );
2828 printk("%s: %d is wrong version id. "
2830 dev->name, p_ctlbk->version,
2833 p_sysval=(struct sysval *)&(p_ctlbk->data);
2834 printk( "%s: Recv Sys Validate Request: "
2835 "Vers=%d,link_id=%d,Corr=%d,WS name=%."
2836 "8s,Host name=%.8s\n",
2837 dev->name, p_ctlbk->version,
2839 p_ctlbk->correlator,
2841 p_sysval->host_name);
2842 if (0!=memcmp(temp_host_name,p_sysval->host_name,8)) {
2843 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2844 CLAW_RC_NAME_MISMATCH );
2845 CLAW_DBF_TEXT(2,setup,"HSTBAD");
2846 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->host_name);
2847 CLAW_DBF_TEXT_(2,setup,"%s",temp_host_name);
2848 printk(KERN_INFO "%s: Host name mismatch\n",
2850 printk(KERN_INFO "%s: Received :%s: "
2853 p_sysval->host_name,
2856 if (0!=memcmp(temp_ws_name,p_sysval->WS_name,8)) {
2857 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2858 CLAW_RC_NAME_MISMATCH );
2859 CLAW_DBF_TEXT(2,setup,"WSNBAD");
2860 CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->WS_name);
2861 CLAW_DBF_TEXT_(2,setup,"%s",temp_ws_name);
2862 printk(KERN_INFO "%s: WS name mismatch\n",
2864 printk(KERN_INFO "%s: Received :%s: "
2870 if (( p_sysval->write_frame_size < p_env->write_size) &&
2871 ( p_env->packing == 0)) {
2872 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2873 CLAW_RC_HOST_RCV_TOO_SMALL );
2874 printk(KERN_INFO "%s: host write size is too "
2875 "small\n", dev->name);
2876 CLAW_DBF_TEXT(2,setup,"wrtszbad");
2878 if (( p_sysval->read_frame_size < p_env->read_size) &&
2879 ( p_env->packing == 0)) {
2880 claw_snd_sys_validate_rsp(dev, p_ctlbk,
2881 CLAW_RC_HOST_RCV_TOO_SMALL );
2882 printk(KERN_INFO "%s: host read size is too "
2883 "small\n", dev->name);
2884 CLAW_DBF_TEXT(2,setup,"rdsizbad");
2886 claw_snd_sys_validate_rsp(dev, p_ctlbk, 0 );
2887 printk("%s: CLAW device %.8s: System validate"
2888 " completed.\n",dev->name, temp_ws_name);
2889 printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev->name,
2890 p_sysval->read_frame_size,p_sysval->write_frame_size);
2891 privptr->system_validate_comp=1;
2892 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
2893 p_env->packing = PACKING_ASK;
2895 claw_strt_conn_req(dev);
2898 case SYSTEM_VALIDATE_RESPONSE:
2899 p_sysval=(struct sysval *)&(p_ctlbk->data);
2900 printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
2901 "WS name=%.8s,Host name=%.8s\n",
2904 p_ctlbk->correlator,
2907 p_sysval->host_name);
2908 switch (p_ctlbk->rc)
2911 printk(KERN_INFO "%s: CLAW device "
2912 "%.8s: System validate "
2914 dev->name, temp_ws_name);
2915 if (privptr->system_validate_comp == 0)
2916 claw_strt_conn_req(dev);
2917 privptr->system_validate_comp=1;
2919 case CLAW_RC_NAME_MISMATCH:
2920 printk(KERN_INFO "%s: Sys Validate "
2921 "Resp : Host, WS name is "
2925 case CLAW_RC_WRONG_VERSION:
2926 printk(KERN_INFO "%s: Sys Validate "
2927 "Resp : Wrong version\n",
2930 case CLAW_RC_HOST_RCV_TOO_SMALL:
2931 printk(KERN_INFO "%s: Sys Validate "
2932 "Resp : bad frame size\n",
2936 printk(KERN_INFO "%s: Sys Validate "
2938 dev->name, p_ctlbk->rc );
2943 case CONNECTION_REQUEST:
2944 p_connect=(struct conncmd *)&(p_ctlbk->data);
2945 printk(KERN_INFO "%s: Recv Conn Req: Vers=%d,link_id=%d,"
2946 "Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
2950 p_ctlbk->correlator,
2951 p_connect->host_name,
2952 p_connect->WS_name);
2953 if (privptr->active_link_ID!=0 ) {
2954 claw_snd_disc(dev, p_ctlbk);
2955 printk(KERN_INFO "%s: Conn Req error : "
2956 "already logical link is active \n",
2959 if (p_ctlbk->linkid!=1 ) {
2960 claw_snd_disc(dev, p_ctlbk);
2961 printk(KERN_INFO "%s: Conn Req error : "
2962 "req logical link id is not 1\n",
2966 p_connect->host_name, p_connect->WS_name);
2968 claw_snd_disc(dev, p_ctlbk);
2969 printk(KERN_INFO "%s: Conn Req error : "
2970 "req appl name does not match\n",
2973 claw_send_control(dev,
2974 CONNECTION_CONFIRM, p_ctlbk->linkid,
2975 p_ctlbk->correlator,
2976 0, p_connect->host_name,
2977 p_connect->WS_name);
2978 if (p_env->packing == PACKING_ASK) {
2979 printk("%s: Now Pack ask\n",dev->name);
2980 p_env->packing = PACK_SEND;
2981 claw_snd_conn_req(dev,0);
2983 printk(KERN_INFO "%s: CLAW device %.8s: Connection "
2984 "completed link_id=%d.\n",
2985 dev->name, temp_ws_name,
2987 privptr->active_link_ID=p_ctlbk->linkid;
2988 p_ch=&privptr->channel[WRITE];
2989 wake_up(&p_ch->wait); /* wake up claw_open ( WRITE) */
2991 case CONNECTION_RESPONSE:
2992 p_connect=(struct conncmd *)&(p_ctlbk->data);
2993 printk(KERN_INFO "%s: Revc Conn Resp: Vers=%d,link_id=%d,"
2994 "Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
2998 p_ctlbk->correlator,
3000 p_connect->host_name,
3001 p_connect->WS_name);
3003 if (p_ctlbk->rc !=0 ) {
3004 printk(KERN_INFO "%s: Conn Resp error: rc=%d \n",
3005 dev->name, p_ctlbk->rc);
3009 p_connect->host_name, p_connect->WS_name);
3011 claw_snd_disc(dev, p_ctlbk);
3012 printk(KERN_INFO "%s: Conn Resp error: "
3013 "req appl name does not match\n",
3016 /* should be until CONNECTION_CONFIRM */
3017 privptr->active_link_ID = - (p_ctlbk->linkid);
3019 case CONNECTION_CONFIRM:
3020 p_connect=(struct conncmd *)&(p_ctlbk->data);
3021 printk(KERN_INFO "%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
3022 "Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
3026 p_ctlbk->correlator,
3027 p_connect->host_name,
3028 p_connect->WS_name);
3029 if (p_ctlbk->linkid== -(privptr->active_link_ID)) {
3030 privptr->active_link_ID=p_ctlbk->linkid;
3031 if (p_env->packing > PACKING_ASK) {
3032 printk(KERN_INFO "%s: Confirmed Now packing\n",dev->name);
3033 p_env->packing = DO_PACKED;
3035 p_ch=&privptr->channel[WRITE];
3036 wake_up(&p_ch->wait);
3039 printk(KERN_INFO "%s: Conn confirm: "
3040 "unexpected linkid=%d \n",
3041 dev->name, p_ctlbk->linkid);
3042 claw_snd_disc(dev, p_ctlbk);
3046 printk(KERN_INFO "%s: Disconnect: "
3047 "Vers=%d,link_id=%d,Corr=%d\n",
3048 dev->name, p_ctlbk->version,
3049 p_ctlbk->linkid, p_ctlbk->correlator);
3050 if ((p_ctlbk->linkid == 2) &&
3051 (p_env->packing == PACK_SEND)) {
3052 privptr->active_link_ID = 1;
3053 p_env->packing = DO_PACKED;
3056 privptr->active_link_ID=0;
3059 printk(KERN_INFO "%s: CLAW ERROR detected\n",
3063 printk(KERN_INFO "%s: Unexpected command code=%d \n",
3064 dev->name, p_ctlbk->command);
3069 printk(KERN_INFO "%s: %s() exit on line %d, rc = 0\n",
3070 dev->name,__FUNCTION__,__LINE__);
3074 } /* end of claw_process_control */
3077 /*-------------------------------------------------------------------*
3078 * claw_send_control *
3080 *--------------------------------------------------------------------*/
3083 claw_send_control(struct net_device *dev, __u8 type, __u8 link,
3084 __u8 correlator, __u8 rc, char *local_name, char *remote_name)
3086 struct claw_privbk *privptr;
3087 struct clawctl *p_ctl;
3088 struct sysval *p_sysval;
3089 struct conncmd *p_connect;
3090 struct sk_buff *skb;
3093 printk(KERN_INFO "%s:%s > enter \n",dev->name,__FUNCTION__);
3095 CLAW_DBF_TEXT(2,setup,"sndcntl");
3097 printk(KERN_INFO "%s: Sending Control Packet \n",dev->name);
3098 printk(KERN_INFO "%s: variable type = 0x%X, link = "
3099 "%d, correlator = %d, rc = %d\n",
3100 dev->name,type, link, correlator, rc);
3101 printk(KERN_INFO "%s: variable local_name = %s, "
3102 "remote_name = %s\n",dev->name, local_name, remote_name);
3105 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3107 p_ctl->command=type;
3108 p_ctl->version=CLAW_VERSION_ID;
3110 p_ctl->correlator=correlator;
3113 p_sysval=(struct sysval *)&p_ctl->data;
3114 p_connect=(struct conncmd *)&p_ctl->data;
3116 switch (p_ctl->command) {
3117 case SYSTEM_VALIDATE_REQUEST:
3118 case SYSTEM_VALIDATE_RESPONSE:
3119 memcpy(&p_sysval->host_name, local_name, 8);
3120 memcpy(&p_sysval->WS_name, remote_name, 8);
3121 if (privptr->p_env->packing > 0) {
3122 p_sysval->read_frame_size=DEF_PACK_BUFSIZE;
3123 p_sysval->write_frame_size=DEF_PACK_BUFSIZE;
3125 /* how big is the piggest group of packets */
3126 p_sysval->read_frame_size=privptr->p_env->read_size;
3127 p_sysval->write_frame_size=privptr->p_env->write_size;
3129 memset(&p_sysval->reserved, 0x00, 4);
3131 case CONNECTION_REQUEST:
3132 case CONNECTION_RESPONSE:
3133 case CONNECTION_CONFIRM:
3135 memcpy(&p_sysval->host_name, local_name, 8);
3136 memcpy(&p_sysval->WS_name, remote_name, 8);
3137 if (privptr->p_env->packing > 0) {
3138 /* How big is the biggest packet */
3139 p_connect->reserved1[0]=CLAW_FRAME_SIZE;
3140 p_connect->reserved1[1]=CLAW_FRAME_SIZE;
3142 memset(&p_connect->reserved1, 0x00, 4);
3143 memset(&p_connect->reserved2, 0x00, 4);
3150 /* write Control Record to the device */
3153 skb = dev_alloc_skb(sizeof(struct clawctl));
3155 printk( "%s:%s low on mem, returning...\n",
3156 dev->name,__FUNCTION__);
3158 printk(KERN_INFO "%s:%s Exit, rc = ENOMEM\n",
3159 dev->name,__FUNCTION__);
3163 memcpy(skb_put(skb, sizeof(struct clawctl)),
3164 p_ctl, sizeof(struct clawctl));
3166 printk(KERN_INFO "%s: outbnd claw cntl data \n",dev->name);
3167 dumpit((char *)p_ctl,sizeof(struct clawctl));
3169 if (privptr->p_env->packing >= PACK_SEND)
3170 claw_hw_tx(skb, dev, 1);
3172 claw_hw_tx(skb, dev, 0);
3174 printk(KERN_INFO "%s:%s Exit on line %d\n",
3175 dev->name,__FUNCTION__,__LINE__);
3179 } /* end of claw_send_control */
3181 /*-------------------------------------------------------------------*
3182 * claw_snd_conn_req *
3184 *--------------------------------------------------------------------*/
3186 claw_snd_conn_req(struct net_device *dev, __u8 link)
3189 struct claw_privbk *privptr=dev->priv;
3190 struct clawctl *p_ctl;
3193 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
3195 CLAW_DBF_TEXT(2,setup,"snd_conn");
3197 printk(KERN_INFO "%s: variable link = %X, dev =\n",dev->name, link);
3198 dumpit((char *) dev, sizeof(struct net_device));
3201 p_ctl=(struct clawctl *)&privptr->ctl_bk;
3202 p_ctl->linkid = link;
3203 if ( privptr->system_validate_comp==0x00 ) {
3205 printk(KERN_INFO "%s:%s Exit on line %d, rc = 1\n",
3206 dev->name,__FUNCTION__,__LINE__);
3210 if (privptr->p_env->packing == PACKING_ASK )
3211 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3212 WS_APPL_NAME_PACKED, WS_APPL_NAME_PACKED);
3213 if (privptr->p_env->packing == PACK_SEND) {
3214 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3215 WS_APPL_NAME_IP_NAME, WS_APPL_NAME_IP_NAME);
3217 if (privptr->p_env->packing == 0)
3218 rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
3219 HOST_APPL_NAME, privptr->p_env->api_type);
3221 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3222 dev->name,__FUNCTION__,__LINE__, rc);
3226 } /* end of claw_snd_conn_req */
3229 /*-------------------------------------------------------------------*
3232 *--------------------------------------------------------------------*/
3235 claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl)
3238 struct conncmd * p_connect;
3241 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3243 CLAW_DBF_TEXT(2,setup,"snd_dsc");
3245 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3246 dumpit((char *) dev, sizeof(struct net_device));
3247 printk(KERN_INFO "%s: variable p_ctl",dev->name);
3248 dumpit((char *) p_ctl, sizeof(struct clawctl));
3250 p_connect=(struct conncmd *)&p_ctl->data;
3252 rc=claw_send_control(dev, DISCONNECT, p_ctl->linkid,
3253 p_ctl->correlator, 0,
3254 p_connect->host_name, p_connect->WS_name);
3256 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3257 dev->name,__FUNCTION__, __LINE__, rc);
3260 } /* end of claw_snd_disc */
3263 /*-------------------------------------------------------------------*
3264 * claw_snd_sys_validate_rsp *
3266 *--------------------------------------------------------------------*/
3269 claw_snd_sys_validate_rsp(struct net_device *dev,
3270 struct clawctl *p_ctl, __u32 return_code)
3272 struct claw_env * p_env;
3273 struct claw_privbk *privptr;
3277 printk(KERN_INFO "%s:%s Enter\n",
3278 dev->name,__FUNCTION__);
3280 CLAW_DBF_TEXT(2,setup,"chkresp");
3282 printk(KERN_INFO "%s: variable return_code = %d, dev =\n",
3283 dev->name, return_code);
3284 dumpit((char *) dev, sizeof(struct net_device));
3285 printk(KERN_INFO "%s: variable p_ctl =\n",dev->name);
3286 dumpit((char *) p_ctl, sizeof(struct clawctl));
3288 privptr = dev->priv;
3289 p_env=privptr->p_env;
3290 rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE,
3295 p_env->adapter_name );
3297 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3298 dev->name,__FUNCTION__,__LINE__, rc);
3301 } /* end of claw_snd_sys_validate_rsp */
3303 /*-------------------------------------------------------------------*
3304 * claw_strt_conn_req *
3306 *--------------------------------------------------------------------*/
3309 claw_strt_conn_req(struct net_device *dev )
3314 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3316 CLAW_DBF_TEXT(2,setup,"conn_req");
3318 printk(KERN_INFO "%s: variable dev =\n",dev->name);
3319 dumpit((char *) dev, sizeof(struct net_device));
3321 rc=claw_snd_conn_req(dev, 1);
3323 printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
3324 dev->name,__FUNCTION__,__LINE__, rc);
3327 } /* end of claw_strt_conn_req */
3331 /*-------------------------------------------------------------------*
3333 *-------------------------------------------------------------------*/
3336 net_device_stats *claw_stats(struct net_device *dev)
3338 struct claw_privbk *privptr;
3340 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3342 CLAW_DBF_TEXT(4,trace,"stats");
3343 privptr = dev->priv;
3345 printk(KERN_INFO "%s:%s Exit on line %d\n",
3346 dev->name,__FUNCTION__,__LINE__);
3348 return &privptr->stats;
3349 } /* end of claw_stats */
3352 /*-------------------------------------------------------------------*
3355 *--------------------------------------------------------------------*/
3357 unpack_read(struct net_device *dev )
3359 struct sk_buff *skb;
3360 struct claw_privbk *privptr;
3361 struct claw_env *p_env;
3362 struct ccwbk *p_this_ccw;
3363 struct ccwbk *p_first_ccw;
3364 struct ccwbk *p_last_ccw;
3365 struct clawph *p_packh;
3367 struct clawctl *p_ctlrec=NULL;
3372 __u8 mtc_this_frm=0;
3374 struct chbk *p_ch = NULL;
3379 printk(KERN_INFO "%s:%s enter \n",dev->name,__FUNCTION__);
3381 CLAW_DBF_TEXT(4,trace,"unpkread");
3387 p_env = privptr->p_env;
3388 p_this_ccw=privptr->p_read_active_first;
3390 while (p_this_ccw!=NULL && p_this_ccw->header.flag!=CLAW_PENDING) {
3392 printk(KERN_INFO "%s p_this_ccw \n",dev->name);
3393 dumpit((char*)p_this_ccw, sizeof(struct ccwbk));
3394 printk(KERN_INFO "%s Inbound p_this_ccw->p_buffer(64)"
3395 " pk=%d \n",dev->name,p_env->packing);
3396 dumpit((char *)p_this_ccw->p_buffer, 64 );
3400 p_this_ccw->header.flag=CLAW_PENDING;
3401 privptr->p_read_active_first=p_this_ccw->next;
3402 p_this_ccw->next=NULL;
3403 p_packh = (struct clawph *)p_this_ccw->p_buffer;
3404 if ((p_env->packing == PACK_SEND) &&
3405 (p_packh->len == 32) &&
3406 (p_packh->link_num == 0)) { /* is it a packed ctl rec? */
3407 p_packh++; /* peek past pack header */
3408 p_ctlrec = (struct clawctl *)p_packh;
3409 p_packh--; /* un peek */
3410 if ((p_ctlrec->command == CONNECTION_RESPONSE) ||
3411 (p_ctlrec->command == CONNECTION_CONFIRM))
3412 p_env->packing = DO_PACKED;
3414 if (p_env->packing == DO_PACKED)
3415 link_num=p_packh->link_num;
3417 link_num=p_this_ccw->header.opcode / 8;
3418 if ((p_this_ccw->header.opcode & MORE_to_COME_FLAG)!=0) {
3420 printk(KERN_INFO "%s: %s > More_to_come is ON\n",
3421 dev->name,__FUNCTION__);
3424 if (p_this_ccw->header.length!=
3425 privptr->p_env->read_size ) {
3426 printk(KERN_INFO " %s: Invalid frame detected "
3427 "length is %02x\n" ,
3428 dev->name, p_this_ccw->header.length);
3432 if (privptr->mtc_skipping) {
3434 * We're in the mode of skipping past a
3435 * multi-frame message
3436 * that we can't process for some reason or other.
3437 * The first frame without the More-To-Come flag is
3438 * the last frame of the skipped message.
3440 /* in case of More-To-Come not set in this frame */
3441 if (mtc_this_frm==0) {
3442 privptr->mtc_skipping=0; /* Ok, the end */
3443 privptr->mtc_logical_link=-1;
3446 printk(KERN_INFO "%s:%s goto next "
3447 "frame from MoretoComeSkip \n",
3448 dev->name,__FUNCTION__);
3454 claw_process_control(dev, p_this_ccw);
3456 printk(KERN_INFO "%s:%s goto next "
3457 "frame from claw_process_control \n",
3458 dev->name,__FUNCTION__);
3460 CLAW_DBF_TEXT(4,trace,"UnpkCntl");
3464 if (p_env->packing == DO_PACKED) {
3465 if (pack_off > p_env->read_size)
3467 p_packd = p_this_ccw->p_buffer+pack_off;
3468 p_packh = (struct clawph *) p_packd;
3469 if ((p_packh->len == 0) || /* all done with this frame? */
3470 (p_packh->flag != 0))
3472 bytes_to_mov = p_packh->len;
3473 pack_off += bytes_to_mov+sizeof(struct clawph);
3476 bytes_to_mov=p_this_ccw->header.length;
3478 if (privptr->mtc_logical_link<0) {
3480 printk(KERN_INFO "%s: %s mtc_logical_link < 0 \n",
3481 dev->name,__FUNCTION__);
3485 * if More-To-Come is set in this frame then we don't know
3486 * length of entire message, and hence have to allocate
3489 /* We are starting a new envelope */
3490 privptr->mtc_offset=0;
3491 privptr->mtc_logical_link=link_num;
3494 if (bytes_to_mov > (MAX_ENVELOPE_SIZE- privptr->mtc_offset) ) {
3497 printk(KERN_INFO "%s: %s > goto next "
3498 "frame from MoretoComeSkip \n",
3501 printk(KERN_INFO " bytes_to_mov %d > (MAX_ENVELOPE_"
3502 "SIZE-privptr->mtc_offset %d)\n",
3503 bytes_to_mov,(MAX_ENVELOPE_SIZE- privptr->mtc_offset));
3505 privptr->stats.rx_frame_errors++;
3508 if (p_env->packing == DO_PACKED) {
3509 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3510 p_packd+sizeof(struct clawph), bytes_to_mov);
3513 memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
3514 p_this_ccw->p_buffer, bytes_to_mov);
3517 printk(KERN_INFO "%s: %s() received data \n",
3518 dev->name,__FUNCTION__);
3519 if (p_env->packing == DO_PACKED)
3520 dumpit((char *)p_packd+sizeof(struct clawph),32);
3522 dumpit((char *)p_this_ccw->p_buffer, 32);
3523 printk(KERN_INFO "%s: %s() bytelength %d \n",
3524 dev->name,__FUNCTION__,bytes_to_mov);
3526 if (mtc_this_frm==0) {
3527 len_of_data=privptr->mtc_offset+bytes_to_mov;
3528 skb=dev_alloc_skb(len_of_data);
3530 memcpy(skb_put(skb,len_of_data),
3531 privptr->p_mtc_envelope,
3533 skb->mac.raw=skb->data;
3535 skb->protocol=htons(ETH_P_IP);
3536 skb->ip_summed=CHECKSUM_UNNECESSARY;
3537 privptr->stats.rx_packets++;
3538 privptr->stats.rx_bytes+=len_of_data;
3541 printk(KERN_INFO "%s: %s() netif_"
3542 "rx(skb) completed \n",
3543 dev->name,__FUNCTION__);
3547 privptr->stats.rx_dropped++;
3548 printk(KERN_WARNING "%s: %s() low on memory\n",
3549 dev->name,__FUNCTION__);
3551 privptr->mtc_offset=0;
3552 privptr->mtc_logical_link=-1;
3555 privptr->mtc_offset+=bytes_to_mov;
3557 if (p_env->packing == DO_PACKED)
3561 * Remove ThisCCWblock from active read queue, and add it
3562 * to queue of free blocks to be reused.
3565 p_this_ccw->header.length=0xffff;
3566 p_this_ccw->header.opcode=0xff;
3568 * add this one to the free queue for later reuse
3570 if (p_first_ccw==NULL) {
3571 p_first_ccw = p_this_ccw;
3574 p_last_ccw->next = p_this_ccw;
3576 p_last_ccw = p_this_ccw;
3578 * chain to next block on active read queue
3580 p_this_ccw = privptr->p_read_active_first;
3581 CLAW_DBF_TEXT_(4,trace,"rxpkt %d",p);
3582 } /* end of while */
3584 /* check validity */
3587 printk(KERN_INFO "%s:%s processed frame is %d \n",
3588 dev->name,__FUNCTION__,i);
3589 printk(KERN_INFO "%s:%s F:%lx L:%lx\n",
3592 (unsigned long)p_first_ccw,
3593 (unsigned long)p_last_ccw);
3595 CLAW_DBF_TEXT_(4,trace,"rxfrm %d",i);
3596 add_claw_reads(dev, p_first_ccw, p_last_ccw);
3597 p_ch=&privptr->channel[READ];
3598 claw_strt_read(dev, LOCK_YES);
3600 printk(KERN_INFO "%s: %s exit on line %d\n",
3601 dev->name, __FUNCTION__, __LINE__);
3604 } /* end of unpack_read */
3606 /*-------------------------------------------------------------------*
3609 *--------------------------------------------------------------------*/
3611 claw_strt_read (struct net_device *dev, int lock )
3615 unsigned long saveflags = 0;
3616 struct claw_privbk *privptr=dev->priv;
3617 struct ccwbk*p_ccwbk;
3619 struct clawh *p_clawh;
3620 p_ch=&privptr->channel[READ];
3623 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
3624 printk(KERN_INFO "%s: variable lock = %d, dev =\n",dev->name, lock);
3625 dumpit((char *) dev, sizeof(struct net_device));
3627 CLAW_DBF_TEXT(4,trace,"StRdNter");
3628 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3629 p_clawh->flag=CLAW_IDLE; /* 0x00 */
3631 if ((privptr->p_write_active_first!=NULL &&
3632 privptr->p_write_active_first->header.flag!=CLAW_PENDING) ||
3633 (privptr->p_read_active_first!=NULL &&
3634 privptr->p_read_active_first->header.flag!=CLAW_PENDING )) {
3635 p_clawh->flag=CLAW_BUSY; /* 0xff */
3638 printk(KERN_INFO "%s:%s state-%02x\n" ,
3639 dev->name,__FUNCTION__, p_ch->claw_state);
3641 if (lock==LOCK_YES) {
3642 spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
3644 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3646 printk(KERN_INFO "%s: HOT READ started in %s\n" ,
3647 dev->name,__FUNCTION__);
3648 p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
3649 dumpit((char *)&p_clawh->flag , 1);
3651 CLAW_DBF_TEXT(4,trace,"HotRead");
3652 p_ccwbk=privptr->p_read_active_first;
3653 parm = (unsigned long) p_ch;
3654 rc = ccw_device_start (p_ch->cdev, &p_ccwbk->read, parm,
3657 ccw_check_return_code(p_ch->cdev, rc);
3662 printk(KERN_INFO "%s: No READ started by %s() In progress\n" ,
3663 dev->name,__FUNCTION__);
3665 CLAW_DBF_TEXT(2,trace,"ReadAct");
3668 if (lock==LOCK_YES) {
3669 spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
3672 printk(KERN_INFO "%s:%s Exit on line %d\n",
3673 dev->name,__FUNCTION__,__LINE__);
3675 CLAW_DBF_TEXT(4,trace,"StRdExit");
3677 } /* end of claw_strt_read */
3679 /*-------------------------------------------------------------------*
3680 * claw_strt_out_IO *
3682 *--------------------------------------------------------------------*/
3685 claw_strt_out_IO( struct net_device *dev )
3689 struct claw_privbk *privptr;
3691 struct ccwbk *p_first_ccw;
3694 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3699 privptr=(struct claw_privbk *)dev->priv;
3700 p_ch=&privptr->channel[WRITE];
3703 printk(KERN_INFO "%s:%s state-%02x\n" ,
3704 dev->name,__FUNCTION__,p_ch->claw_state);
3706 CLAW_DBF_TEXT(4,trace,"strt_io");
3707 p_first_ccw=privptr->p_write_active_first;
3709 if (p_ch->claw_state == CLAW_STOP)
3711 if (p_first_ccw == NULL) {
3713 printk(KERN_INFO "%s:%s Exit on line %d\n",
3714 dev->name,__FUNCTION__,__LINE__);
3718 if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
3719 parm = (unsigned long) p_ch;
3721 printk(KERN_INFO "%s:%s do_io \n" ,dev->name,__FUNCTION__);
3722 dumpit((char *)p_first_ccw, sizeof(struct ccwbk));
3724 CLAW_DBF_TEXT(2,trace,"StWrtIO");
3725 rc = ccw_device_start (p_ch->cdev,&p_first_ccw->write, parm,
3728 ccw_check_return_code(p_ch->cdev, rc);
3731 dev->trans_start = jiffies;
3733 printk(KERN_INFO "%s:%s Exit on line %d\n",
3734 dev->name,__FUNCTION__,__LINE__);
3738 } /* end of claw_strt_out_IO */
3740 /*-------------------------------------------------------------------*
3741 * Free write buffers *
3743 *--------------------------------------------------------------------*/
3746 claw_free_wrt_buf( struct net_device *dev )
3749 struct claw_privbk *privptr=(struct claw_privbk *)dev->priv;
3750 struct ccwbk*p_first_ccw;
3751 struct ccwbk*p_last_ccw;
3752 struct ccwbk*p_this_ccw;
3753 struct ccwbk*p_next_ccw;
3758 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3759 printk(KERN_INFO "%s: free count = %d variable dev =\n",
3760 dev->name,privptr->write_free_count);
3762 CLAW_DBF_TEXT(4,trace,"freewrtb");
3763 /* scan the write queue to free any completed write packets */
3767 printk(KERN_INFO "%s: Dump current CCW chain \n",dev->name );
3768 p_buf=privptr->p_write_active_first;
3769 while (p_buf!=NULL) {
3770 dumpit((char *)p_buf, sizeof(struct ccwbk));
3774 printk(KERN_INFO "%s: privptr->p_write_"
3775 "active_first==NULL\n",dev->name );
3777 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3778 dumpit((char *)p_buf, sizeof(struct endccw));
3780 p_this_ccw=privptr->p_write_active_first;
3781 while ( (p_this_ccw!=NULL) && (p_this_ccw->header.flag!=CLAW_PENDING))
3783 p_next_ccw = p_this_ccw->next;
3784 if (((p_next_ccw!=NULL) &&
3785 (p_next_ccw->header.flag!=CLAW_PENDING)) ||
3786 ((p_this_ccw == privptr->p_write_active_last) &&
3787 (p_this_ccw->header.flag!=CLAW_PENDING))) {
3788 /* The next CCW is OK or this is */
3789 /* the last CCW...free it @A1A */
3790 privptr->p_write_active_first=p_this_ccw->next;
3791 p_this_ccw->header.flag=CLAW_PENDING;
3792 p_this_ccw->next=privptr->p_write_free_chain;
3793 privptr->p_write_free_chain=p_this_ccw;
3794 ++privptr->write_free_count;
3795 privptr->stats.tx_bytes+= p_this_ccw->write.count;
3796 p_this_ccw=privptr->p_write_active_first;
3797 privptr->stats.tx_packets++;
3803 if (privptr->write_free_count!=0) {
3804 claw_clearbit_busy(TB_NOBUFFER,dev);
3806 /* whole chain removed? */
3807 if (privptr->p_write_active_first==NULL) {
3808 privptr->p_write_active_last=NULL;
3810 printk(KERN_INFO "%s:%s p_write_"
3811 "active_first==NULL\n",dev->name,__FUNCTION__);
3815 printk(KERN_INFO "%s: Dump arranged CCW chain \n",dev->name );
3816 p_buf=privptr->p_write_active_first;
3817 while (p_buf!=NULL) {
3818 dumpit((char *)p_buf, sizeof(struct ccwbk));
3822 printk(KERN_INFO "%s: privptr->p_write_active_"
3823 "first==NULL\n",dev->name );
3825 p_buf=(struct ccwbk*)privptr->p_end_ccw;
3826 dumpit((char *)p_buf, sizeof(struct endccw));
3829 CLAW_DBF_TEXT_(4,trace,"FWC=%d",privptr->write_free_count);
3831 printk(KERN_INFO "%s:%s Exit on line %d free_count =%d\n",
3832 dev->name,__FUNCTION__, __LINE__,privptr->write_free_count);
3837 /*-------------------------------------------------------------------*
3838 * claw free netdevice *
3840 *--------------------------------------------------------------------*/
3842 claw_free_netdevice(struct net_device * dev, int free_dev)
3844 struct claw_privbk *privptr;
3846 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3848 CLAW_DBF_TEXT(2,setup,"free_dev");
3852 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3853 privptr = dev->priv;
3854 if (dev->flags & IFF_RUNNING)
3857 privptr->channel[READ].ndev = NULL; /* say it's free */
3865 CLAW_DBF_TEXT(2,setup,"feee_ok");
3867 printk(KERN_INFO "%s:%s Exit\n",dev->name,__FUNCTION__);
3872 * Claw init netdevice
3873 * Initialize everything of the net device except the name and the
3877 claw_init_netdevice(struct net_device * dev)
3880 printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);
3882 CLAW_DBF_TEXT(2,setup,"init_dev");
3883 CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
3885 printk(KERN_WARNING "claw:%s BAD Device exit line %d\n",
3886 __FUNCTION__,__LINE__);
3887 CLAW_DBF_TEXT(2,setup,"baddev");
3890 dev->mtu = CLAW_DEFAULT_MTU_SIZE;
3891 dev->hard_start_xmit = claw_tx;
3892 dev->open = claw_open;
3893 dev->stop = claw_release;
3894 dev->get_stats = claw_stats;
3895 dev->change_mtu = claw_change_mtu;
3896 dev->hard_header_len = 0;
3898 dev->type = ARPHRD_SLIP;
3899 dev->tx_queue_len = 1300;
3900 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
3901 SET_MODULE_OWNER(dev);
3903 printk(KERN_INFO "%s:%s Exit\n",dev->name,__FUNCTION__);
3905 CLAW_DBF_TEXT(2,setup,"initok");
3910 * Init a new channel in the privptr->channel[i].
3912 * @param cdev The ccw_device to be added.
3914 * @return 0 on success, !0 on error.
3917 add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
3922 printk(KERN_INFO "%s:%s Enter\n",cdev->dev.bus_id,__FUNCTION__);
3924 CLAW_DBF_TEXT_(2,setup,"%s",cdev->dev.bus_id);
3925 privptr->channel[i].flag = i+1; /* Read is 1 Write is 2 */
3926 p_ch = &privptr->channel[i];
3928 snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id);
3929 sscanf(cdev->dev.bus_id+4,"%x",&p_ch->devno);
3930 if ((p_ch->irb = kmalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) {
3931 printk(KERN_WARNING "%s Out of memory in %s for irb\n",
3932 p_ch->id,__FUNCTION__);
3934 printk(KERN_INFO "%s:%s Exit on line %d\n",
3935 p_ch->id,__FUNCTION__,__LINE__);
3939 memset(p_ch->irb, 0, sizeof (struct irb));
3941 printk(KERN_INFO "%s:%s Exit on line %d\n",
3942 cdev->dev.bus_id,__FUNCTION__,__LINE__);
3950 * Setup an interface.
3952 * @param cgdev Device to be setup.
3954 * @returns 0 on success, !0 on failure.
3957 claw_new_device(struct ccwgroup_device *cgdev)
3959 struct claw_privbk *privptr;
3960 struct claw_env *p_env;
3961 struct net_device *dev;
3964 pr_debug("%s() called\n", __FUNCTION__);
3965 printk(KERN_INFO "claw: add for %s\n",cgdev->cdev[READ]->dev.bus_id);
3966 CLAW_DBF_TEXT(2,setup,"new_dev");
3967 privptr = cgdev->dev.driver_data;
3968 cgdev->cdev[READ]->dev.driver_data = privptr;
3969 cgdev->cdev[WRITE]->dev.driver_data = privptr;
3972 p_env = privptr->p_env;
3973 sscanf(cgdev->cdev[READ]->dev.bus_id+4,"%x",
3974 &p_env->devno[READ]);
3975 sscanf(cgdev->cdev[WRITE]->dev.bus_id+4,"%x",
3976 &p_env->devno[WRITE]);
3977 ret = add_channel(cgdev->cdev[0],0,privptr);
3979 ret = add_channel(cgdev->cdev[1],1,privptr);
3982 "add channel failed "
3983 "with ret = %d\n", ret);
3986 ret = ccw_device_set_online(cgdev->cdev[READ]);
3989 "claw: ccw_device_set_online %s READ failed "
3990 "with ret = %d\n",cgdev->cdev[READ]->dev.bus_id,ret);
3993 ret = ccw_device_set_online(cgdev->cdev[WRITE]);
3996 "claw: ccw_device_set_online %s WRITE failed "
3997 "with ret = %d\n",cgdev->cdev[WRITE]->dev.bus_id, ret);
4000 dev = alloc_netdev(0,"claw%d",claw_init_netdevice);
4002 printk(KERN_WARNING "%s:alloc_netdev failed\n",__FUNCTION__);
4005 dev->priv = privptr;
4006 cgdev->dev.driver_data = privptr;
4007 cgdev->cdev[READ]->dev.driver_data = privptr;
4008 cgdev->cdev[WRITE]->dev.driver_data = privptr;
4010 SET_NETDEV_DEV(dev, &cgdev->dev);
4011 if (register_netdev(dev) != 0) {
4012 claw_free_netdevice(dev, 1);
4013 CLAW_DBF_TEXT(2,trace,"regfail");
4016 dev->flags &=~IFF_RUNNING;
4017 if (privptr->buffs_alloc == 0) {
4018 ret=init_ccw_bk(dev);
4021 "claw: init_ccw_bk failed with ret=%d\n", ret);
4022 unregister_netdev(dev);
4023 claw_free_netdevice(dev,1);
4024 CLAW_DBF_TEXT(2,trace,"ccwmem");
4028 privptr->channel[READ].ndev = dev;
4029 privptr->channel[WRITE].ndev = dev;
4030 privptr->p_env->ndev = dev;
4032 printk(KERN_INFO "%s:readsize=%d writesize=%d "
4033 "readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
4034 dev->name, p_env->read_size,
4035 p_env->write_size, p_env->read_buffers,
4036 p_env->write_buffers, p_env->devno[READ],
4037 p_env->devno[WRITE]);
4038 printk(KERN_INFO "%s:host_name:%.8s, adapter_name "
4039 ":%.8s api_type: %.8s\n",
4040 dev->name, p_env->host_name,
4041 p_env->adapter_name , p_env->api_type);
4044 ccw_device_set_offline(cgdev->cdev[1]);
4045 ccw_device_set_offline(cgdev->cdev[0]);
4051 claw_purge_skb_queue(struct sk_buff_head *q)
4053 struct sk_buff *skb;
4055 CLAW_DBF_TEXT(4,trace,"purgque");
4057 while ((skb = skb_dequeue(q))) {
4058 atomic_dec(&skb->users);
4059 dev_kfree_skb_any(skb);
4064 * Shutdown an interface.
4066 * @param cgdev Device to be shut down.
4068 * @returns 0 on success, !0 on failure.
4071 claw_shutdown_device(struct ccwgroup_device *cgdev)
4073 struct claw_privbk *priv;
4074 struct net_device *ndev;
4077 pr_debug("%s() called\n", __FUNCTION__);
4078 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4079 priv = cgdev->dev.driver_data;
4082 ndev = priv->channel[READ].ndev;
4084 /* Close the device */
4086 "%s: shuting down \n",ndev->name);
4087 if (ndev->flags & IFF_RUNNING)
4088 ret = claw_release(ndev);
4089 ndev->flags &=~IFF_RUNNING;
4090 unregister_netdev(ndev);
4091 ndev->priv = NULL; /* cgdev data, not ndev's to free */
4092 claw_free_netdevice(ndev, 1);
4093 priv->channel[READ].ndev = NULL;
4094 priv->channel[WRITE].ndev = NULL;
4095 priv->p_env->ndev = NULL;
4097 ccw_device_set_offline(cgdev->cdev[1]);
4098 ccw_device_set_offline(cgdev->cdev[0]);
4103 claw_remove_device(struct ccwgroup_device *cgdev)
4105 struct claw_privbk *priv;
4107 pr_debug("%s() called\n", __FUNCTION__);
4108 CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
4109 priv = cgdev->dev.driver_data;
4111 printk(KERN_WARNING "claw: %s() no Priv exiting\n",__FUNCTION__);
4114 printk(KERN_INFO "claw: %s() called %s will be removed.\n",
4115 __FUNCTION__,cgdev->cdev[0]->dev.bus_id);
4116 if (cgdev->state == CCWGROUP_ONLINE)
4117 claw_shutdown_device(cgdev);
4118 claw_remove_files(&cgdev->dev);
4119 kfree(priv->p_mtc_envelope);
4120 priv->p_mtc_envelope=NULL;
4123 kfree(priv->channel[0].irb);
4124 priv->channel[0].irb=NULL;
4125 kfree(priv->channel[1].irb);
4126 priv->channel[1].irb=NULL;
4128 cgdev->dev.driver_data=NULL;
4129 cgdev->cdev[READ]->dev.driver_data = NULL;
4130 cgdev->cdev[WRITE]->dev.driver_data = NULL;
4131 put_device(&cgdev->dev);
4139 claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
4141 struct claw_privbk *priv;
4142 struct claw_env * p_env;
4144 priv = dev->driver_data;
4147 p_env = priv->p_env;
4148 return sprintf(buf, "%s\n",p_env->host_name);
4152 claw_hname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4154 struct claw_privbk *priv;
4155 struct claw_env * p_env;
4157 priv = dev->driver_data;
4160 p_env = priv->p_env;
4161 if (count > MAX_NAME_LEN+1)
4163 memset(p_env->host_name, 0x20, MAX_NAME_LEN);
4164 strncpy(p_env->host_name,buf, count);
4165 p_env->host_name[count-1] = 0x20; /* clear extra 0x0a */
4166 p_env->host_name[MAX_NAME_LEN] = 0x00;
4167 CLAW_DBF_TEXT(2,setup,"HstnSet");
4168 CLAW_DBF_TEXT_(2,setup,"%s",p_env->host_name);
4173 static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write);
4176 claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
4178 struct claw_privbk *priv;
4179 struct claw_env * p_env;
4181 priv = dev->driver_data;
4184 p_env = priv->p_env;
4185 return sprintf(buf, "%s\n",p_env->adapter_name);
4189 claw_adname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4191 struct claw_privbk *priv;
4192 struct claw_env * p_env;
4194 priv = dev->driver_data;
4197 p_env = priv->p_env;
4198 if (count > MAX_NAME_LEN+1)
4200 memset(p_env->adapter_name, 0x20, MAX_NAME_LEN);
4201 strncpy(p_env->adapter_name,buf, count);
4202 p_env->adapter_name[count-1] = 0x20; /* clear extra 0x0a */
4203 p_env->adapter_name[MAX_NAME_LEN] = 0x00;
4204 CLAW_DBF_TEXT(2,setup,"AdnSet");
4205 CLAW_DBF_TEXT_(2,setup,"%s",p_env->adapter_name);
4210 static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write);
4213 claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
4215 struct claw_privbk *priv;
4216 struct claw_env * p_env;
4218 priv = dev->driver_data;
4221 p_env = priv->p_env;
4222 return sprintf(buf, "%s\n",
4227 claw_apname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4229 struct claw_privbk *priv;
4230 struct claw_env * p_env;
4232 priv = dev->driver_data;
4235 p_env = priv->p_env;
4236 if (count > MAX_NAME_LEN+1)
4238 memset(p_env->api_type, 0x20, MAX_NAME_LEN);
4239 strncpy(p_env->api_type,buf, count);
4240 p_env->api_type[count-1] = 0x20; /* we get a loose 0x0a */
4241 p_env->api_type[MAX_NAME_LEN] = 0x00;
4242 if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
4243 p_env->read_size=DEF_PACK_BUFSIZE;
4244 p_env->write_size=DEF_PACK_BUFSIZE;
4245 p_env->packing=PACKING_ASK;
4246 CLAW_DBF_TEXT(2,setup,"PACKING");
4250 p_env->read_size=CLAW_FRAME_SIZE;
4251 p_env->write_size=CLAW_FRAME_SIZE;
4252 CLAW_DBF_TEXT(2,setup,"ApiSet");
4254 CLAW_DBF_TEXT_(2,setup,"%s",p_env->api_type);
4258 static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write);
4261 claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4263 struct claw_privbk *priv;
4264 struct claw_env * p_env;
4266 priv = dev->driver_data;
4269 p_env = priv->p_env;
4270 return sprintf(buf, "%d\n", p_env->write_buffers);
4274 claw_wbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4276 struct claw_privbk *priv;
4277 struct claw_env * p_env;
4280 priv = dev->driver_data;
4283 p_env = priv->p_env;
4284 sscanf(buf, "%i", &nnn);
4285 if (p_env->packing) {
4291 if ((nnn > max ) || (nnn < 2))
4293 p_env->write_buffers = nnn;
4294 CLAW_DBF_TEXT(2,setup,"Wbufset");
4295 CLAW_DBF_TEXT_(2,setup,"WB=%d",p_env->write_buffers);
4299 static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write);
4302 claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4304 struct claw_privbk *priv;
4305 struct claw_env * p_env;
4307 priv = dev->driver_data;
4310 p_env = priv->p_env;
4311 return sprintf(buf, "%d\n", p_env->read_buffers);
4315 claw_rbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4317 struct claw_privbk *priv;
4318 struct claw_env *p_env;
4321 priv = dev->driver_data;
4324 p_env = priv->p_env;
4325 sscanf(buf, "%i", &nnn);
4326 if (p_env->packing) {
4332 if ((nnn > max ) || (nnn < 2))
4334 p_env->read_buffers = nnn;
4335 CLAW_DBF_TEXT(2,setup,"Rbufset");
4336 CLAW_DBF_TEXT_(2,setup,"RB=%d",p_env->read_buffers);
4340 static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write);
4342 static struct attribute *claw_attr[] = {
4343 &dev_attr_read_buffer.attr,
4344 &dev_attr_write_buffer.attr,
4345 &dev_attr_adapter_name.attr,
4346 &dev_attr_api_type.attr,
4347 &dev_attr_host_name.attr,
4351 static struct attribute_group claw_attr_group = {
4356 claw_add_files(struct device *dev)
4358 pr_debug("%s() called\n", __FUNCTION__);
4359 CLAW_DBF_TEXT(2,setup,"add_file");
4360 return sysfs_create_group(&dev->kobj, &claw_attr_group);
4364 claw_remove_files(struct device *dev)
4366 pr_debug("%s() called\n", __FUNCTION__);
4367 CLAW_DBF_TEXT(2,setup,"rem_file");
4368 sysfs_remove_group(&dev->kobj, &claw_attr_group);
4371 /*--------------------------------------------------------------------*
4372 * claw_init and cleanup *
4373 *---------------------------------------------------------------------*/
4378 unregister_cu3088_discipline(&claw_group_driver);
4379 claw_unregister_debug_facility();
4380 printk(KERN_INFO "claw: Driver unloaded\n");
4385 * Initialize module.
4386 * This is called just after the module is loaded.
4388 * @return 0 on success, !0 on error.
4394 printk(KERN_INFO "claw: starting driver "
4398 "compiled into kernel "
4400 " $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $ \n");
4404 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__);
4406 ret = claw_register_debug_facility();
4408 printk(KERN_WARNING "claw: %s() debug_register failed %d\n",
4412 CLAW_DBF_TEXT(2,setup,"init_mod");
4413 ret = register_cu3088_discipline(&claw_group_driver);
4415 claw_unregister_debug_facility();
4416 printk(KERN_WARNING "claw; %s() cu3088 register failed %d\n",
4420 printk(KERN_INFO "claw: %s() exit \n",__FUNCTION__);
4425 module_init(claw_init);
4426 module_exit(claw_cleanup);
4430 /*--------------------------------------------------------------------*
4432 *---------------------------------------------------------------------*/