/*
 *  drivers/s390/net/claw.c
 *    ESCON CLAW network driver
 *
 *  Linux for zSeries version
 *    Copyright (C) 2002,2005 IBM Corporation
 *  Author(s) Original code written by:
 *              Kazuo Iimura (iimura@jp.ibm.com)
 *   	      Rewritten by
 *              Andy Richter (richtera@us.ibm.com)
 *              Marc Price (mwprice@us.ibm.com)
 *
 *    sysfs parms:
 *   group x.x.rrrr,x.x.wwww
 *   read_buffer nnnnnnn
 *   write_buffer nnnnnn
 *   host_name  aaaaaaaa
 *   adapter_name aaaaaaaa
 *   api_type    aaaaaaaa
 *
 *  eg.
 *   group  0.0.0200 0.0.0201
 *   read_buffer 25
 *   write_buffer 20
 *   host_name LINUX390
 *   adapter_name RS6K
 *   api_type     TCPIP
 *
 *  where
 *
 *   The device id is decided by the order entries
 *   are added to the group the first is claw0 the second claw1
 *   up to CLAW_MAX_DEV
 *
 *   rrrr     -	the first of 2 consecutive device addresses used for the
 *		CLAW protocol.
 *		The specified address is always used as the input (Read)
 *		channel and the next address is used as the output channel.
 *
 *   wwww     -	the second of 2 consecutive device addresses used for
 *		the CLAW protocol.
 *              The specified address is always used as the output
 *		channel and the previous address is used as the input channel.
 *
 *   read_buffer	-       specifies number of input buffers to allocate.
 *   write_buffer       -       specifies number of output buffers to allocate.
 *   host_name          -       host name
 *   adaptor_name       -       adaptor name
 *   api_type           -       API type TCPIP or API will be sent and expected
 *				as ws_name
 *
 *   Note the following requirements:
 *   1)  host_name must match the configured adapter_name on the remote side
 *   2)  adaptor_name must match the configured host name on the remote side
 *
 *  Change History
 *    1.00  Initial release shipped
 *    1.10  Changes for Buffer allocation
 *    1.15  Changed for 2.6 Kernel  No longer compiles on 2.4 or lower
 *    1.25  Added Packing support
 */
#include <asm/ccwdev.h>
#include <asm/ccwgroup.h>
#include <asm/debug.h>
#include <asm/idals.h>
#include <asm/io.h>

#include <linux/bitops.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/if_arp.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ip.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/tcp.h>
#include <linux/timer.h>
#include <linux/types.h>

#include "cu3088.h"
#include "claw.h"

MODULE_AUTHOR("Andy Richter <richtera@us.ibm.com>");
MODULE_DESCRIPTION("Linux for zSeries CLAW Driver\n" \
			"Copyright 2000,2005 IBM Corporation\n");
MODULE_LICENSE("GPL");

/* Debugging is based on DEBUGMSG, IOTRACE, or FUNCTRACE  options:
   DEBUGMSG  - Enables output of various debug messages in the code
   IOTRACE   - Enables output of CCW and other IO related traces
   FUNCTRACE - Enables output of function entry/exit trace
   Define any combination of above options to enable tracing

   CLAW also uses the s390dbf file system  see claw_trace and claw_setup
*/

/* following enables tracing */
//#define DEBUGMSG
//#define IOTRACE
//#define FUNCTRACE

#ifdef DEBUGMSG
#define DEBUG
#endif

#ifdef IOTRACE
#define DEBUG
#endif

#ifdef FUNCTRACE
#define DEBUG
#endif

static char debug_buffer[255];
/**
 * Debug Facility Stuff
 */
static debug_info_t *claw_dbf_setup;
static debug_info_t *claw_dbf_trace;

/**
 *  CLAW Debug Facility functions
 */
static void
claw_unregister_debug_facility(void)
{
	if (claw_dbf_setup)
		debug_unregister(claw_dbf_setup);
	if (claw_dbf_trace)
		debug_unregister(claw_dbf_trace);
}

static int
claw_register_debug_facility(void)
{
	claw_dbf_setup = debug_register("claw_setup", 2, 1, 8);
	claw_dbf_trace = debug_register("claw_trace", 2, 2, 8);
	if (claw_dbf_setup == NULL || claw_dbf_trace == NULL) {
		printk(KERN_WARNING "Not enough memory for debug facility.\n");
		claw_unregister_debug_facility();
		return -ENOMEM;
	}
	debug_register_view(claw_dbf_setup, &debug_hex_ascii_view);
	debug_set_level(claw_dbf_setup, 2);
	debug_register_view(claw_dbf_trace, &debug_hex_ascii_view);
	debug_set_level(claw_dbf_trace, 2);
	return 0;
}

static inline void
claw_set_busy(struct net_device *dev)
{
 ((struct claw_privbk *) dev->priv)->tbusy=1;
 eieio();
}

static inline void
claw_clear_busy(struct net_device *dev)
{
	clear_bit(0, &(((struct claw_privbk *) dev->priv)->tbusy));
	netif_wake_queue(dev);
	eieio();
}

static inline int
claw_check_busy(struct net_device *dev)
{
	eieio();
	return ((struct claw_privbk *) dev->priv)->tbusy;
}

static inline void
claw_setbit_busy(int nr,struct net_device *dev)
{
	netif_stop_queue(dev);
 	set_bit(nr, (void *)&(((struct claw_privbk *)dev->priv)->tbusy));
}

static inline void
claw_clearbit_busy(int nr,struct net_device *dev)
{
 	clear_bit(nr,(void *)&(((struct claw_privbk *)dev->priv)->tbusy));
	netif_wake_queue(dev);
}

static inline int
claw_test_and_setbit_busy(int nr,struct net_device *dev)
{
	netif_stop_queue(dev);
	return test_and_set_bit(nr,
 		(void *)&(((struct claw_privbk *) dev->priv)->tbusy));
}


/* Functions for the DEV methods */

static int claw_probe(struct ccwgroup_device *cgdev);
static void claw_remove_device(struct ccwgroup_device *cgdev);
static void claw_purge_skb_queue(struct sk_buff_head *q);
static int claw_new_device(struct ccwgroup_device *cgdev);
static int claw_shutdown_device(struct ccwgroup_device *cgdev);
static int claw_tx(struct sk_buff *skb, struct net_device *dev);
static int claw_change_mtu( struct net_device *dev, int new_mtu);
static int claw_open(struct net_device *dev);
static void claw_irq_handler(struct ccw_device *cdev,
	unsigned long intparm, struct irb *irb);
static void claw_irq_tasklet ( unsigned long data );
static int claw_release(struct net_device *dev);
static void claw_write_retry ( struct chbk * p_ch );
static void claw_write_next ( struct chbk * p_ch );
static void claw_timer ( struct chbk * p_ch );

/* Functions */
static int add_claw_reads(struct net_device *dev,
	struct ccwbk* p_first, struct ccwbk* p_last);
static void ccw_check_return_code (struct ccw_device *cdev, int return_code);
static void ccw_check_unit_check (struct chbk * p_ch, unsigned char sense );
static int find_link(struct net_device *dev, char *host_name, char *ws_name );
static int claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid);
static int init_ccw_bk(struct net_device *dev);
static void probe_error( struct ccwgroup_device *cgdev);
static struct net_device_stats *claw_stats(struct net_device *dev);
static int pages_to_order_of_mag(int num_of_pages);
static struct sk_buff *claw_pack_skb(struct claw_privbk *privptr);
#ifdef DEBUG
static void dumpit (char *buf, int len);
#endif
/* sysfs Functions */
static ssize_t claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t claw_hname_write(struct device *dev, struct device_attribute *attr,
	const char *buf, size_t count);
static ssize_t claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t claw_adname_write(struct device *dev, struct device_attribute *attr,
	const char *buf, size_t count);
static ssize_t claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t claw_apname_write(struct device *dev, struct device_attribute *attr,
	const char *buf, size_t count);
static ssize_t claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t claw_wbuff_write(struct device *dev, struct device_attribute *attr,
	const char *buf, size_t count);
static ssize_t claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t claw_rbuff_write(struct device *dev, struct device_attribute *attr,
	const char *buf, size_t count);
static int claw_add_files(struct device *dev);
static void claw_remove_files(struct device *dev);

/*   Functions for System Validate  */
static int claw_process_control( struct net_device *dev, struct ccwbk * p_ccw);
static int claw_send_control(struct net_device *dev, __u8 type, __u8 link,
       __u8 correlator, __u8 rc , char *local_name, char *remote_name);
static int claw_snd_conn_req(struct net_device *dev, __u8 link);
static int claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl);
static int claw_snd_sys_validate_rsp(struct net_device *dev,
        struct clawctl * p_ctl, __u32 return_code);
static int claw_strt_conn_req(struct net_device *dev );
static void claw_strt_read ( struct net_device *dev, int lock );
static void claw_strt_out_IO( struct net_device *dev );
static void claw_free_wrt_buf( struct net_device *dev );

/* Functions for unpack reads   */
static void unpack_read (struct net_device *dev );

/* ccwgroup table  */

static struct ccwgroup_driver claw_group_driver = {
        .owner       = THIS_MODULE,
        .name        = "claw",
        .max_slaves  = 2,
        .driver_id   = 0xC3D3C1E6,
        .probe       = claw_probe,
        .remove      = claw_remove_device,
        .set_online  = claw_new_device,
        .set_offline = claw_shutdown_device,
};

/*
*
*       Key functions
*/

/*----------------------------------------------------------------*
 *   claw_probe                                                   *
 *      this function is called for each CLAW device.             *
 *----------------------------------------------------------------*/
static int
claw_probe(struct ccwgroup_device *cgdev)
{
	int  		rc;
	struct claw_privbk *privptr=NULL;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s Enter\n",__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"probe");
	if (!get_device(&cgdev->dev))
		return -ENODEV;
#ifdef DEBUGMSG
        printk(KERN_INFO "claw: variable cgdev =\n");
        dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
#endif
	privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
	if (privptr == NULL) {
		probe_error(cgdev);
		put_device(&cgdev->dev);
		printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
			cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
		CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
		return -ENOMEM;
	}
	privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
	privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL);
        if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
                probe_error(cgdev);
		put_device(&cgdev->dev);
		printk(KERN_WARNING "Out of memory %s %s Exit Line %d \n",
			cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
		CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
                return -ENOMEM;
        }
	memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
	memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
	memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
	privptr->p_env->packing = 0;
	privptr->p_env->write_buffers = 5;
	privptr->p_env->read_buffers = 5;
	privptr->p_env->read_size = CLAW_FRAME_SIZE;
	privptr->p_env->write_size = CLAW_FRAME_SIZE;
	rc = claw_add_files(&cgdev->dev);
	if (rc) {
		probe_error(cgdev);
		put_device(&cgdev->dev);
		printk(KERN_WARNING "add_files failed %s %s Exit Line %d \n",
			cgdev->cdev[0]->dev.bus_id,__func__,__LINE__);
		CLAW_DBF_TEXT_(2,setup,"probex%d",rc);
		return rc;
	}
	printk(KERN_INFO "claw: sysfs files added for %s\n",cgdev->cdev[0]->dev.bus_id);
	privptr->p_env->p_priv = privptr;
        cgdev->cdev[0]->handler = claw_irq_handler;
	cgdev->cdev[1]->handler = claw_irq_handler;
	cgdev->dev.driver_data = privptr;
#ifdef FUNCTRACE
        printk(KERN_INFO "claw:%s exit on line %d, "
		"rc = 0\n",__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(2,setup,"prbext 0");

        return 0;
}  /*  end of claw_probe       */

/*-------------------------------------------------------------------*
 *   claw_tx                                                         *
 *-------------------------------------------------------------------*/

static int
claw_tx(struct sk_buff *skb, struct net_device *dev)
{
        int             rc;
        struct claw_privbk *privptr=dev->priv;
	unsigned long saveflags;
        struct chbk *p_ch;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"claw_tx");
        p_ch=&privptr->channel[WRITE];
        if (skb == NULL) {
                printk(KERN_WARNING "%s: null pointer passed as sk_buffer\n",
			dev->name);
                privptr->stats.tx_dropped++;
#ifdef FUNCTRACE
                printk(KERN_INFO "%s: %s() exit on line %d, rc = EIO\n",
			dev->name,__func__, __LINE__);
#endif
		CLAW_DBF_TEXT_(2,trace,"clawtx%d",-EIO);
                return -EIO;
        }

#ifdef IOTRACE
        printk(KERN_INFO "%s: variable sk_buff=\n",dev->name);
        dumpit((char *) skb, sizeof(struct sk_buff));
        printk(KERN_INFO "%s: variable dev=\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
#endif
        spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
        rc=claw_hw_tx( skb, dev, 1 );
        spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s exit on line %d, rc = %d\n",
		dev->name, __func__, __LINE__, rc);
#endif
	CLAW_DBF_TEXT_(4,trace,"clawtx%d",rc);
        return rc;
}   /*  end of claw_tx */

/*------------------------------------------------------------------*
 *  pack the collect queue into an skb and return it                *
 *   If not packing just return the top skb from the queue          *
 *------------------------------------------------------------------*/

static struct sk_buff *
claw_pack_skb(struct claw_privbk *privptr)
{
	struct sk_buff *new_skb,*held_skb;
	struct chbk *p_ch = &privptr->channel[WRITE];
	struct claw_env  *p_env = privptr->p_env;
	int	pkt_cnt,pk_ind,so_far;

	new_skb = NULL;		/* assume no dice */
	pkt_cnt = 0;
	CLAW_DBF_TEXT(4,trace,"PackSKBe");
	if (!skb_queue_empty(&p_ch->collect_queue)) {
	/* some data */
		held_skb = skb_dequeue(&p_ch->collect_queue);
		if (held_skb)
			dev_kfree_skb_any(held_skb);
		else
			return NULL;
		if (p_env->packing != DO_PACKED)
			return held_skb;
		/* get a new SKB we will pack at least one */
		new_skb = dev_alloc_skb(p_env->write_size);
		if (new_skb == NULL) {
			atomic_inc(&held_skb->users);
			skb_queue_head(&p_ch->collect_queue,held_skb);
			return NULL;
		}
		/* we have packed packet and a place to put it  */
		pk_ind = 1;
		so_far = 0;
		new_skb->cb[1] = 'P'; /* every skb on queue has pack header */
		while ((pk_ind) && (held_skb != NULL)) {
			if (held_skb->len+so_far <= p_env->write_size-8) {
				memcpy(skb_put(new_skb,held_skb->len),
					held_skb->data,held_skb->len);
				privptr->stats.tx_packets++;
				so_far += held_skb->len;
				pkt_cnt++;
				dev_kfree_skb_any(held_skb);
				held_skb = skb_dequeue(&p_ch->collect_queue);
				if (held_skb)
					atomic_dec(&held_skb->users);
			} else {
				pk_ind = 0;
				atomic_inc(&held_skb->users);
				skb_queue_head(&p_ch->collect_queue,held_skb);
			}
		}
#ifdef IOTRACE
		printk(KERN_INFO "%s: %s() Packed %d len %d\n",
			p_env->ndev->name,
			__func__,pkt_cnt,new_skb->len);
#endif
	}
	CLAW_DBF_TEXT(4,trace,"PackSKBx");
	return new_skb;
}

/*-------------------------------------------------------------------*
 *   claw_change_mtu                                                 *
 *                                                                   *
 *-------------------------------------------------------------------*/

static int
claw_change_mtu(struct net_device *dev, int new_mtu)
{
	struct claw_privbk  *privptr=dev->priv;
	int buff_size;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
#ifdef DEBUGMSG
        printk(KERN_INFO "variable dev =\n");
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "variable new_mtu = %d\n", new_mtu);
#endif
	CLAW_DBF_TEXT(4,trace,"setmtu");
	buff_size = privptr->p_env->write_size;
        if ((new_mtu < 60) || (new_mtu > buff_size)) {
#ifdef FUNCTRACE
                printk(KERN_INFO "%s:%s Exit on line %d, rc=EINVAL\n",
		dev->name,
		__func__, __LINE__);
#endif
                return -EINVAL;
        }
        dev->mtu = new_mtu;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",dev->name,
	__func__, __LINE__);
#endif
        return 0;
}  /*   end of claw_change_mtu */


/*-------------------------------------------------------------------*
 *   claw_open                                                       *
 *                                                                   *
 *-------------------------------------------------------------------*/
static int
claw_open(struct net_device *dev)
{

        int     rc;
        int     i;
        unsigned long       saveflags=0;
        unsigned long       parm;
        struct claw_privbk  *privptr;
	DECLARE_WAITQUEUE(wait, current);
        struct timer_list  timer;
        struct ccwbk *p_buf;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"open");
	if (!dev || (dev->name[0] == 0x00)) {
		CLAW_DBF_TEXT(2,trace,"BadDev");
	 	printk(KERN_WARNING "claw: Bad device at open failing \n");
		return -ENODEV;
	}
	privptr = (struct claw_privbk *)dev->priv;
        /*   allocate and initialize CCW blocks */
	if (privptr->buffs_alloc == 0) {
	        rc=init_ccw_bk(dev);
        	if (rc) {
                	printk(KERN_INFO "%s:%s Exit on line %d, rc=ENOMEM\n",
			dev->name,
			__func__, __LINE__);
			CLAW_DBF_TEXT(2,trace,"openmem");
                	return -ENOMEM;
        	}
	}
        privptr->system_validate_comp=0;
        privptr->release_pend=0;
	if(strncmp(privptr->p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
		privptr->p_env->read_size=DEF_PACK_BUFSIZE;
		privptr->p_env->write_size=DEF_PACK_BUFSIZE;
		privptr->p_env->packing=PACKING_ASK;
	} else {
		privptr->p_env->packing=0;
		privptr->p_env->read_size=CLAW_FRAME_SIZE;
		privptr->p_env->write_size=CLAW_FRAME_SIZE;
	}
        claw_set_busy(dev);
	tasklet_init(&privptr->channel[READ].tasklet, claw_irq_tasklet,
        	(unsigned long) &privptr->channel[READ]);
        for ( i = 0; i < 2;  i++) {
		CLAW_DBF_TEXT_(2,trace,"opn_ch%d",i);
                init_waitqueue_head(&privptr->channel[i].wait);
		/* skb_queue_head_init(&p_ch->io_queue); */
		if (i == WRITE)
			skb_queue_head_init(
				&privptr->channel[WRITE].collect_queue);
                privptr->channel[i].flag_a = 0;
                privptr->channel[i].IO_active = 0;
                privptr->channel[i].flag  &= ~CLAW_TIMER;
                init_timer(&timer);
                timer.function = (void *)claw_timer;
                timer.data = (unsigned long)(&privptr->channel[i]);
                timer.expires = jiffies + 15*HZ;
                add_timer(&timer);
                spin_lock_irqsave(get_ccwdev_lock(
			privptr->channel[i].cdev), saveflags);
                parm = (unsigned long) &privptr->channel[i];
                privptr->channel[i].claw_state = CLAW_START_HALT_IO;
		rc = 0;
		add_wait_queue(&privptr->channel[i].wait, &wait);
                rc = ccw_device_halt(
			(struct ccw_device *)privptr->channel[i].cdev,parm);
                set_current_state(TASK_INTERRUPTIBLE);
                spin_unlock_irqrestore(
			get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
                schedule();
		set_current_state(TASK_RUNNING);
                remove_wait_queue(&privptr->channel[i].wait, &wait);
                if(rc != 0)
                        ccw_check_return_code(privptr->channel[i].cdev, rc);
                if((privptr->channel[i].flag & CLAW_TIMER) == 0x00)
                        del_timer(&timer);
        }
        if ((((privptr->channel[READ].last_dstat |
		privptr->channel[WRITE].last_dstat) &
           ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) ||
           (((privptr->channel[READ].flag |
	   	privptr->channel[WRITE].flag) & CLAW_TIMER) != 0x00)) {
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: channel problems during open - read:"
			" %02x -  write: %02x\n",
                        dev->name,
			privptr->channel[READ].last_dstat,
			privptr->channel[WRITE].last_dstat);
#endif
                printk(KERN_INFO "%s: remote side is not ready\n", dev->name);
		CLAW_DBF_TEXT(2,trace,"notrdy");

                for ( i = 0; i < 2;  i++) {
                        spin_lock_irqsave(
				get_ccwdev_lock(privptr->channel[i].cdev),
				saveflags);
                        parm = (unsigned long) &privptr->channel[i];
                        privptr->channel[i].claw_state = CLAW_STOP;
                        rc = ccw_device_halt(
				(struct ccw_device *)&privptr->channel[i].cdev,
				parm);
                        spin_unlock_irqrestore(
				get_ccwdev_lock(privptr->channel[i].cdev),
				saveflags);
                        if (rc != 0) {
                                ccw_check_return_code(
					privptr->channel[i].cdev, rc);
                        }
                }
                free_pages((unsigned long)privptr->p_buff_ccw,
			(int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
                if (privptr->p_env->read_size < PAGE_SIZE) {
                        free_pages((unsigned long)privptr->p_buff_read,
			       (int)pages_to_order_of_mag(
			       		privptr->p_buff_read_num));
                }
                else {
                        p_buf=privptr->p_read_active_first;
                        while (p_buf!=NULL) {
                                free_pages((unsigned long)p_buf->p_buffer,
				      (int)pages_to_order_of_mag(
				      	privptr->p_buff_pages_perread ));
                                p_buf=p_buf->next;
                        }
                }
                if (privptr->p_env->write_size < PAGE_SIZE ) {
                        free_pages((unsigned long)privptr->p_buff_write,
			     (int)pages_to_order_of_mag(
			     	privptr->p_buff_write_num));
                }
                else {
                        p_buf=privptr->p_write_active_first;
                        while (p_buf!=NULL) {
                                free_pages((unsigned long)p_buf->p_buffer,
				     (int)pages_to_order_of_mag(
				     	privptr->p_buff_pages_perwrite ));
                                p_buf=p_buf->next;
                        }
                }
		privptr->buffs_alloc = 0;
		privptr->channel[READ].flag= 0x00;
		privptr->channel[WRITE].flag = 0x00;
                privptr->p_buff_ccw=NULL;
                privptr->p_buff_read=NULL;
                privptr->p_buff_write=NULL;
                claw_clear_busy(dev);
#ifdef FUNCTRACE
                printk(KERN_INFO "%s:%s Exit on line %d, rc=EIO\n",
		dev->name,__func__,__LINE__);
#endif
		CLAW_DBF_TEXT(2,trace,"open EIO");
                return -EIO;
        }

        /*   Send SystemValidate command */

        claw_clear_busy(dev);

#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d, rc=0\n",
		dev->name,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"openok");
        return 0;
}    /*     end of claw_open    */

/*-------------------------------------------------------------------*
*                                                                    *
*       claw_irq_handler                                             *
*                                                                    *
*--------------------------------------------------------------------*/
static void
claw_irq_handler(struct ccw_device *cdev,
	unsigned long intparm, struct irb *irb)
{
        struct chbk *p_ch = NULL;
        struct claw_privbk *privptr = NULL;
        struct net_device *dev = NULL;
        struct claw_env  *p_env;
        struct chbk *p_ch_r=NULL;


#ifdef FUNCTRACE
	printk(KERN_INFO "%s enter  \n",__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"clawirq");
        /* Bypass all 'unsolicited interrupts' */
	if (!cdev->dev.driver_data) {
                printk(KERN_WARNING "claw: unsolicited interrupt for device:"
		 	"%s received c-%02x d-%02x\n",
                        cdev->dev.bus_id,irb->scsw.cstat, irb->scsw.dstat);
#ifdef FUNCTRACE
                printk(KERN_INFO "claw: %s() "
			"exit on line %d\n",__func__,__LINE__);
#endif
		CLAW_DBF_TEXT(2,trace,"badirq");
                return;
        }
	privptr = (struct claw_privbk *)cdev->dev.driver_data;

	/* Try to extract channel from driver data. */
	if (privptr->channel[READ].cdev == cdev)
		p_ch = &privptr->channel[READ];
	else if (privptr->channel[WRITE].cdev == cdev)
		p_ch = &privptr->channel[WRITE];
	else {
		printk(KERN_WARNING "claw: Can't determine channel for "
			"interrupt, device %s\n", cdev->dev.bus_id);
		CLAW_DBF_TEXT(2,trace,"badchan");
		return;
	}
	CLAW_DBF_TEXT_(4,trace,"IRQCH=%d",p_ch->flag);

	dev = (struct net_device *) (p_ch->ndev);
        p_env=privptr->p_env;

#ifdef IOTRACE
        printk(KERN_INFO "%s: interrupt for device: %04x "
		"received c-%02x d-%02x state-%02x\n",
                dev->name, p_ch->devno, irb->scsw.cstat,
		irb->scsw.dstat, p_ch->claw_state);
#endif

	/* Copy interruption response block. */
	memcpy(p_ch->irb, irb, sizeof(struct irb));

        /* Check for good subchannel return code, otherwise error message */
        if (irb->scsw.cstat  &&  !(irb->scsw.cstat & SCHN_STAT_PCI)) {
                printk(KERN_INFO "%s: subchannel check for device: %04x -"
			" Sch Stat %02x  Dev Stat %02x CPA - %04x\n",
                        dev->name, p_ch->devno,
			irb->scsw.cstat, irb->scsw.dstat,irb->scsw.cpa);
#ifdef IOTRACE
		dumpit((char *)irb,sizeof(struct irb));
		dumpit((char *)(unsigned long)irb->scsw.cpa,
			sizeof(struct ccw1));
#endif
#ifdef FUNCTRACE
		printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
		CLAW_DBF_TEXT(2,trace,"chanchk");
                /* return; */
        }

        /* Check the reason-code of a unit check */
        if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
                ccw_check_unit_check(p_ch, irb->ecw[0]);
        }

        /* State machine to bring the connection up, down and to restart */
        p_ch->last_dstat = irb->scsw.dstat;

        switch (p_ch->claw_state) {
                case CLAW_STOP:/* HALT_IO by claw_release (halt sequence) */
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: CLAW_STOP enter\n", dev->name);
#endif
                        if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
	    		(p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
	    		(p_ch->irb->scsw.stctl ==
	     		(SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
#ifdef FUNCTRACE
                                printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
                                return;
                        }
                        wake_up(&p_ch->wait);   /* wake up claw_release */

#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: CLAW_STOP exit\n", dev->name);
#endif
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s:%s Exit on line %d\n",
				dev->name,__func__,__LINE__);
#endif
			CLAW_DBF_TEXT(4,trace,"stop");
                        return;

                case CLAW_START_HALT_IO: /* HALT_IO issued by claw_open  */
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO\n",
				dev->name);
#endif
                        if (!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
	    		(p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
	    		(p_ch->irb->scsw.stctl ==
	     		(SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
				CLAW_DBF_TEXT(4,trace,"haltio");
                                return;
                        }
                        if (p_ch->flag == CLAW_READ) {
                                p_ch->claw_state = CLAW_START_READ;
                                wake_up(&p_ch->wait); /* wake claw_open (READ)*/
                        }
			else
			   if (p_ch->flag == CLAW_WRITE) {
                                p_ch->claw_state = CLAW_START_WRITE;
                                /*      send SYSTEM_VALIDATE                    */
                                claw_strt_read(dev, LOCK_NO);
                               	claw_send_control(dev,
					SYSTEM_VALIDATE_REQUEST,
					0, 0, 0,
					p_env->host_name,
					p_env->adapter_name );
                        } else {
				printk(KERN_WARNING "claw: unsolicited "
					"interrupt for device:"
				 	"%s received c-%02x d-%02x\n",
                		        cdev->dev.bus_id,
					irb->scsw.cstat,
					irb->scsw.dstat);
				return;
				}
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: process CLAW_STAT_HALT_IO exit\n",
				dev->name);
#endif
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s:%s Exit on line %d\n",
				dev->name,__func__,__LINE__);
#endif
			CLAW_DBF_TEXT(4,trace,"haltio");
                        return;
                case CLAW_START_READ:
			CLAW_DBF_TEXT(4,trace,"ReadIRQ");
                        if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
                                clear_bit(0, (void *)&p_ch->IO_active);
                                if ((p_ch->irb->ecw[0] & 0x41) == 0x41 ||
                                    (p_ch->irb->ecw[0] & 0x40) == 0x40 ||
                                    (p_ch->irb->ecw[0])        == 0)
                                {
                                        privptr->stats.rx_errors++;
                                        printk(KERN_INFO "%s: Restart is "
						"required after remote "
						"side recovers \n",
						dev->name);
                                }
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
					CLAW_DBF_TEXT(4,trace,"notrdy");
                                        return;
                        }
                        if ((p_ch->irb->scsw.cstat & SCHN_STAT_PCI) &&
			    (p_ch->irb->scsw.dstat==0)) {
                                if (test_and_set_bit(CLAW_BH_ACTIVE,
					(void *)&p_ch->flag_a) == 0) {
					tasklet_schedule(&p_ch->tasklet);
                                }
				else {
					CLAW_DBF_TEXT(4,trace,"PCINoBH");
				}
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
				CLAW_DBF_TEXT(4,trace,"PCI_read");
                                return;
                        }
                        if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
	    		 (p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
	    		 (p_ch->irb->scsw.stctl ==
	     		 (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
				CLAW_DBF_TEXT(4,trace,"SPend_rd");
                                return;
                        }
                        clear_bit(0, (void *)&p_ch->IO_active);
                        claw_clearbit_busy(TB_RETRY,dev);
                        if (test_and_set_bit(CLAW_BH_ACTIVE,
    				(void *)&p_ch->flag_a) == 0) {
    				tasklet_schedule(&p_ch->tasklet);
                         }
    			else {
    				CLAW_DBF_TEXT(4,trace,"RdBHAct");
    			}

#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: process CLAW_START_READ exit\n",
				dev->name);
#endif
#ifdef FUNCTRACE
			printk(KERN_INFO "%s:%s Exit on line %d\n",
				dev->name,__func__,__LINE__);
#endif
			CLAW_DBF_TEXT(4,trace,"RdIRQXit");
                        return;
                case CLAW_START_WRITE:
                        if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
                                printk(KERN_INFO "%s: Unit Check Occured in "
					"write channel\n",dev->name);
                                clear_bit(0, (void *)&p_ch->IO_active);
                                if (p_ch->irb->ecw[0] & 0x80 ) {
                                        printk(KERN_INFO "%s: Resetting Event "
						"occurred:\n",dev->name);
                                        init_timer(&p_ch->timer);
                                        p_ch->timer.function =
						(void *)claw_write_retry;
                                        p_ch->timer.data = (unsigned long)p_ch;
                                        p_ch->timer.expires = jiffies + 10*HZ;
                                        add_timer(&p_ch->timer);
                                        printk(KERN_INFO "%s: write connection "
						"restarting\n",dev->name);
                                }
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
				CLAW_DBF_TEXT(4,trace,"rstrtwrt");
                                return;
                        }
                        if (p_ch->irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) {
                                        clear_bit(0, (void *)&p_ch->IO_active);
                                        printk(KERN_INFO "%s: Unit Exception "
						"Occured in write channel\n",
						dev->name);
                        }
                        if(!((p_ch->irb->scsw.stctl & SCSW_STCTL_SEC_STATUS) ||
	    		(p_ch->irb->scsw.stctl == SCSW_STCTL_STATUS_PEND) ||
	    		(p_ch->irb->scsw.stctl ==
	     		(SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)))) {
#ifdef FUNCTRACE
				printk(KERN_INFO "%s:%s Exit on line %d\n",
					dev->name,__func__,__LINE__);
#endif
				CLAW_DBF_TEXT(4,trace,"writeUE");
                                return;
                        }
                        clear_bit(0, (void *)&p_ch->IO_active);
                        if (claw_test_and_setbit_busy(TB_TX,dev)==0) {
                                claw_write_next(p_ch);
                                claw_clearbit_busy(TB_TX,dev);
                                claw_clear_busy(dev);
                        }
                        p_ch_r=(struct chbk *)&privptr->channel[READ];
                        if (test_and_set_bit(CLAW_BH_ACTIVE,
 					(void *)&p_ch_r->flag_a) == 0) {
			 	tasklet_schedule(&p_ch_r->tasklet);
                        }

#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: process CLAW_START_WRITE exit\n",
				 dev->name);
#endif
#ifdef FUNCTRACE
			printk(KERN_INFO "%s:%s Exit on line %d\n",
				dev->name,__func__,__LINE__);
#endif
			CLAW_DBF_TEXT(4,trace,"StWtExit");
                        return;
                default:
                        printk(KERN_WARNING "%s: wrong selection code - irq "
				"state=%d\n",dev->name,p_ch->claw_state);
#ifdef FUNCTRACE
			printk(KERN_INFO "%s:%s Exit on line %d\n",
				dev->name,__func__,__LINE__);
#endif
			CLAW_DBF_TEXT(2,trace,"badIRQ");
                        return;
        }

}       /*   end of claw_irq_handler    */


/*-------------------------------------------------------------------*
*       claw_irq_tasklet                                             *
*                                                                    *
*--------------------------------------------------------------------*/
static void
claw_irq_tasklet ( unsigned long data )
{
	struct chbk * p_ch;
        struct net_device  *dev;
        struct claw_privbk *       privptr;

	p_ch = (struct chbk *) data;
        dev = (struct net_device *)p_ch->ndev;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable p_ch =\n",dev->name);
        dumpit((char *) p_ch, sizeof(struct chbk));
#endif
	CLAW_DBF_TEXT(4,trace,"IRQtask");

        privptr = (struct claw_privbk *) dev->priv;

#ifdef DEBUGMSG
        printk(KERN_INFO "%s: bh routine - state-%02x\n" ,
		dev->name, p_ch->claw_state);
#endif

        unpack_read(dev);
        clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a);
	CLAW_DBF_TEXT(4,trace,"TskletXt");
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
        return;
}       /*    end of claw_irq_bh    */

/*-------------------------------------------------------------------*
*       claw_release                                                 *
*                                                                    *
*--------------------------------------------------------------------*/
static int
claw_release(struct net_device *dev)
{
        int                rc;
        int                i;
        unsigned long      saveflags;
        unsigned long      parm;
        struct claw_privbk *privptr;
        DECLARE_WAITQUEUE(wait, current);
        struct ccwbk*             p_this_ccw;
        struct ccwbk*             p_buf;

	if (!dev)
                return 0;
        privptr = (struct claw_privbk *) dev->priv;
        if (!privptr)
                return 0;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"release");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
	printk(KERN_INFO "Priv Buffalloc %d\n",privptr->buffs_alloc);
	printk(KERN_INFO "Priv p_buff_ccw = %p\n",&privptr->p_buff_ccw);
#endif
        privptr->release_pend=1;
        claw_setbit_busy(TB_STOP,dev);
        for ( i = 1; i >=0 ;  i--) {
                spin_lock_irqsave(
			get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
             /*   del_timer(&privptr->channel[READ].timer);  */
 		privptr->channel[i].claw_state = CLAW_STOP;
                privptr->channel[i].IO_active = 0;
                parm = (unsigned long) &privptr->channel[i];
		if (i == WRITE)
			claw_purge_skb_queue(
				&privptr->channel[WRITE].collect_queue);
                rc = ccw_device_halt (privptr->channel[i].cdev, parm);
	        if (privptr->system_validate_comp==0x00)  /* never opened? */
                   init_waitqueue_head(&privptr->channel[i].wait);
                add_wait_queue(&privptr->channel[i].wait, &wait);
                set_current_state(TASK_INTERRUPTIBLE);
	        spin_unlock_irqrestore(
			get_ccwdev_lock(privptr->channel[i].cdev), saveflags);
	        schedule();
		set_current_state(TASK_RUNNING);
	        remove_wait_queue(&privptr->channel[i].wait, &wait);
	        if (rc != 0) {
                        ccw_check_return_code(privptr->channel[i].cdev, rc);
                }
        }
	if (privptr->pk_skb != NULL) {
		dev_kfree_skb_any(privptr->pk_skb);
		privptr->pk_skb = NULL;
	}
	if(privptr->buffs_alloc != 1) {
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
		CLAW_DBF_TEXT(4,trace,"none2fre");
		return 0;
	}
	CLAW_DBF_TEXT(4,trace,"freebufs");
	if (privptr->p_buff_ccw != NULL) {
        	free_pages((unsigned long)privptr->p_buff_ccw,
	        	(int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
	}
	CLAW_DBF_TEXT(4,trace,"freeread");
        if (privptr->p_env->read_size < PAGE_SIZE) {
	    if (privptr->p_buff_read != NULL) {
                free_pages((unsigned long)privptr->p_buff_read,
		      (int)pages_to_order_of_mag(privptr->p_buff_read_num));
		}
        }
        else {
                p_buf=privptr->p_read_active_first;
                while (p_buf!=NULL) {
                        free_pages((unsigned long)p_buf->p_buffer,
			     (int)pages_to_order_of_mag(
			     	privptr->p_buff_pages_perread ));
                        p_buf=p_buf->next;
                }
        }
	 CLAW_DBF_TEXT(4,trace,"freewrit");
        if (privptr->p_env->write_size < PAGE_SIZE ) {
                free_pages((unsigned long)privptr->p_buff_write,
		      (int)pages_to_order_of_mag(privptr->p_buff_write_num));
        }
        else {
                p_buf=privptr->p_write_active_first;
                while (p_buf!=NULL) {
                        free_pages((unsigned long)p_buf->p_buffer,
			      (int)pages_to_order_of_mag(
			      privptr->p_buff_pages_perwrite ));
                        p_buf=p_buf->next;
                }
        }
	 CLAW_DBF_TEXT(4,trace,"clearptr");
	privptr->buffs_alloc = 0;
        privptr->p_buff_ccw=NULL;
        privptr->p_buff_read=NULL;
        privptr->p_buff_write=NULL;
        privptr->system_validate_comp=0;
        privptr->release_pend=0;
        /*      Remove any writes that were pending and reset all reads   */
        p_this_ccw=privptr->p_read_active_first;
        while (p_this_ccw!=NULL) {
                p_this_ccw->header.length=0xffff;
                p_this_ccw->header.opcode=0xff;
                p_this_ccw->header.flag=0x00;
                p_this_ccw=p_this_ccw->next;
        }

        while (privptr->p_write_active_first!=NULL) {
                p_this_ccw=privptr->p_write_active_first;
                p_this_ccw->header.flag=CLAW_PENDING;
                privptr->p_write_active_first=p_this_ccw->next;
                p_this_ccw->next=privptr->p_write_free_chain;
                privptr->p_write_free_chain=p_this_ccw;
                ++privptr->write_free_count;
        }
        privptr->p_write_active_last=NULL;
        privptr->mtc_logical_link = -1;
        privptr->mtc_skipping = 1;
        privptr->mtc_offset=0;

        if (((privptr->channel[READ].last_dstat |
		privptr->channel[WRITE].last_dstat) &
		~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) {
                printk(KERN_WARNING "%s: channel problems during close - "
			"read: %02x -  write: %02x\n",
                dev->name,
		privptr->channel[READ].last_dstat,
		privptr->channel[WRITE].last_dstat);
		 CLAW_DBF_TEXT(2,trace,"badclose");
        }
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"rlsexit");
        return 0;
}      /* end of claw_release     */



/*-------------------------------------------------------------------*
*       claw_write_retry                                             *
*                                                                    *
*--------------------------------------------------------------------*/

static void
claw_write_retry ( struct chbk *p_ch )
{

        struct net_device  *dev=p_ch->ndev;


#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
        printk(KERN_INFO "claw: variable p_ch =\n");
        dumpit((char *) p_ch, sizeof(struct chbk));
#endif
	CLAW_DBF_TEXT(4,trace,"w_retry");
        if (p_ch->claw_state == CLAW_STOP) {
#ifdef FUNCTRACE
		printk(KERN_INFO "%s:%s Exit on line %d\n",
			dev->name,__func__,__LINE__);
#endif
        	return;
        }
#ifdef DEBUGMSG
        printk( KERN_INFO "%s:%s  state-%02x\n" ,
		dev->name,
		__func__,
		p_ch->claw_state);
#endif
	claw_strt_out_IO( dev );
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"rtry_xit");
        return;
}      /* end of claw_write_retry      */


/*-------------------------------------------------------------------*
*       claw_write_next                                              *
*                                                                    *
*--------------------------------------------------------------------*/

static void
claw_write_next ( struct chbk * p_ch )
{

        struct net_device  *dev;
        struct claw_privbk *privptr=NULL;
	struct sk_buff *pk_skb;
	int	rc;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",p_ch->ndev->name,__func__);
        printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
        dumpit((char *) p_ch, sizeof(struct chbk));
#endif
	CLAW_DBF_TEXT(4,trace,"claw_wrt");
        if (p_ch->claw_state == CLAW_STOP)
                return;
        dev = (struct net_device *) p_ch->ndev;
	privptr = (struct claw_privbk *) dev->priv;
        claw_free_wrt_buf( dev );
	if ((privptr->write_free_count > 0) &&
	    !skb_queue_empty(&p_ch->collect_queue)) {
	  	pk_skb = claw_pack_skb(privptr);
		while (pk_skb != NULL) {
			rc = claw_hw_tx( pk_skb, dev,1);
			if (privptr->write_free_count > 0) {
	   			pk_skb = claw_pack_skb(privptr);
			} else
				pk_skb = NULL;
		}
	}
        if (privptr->p_write_active_first!=NULL) {
                claw_strt_out_IO(dev);
        }

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
        return;
}      /* end of claw_write_next      */

/*-------------------------------------------------------------------*
*                                                                    *
*       claw_timer                                                   *
*--------------------------------------------------------------------*/

static void
claw_timer ( struct chbk * p_ch )
{
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Entry\n",p_ch->ndev->name,__func__);
        printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);
        dumpit((char *) p_ch, sizeof(struct chbk));
#endif
	CLAW_DBF_TEXT(4,trace,"timer");
        p_ch->flag |= CLAW_TIMER;
        wake_up(&p_ch->wait);
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		p_ch->ndev->name,__func__,__LINE__);
#endif
        return;
}      /* end of claw_timer  */


/*
*
*       functions
*/


/*-------------------------------------------------------------------*
*                                                                    *
*     pages_to_order_of_mag                                          *
*                                                                    *
*    takes a number of pages from 1 to 512 and returns the           *
*    log(num_pages)/log(2) get_free_pages() needs a base 2 order     *
*    of magnitude get_free_pages() has an upper order of 9           *
*--------------------------------------------------------------------*/

static int
pages_to_order_of_mag(int num_of_pages)
{
	int	order_of_mag=1;		/* assume 2 pages */
	int	nump=2;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s Enter pages = %d \n",__func__,num_of_pages);
#endif
	CLAW_DBF_TEXT_(5,trace,"pages%d",num_of_pages);
	if (num_of_pages == 1)   {return 0; }  /* magnitude of 0 = 1 page */
	/* 512 pages = 2Meg on 4k page systems */
	if (num_of_pages >= 512) {return 9; }
	/* we have two or more pages order is at least 1 */
	for (nump=2 ;nump <= 512;nump*=2) {
	  if (num_of_pages <= nump)
		  break;
	  order_of_mag +=1;
	}
	if (order_of_mag > 9) { order_of_mag = 9; }  /* I know it's paranoid */
#ifdef FUNCTRACE
        printk(KERN_INFO "%s Exit on line %d, order = %d\n",
	__func__,__LINE__, order_of_mag);
#endif
	CLAW_DBF_TEXT_(5,trace,"mag%d",order_of_mag);
	return order_of_mag;
}

/*-------------------------------------------------------------------*
*                                                                    *
*     add_claw_reads                                                 *
*                                                                    *
*--------------------------------------------------------------------*/
static int
add_claw_reads(struct net_device *dev, struct ccwbk* p_first,
	struct ccwbk* p_last)
{
        struct claw_privbk *privptr;
        struct ccw1  temp_ccw;
        struct endccw * p_end;
#ifdef IOTRACE
        struct ccwbk*  p_buf;
#endif
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
#ifdef DEBUGMSG
        printk(KERN_INFO "dev\n");
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "p_first\n");
        dumpit((char *) p_first, sizeof(struct ccwbk));
        printk(KERN_INFO "p_last\n");
        dumpit((char *) p_last, sizeof(struct ccwbk));
#endif
	CLAW_DBF_TEXT(4,trace,"addreads");
        privptr = dev->priv;
        p_end = privptr->p_end_ccw;

        /* first CCW and last CCW contains a new set of read channel programs
        *       to apend the running channel programs
        */
        if ( p_first==NULL) {
#ifdef FUNCTRACE
		printk(KERN_INFO "%s:%s Exit on line %d\n",
			dev->name,__func__,__LINE__);
#endif
		CLAW_DBF_TEXT(4,trace,"addexit");
                return 0;
        }

        /* set up ending CCW sequence for this segment */
        if (p_end->read1) {
                p_end->read1=0x00;    /*  second ending CCW is now active */
                /*      reset ending CCWs and setup TIC CCWs              */
                p_end->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
                p_end->read2_nop2.flags  = CCW_FLAG_SLI | CCW_FLAG_SKIP;
                p_last->r_TIC_1.cda =(__u32)__pa(&p_end->read2_nop1);
                p_last->r_TIC_2.cda =(__u32)__pa(&p_end->read2_nop1);
                p_end->read2_nop2.cda=0;
                p_end->read2_nop2.count=1;
        }
        else {
                p_end->read1=0x01;  /* first ending CCW is now active */
                /*      reset ending CCWs and setup TIC CCWs          */
                p_end->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
                p_end->read1_nop2.flags  = CCW_FLAG_SLI | CCW_FLAG_SKIP;
                p_last->r_TIC_1.cda = (__u32)__pa(&p_end->read1_nop1);
                p_last->r_TIC_2.cda = (__u32)__pa(&p_end->read1_nop1);
                p_end->read1_nop2.cda=0;
                p_end->read1_nop2.count=1;
        }

        if ( privptr-> p_read_active_first ==NULL ) {
#ifdef DEBUGMSG
                printk(KERN_INFO "%s:%s p_read_active_first == NULL \n",
			dev->name,__func__);
                printk(KERN_INFO "%s:%s Read active first/last changed \n",
			dev->name,__func__);
#endif
                privptr-> p_read_active_first= p_first;  /*    set new first */
                privptr-> p_read_active_last = p_last;   /*    set new last  */
        }
        else {

#ifdef DEBUGMSG
                printk(KERN_INFO "%s:%s Read in progress \n",
		dev->name,__func__);
#endif
                /* set up TIC ccw  */
                temp_ccw.cda= (__u32)__pa(&p_first->read);
                temp_ccw.count=0;
                temp_ccw.flags=0;
                temp_ccw.cmd_code = CCW_CLAW_CMD_TIC;


                if (p_end->read1) {

               /* first set of CCW's is chained to the new read              */
               /* chain, so the second set is chained to the active chain.   */
               /* Therefore modify the second set to point to the new        */
               /* read chain set up TIC CCWs                                 */
               /* make sure we update the CCW so channel doesn't fetch it    */
               /* when it's only half done                                   */
                        memcpy( &p_end->read2_nop2, &temp_ccw ,
				sizeof(struct ccw1));
                        privptr->p_read_active_last->r_TIC_1.cda=
				(__u32)__pa(&p_first->read);
                        privptr->p_read_active_last->r_TIC_2.cda=
				(__u32)__pa(&p_first->read);
                }
                else {
                        /* make sure we update the CCW so channel doesn't   */
			/* fetch it when it is only half done               */
                        memcpy( &p_end->read1_nop2, &temp_ccw ,
				sizeof(struct ccw1));
                        privptr->p_read_active_last->r_TIC_1.cda=
				(__u32)__pa(&p_first->read);
                        privptr->p_read_active_last->r_TIC_2.cda=
				(__u32)__pa(&p_first->read);
                }
                /*      chain in new set of blocks                              */
                privptr->p_read_active_last->next = p_first;
                privptr->p_read_active_last=p_last;
        } /* end of if ( privptr-> p_read_active_first ==NULL)  */
#ifdef IOTRACE
	printk(KERN_INFO "%s:%s  dump p_last CCW BK \n",dev->name,__func__);
        dumpit((char *)p_last, sizeof(struct ccwbk));
	printk(KERN_INFO "%s:%s  dump p_end CCW BK \n",dev->name,__func__);
        dumpit((char *)p_end, sizeof(struct endccw));

	printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__func__);
        dumpit((char *)p_first, sizeof(struct ccwbk));
        printk(KERN_INFO "%s:%s Dump Active CCW chain \n",
		dev->name,__func__);
        p_buf=privptr->p_read_active_first;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
#endif
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"addexit");
        return 0;
}    /*     end of add_claw_reads   */

/*-------------------------------------------------------------------*
 *   ccw_check_return_code                                           *
 *                                                                   *
 *-------------------------------------------------------------------*/

static void
ccw_check_return_code(struct ccw_device *cdev, int return_code)
{
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() > enter  \n",
		cdev->dev.bus_id,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"ccwret");
#ifdef DEBUGMSG
        printk(KERN_INFO "variable cdev =\n");
        dumpit((char *) cdev, sizeof(struct ccw_device));
        printk(KERN_INFO "variable return_code = %d\n",return_code);
#endif
        if (return_code != 0) {
                switch (return_code) {
                        case -EBUSY:
                                printk(KERN_INFO "%s: Busy !\n",
					cdev->dev.bus_id);
                                break;
                        case -ENODEV:
                                printk(KERN_EMERG "%s: Missing device called "
					"for IO ENODEV\n", cdev->dev.bus_id);
                                break;
                        case -EIO:
                                printk(KERN_EMERG "%s: Status pending... EIO \n",
					cdev->dev.bus_id);
                                break;
			case -EINVAL:
                                printk(KERN_EMERG "%s: Invalid Dev State EINVAL \n",
					cdev->dev.bus_id);
                                break;
                        default:
                                printk(KERN_EMERG "%s: Unknown error in "
				 "Do_IO %d\n",cdev->dev.bus_id, return_code);
                }
        }
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() > exit on line %d\n",
		cdev->dev.bus_id,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"ccwret");
}    /*    end of ccw_check_return_code   */

/*-------------------------------------------------------------------*
*       ccw_check_unit_check                                         *
*--------------------------------------------------------------------*/

static void
ccw_check_unit_check(struct chbk * p_ch, unsigned char sense )
{
	struct net_device *dev = p_ch->ndev;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s: %s() > enter\n",dev->name,__func__);
#endif
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *)dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable sense =\n",dev->name);
        dumpit((char *)&sense, 2);
#endif
	CLAW_DBF_TEXT(4,trace,"unitchek");

        printk(KERN_INFO "%s: Unit Check with sense byte:0x%04x\n",
                dev->name, sense);

        if (sense & 0x40) {
                if (sense & 0x01) {
                        printk(KERN_WARNING "%s: Interface disconnect or "
				"Selective reset "
			       	"occurred (remote side)\n", dev->name);
                }
                else {
                        printk(KERN_WARNING "%s: System reset occured"
				" (remote side)\n", dev->name);
                }
        }
        else if (sense & 0x20) {
                if (sense & 0x04) {
                        printk(KERN_WARNING "%s: Data-streaming "
				"timeout)\n", dev->name);
                }
                else  {
                        printk(KERN_WARNING "%s: Data-transfer parity"
				" error\n", dev->name);
                }
        }
        else if (sense & 0x10) {
                if (sense & 0x20) {
                        printk(KERN_WARNING "%s: Hardware malfunction "
				"(remote side)\n", dev->name);
                }
                else {
                        printk(KERN_WARNING "%s: read-data parity error "
				"(remote side)\n", dev->name);
                }
        }

#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
}   /*    end of ccw_check_unit_check    */



/*-------------------------------------------------------------------*
* Dump buffer format                                                 *
*                                                                    *
*--------------------------------------------------------------------*/
#ifdef DEBUG
static void
dumpit(char* buf, int len)
{

        __u32      ct, sw, rm, dup;
        char       *ptr, *rptr;
        char       tbuf[82], tdup[82];
#if (CONFIG_64BIT)
        char       addr[22];
#else
        char       addr[12];
#endif
        char       boff[12];
        char       bhex[82], duphex[82];
        char       basc[40];

        sw  = 0;
        rptr =ptr=buf;
        rm  = 16;
        duphex[0]  = 0x00;
        dup = 0;
        for ( ct=0; ct < len; ct++, ptr++, rptr++ )  {
                if (sw == 0) {
#if (CONFIG_64BIT)
                        sprintf(addr, "%16.16lX",(unsigned long)rptr);
#else
                        sprintf(addr, "%8.8X",(__u32)rptr);
#endif
                        sprintf(boff, "%4.4X", (__u32)ct);
                        bhex[0] = '\0';
                        basc[0] = '\0';
                }
                if ((sw == 4) || (sw == 12)) {
                        strcat(bhex, " ");
                }
                if (sw == 8) {
                        strcat(bhex, "  ");
                }
#if (CONFIG_64BIT)
                sprintf(tbuf,"%2.2lX", (unsigned long)*ptr);
#else
                sprintf(tbuf,"%2.2X", (__u32)*ptr);
#endif
                tbuf[2] = '\0';
                strcat(bhex, tbuf);
                if ((0!=isprint(*ptr)) && (*ptr >= 0x20)) {
                        basc[sw] = *ptr;
                }
                else {
                        basc[sw] = '.';
                }
                basc[sw+1] = '\0';
                sw++;
                rm--;
                if (sw==16) {
                        if ((strcmp(duphex, bhex)) !=0) {
                                if (dup !=0) {
					sprintf(tdup,"Duplicate as above to"
						" %s", addr);
                                        printk( KERN_INFO "                 "
						"   --- %s ---\n",tdup);
                                }
                                printk( KERN_INFO "   %s (+%s) : %s  [%s]\n",
					 addr, boff, bhex, basc);
                                dup = 0;
                                strcpy(duphex, bhex);
                        }
                        else {
                                dup++;
                        }
                        sw = 0;
                        rm = 16;
                }
        }  /* endfor */

        if (sw != 0) {
                for ( ; rm > 0; rm--, sw++ ) {
                        if ((sw==4) || (sw==12)) strcat(bhex, " ");
                        if (sw==8)               strcat(bhex, "  ");
                        strcat(bhex, "  ");
                        strcat(basc, " ");
                }
                if (dup !=0) {
                        sprintf(tdup,"Duplicate as above to %s", addr);
                        printk( KERN_INFO "                    --- %s ---\n",
				tdup);
                }
                printk( KERN_INFO "   %s (+%s) : %s  [%s]\n",
			addr, boff, bhex, basc);
        }
        else {
                if (dup >=1) {
                        sprintf(tdup,"Duplicate as above to %s", addr);
                        printk( KERN_INFO "                    --- %s ---\n",
				tdup);
                }
                if (dup !=0) {
                        printk( KERN_INFO "   %s (+%s) : %s  [%s]\n",
				addr, boff, bhex, basc);
                }
        }
        return;

}   /*   end of dumpit  */
#endif

/*-------------------------------------------------------------------*
*               find_link                                            *
*--------------------------------------------------------------------*/
static int
find_link(struct net_device *dev, char *host_name, char *ws_name )
{
	struct claw_privbk *privptr;
	struct claw_env *p_env;
	int    rc=0;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s > enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"findlink");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev = \n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable host_name = %s\n",dev->name, host_name);
        printk(KERN_INFO "%s: variable ws_name = %s\n",dev->name, ws_name);
#endif
        privptr=dev->priv;
        p_env=privptr->p_env;
	switch (p_env->packing)
	{
		case  PACKING_ASK:
			if ((memcmp(WS_APPL_NAME_PACKED, host_name, 8)!=0) ||
			    (memcmp(WS_APPL_NAME_PACKED, ws_name, 8)!=0 ))
        	             rc = EINVAL;
			break;
		case  DO_PACKED:
		case  PACK_SEND:
			if ((memcmp(WS_APPL_NAME_IP_NAME, host_name, 8)!=0) ||
			    (memcmp(WS_APPL_NAME_IP_NAME, ws_name, 8)!=0 ))
        	        	rc = EINVAL;
			break;
		default:
	       		if ((memcmp(HOST_APPL_NAME, host_name, 8)!=0) ||
		    	    (memcmp(p_env->api_type , ws_name, 8)!=0))
        	        	rc = EINVAL;
			break;
	}

#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
        return 0;
}    /*    end of find_link    */

/*-------------------------------------------------------------------*
 *   claw_hw_tx                                                      *
 *                                                                   *
 *                                                                   *
 *-------------------------------------------------------------------*/

static int
claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid)
{
        int                             rc=0;
        struct claw_privbk 		*privptr;
        struct ccwbk           *p_this_ccw;
        struct ccwbk           *p_first_ccw;
        struct ccwbk           *p_last_ccw;
        __u32                           numBuffers;
        signed long                     len_of_data;
        unsigned long                   bytesInThisBuffer;
        unsigned char                   *pDataAddress;
        struct endccw                   *pEnd;
        struct ccw1                     tempCCW;
        struct chbk                     *p_ch;
	struct claw_env			*p_env;
        int                             lock;
	struct clawph			*pk_head;
	struct chbk			*ch;
#ifdef IOTRACE
        struct ccwbk                   *p_buf;
#endif
#ifdef FUNCTRACE
	printk(KERN_INFO "%s: %s() > enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"hw_tx");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev skb =\n",dev->name);
        dumpit((char *) skb, sizeof(struct sk_buff));
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable linkid = %ld\n",dev->name,linkid);
#endif
        privptr = (struct claw_privbk *) (dev->priv);
        p_ch=(struct chbk *)&privptr->channel[WRITE];
	p_env =privptr->p_env;
#ifdef IOTRACE
	printk(KERN_INFO "%s: %s() dump sk_buff  \n",dev->name,__func__);
        dumpit((char *)skb ,sizeof(struct sk_buff));
#endif
	claw_free_wrt_buf(dev);	/* Clean up free chain if posible */
        /*  scan the write queue to free any completed write packets   */
        p_first_ccw=NULL;
        p_last_ccw=NULL;
	if ((p_env->packing >= PACK_SEND) &&
       	    (skb->cb[1] != 'P')) {
		skb_push(skb,sizeof(struct clawph));
		pk_head=(struct clawph *)skb->data;
		pk_head->len=skb->len-sizeof(struct clawph);
		if (pk_head->len%4)  {
			pk_head->len+= 4-(pk_head->len%4);
			skb_pad(skb,4-(pk_head->len%4));
			skb_put(skb,4-(pk_head->len%4));
		}
		if (p_env->packing == DO_PACKED)
			pk_head->link_num = linkid;
		else
			pk_head->link_num = 0;
		pk_head->flag = 0x00;
		skb_pad(skb,4);
		skb->cb[1] = 'P';
	}
        if (linkid == 0) {
        	if (claw_check_busy(dev)) {
                	if (privptr->write_free_count!=0) {
                                claw_clear_busy(dev);
                        }
                        else {
                                claw_strt_out_IO(dev );
                                claw_free_wrt_buf( dev );
                                if (privptr->write_free_count==0) {
#ifdef IOTRACE
                                	printk(KERN_INFO "%s: "
					   "(claw_check_busy) no free write "
					   "buffers\n", dev->name);
#endif
					ch = &privptr->channel[WRITE];
					atomic_inc(&skb->users);
					skb_queue_tail(&ch->collect_queue, skb);
                                	goto Done;
                                }
                                else {
                                	claw_clear_busy(dev);
                                }
                        }
                }
                /*  tx lock  */
                if (claw_test_and_setbit_busy(TB_TX,dev)) { /* set to busy */
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s:  busy  (claw_test_and_setbit_"
				"busy)\n", dev->name);
#endif
			ch = &privptr->channel[WRITE];
			atomic_inc(&skb->users);
			skb_queue_tail(&ch->collect_queue, skb);
                        claw_strt_out_IO(dev );
                        rc=-EBUSY;
                        goto Done2;
                }
        }
        /*      See how many write buffers are required to hold this data */
	numBuffers = DIV_ROUND_UP(skb->len, privptr->p_env->write_size);

        /*      If that number of buffers isn't available, give up for now */
        if (privptr->write_free_count < numBuffers ||
            privptr->p_write_free_chain == NULL ) {

                claw_setbit_busy(TB_NOBUFFER,dev);

#ifdef DEBUGMSG
                printk(KERN_INFO "%s:  busy  (claw_setbit_busy"
			"(TB_NOBUFFER))\n", dev->name);
                printk(KERN_INFO "       free_count: %d, numBuffers : %d\n",
			(int)privptr->write_free_count,(int) numBuffers );
#endif
		ch = &privptr->channel[WRITE];
		atomic_inc(&skb->users);
		skb_queue_tail(&ch->collect_queue, skb);
		CLAW_DBF_TEXT(2,trace,"clawbusy");
                goto Done2;
        }
        pDataAddress=skb->data;
        len_of_data=skb->len;

        while (len_of_data > 0) {
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: %s() length-of-data is %ld \n",
			dev->name ,__func__,len_of_data);
                dumpit((char *)pDataAddress ,64);
#endif
                p_this_ccw=privptr->p_write_free_chain;  /* get a block */
		if (p_this_ccw == NULL) { /* lost the race */
			ch = &privptr->channel[WRITE];
			atomic_inc(&skb->users);
			skb_queue_tail(&ch->collect_queue, skb);
			goto Done2;
		}
                privptr->p_write_free_chain=p_this_ccw->next;
                p_this_ccw->next=NULL;
                --privptr->write_free_count; /* -1 */
                bytesInThisBuffer=len_of_data;
                memcpy( p_this_ccw->p_buffer,pDataAddress, bytesInThisBuffer);
                len_of_data-=bytesInThisBuffer;
                pDataAddress+=(unsigned long)bytesInThisBuffer;
                /*      setup write CCW         */
                p_this_ccw->write.cmd_code = (linkid * 8) +1;
                if (len_of_data>0) {
                        p_this_ccw->write.cmd_code+=MORE_to_COME_FLAG;
                }
                p_this_ccw->write.count=bytesInThisBuffer;
                /*      now add to end of this chain    */
                if (p_first_ccw==NULL)    {
                        p_first_ccw=p_this_ccw;
                }
                if (p_last_ccw!=NULL) {
                        p_last_ccw->next=p_this_ccw;
                        /*      set up TIC ccws         */
                        p_last_ccw->w_TIC_1.cda=
				(__u32)__pa(&p_this_ccw->write);
                }
                p_last_ccw=p_this_ccw;      /* save new last block */
#ifdef IOTRACE
		printk(KERN_INFO "%s: %s() > CCW and Buffer %ld bytes long \n",
			dev->name,__func__,bytesInThisBuffer);
                dumpit((char *)p_this_ccw, sizeof(struct ccwbk));
                dumpit((char *)p_this_ccw->p_buffer, 64);
#endif
        }

        /*      FirstCCW and LastCCW now contain a new set of write channel
        *       programs to append to the running channel program
        */

        if (p_first_ccw!=NULL) {
                /*      setup ending ccw sequence for this segment              */
                pEnd=privptr->p_end_ccw;
                if (pEnd->write1) {
                        pEnd->write1=0x00;   /* second end ccw is now active */
                        /*      set up Tic CCWs         */
                        p_last_ccw->w_TIC_1.cda=
				(__u32)__pa(&pEnd->write2_nop1);
                        pEnd->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
                        pEnd->write2_nop2.flags    =
				CCW_FLAG_SLI | CCW_FLAG_SKIP;
                        pEnd->write2_nop2.cda=0;
                        pEnd->write2_nop2.count=1;
                }
                else {  /*  end of if (pEnd->write1)*/
                        pEnd->write1=0x01;   /* first end ccw is now active */
                        /*      set up Tic CCWs         */
                        p_last_ccw->w_TIC_1.cda=
				(__u32)__pa(&pEnd->write1_nop1);
                        pEnd->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
                        pEnd->write1_nop2.flags    =
				CCW_FLAG_SLI | CCW_FLAG_SKIP;
                        pEnd->write1_nop2.cda=0;
                        pEnd->write1_nop2.count=1;
                }  /* end if if (pEnd->write1) */


                if (privptr->p_write_active_first==NULL ) {
                        privptr->p_write_active_first=p_first_ccw;
                        privptr->p_write_active_last=p_last_ccw;
                }
                else {

                        /*      set up Tic CCWs         */

                        tempCCW.cda=(__u32)__pa(&p_first_ccw->write);
                        tempCCW.count=0;
                        tempCCW.flags=0;
                        tempCCW.cmd_code=CCW_CLAW_CMD_TIC;

                        if (pEnd->write1) {

                 /*
                 * first set of ending CCW's is chained to the new write
                 * chain, so the second set is chained to the active chain
                 * Therefore modify the second set to point the new write chain.
                 * make sure we update the CCW atomically
                 * so channel does not fetch it when it's only half done
                 */
                                memcpy( &pEnd->write2_nop2, &tempCCW ,
					sizeof(struct ccw1));
                                privptr->p_write_active_last->w_TIC_1.cda=
					(__u32)__pa(&p_first_ccw->write);
                        }
                        else {

                        /*make sure we update the CCW atomically
                         *so channel does not fetch it when it's only half done
                         */
                                memcpy(&pEnd->write1_nop2, &tempCCW ,
					sizeof(struct ccw1));
                                privptr->p_write_active_last->w_TIC_1.cda=
				        (__u32)__pa(&p_first_ccw->write);

                        } /* end if if (pEnd->write1) */

                        privptr->p_write_active_last->next=p_first_ccw;
                        privptr->p_write_active_last=p_last_ccw;
                }

        } /* endif (p_first_ccw!=NULL)  */


#ifdef IOTRACE
        printk(KERN_INFO "%s: %s() >  Dump Active CCW chain \n",
		dev->name,__func__);
        p_buf=privptr->p_write_active_first;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
        p_buf=(struct ccwbk*)privptr->p_end_ccw;
        dumpit((char *)p_buf, sizeof(struct endccw));
#endif
        dev_kfree_skb_any(skb);
	if (linkid==0) {
        	lock=LOCK_NO;
        }
        else  {
                lock=LOCK_YES;
        }
        claw_strt_out_IO(dev );
        /*      if write free count is zero , set NOBUFFER       */
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() > free_count is %d\n",
		dev->name,__func__,
		(int) privptr->write_free_count );
#endif
	if (privptr->write_free_count==0) {
		claw_setbit_busy(TB_NOBUFFER,dev);
        }
Done2:
	claw_clearbit_busy(TB_TX,dev);
Done:
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() > exit on line %d, rc = %d \n",
		dev->name,__func__,__LINE__, rc);
#endif
	return(rc);
}    /*    end of claw_hw_tx    */

/*-------------------------------------------------------------------*
*                                                                    *
*     init_ccw_bk                                                    *
*                                                                    *
*--------------------------------------------------------------------*/

static int
init_ccw_bk(struct net_device *dev)
{

        __u32   ccw_blocks_required;
        __u32   ccw_blocks_perpage;
        __u32   ccw_pages_required;
        __u32   claw_reads_perpage=1;
        __u32   claw_read_pages;
        __u32   claw_writes_perpage=1;
        __u32   claw_write_pages;
        void    *p_buff=NULL;
        struct ccwbk*p_free_chain;
	struct ccwbk*p_buf;
	struct ccwbk*p_last_CCWB;
	struct ccwbk*p_first_CCWB;
        struct endccw *p_endccw=NULL;
        addr_t  real_address;
        struct claw_privbk *privptr=dev->priv;
        struct clawh *pClawH=NULL;
        addr_t   real_TIC_address;
        int i,j;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s: %s() enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"init_ccw");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
#endif

        /*  initialize  statistics field */
        privptr->active_link_ID=0;
        /*  initialize  ccwbk pointers  */
        privptr->p_write_free_chain=NULL;   /* pointer to free ccw chain*/
        privptr->p_write_active_first=NULL; /* pointer to the first write ccw*/
        privptr->p_write_active_last=NULL;  /* pointer to the last write ccw*/
        privptr->p_read_active_first=NULL;  /* pointer to the first read ccw*/
        privptr->p_read_active_last=NULL;   /* pointer to the last read ccw */
        privptr->p_end_ccw=NULL;            /* pointer to ending ccw        */
        privptr->p_claw_signal_blk=NULL;    /* pointer to signal block      */
	privptr->buffs_alloc = 0;
        memset(&privptr->end_ccw, 0x00, sizeof(struct endccw));
        memset(&privptr->ctl_bk, 0x00, sizeof(struct clawctl));
        /*  initialize  free write ccwbk counter  */
        privptr->write_free_count=0;  /* number of free bufs on write chain */
        p_last_CCWB = NULL;
        p_first_CCWB= NULL;
        /*
        *  We need 1 CCW block for each read buffer, 1 for each
        *  write buffer, plus 1 for ClawSignalBlock
        */
        ccw_blocks_required =
		privptr->p_env->read_buffers+privptr->p_env->write_buffers+1;
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() "
		"ccw_blocks_required=%d\n",
		dev->name,__func__,
		ccw_blocks_required);
        printk(KERN_INFO "%s: %s() "
		"PAGE_SIZE=0x%x\n",
		dev->name,__func__,
		(unsigned int)PAGE_SIZE);
        printk(KERN_INFO "%s: %s() > "
		"PAGE_MASK=0x%x\n",
		dev->name,__func__,
		(unsigned int)PAGE_MASK);
#endif
        /*
        * compute number of CCW blocks that will fit in a page
        */
        ccw_blocks_perpage= PAGE_SIZE /  CCWBK_SIZE;
        ccw_pages_required=
		DIV_ROUND_UP(ccw_blocks_required, ccw_blocks_perpage);

#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
		dev->name,__func__,
		ccw_blocks_perpage);
        printk(KERN_INFO "%s: %s() > ccw_pages_required=%d\n",
		dev->name,__func__,
		ccw_pages_required);
#endif
        /*
         *  read and write sizes are set by 2 constants in claw.h
	 *  4k and 32k.  Unpacked values other than 4k are not going to
	 * provide good performance. With packing buffers support 32k
	 * buffers are used.
         */
	if (privptr->p_env->read_size < PAGE_SIZE) {
		claw_reads_perpage = PAGE_SIZE / privptr->p_env->read_size;
		claw_read_pages = DIV_ROUND_UP(privptr->p_env->read_buffers,
						claw_reads_perpage);
         }
         else {       /* > or equal  */
		privptr->p_buff_pages_perread =
			DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
		claw_read_pages = privptr->p_env->read_buffers *
					privptr->p_buff_pages_perread;
         }
        if (privptr->p_env->write_size < PAGE_SIZE) {
		claw_writes_perpage =
			PAGE_SIZE / privptr->p_env->write_size;
		claw_write_pages = DIV_ROUND_UP(privptr->p_env->write_buffers,
						claw_writes_perpage);

        }
        else {      /* >  or equal  */
		privptr->p_buff_pages_perwrite =
			DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
		claw_write_pages = privptr->p_env->write_buffers *
					privptr->p_buff_pages_perwrite;
        }
#ifdef DEBUGMSG
        if (privptr->p_env->read_size < PAGE_SIZE) {
            printk(KERN_INFO "%s: %s() reads_perpage=%d\n",
		dev->name,__func__,
		claw_reads_perpage);
        }
        else {
            printk(KERN_INFO "%s: %s() pages_perread=%d\n",
		dev->name,__func__,
		privptr->p_buff_pages_perread);
        }
        printk(KERN_INFO "%s: %s() read_pages=%d\n",
		dev->name,__func__,
		claw_read_pages);
        if (privptr->p_env->write_size < PAGE_SIZE) {
            printk(KERN_INFO "%s: %s() writes_perpage=%d\n",
		dev->name,__func__,
		claw_writes_perpage);
        }
        else {
            printk(KERN_INFO "%s: %s() pages_perwrite=%d\n",
		dev->name,__func__,
		privptr->p_buff_pages_perwrite);
        }
        printk(KERN_INFO "%s: %s() write_pages=%d\n",
		dev->name,__func__,
		claw_write_pages);
#endif


        /*
        *               allocate ccw_pages_required
        */
        if (privptr->p_buff_ccw==NULL) {
                privptr->p_buff_ccw=
			(void *)__get_free_pages(__GFP_DMA,
		        (int)pages_to_order_of_mag(ccw_pages_required ));
                if (privptr->p_buff_ccw==NULL) {
                        printk(KERN_INFO "%s: %s()  "
				"__get_free_pages for CCWs failed : "
				"pages is %d\n",
				dev->name,__func__,
				ccw_pages_required );
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s: %s() > "
				"exit on line %d, rc = ENOMEM\n",
				dev->name,__func__,
				 __LINE__);
#endif
                        return -ENOMEM;
                }
                privptr->p_buff_ccw_num=ccw_pages_required;
        }
        memset(privptr->p_buff_ccw, 0x00,
		privptr->p_buff_ccw_num * PAGE_SIZE);

        /*
        *               obtain ending ccw block address
        *
        */
        privptr->p_end_ccw = (struct endccw *)&privptr->end_ccw;
        real_address  = (__u32)__pa(privptr->p_end_ccw);
        /*                              Initialize ending CCW block       */
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() begin initialize ending CCW blocks\n",
		dev->name,__func__);
#endif

        p_endccw=privptr->p_end_ccw;
        p_endccw->real=real_address;
        p_endccw->write1=0x00;
        p_endccw->read1=0x00;

        /*      write1_nop1                                     */
        p_endccw->write1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
        p_endccw->write1_nop1.flags       = CCW_FLAG_SLI | CCW_FLAG_CC;
        p_endccw->write1_nop1.count       = 1;
        p_endccw->write1_nop1.cda         = 0;

        /*      write1_nop2                                     */
        p_endccw->write1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
        p_endccw->write1_nop2.flags        = CCW_FLAG_SLI | CCW_FLAG_SKIP;
        p_endccw->write1_nop2.count      = 1;
        p_endccw->write1_nop2.cda        = 0;

        /*      write2_nop1                                     */
        p_endccw->write2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
        p_endccw->write2_nop1.flags        = CCW_FLAG_SLI | CCW_FLAG_CC;
        p_endccw->write2_nop1.count        = 1;
        p_endccw->write2_nop1.cda          = 0;

        /*      write2_nop2                                     */
        p_endccw->write2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
        p_endccw->write2_nop2.flags        = CCW_FLAG_SLI | CCW_FLAG_SKIP;
        p_endccw->write2_nop2.count        = 1;
        p_endccw->write2_nop2.cda          = 0;

        /*      read1_nop1                                      */
        p_endccw->read1_nop1.cmd_code = CCW_CLAW_CMD_NOP;
        p_endccw->read1_nop1.flags        = CCW_FLAG_SLI | CCW_FLAG_CC;
        p_endccw->read1_nop1.count        = 1;
        p_endccw->read1_nop1.cda          = 0;

        /*      read1_nop2                                      */
        p_endccw->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;
        p_endccw->read1_nop2.flags        = CCW_FLAG_SLI | CCW_FLAG_SKIP;
        p_endccw->read1_nop2.count        = 1;
        p_endccw->read1_nop2.cda          = 0;

        /*      read2_nop1                                      */
        p_endccw->read2_nop1.cmd_code = CCW_CLAW_CMD_NOP;
        p_endccw->read2_nop1.flags        = CCW_FLAG_SLI | CCW_FLAG_CC;
        p_endccw->read2_nop1.count        = 1;
        p_endccw->read2_nop1.cda          = 0;

        /*      read2_nop2                                      */
        p_endccw->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;
        p_endccw->read2_nop2.flags        = CCW_FLAG_SLI | CCW_FLAG_SKIP;
        p_endccw->read2_nop2.count        = 1;
        p_endccw->read2_nop2.cda          = 0;

#ifdef IOTRACE
        printk(KERN_INFO "%s: %s() dump claw ending CCW BK \n",
		dev->name,__func__);
        dumpit((char *)p_endccw, sizeof(struct endccw));
#endif

        /*
        *                               Build a chain of CCWs
        *
        */

#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s()  Begin build a chain of CCW buffer \n",
		dev->name,__func__);
#endif
        p_buff=privptr->p_buff_ccw;

        p_free_chain=NULL;
        for (i=0 ; i < ccw_pages_required; i++ ) {
                real_address  = (__u32)__pa(p_buff);
                p_buf=p_buff;
                for (j=0 ; j < ccw_blocks_perpage ; j++) {
                        p_buf->next  = p_free_chain;
                        p_free_chain = p_buf;
                        p_buf->real=(__u32)__pa(p_buf);
                        ++p_buf;
                }
                p_buff+=PAGE_SIZE;
        }
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() "
		"End build a chain of CCW buffer \n",
			dev->name,__func__);
        p_buf=p_free_chain;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
#endif

        /*
        *                               Initialize ClawSignalBlock
        *
        */
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() "
		"Begin initialize ClawSignalBlock \n",
		dev->name,__func__);
#endif
        if (privptr->p_claw_signal_blk==NULL) {
                privptr->p_claw_signal_blk=p_free_chain;
                p_free_chain=p_free_chain->next;
                pClawH=(struct clawh *)privptr->p_claw_signal_blk;
                pClawH->length=0xffff;
                pClawH->opcode=0xff;
                pClawH->flag=CLAW_BUSY;
        }
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() >  End initialize "
	 	"ClawSignalBlock\n",
		dev->name,__func__);
        dumpit((char *)privptr->p_claw_signal_blk, sizeof(struct ccwbk));
#endif

        /*
        *               allocate write_pages_required and add to free chain
        */
        if (privptr->p_buff_write==NULL) {
            if (privptr->p_env->write_size < PAGE_SIZE) {
                privptr->p_buff_write=
			(void *)__get_free_pages(__GFP_DMA,
			(int)pages_to_order_of_mag(claw_write_pages ));
                if (privptr->p_buff_write==NULL) {
                        printk(KERN_INFO "%s: %s() __get_free_pages for write"
				" bufs failed : get is for %d pages\n",
				dev->name,__func__,claw_write_pages );
                        free_pages((unsigned long)privptr->p_buff_ccw,
			   (int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
                        privptr->p_buff_ccw=NULL;
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s: %s() > exit on line %d,"
			 	"rc = ENOMEM\n",
				dev->name,__func__,__LINE__);
#endif
                        return -ENOMEM;
                }
                /*
                *                               Build CLAW write free chain
                *
                */

                memset(privptr->p_buff_write, 0x00,
			ccw_pages_required * PAGE_SIZE);
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: %s() Begin build claw write free "
			"chain \n",dev->name,__func__);
#endif
                privptr->p_write_free_chain=NULL;

                p_buff=privptr->p_buff_write;

                for (i=0 ; i< privptr->p_env->write_buffers ; i++) {
                        p_buf        = p_free_chain;      /*  get a CCW */
                        p_free_chain = p_buf->next;
                        p_buf->next  =privptr->p_write_free_chain;
                        privptr->p_write_free_chain = p_buf;
                        p_buf-> p_buffer	= (struct clawbuf *)p_buff;
                        p_buf-> write.cda       = (__u32)__pa(p_buff);
                        p_buf-> write.flags     = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
                        p_buf-> w_read_FF.flags   = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> w_read_FF.count   = 1;
                        p_buf-> w_read_FF.cda     =
				(__u32)__pa(&p_buf-> header.flag);
                        p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
                        p_buf-> w_TIC_1.flags      = 0;
                        p_buf-> w_TIC_1.count      = 0;

                        if (((unsigned long)p_buff+privptr->p_env->write_size) >=
			   ((unsigned long)(p_buff+2*
				(privptr->p_env->write_size) -1) & PAGE_MASK)) {
                        p_buff= p_buff+privptr->p_env->write_size;
                        }
                }
           }
           else      /*  Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
           {
               privptr->p_write_free_chain=NULL;
               for (i = 0; i< privptr->p_env->write_buffers ; i++) {
                   p_buff=(void *)__get_free_pages(__GFP_DMA,
		        (int)pages_to_order_of_mag(
			privptr->p_buff_pages_perwrite) );
#ifdef IOTRACE
                   printk(KERN_INFO "%s:%s __get_free_pages "
		    "for writes buf: get for %d pages\n",
		    dev->name,__func__,
		    privptr->p_buff_pages_perwrite);
#endif
                   if (p_buff==NULL) {
			printk(KERN_INFO "%s:%s __get_free_pages "
			 	"for writes buf failed : get is for %d pages\n",
				dev->name,
				__func__,
				privptr->p_buff_pages_perwrite );
                        free_pages((unsigned long)privptr->p_buff_ccw,
			      (int)pages_to_order_of_mag(
			      		privptr->p_buff_ccw_num));
                        privptr->p_buff_ccw=NULL;
			p_buf=privptr->p_buff_write;
                        while (p_buf!=NULL) {
                                free_pages((unsigned long)
					p_buf->p_buffer,
					(int)pages_to_order_of_mag(
					privptr->p_buff_pages_perwrite));
                                p_buf=p_buf->next;
                        }
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s: %s exit on line %d, rc = ENOMEM\n",
			dev->name,
			__func__,
			__LINE__);
#endif
                        return -ENOMEM;
                   }  /* Error on get_pages   */
                   memset(p_buff, 0x00, privptr->p_env->write_size );
                   p_buf         = p_free_chain;
                   p_free_chain  = p_buf->next;
                   p_buf->next   = privptr->p_write_free_chain;
                   privptr->p_write_free_chain = p_buf;
                   privptr->p_buff_write = p_buf;
                   p_buf->p_buffer=(struct clawbuf *)p_buff;
                   p_buf-> write.cda     = (__u32)__pa(p_buff);
                   p_buf-> write.flags   = CCW_FLAG_SLI | CCW_FLAG_CC;
                   p_buf-> w_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
                   p_buf-> w_read_FF.flags    = CCW_FLAG_SLI | CCW_FLAG_CC;
                   p_buf-> w_read_FF.count    = 1;
                   p_buf-> w_read_FF.cda      =
			(__u32)__pa(&p_buf-> header.flag);
                   p_buf-> w_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
                   p_buf-> w_TIC_1.flags   = 0;
                   p_buf-> w_TIC_1.count   = 0;
               }  /* for all write_buffers   */

           }    /* else buffers are PAGE_SIZE or bigger */

        }
        privptr->p_buff_write_num=claw_write_pages;
        privptr->write_free_count=privptr->p_env->write_buffers;


#ifdef DEBUGMSG
        printk(KERN_INFO "%s:%s  End build claw write free chain \n",
	dev->name,__func__);
        p_buf=privptr->p_write_free_chain;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
#endif
        /*
        *               allocate read_pages_required and chain to free chain
        */
        if (privptr->p_buff_read==NULL) {
            if (privptr->p_env->read_size < PAGE_SIZE)  {
                privptr->p_buff_read=
			(void *)__get_free_pages(__GFP_DMA,
			(int)pages_to_order_of_mag(claw_read_pages) );
                if (privptr->p_buff_read==NULL) {
                        printk(KERN_INFO "%s: %s() "
			 	"__get_free_pages for read buf failed : "
			 	"get is for %d pages\n",
				dev->name,__func__,claw_read_pages );
                        free_pages((unsigned long)privptr->p_buff_ccw,
				(int)pages_to_order_of_mag(
					privptr->p_buff_ccw_num));
			/* free the write pages size is < page size  */
                        free_pages((unsigned long)privptr->p_buff_write,
				(int)pages_to_order_of_mag(
				privptr->p_buff_write_num));
                        privptr->p_buff_ccw=NULL;
                        privptr->p_buff_write=NULL;
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s: %s() > exit on line %d, rc ="
				" ENOMEM\n",dev->name,__func__,__LINE__);
#endif
                        return -ENOMEM;
                }
                memset(privptr->p_buff_read, 0x00, claw_read_pages * PAGE_SIZE);
                privptr->p_buff_read_num=claw_read_pages;
                /*
                *                               Build CLAW read free chain
                *
                */
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
			dev->name,__func__);
#endif
                p_buff=privptr->p_buff_read;
                for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
                        p_buf        = p_free_chain;
                        p_free_chain = p_buf->next;

                        if (p_last_CCWB==NULL) {
                                p_buf->next=NULL;
                                real_TIC_address=0;
                                p_last_CCWB=p_buf;
                        }
                        else {
                                p_buf->next=p_first_CCWB;
                                real_TIC_address=
				(__u32)__pa(&p_first_CCWB -> read );
                        }

                        p_first_CCWB=p_buf;

                        p_buf->p_buffer=(struct clawbuf *)p_buff;
                        /*  initialize read command */
                        p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
                        p_buf-> read.cda = (__u32)__pa(p_buff);
                        p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> read.count       = privptr->p_env->read_size;

                        /*  initialize read_h command */
                        p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
                        p_buf-> read_h.cda =
				(__u32)__pa(&(p_buf->header));
                        p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> read_h.count      = sizeof(struct clawh);

                        /*  initialize Signal command */
                        p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
                        p_buf-> signal.cda =
				(__u32)__pa(&(pClawH->flag));
                        p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> signal.count     = 1;

                        /*  initialize r_TIC_1 command */
                        p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
                        p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
                        p_buf-> r_TIC_1.flags = 0;
                        p_buf-> r_TIC_1.count      = 0;

                        /*  initialize r_read_FF command */
                        p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
                        p_buf-> r_read_FF.cda =
				(__u32)__pa(&(pClawH->flag));
                        p_buf-> r_read_FF.flags =
				CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
                        p_buf-> r_read_FF.count    = 1;

                        /*    initialize r_TIC_2          */
                        memcpy(&p_buf->r_TIC_2,
				&p_buf->r_TIC_1, sizeof(struct ccw1));

                        /*     initialize Header     */
                        p_buf->header.length=0xffff;
                        p_buf->header.opcode=0xff;
                        p_buf->header.flag=CLAW_PENDING;

                        if (((unsigned long)p_buff+privptr->p_env->read_size) >=
				((unsigned long)(p_buff+2*(privptr->p_env->read_size) -1)
				 & PAGE_MASK) ) {
                                p_buff= p_buff+privptr->p_env->read_size;
                        }
                        else {
                                p_buff=
				(void *)((unsigned long)
					(p_buff+2*(privptr->p_env->read_size) -1)
					 & PAGE_MASK) ;
                        }
                }   /* for read_buffers   */
          }         /* read_size < PAGE_SIZE  */
          else {  /* read Size >= PAGE_SIZE  */

#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() Begin build claw read free chain \n",
		dev->name,__func__);
#endif
                for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
                        p_buff = (void *)__get_free_pages(__GFP_DMA,
				(int)pages_to_order_of_mag(privptr->p_buff_pages_perread) );
                        if (p_buff==NULL) {
                                printk(KERN_INFO "%s: %s() __get_free_pages for read "
					"buf failed : get is for %d pages\n",
					dev->name,__func__,
                                        privptr->p_buff_pages_perread );
                                free_pages((unsigned long)privptr->p_buff_ccw,
					(int)pages_to_order_of_mag(privptr->p_buff_ccw_num));
				/* free the write pages  */
	                        p_buf=privptr->p_buff_write;
                                while (p_buf!=NULL) {
                                        free_pages((unsigned long)p_buf->p_buffer,
						(int)pages_to_order_of_mag(
						privptr->p_buff_pages_perwrite ));
                                        p_buf=p_buf->next;
                                }
				/* free any read pages already alloc  */
	                        p_buf=privptr->p_buff_read;
                                while (p_buf!=NULL) {
                                        free_pages((unsigned long)p_buf->p_buffer,
						(int)pages_to_order_of_mag(
						privptr->p_buff_pages_perread ));
                                        p_buf=p_buf->next;
                                }
                                privptr->p_buff_ccw=NULL;
                                privptr->p_buff_write=NULL;
#ifdef FUNCTRACE
                                printk(KERN_INFO "%s: %s() exit on line %d, rc = ENOMEM\n",
					dev->name,__func__,
					__LINE__);
#endif
                                return -ENOMEM;
                        }
                        memset(p_buff, 0x00, privptr->p_env->read_size);
                        p_buf        = p_free_chain;
                        privptr->p_buff_read = p_buf;
                        p_free_chain = p_buf->next;

                        if (p_last_CCWB==NULL) {
                                p_buf->next=NULL;
                                real_TIC_address=0;
                                p_last_CCWB=p_buf;
                        }
                        else {
                                p_buf->next=p_first_CCWB;
                                real_TIC_address=
					(addr_t)__pa(
						&p_first_CCWB -> read );
                        }

                        p_first_CCWB=p_buf;
				/* save buff address */
                        p_buf->p_buffer=(struct clawbuf *)p_buff;
                        /*  initialize read command */
                        p_buf-> read.cmd_code = CCW_CLAW_CMD_READ;
                        p_buf-> read.cda = (__u32)__pa(p_buff);
                        p_buf-> read.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> read.count       = privptr->p_env->read_size;

                        /*  initialize read_h command */
                        p_buf-> read_h.cmd_code = CCW_CLAW_CMD_READHEADER;
                        p_buf-> read_h.cda =
				(__u32)__pa(&(p_buf->header));
                        p_buf-> read_h.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> read_h.count      = sizeof(struct clawh);

                        /*  initialize Signal command */
                        p_buf-> signal.cmd_code = CCW_CLAW_CMD_SIGNAL_SMOD;
                        p_buf-> signal.cda =
				(__u32)__pa(&(pClawH->flag));
                        p_buf-> signal.flags = CCW_FLAG_SLI | CCW_FLAG_CC;
                        p_buf-> signal.count     = 1;

                        /*  initialize r_TIC_1 command */
                        p_buf-> r_TIC_1.cmd_code = CCW_CLAW_CMD_TIC;
                        p_buf-> r_TIC_1.cda = (__u32)real_TIC_address;
                        p_buf-> r_TIC_1.flags = 0;
                        p_buf-> r_TIC_1.count      = 0;

                        /*  initialize r_read_FF command */
                        p_buf-> r_read_FF.cmd_code = CCW_CLAW_CMD_READFF;
                        p_buf-> r_read_FF.cda =
				(__u32)__pa(&(pClawH->flag));
                        p_buf-> r_read_FF.flags =
				CCW_FLAG_SLI | CCW_FLAG_CC | CCW_FLAG_PCI;
                        p_buf-> r_read_FF.count    = 1;

                        /*    initialize r_TIC_2          */
                        memcpy(&p_buf->r_TIC_2, &p_buf->r_TIC_1,
				sizeof(struct ccw1));

                        /*     initialize Header     */
                        p_buf->header.length=0xffff;
                        p_buf->header.opcode=0xff;
                        p_buf->header.flag=CLAW_PENDING;

                }    /* For read_buffers   */
          }     /*  read_size >= PAGE_SIZE   */
        }       /*  pBuffread = NULL */
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() >  End build claw read free chain \n",
		dev->name,__func__);
        p_buf=p_first_CCWB;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }

#endif
        add_claw_reads( dev  ,p_first_CCWB , p_last_CCWB);
	privptr->buffs_alloc = 1;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
        return 0;
}    /*    end of init_ccw_bk */

/*-------------------------------------------------------------------*
*                                                                    *
*       probe_error                                                  *
*                                                                    *
*--------------------------------------------------------------------*/

static void
probe_error( struct ccwgroup_device *cgdev)
{
  struct claw_privbk *privptr;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s enter  \n",__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"proberr");
#ifdef DEBUGMSG
	printk(KERN_INFO "%s variable cgdev =\n",__func__);
        dumpit((char *) cgdev, sizeof(struct ccwgroup_device));
#endif
        privptr=(struct claw_privbk *)cgdev->dev.driver_data;
	if (privptr!=NULL) {
		kfree(privptr->p_env);
		privptr->p_env=NULL;
                kfree(privptr->p_mtc_envelope);
               	privptr->p_mtc_envelope=NULL;
                kfree(privptr);
                privptr=NULL;
        }
#ifdef FUNCTRACE
        printk(KERN_INFO "%s > exit on line %d\n",
		 __func__,__LINE__);
#endif

        return;
}    /*    probe_error    */



/*-------------------------------------------------------------------*
*    claw_process_control                                            *
*                                                                    *
*                                                                    *
*--------------------------------------------------------------------*/

static int
claw_process_control( struct net_device *dev, struct ccwbk * p_ccw)
{

        struct clawbuf *p_buf;
        struct clawctl  ctlbk;
        struct clawctl *p_ctlbk;
        char    temp_host_name[8];
        char    temp_ws_name[8];
        struct claw_privbk *privptr;
        struct claw_env *p_env;
        struct sysval *p_sysval;
        struct conncmd *p_connect=NULL;
        int rc;
        struct chbk *p_ch = NULL;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() > enter  \n",
		dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"clw_cntl");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable p_ccw =\n",dev->name);
        dumpit((char *) p_ccw, sizeof(struct ccwbk *));
#endif
        udelay(1000);  /* Wait a ms for the control packets to
			*catch up to each other */
        privptr=dev->priv;
        p_env=privptr->p_env;
	memcpy( &temp_host_name, p_env->host_name, 8);
        memcpy( &temp_ws_name, p_env->adapter_name , 8);
        printk(KERN_INFO "%s: CLAW device %.8s: "
		"Received Control Packet\n",
		dev->name, temp_ws_name);
        if (privptr->release_pend==1) {
#ifdef FUNCTRACE
                printk(KERN_INFO "%s: %s() > "
			"exit on line %d, rc=0\n",
			dev->name,__func__,__LINE__);
#endif
                return 0;
        }
        p_buf=p_ccw->p_buffer;
        p_ctlbk=&ctlbk;
	if (p_env->packing == DO_PACKED) { /* packing in progress?*/
		memcpy(p_ctlbk, &p_buf->buffer[4], sizeof(struct clawctl));
	} else {
		memcpy(p_ctlbk, p_buf, sizeof(struct clawctl));
	}
#ifdef IOTRACE
        printk(KERN_INFO "%s: dump claw control data inbound\n",dev->name);
        dumpit((char *)p_ctlbk, sizeof(struct clawctl));
#endif
        switch (p_ctlbk->command)
        {
                case SYSTEM_VALIDATE_REQUEST:
                        if (p_ctlbk->version!=CLAW_VERSION_ID) {
                                claw_snd_sys_validate_rsp(dev, p_ctlbk,
					CLAW_RC_WRONG_VERSION );
                                printk("%s: %d is wrong version id. "
					"Expected %d\n",
					dev->name, p_ctlbk->version,
                                        CLAW_VERSION_ID);
                        }
                        p_sysval=(struct sysval *)&(p_ctlbk->data);
			printk( "%s: Recv Sys Validate Request: "
				"Vers=%d,link_id=%d,Corr=%d,WS name=%."
				"8s,Host name=%.8s\n",
                                dev->name, p_ctlbk->version,
				p_ctlbk->linkid,
				p_ctlbk->correlator,
				p_sysval->WS_name,
                                p_sysval->host_name);
                        if (0!=memcmp(temp_host_name,p_sysval->host_name,8)) {
                                claw_snd_sys_validate_rsp(dev, p_ctlbk,
					CLAW_RC_NAME_MISMATCH );
				CLAW_DBF_TEXT(2,setup,"HSTBAD");
				CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->host_name);
				CLAW_DBF_TEXT_(2,setup,"%s",temp_host_name);
                                printk(KERN_INFO "%s:  Host name mismatch\n",
					dev->name);
				printk(KERN_INFO "%s: Received :%s: "
					"expected :%s: \n",
					dev->name,
					p_sysval->host_name,
					temp_host_name);
                        }
                        if (0!=memcmp(temp_ws_name,p_sysval->WS_name,8)) {
                                claw_snd_sys_validate_rsp(dev, p_ctlbk,
					CLAW_RC_NAME_MISMATCH );
				CLAW_DBF_TEXT(2,setup,"WSNBAD");
                                CLAW_DBF_TEXT_(2,setup,"%s",p_sysval->WS_name);
                                CLAW_DBF_TEXT_(2,setup,"%s",temp_ws_name);
                                printk(KERN_INFO "%s: WS name mismatch\n",
					dev->name);
				 printk(KERN_INFO "%s: Received :%s: "
                                        "expected :%s: \n",
                                        dev->name,
                                        p_sysval->WS_name,
					temp_ws_name);
                        }
                        if (( p_sysval->write_frame_size < p_env->write_size) &&
			   ( p_env->packing == 0)) {
                                claw_snd_sys_validate_rsp(dev, p_ctlbk,
					CLAW_RC_HOST_RCV_TOO_SMALL );
                                printk(KERN_INFO "%s: host write size is too "
					"small\n", dev->name);
				CLAW_DBF_TEXT(2,setup,"wrtszbad");
                        }
                        if (( p_sysval->read_frame_size < p_env->read_size) &&
			   ( p_env->packing == 0)) {
                                claw_snd_sys_validate_rsp(dev, p_ctlbk,
					CLAW_RC_HOST_RCV_TOO_SMALL );
                                printk(KERN_INFO "%s: host read size is too "
					"small\n", dev->name);
				CLAW_DBF_TEXT(2,setup,"rdsizbad");
                        }
                        claw_snd_sys_validate_rsp(dev, p_ctlbk, 0 );
                        printk("%s: CLAW device %.8s: System validate"
				" completed.\n",dev->name, temp_ws_name);
			printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev->name,
				p_sysval->read_frame_size,p_sysval->write_frame_size);
                        privptr->system_validate_comp=1;
                	if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
				p_env->packing = PACKING_ASK;
			}
                        claw_strt_conn_req(dev);
                        break;

                case SYSTEM_VALIDATE_RESPONSE:
			p_sysval=(struct sysval *)&(p_ctlbk->data);
			printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
				"WS name=%.8s,Host name=%.8s\n",
                        	dev->name,
                        	p_ctlbk->version,
                        	p_ctlbk->correlator,
                        	p_ctlbk->rc,
                        	p_sysval->WS_name,
                        	p_sysval->host_name);
                        switch (p_ctlbk->rc)
                        {
                                case 0:
                                        printk(KERN_INFO "%s: CLAW device "
						"%.8s: System validate "
						"completed.\n",
                                                dev->name, temp_ws_name);
					if (privptr->system_validate_comp == 0)
	                                        claw_strt_conn_req(dev);
					privptr->system_validate_comp=1;
                                        break;
                                case CLAW_RC_NAME_MISMATCH:
                                        printk(KERN_INFO "%s: Sys Validate "
						"Resp : Host, WS name is "
						"mismatch\n",
                                                dev->name);
                                        break;
                                case CLAW_RC_WRONG_VERSION:
                                        printk(KERN_INFO "%s: Sys Validate "
						"Resp : Wrong version\n",
						dev->name);
                                        break;
                                case CLAW_RC_HOST_RCV_TOO_SMALL:
                                        printk(KERN_INFO "%s: Sys Validate "
						"Resp : bad frame size\n",
						dev->name);
                                        break;
                                default:
                                        printk(KERN_INFO "%s: Sys Validate "
						"error code=%d \n",
						 dev->name, p_ctlbk->rc );
                                        break;
                        }
                        break;

                case CONNECTION_REQUEST:
                        p_connect=(struct conncmd *)&(p_ctlbk->data);
                        printk(KERN_INFO "%s: Recv Conn Req: Vers=%d,link_id=%d,"
				"Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
                        	dev->name,
	                        p_ctlbk->version,
        	                p_ctlbk->linkid,
                	        p_ctlbk->correlator,
                        	p_connect->host_name,
                      		p_connect->WS_name);
                        if (privptr->active_link_ID!=0 ) {
                                claw_snd_disc(dev, p_ctlbk);
                                printk(KERN_INFO "%s: Conn Req error : "
					"already logical link is active \n",
					dev->name);
                        }
                        if (p_ctlbk->linkid!=1 ) {
                                claw_snd_disc(dev, p_ctlbk);
                                printk(KERN_INFO "%s: Conn Req error : "
					"req logical link id is not 1\n",
					dev->name);
                        }
                        rc=find_link(dev,
				p_connect->host_name, p_connect->WS_name);
                        if (rc!=0) {
                                claw_snd_disc(dev, p_ctlbk);
                                printk(KERN_INFO "%s: Conn Req error : "
					"req appl name does not match\n",
					 dev->name);
                        }
                        claw_send_control(dev,
				CONNECTION_CONFIRM, p_ctlbk->linkid,
				p_ctlbk->correlator,
				0, p_connect->host_name,
                                p_connect->WS_name);
			if (p_env->packing == PACKING_ASK) {
				printk("%s: Now Pack ask\n",dev->name);
				p_env->packing = PACK_SEND;
				claw_snd_conn_req(dev,0);
			}
                        printk(KERN_INFO "%s: CLAW device %.8s: Connection "
				"completed link_id=%d.\n",
				dev->name, temp_ws_name,
                                p_ctlbk->linkid);
                        privptr->active_link_ID=p_ctlbk->linkid;
                        p_ch=&privptr->channel[WRITE];
                        wake_up(&p_ch->wait);  /* wake up claw_open ( WRITE) */
                        break;
                case CONNECTION_RESPONSE:
                        p_connect=(struct conncmd *)&(p_ctlbk->data);
                        printk(KERN_INFO "%s: Revc Conn Resp: Vers=%d,link_id=%d,"
				"Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
                                dev->name,
				p_ctlbk->version,
				p_ctlbk->linkid,
				p_ctlbk->correlator,
				p_ctlbk->rc,
				p_connect->host_name,
                                p_connect->WS_name);

                        if (p_ctlbk->rc !=0 ) {
                                printk(KERN_INFO "%s: Conn Resp error: rc=%d \n",
					dev->name, p_ctlbk->rc);
                                return 1;
                        }
                        rc=find_link(dev,
				p_connect->host_name, p_connect->WS_name);
                        if (rc!=0) {
                                claw_snd_disc(dev, p_ctlbk);
                                printk(KERN_INFO "%s: Conn Resp error: "
					"req appl name does not match\n",
					 dev->name);
                        }
			/* should be until CONNECTION_CONFIRM */
                        privptr->active_link_ID =  - (p_ctlbk->linkid);
                        break;
                case CONNECTION_CONFIRM:
                        p_connect=(struct conncmd *)&(p_ctlbk->data);
                        printk(KERN_INFO "%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
				"Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
                        dev->name,
                        p_ctlbk->version,
                        p_ctlbk->linkid,
                        p_ctlbk->correlator,
                        p_connect->host_name,
                        p_connect->WS_name);
                        if (p_ctlbk->linkid== -(privptr->active_link_ID)) {
                                privptr->active_link_ID=p_ctlbk->linkid;
				if (p_env->packing > PACKING_ASK) {
					printk(KERN_INFO "%s: Confirmed Now packing\n",dev->name);
					p_env->packing = DO_PACKED;
					}
				p_ch=&privptr->channel[WRITE];
                                wake_up(&p_ch->wait);
                        }
                        else {
                                printk(KERN_INFO "%s: Conn confirm: "
					"unexpected linkid=%d \n",
					dev->name, p_ctlbk->linkid);
                                claw_snd_disc(dev, p_ctlbk);
                        }
                        break;
                case DISCONNECT:
                        printk(KERN_INFO "%s: Disconnect: "
				"Vers=%d,link_id=%d,Corr=%d\n",
				dev->name, p_ctlbk->version,
                                p_ctlbk->linkid, p_ctlbk->correlator);
			if ((p_ctlbk->linkid == 2) &&
			    (p_env->packing == PACK_SEND)) {
				privptr->active_link_ID = 1;
				p_env->packing = DO_PACKED;
			}
			else
	                        privptr->active_link_ID=0;
                        break;
                case CLAW_ERROR:
                        printk(KERN_INFO "%s: CLAW ERROR detected\n",
				dev->name);
                        break;
                default:
                        printk(KERN_INFO "%s:  Unexpected command code=%d \n",
				dev->name,  p_ctlbk->command);
                        break;
        }

#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s() exit on line %d, rc = 0\n",
		dev->name,__func__,__LINE__);
#endif

        return 0;
}   /*    end of claw_process_control    */


/*-------------------------------------------------------------------*
*               claw_send_control                                    *
*                                                                    *
*--------------------------------------------------------------------*/

static int
claw_send_control(struct net_device *dev, __u8 type, __u8 link,
	 __u8 correlator, __u8 rc, char *local_name, char *remote_name)
{
        struct claw_privbk 		*privptr;
        struct clawctl                  *p_ctl;
        struct sysval                   *p_sysval;
        struct conncmd                  *p_connect;
        struct sk_buff 			*skb;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s > enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"sndcntl");
#ifdef DEBUGMSG
	printk(KERN_INFO "%s: Sending Control Packet \n",dev->name);
        printk(KERN_INFO "%s: variable type = 0x%X, link = "
		"%d, correlator = %d, rc = %d\n",
                dev->name,type, link, correlator, rc);
        printk(KERN_INFO "%s: variable local_name = %s, "
		"remote_name = %s\n",dev->name, local_name, remote_name);
#endif
        privptr=dev->priv;
        p_ctl=(struct clawctl *)&privptr->ctl_bk;

        p_ctl->command=type;
        p_ctl->version=CLAW_VERSION_ID;
        p_ctl->linkid=link;
        p_ctl->correlator=correlator;
        p_ctl->rc=rc;

        p_sysval=(struct sysval *)&p_ctl->data;
        p_connect=(struct conncmd *)&p_ctl->data;

        switch (p_ctl->command) {
                case SYSTEM_VALIDATE_REQUEST:
                case SYSTEM_VALIDATE_RESPONSE:
                        memcpy(&p_sysval->host_name, local_name, 8);
                        memcpy(&p_sysval->WS_name, remote_name, 8);
			if (privptr->p_env->packing > 0) {
                        	p_sysval->read_frame_size=DEF_PACK_BUFSIZE;
	                        p_sysval->write_frame_size=DEF_PACK_BUFSIZE;
			} else {
				/* how big is the piggest group of packets */
				p_sysval->read_frame_size=privptr->p_env->read_size;
	                        p_sysval->write_frame_size=privptr->p_env->write_size;
			}
                        memset(&p_sysval->reserved, 0x00, 4);
                        break;
                case CONNECTION_REQUEST:
                case CONNECTION_RESPONSE:
                case CONNECTION_CONFIRM:
                case DISCONNECT:
                        memcpy(&p_sysval->host_name, local_name, 8);
                        memcpy(&p_sysval->WS_name, remote_name, 8);
			if (privptr->p_env->packing > 0) {
			/* How big is the biggest packet */
				p_connect->reserved1[0]=CLAW_FRAME_SIZE;
                        	p_connect->reserved1[1]=CLAW_FRAME_SIZE;
			} else {
	                        memset(&p_connect->reserved1, 0x00, 4);
        	                memset(&p_connect->reserved2, 0x00, 4);
			}
                        break;
                default:
                        break;
        }

        /*      write Control Record to the device                   */


        skb = dev_alloc_skb(sizeof(struct clawctl));
        if (!skb) {
                printk(  "%s:%s low on mem, returning...\n",
			dev->name,__func__);
#ifdef DEBUG
                printk(KERN_INFO "%s:%s Exit, rc = ENOMEM\n",
			dev->name,__func__);
#endif
                return -ENOMEM;
        }
	memcpy(skb_put(skb, sizeof(struct clawctl)),
		p_ctl, sizeof(struct clawctl));
#ifdef IOTRACE
	 printk(KERN_INFO "%s: outbnd claw cntl data \n",dev->name);
        dumpit((char *)p_ctl,sizeof(struct clawctl));
#endif
	if (privptr->p_env->packing >= PACK_SEND)
		claw_hw_tx(skb, dev, 1);
	else
        	claw_hw_tx(skb, dev, 0);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif

        return 0;
}  /*   end of claw_send_control  */

/*-------------------------------------------------------------------*
*               claw_snd_conn_req                                    *
*                                                                    *
*--------------------------------------------------------------------*/
static int
claw_snd_conn_req(struct net_device *dev, __u8 link)
{
        int                rc;
        struct claw_privbk *privptr=dev->priv;
        struct clawctl 	   *p_ctl;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"snd_conn");
#ifdef  DEBUGMSG
        printk(KERN_INFO "%s: variable link = %X, dev =\n",dev->name, link);
        dumpit((char *) dev, sizeof(struct net_device));
#endif
	rc = 1;
        p_ctl=(struct clawctl *)&privptr->ctl_bk;
	p_ctl->linkid = link;
        if ( privptr->system_validate_comp==0x00 ) {
#ifdef FUNCTRACE
                printk(KERN_INFO "%s:%s Exit on line %d, rc = 1\n",
			dev->name,__func__,__LINE__);
#endif
                return rc;
        }
	if (privptr->p_env->packing == PACKING_ASK )
		rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
        		WS_APPL_NAME_PACKED, WS_APPL_NAME_PACKED);
	if (privptr->p_env->packing == PACK_SEND)  {
		rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
        		WS_APPL_NAME_IP_NAME, WS_APPL_NAME_IP_NAME);
	}
	if (privptr->p_env->packing == 0)
        	rc=claw_send_control(dev, CONNECTION_REQUEST,0,0,0,
       			HOST_APPL_NAME, privptr->p_env->api_type);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
		dev->name,__func__,__LINE__, rc);
#endif
        return rc;

}  /*  end of claw_snd_conn_req */


/*-------------------------------------------------------------------*
*               claw_snd_disc                                        *
*                                                                    *
*--------------------------------------------------------------------*/

static int
claw_snd_disc(struct net_device *dev, struct clawctl * p_ctl)
{
        int rc;
        struct conncmd *  p_connect;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"snd_dsc");
#ifdef  DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable p_ctl",dev->name);
        dumpit((char *) p_ctl, sizeof(struct clawctl));
#endif
        p_connect=(struct conncmd *)&p_ctl->data;

        rc=claw_send_control(dev, DISCONNECT, p_ctl->linkid,
		p_ctl->correlator, 0,
                p_connect->host_name, p_connect->WS_name);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
		dev->name,__func__, __LINE__, rc);
#endif
        return rc;
}     /*   end of claw_snd_disc    */


/*-------------------------------------------------------------------*
*               claw_snd_sys_validate_rsp                            *
*                                                                    *
*--------------------------------------------------------------------*/

static int
claw_snd_sys_validate_rsp(struct net_device *dev,
	struct clawctl *p_ctl, __u32 return_code)
{
        struct claw_env *  p_env;
        struct claw_privbk *privptr;
        int    rc;

#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Enter\n",
		dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"chkresp");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable return_code = %d, dev =\n",
		dev->name, return_code);
        dumpit((char *) dev, sizeof(struct net_device));
        printk(KERN_INFO "%s: variable p_ctl =\n",dev->name);
        dumpit((char *) p_ctl, sizeof(struct clawctl));
#endif
        privptr = dev->priv;
        p_env=privptr->p_env;
        rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE,
		p_ctl->linkid,
		p_ctl->correlator,
                return_code,
		p_env->host_name,
		p_env->adapter_name  );
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
		dev->name,__func__,__LINE__, rc);
#endif
        return rc;
}     /*    end of claw_snd_sys_validate_rsp    */

/*-------------------------------------------------------------------*
*               claw_strt_conn_req                                   *
*                                                                    *
*--------------------------------------------------------------------*/

static int
claw_strt_conn_req(struct net_device *dev )
{
        int rc;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"conn_req");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s: variable dev =\n",dev->name);
        dumpit((char *) dev, sizeof(struct net_device));
#endif
        rc=claw_snd_conn_req(dev, 1);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d, rc = %d\n",
		dev->name,__func__,__LINE__, rc);
#endif
        return rc;
}    /*   end of claw_strt_conn_req   */



/*-------------------------------------------------------------------*
 *   claw_stats                                                      *
 *-------------------------------------------------------------------*/

static struct
net_device_stats *claw_stats(struct net_device *dev)
{
        struct claw_privbk *privptr;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"stats");
        privptr = dev->priv;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
        return &privptr->stats;
}     /*   end of claw_stats   */


/*-------------------------------------------------------------------*
*       unpack_read                                                  *
*                                                                    *
*--------------------------------------------------------------------*/
static void
unpack_read(struct net_device *dev )
{
        struct sk_buff *skb;
        struct claw_privbk *privptr;
	struct claw_env    *p_env;
        struct ccwbk 	*p_this_ccw;
        struct ccwbk 	*p_first_ccw;
        struct ccwbk 	*p_last_ccw;
	struct clawph 	*p_packh;
	void		*p_packd;
	struct clawctl 	*p_ctlrec=NULL;

        __u32	len_of_data;
	__u32	pack_off;
        __u8	link_num;
        __u8 	mtc_this_frm=0;
        __u32	bytes_to_mov;
        struct chbk *p_ch = NULL;
        int	i=0;
	int     p=0;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s enter  \n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(4,trace,"unpkread");
        p_first_ccw=NULL;
        p_last_ccw=NULL;
	p_packh=NULL;
	p_packd=NULL;
        privptr=dev->priv;
	p_env = privptr->p_env;
        p_this_ccw=privptr->p_read_active_first;
        i=0;
	while (p_this_ccw!=NULL && p_this_ccw->header.flag!=CLAW_PENDING) {
#ifdef IOTRACE
		printk(KERN_INFO "%s p_this_ccw \n",dev->name);
                dumpit((char*)p_this_ccw, sizeof(struct ccwbk));
                printk(KERN_INFO "%s Inbound p_this_ccw->p_buffer(64)"
			" pk=%d \n",dev->name,p_env->packing);
                dumpit((char *)p_this_ccw->p_buffer, 64 );
#endif
		pack_off = 0;
		p = 0;
		p_this_ccw->header.flag=CLAW_PENDING;
		privptr->p_read_active_first=p_this_ccw->next;
                p_this_ccw->next=NULL;
		p_packh = (struct clawph *)p_this_ccw->p_buffer;
		if ((p_env->packing == PACK_SEND) &&
		    (p_packh->len == 32)           &&
		    (p_packh->link_num == 0)) {   /* is it a packed ctl rec? */
			p_packh++;  /* peek past pack header */
			p_ctlrec = (struct clawctl *)p_packh;
			p_packh--;  /* un peek */
			if ((p_ctlrec->command == CONNECTION_RESPONSE) ||
		            (p_ctlrec->command == CONNECTION_CONFIRM))
				p_env->packing = DO_PACKED;
		}
		if (p_env->packing == DO_PACKED)
			link_num=p_packh->link_num;
		else
	                link_num=p_this_ccw->header.opcode / 8;
                if ((p_this_ccw->header.opcode & MORE_to_COME_FLAG)!=0) {
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: %s > More_to_come is ON\n",
			dev->name,__func__);
#endif
                        mtc_this_frm=1;
                        if (p_this_ccw->header.length!=
				privptr->p_env->read_size ) {
                                printk(KERN_INFO " %s: Invalid frame detected "
					"length is %02x\n" ,
                                        dev->name, p_this_ccw->header.length);
                        }
                }

                if (privptr->mtc_skipping) {
                        /*
                        *   We're in the mode of skipping past a
			*   multi-frame message
                        *   that we can't process for some reason or other.
                        *   The first frame without the More-To-Come flag is
			*   the last frame of the skipped message.
                        */
                        /*  in case of More-To-Come not set in this frame */
                        if (mtc_this_frm==0) {
                                privptr->mtc_skipping=0; /* Ok, the end */
                                privptr->mtc_logical_link=-1;
                        }
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s:%s goto next "
				"frame from MoretoComeSkip \n",
				dev->name,__func__);
#endif
                        goto NextFrame;
                }

                if (link_num==0) {
                        claw_process_control(dev, p_this_ccw);
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s:%s goto next "
				"frame from claw_process_control \n",
				dev->name,__func__);
#endif
			CLAW_DBF_TEXT(4,trace,"UnpkCntl");
                        goto NextFrame;
                }
unpack_next:
		if (p_env->packing == DO_PACKED) {
			if (pack_off > p_env->read_size)
				goto NextFrame;
			p_packd = p_this_ccw->p_buffer+pack_off;
			p_packh = (struct clawph *) p_packd;
			if ((p_packh->len == 0) || /* all done with this frame? */
			    (p_packh->flag != 0))
				goto NextFrame;
			bytes_to_mov = p_packh->len;
			pack_off += bytes_to_mov+sizeof(struct clawph);
			p++;
		} else {
                	bytes_to_mov=p_this_ccw->header.length;
		}
                if (privptr->mtc_logical_link<0) {
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: %s mtc_logical_link < 0  \n",
			dev->name,__func__);
#endif

                /*
                *  if More-To-Come is set in this frame then we don't know
                *  length of entire message, and hence have to allocate
		*  large buffer   */

                /*      We are starting a new envelope  */
                privptr->mtc_offset=0;
                        privptr->mtc_logical_link=link_num;
                }

                if (bytes_to_mov > (MAX_ENVELOPE_SIZE- privptr->mtc_offset) ) {
                        /*      error     */
#ifdef DEBUGMSG
                        printk(KERN_INFO "%s: %s > goto next "
				"frame from MoretoComeSkip \n",
				dev->name,
				__func__);
                        printk(KERN_INFO "      bytes_to_mov %d > (MAX_ENVELOPE_"
				"SIZE-privptr->mtc_offset %d)\n",
				bytes_to_mov,(MAX_ENVELOPE_SIZE- privptr->mtc_offset));
#endif
                        privptr->stats.rx_frame_errors++;
                        goto NextFrame;
                }
		if (p_env->packing == DO_PACKED) {
			memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
				p_packd+sizeof(struct clawph), bytes_to_mov);

		} else	{
                	memcpy( privptr->p_mtc_envelope+ privptr->mtc_offset,
                        	p_this_ccw->p_buffer, bytes_to_mov);
		}
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: %s() received data \n",
			dev->name,__func__);
		if (p_env->packing == DO_PACKED)
			dumpit((char *)p_packd+sizeof(struct clawph),32);
		else
	                dumpit((char *)p_this_ccw->p_buffer, 32);
		printk(KERN_INFO "%s: %s() bytelength %d \n",
			dev->name,__func__,bytes_to_mov);
#endif
                if (mtc_this_frm==0) {
                        len_of_data=privptr->mtc_offset+bytes_to_mov;
                        skb=dev_alloc_skb(len_of_data);
                        if (skb) {
                                memcpy(skb_put(skb,len_of_data),
					privptr->p_mtc_envelope,
					len_of_data);
                                skb->dev=dev;
				skb_reset_mac_header(skb);
                                skb->protocol=htons(ETH_P_IP);
                                skb->ip_summed=CHECKSUM_UNNECESSARY;
                                privptr->stats.rx_packets++;
				privptr->stats.rx_bytes+=len_of_data;
                                netif_rx(skb);
#ifdef DEBUGMSG
                                printk(KERN_INFO "%s: %s() netif_"
					"rx(skb) completed \n",
					dev->name,__func__);
#endif
                        }
                        else {
                                privptr->stats.rx_dropped++;
                                printk(KERN_WARNING "%s: %s() low on memory\n",
				dev->name,__func__);
                        }
                        privptr->mtc_offset=0;
                        privptr->mtc_logical_link=-1;
                }
                else {
                        privptr->mtc_offset+=bytes_to_mov;
                }
		if (p_env->packing == DO_PACKED)
			goto unpack_next;
NextFrame:
                /*
                *   Remove ThisCCWblock from active read queue, and add it
                *   to queue of free blocks to be reused.
                */
                i++;
                p_this_ccw->header.length=0xffff;
                p_this_ccw->header.opcode=0xff;
                /*
                *       add this one to the free queue for later reuse
                */
                if (p_first_ccw==NULL) {
                        p_first_ccw = p_this_ccw;
                }
                else {
                        p_last_ccw->next = p_this_ccw;
                }
                p_last_ccw = p_this_ccw;
                /*
                *       chain to next block on active read queue
                */
                p_this_ccw = privptr->p_read_active_first;
		CLAW_DBF_TEXT_(4,trace,"rxpkt %d",p);
        } /* end of while */

        /*      check validity                  */

#ifdef IOTRACE
        printk(KERN_INFO "%s:%s processed frame is %d \n",
		dev->name,__func__,i);
        printk(KERN_INFO "%s:%s  F:%lx L:%lx\n",
		dev->name,
		__func__,
		(unsigned long)p_first_ccw,
		(unsigned long)p_last_ccw);
#endif
	CLAW_DBF_TEXT_(4,trace,"rxfrm %d",i);
        add_claw_reads(dev, p_first_ccw, p_last_ccw);
        p_ch=&privptr->channel[READ];
        claw_strt_read(dev, LOCK_YES);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s: %s exit on line %d\n",
		dev->name, __func__, __LINE__);
#endif
        return;
}     /*  end of unpack_read   */

/*-------------------------------------------------------------------*
*       claw_strt_read                                               *
*                                                                    *
*--------------------------------------------------------------------*/
static void
claw_strt_read (struct net_device *dev, int lock )
{
        int        rc = 0;
        __u32      parm;
        unsigned long  saveflags = 0;
        struct claw_privbk *privptr=dev->priv;
        struct ccwbk*p_ccwbk;
        struct chbk *p_ch;
        struct clawh *p_clawh;
        p_ch=&privptr->channel[READ];

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter  \n",dev->name,__func__);
        printk(KERN_INFO "%s: variable lock = %d, dev =\n",dev->name, lock);
        dumpit((char *) dev, sizeof(struct net_device));
#endif
	CLAW_DBF_TEXT(4,trace,"StRdNter");
        p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
        p_clawh->flag=CLAW_IDLE;    /* 0x00 */

        if ((privptr->p_write_active_first!=NULL &&
             privptr->p_write_active_first->header.flag!=CLAW_PENDING) ||
            (privptr->p_read_active_first!=NULL &&
             privptr->p_read_active_first->header.flag!=CLAW_PENDING )) {
                p_clawh->flag=CLAW_BUSY;    /* 0xff */
        }
#ifdef DEBUGMSG
        printk(KERN_INFO "%s:%s state-%02x\n" ,
		dev->name,__func__, p_ch->claw_state);
#endif
        if (lock==LOCK_YES) {
                spin_lock_irqsave(get_ccwdev_lock(p_ch->cdev), saveflags);
        }
        if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
#ifdef DEBUGMSG
                printk(KERN_INFO "%s: HOT READ started in %s\n" ,
			dev->name,__func__);
                p_clawh=(struct clawh *)privptr->p_claw_signal_blk;
                dumpit((char *)&p_clawh->flag , 1);
#endif
		CLAW_DBF_TEXT(4,trace,"HotRead");
                p_ccwbk=privptr->p_read_active_first;
                parm = (unsigned long) p_ch;
                rc = ccw_device_start (p_ch->cdev, &p_ccwbk->read, parm,
				       0xff, 0);
                if (rc != 0) {
                        ccw_check_return_code(p_ch->cdev, rc);
                }
        }
	else {
#ifdef DEBUGMSG
		printk(KERN_INFO "%s: No READ started by %s() In progress\n" ,
			dev->name,__func__);
#endif
		CLAW_DBF_TEXT(2,trace,"ReadAct");
	}

        if (lock==LOCK_YES) {
                spin_unlock_irqrestore(get_ccwdev_lock(p_ch->cdev), saveflags);
        }
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif
	CLAW_DBF_TEXT(4,trace,"StRdExit");
        return;
}       /*    end of claw_strt_read    */

/*-------------------------------------------------------------------*
*       claw_strt_out_IO                                             *
*                                                                    *
*--------------------------------------------------------------------*/

static void
claw_strt_out_IO( struct net_device *dev )
{
        int             	rc = 0;
        unsigned long   	parm;
        struct claw_privbk 	*privptr;
        struct chbk     	*p_ch;
        struct ccwbk   	*p_first_ccw;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	if (!dev) {
		return;
	}
        privptr=(struct claw_privbk *)dev->priv;
        p_ch=&privptr->channel[WRITE];

#ifdef DEBUGMSG
        printk(KERN_INFO "%s:%s state-%02x\n" ,
		dev->name,__func__,p_ch->claw_state);
#endif
        CLAW_DBF_TEXT(4,trace,"strt_io");
        p_first_ccw=privptr->p_write_active_first;

        if (p_ch->claw_state == CLAW_STOP)
                return;
        if (p_first_ccw == NULL) {
#ifdef FUNCTRACE
                printk(KERN_INFO "%s:%s Exit on line %d\n",
			dev->name,__func__,__LINE__);
#endif
                return;
        }
        if (test_and_set_bit(0, (void *)&p_ch->IO_active) == 0) {
                parm = (unsigned long) p_ch;
#ifdef DEBUGMSG
		printk(KERN_INFO "%s:%s do_io \n" ,dev->name,__func__);
                dumpit((char *)p_first_ccw, sizeof(struct ccwbk));
#endif
		CLAW_DBF_TEXT(2,trace,"StWrtIO");
                rc = ccw_device_start (p_ch->cdev,&p_first_ccw->write, parm,
				       0xff, 0);
                if (rc != 0) {
                        ccw_check_return_code(p_ch->cdev, rc);
                }
        }
        dev->trans_start = jiffies;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__func__,__LINE__);
#endif

        return;
}       /*    end of claw_strt_out_IO    */

/*-------------------------------------------------------------------*
*       Free write buffers                                           *
*                                                                    *
*--------------------------------------------------------------------*/

static void
claw_free_wrt_buf( struct net_device *dev )
{

        struct claw_privbk *privptr=(struct claw_privbk *)dev->priv;
        struct ccwbk*p_first_ccw;
	struct ccwbk*p_last_ccw;
	struct ccwbk*p_this_ccw;
	struct ccwbk*p_next_ccw;
#ifdef IOTRACE
        struct ccwbk*p_buf;
#endif
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
        printk(KERN_INFO "%s: free count = %d  variable dev =\n",
		dev->name,privptr->write_free_count);
#endif
	CLAW_DBF_TEXT(4,trace,"freewrtb");
        /*  scan the write queue to free any completed write packets   */
        p_first_ccw=NULL;
        p_last_ccw=NULL;
#ifdef IOTRACE
        printk(KERN_INFO "%s:  Dump current CCW chain \n",dev->name  );
        p_buf=privptr->p_write_active_first;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
        if (p_buf==NULL) {
                printk(KERN_INFO "%s: privptr->p_write_"
			"active_first==NULL\n",dev->name  );
        }
        p_buf=(struct ccwbk*)privptr->p_end_ccw;
        dumpit((char *)p_buf, sizeof(struct endccw));
#endif
        p_this_ccw=privptr->p_write_active_first;
        while ( (p_this_ccw!=NULL) && (p_this_ccw->header.flag!=CLAW_PENDING))
        {
                p_next_ccw = p_this_ccw->next;
                if (((p_next_ccw!=NULL) &&
		     (p_next_ccw->header.flag!=CLAW_PENDING)) ||
                    ((p_this_ccw == privptr->p_write_active_last) &&
                     (p_this_ccw->header.flag!=CLAW_PENDING))) {
                        /* The next CCW is OK or this is  */
			/* the last CCW...free it   @A1A  */
                        privptr->p_write_active_first=p_this_ccw->next;
			p_this_ccw->header.flag=CLAW_PENDING;
                        p_this_ccw->next=privptr->p_write_free_chain;
			privptr->p_write_free_chain=p_this_ccw;
                        ++privptr->write_free_count;
			privptr->stats.tx_bytes+= p_this_ccw->write.count;
			p_this_ccw=privptr->p_write_active_first;
                        privptr->stats.tx_packets++;
                }
                else {
			break;
                }
        }
        if (privptr->write_free_count!=0) {
                claw_clearbit_busy(TB_NOBUFFER,dev);
        }
        /*   whole chain removed?   */
        if (privptr->p_write_active_first==NULL) {
                privptr->p_write_active_last=NULL;
#ifdef DEBUGMSG
                printk(KERN_INFO "%s:%s p_write_"
			"active_first==NULL\n",dev->name,__func__);
#endif
        }
#ifdef IOTRACE
        printk(KERN_INFO "%s: Dump arranged CCW chain \n",dev->name  );
        p_buf=privptr->p_write_active_first;
        while (p_buf!=NULL) {
                dumpit((char *)p_buf, sizeof(struct ccwbk));
                p_buf=p_buf->next;
        }
        if (p_buf==NULL) {
                printk(KERN_INFO "%s: privptr->p_write_active_"
			"first==NULL\n",dev->name  );
        }
        p_buf=(struct ccwbk*)privptr->p_end_ccw;
        dumpit((char *)p_buf, sizeof(struct endccw));
#endif

	CLAW_DBF_TEXT_(4,trace,"FWC=%d",privptr->write_free_count);
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d free_count =%d\n",
		dev->name,__func__, __LINE__,privptr->write_free_count);
#endif
        return;
}

/*-------------------------------------------------------------------*
*       claw free netdevice                                          *
*                                                                    *
*--------------------------------------------------------------------*/
static void
claw_free_netdevice(struct net_device * dev, int free_dev)
{
	struct claw_privbk *privptr;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"free_dev");

	if (!dev)
		return;
	CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
	privptr = dev->priv;
	if (dev->flags & IFF_RUNNING)
		claw_release(dev);
	if (privptr) {
		privptr->channel[READ].ndev = NULL;  /* say it's free */
	}
	dev->priv=NULL;
#ifdef MODULE
	if (free_dev) {
		free_netdev(dev);
	}
#endif
	CLAW_DBF_TEXT(2,setup,"feee_ok");
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit\n",dev->name,__func__);
#endif
}

/**
 * Claw init netdevice
 * Initialize everything of the net device except the name and the
 * channel structs.
 */
static void
claw_init_netdevice(struct net_device * dev)
{
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"init_dev");
	CLAW_DBF_TEXT_(2,setup,"%s",dev->name);
	if (!dev) {
        printk(KERN_WARNING "claw:%s BAD Device exit line %d\n",
		__func__,__LINE__);
		CLAW_DBF_TEXT(2,setup,"baddev");
		return;
	}
	dev->mtu = CLAW_DEFAULT_MTU_SIZE;
	dev->hard_start_xmit = claw_tx;
	dev->open = claw_open;
	dev->stop = claw_release;
	dev->get_stats = claw_stats;
	dev->change_mtu = claw_change_mtu;
	dev->hard_header_len = 0;
	dev->addr_len = 0;
	dev->type = ARPHRD_SLIP;
	dev->tx_queue_len = 1300;
	dev->flags = IFF_POINTOPOINT | IFF_NOARP;
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit\n",dev->name,__func__);
#endif
	CLAW_DBF_TEXT(2,setup,"initok");
	return;
}

/**
 * Init a new channel in the privptr->channel[i].
 *
 * @param cdev  The ccw_device to be added.
 *
 * @return 0 on success, !0 on error.
 */
static int
add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
{
	struct chbk *p_ch;
	struct ccw_dev_id dev_id;

#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Enter\n",cdev->dev.bus_id,__func__);
#endif
	CLAW_DBF_TEXT_(2,setup,"%s",cdev->dev.bus_id);
	privptr->channel[i].flag  = i+1;   /* Read is 1 Write is 2 */
	p_ch = &privptr->channel[i];
	p_ch->cdev = cdev;
	snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id);
	ccw_device_get_id(cdev, &dev_id);
	p_ch->devno = dev_id.devno;
	if ((p_ch->irb = kzalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) {
		printk(KERN_WARNING "%s Out of memory in %s for irb\n",
			p_ch->id,__func__);
#ifdef FUNCTRACE
        	printk(KERN_INFO "%s:%s Exit on line %d\n",
			p_ch->id,__func__,__LINE__);
#endif
		return -ENOMEM;
	}
#ifdef FUNCTRACE
        	printk(KERN_INFO "%s:%s Exit on line %d\n",
			cdev->dev.bus_id,__func__,__LINE__);
#endif
	return 0;
}


/**
 *
 * Setup an interface.
 *
 * @param cgdev  Device to be setup.
 *
 * @returns 0 on success, !0 on failure.
 */
static int
claw_new_device(struct ccwgroup_device *cgdev)
{
	struct claw_privbk *privptr;
	struct claw_env *p_env;
	struct net_device *dev;
	int ret;
	struct ccw_dev_id dev_id;

	pr_debug("%s() called\n", __func__);
	printk(KERN_INFO "claw: add for %s\n",cgdev->cdev[READ]->dev.bus_id);
	CLAW_DBF_TEXT(2,setup,"new_dev");
	privptr = cgdev->dev.driver_data;
	cgdev->cdev[READ]->dev.driver_data = privptr;
	cgdev->cdev[WRITE]->dev.driver_data = privptr;
	if (!privptr)
		return -ENODEV;
	p_env = privptr->p_env;
	ccw_device_get_id(cgdev->cdev[READ], &dev_id);
	p_env->devno[READ] = dev_id.devno;
	ccw_device_get_id(cgdev->cdev[WRITE], &dev_id);
	p_env->devno[WRITE] = dev_id.devno;
	ret = add_channel(cgdev->cdev[0],0,privptr);
	if (ret == 0)
		ret = add_channel(cgdev->cdev[1],1,privptr);
	if (ret != 0) {
			printk(KERN_WARNING
		 	"add channel failed "
				"with ret = %d\n", ret);
			goto out;
	}
	ret = ccw_device_set_online(cgdev->cdev[READ]);
	if (ret != 0) {
		printk(KERN_WARNING
		 "claw: ccw_device_set_online %s READ failed "
			"with ret = %d\n",cgdev->cdev[READ]->dev.bus_id,ret);
		goto out;
	}
	ret = ccw_device_set_online(cgdev->cdev[WRITE]);
	if (ret != 0) {
		printk(KERN_WARNING
		 "claw: ccw_device_set_online %s WRITE failed "
			"with ret = %d\n",cgdev->cdev[WRITE]->dev.bus_id, ret);
		goto out;
	}
	dev = alloc_netdev(0,"claw%d",claw_init_netdevice);
	if (!dev) {
		printk(KERN_WARNING "%s:alloc_netdev failed\n",__func__);
		goto out;
	}
	dev->priv = privptr;
	cgdev->dev.driver_data = privptr;
        cgdev->cdev[READ]->dev.driver_data = privptr;
        cgdev->cdev[WRITE]->dev.driver_data = privptr;
	/* sysfs magic */
        SET_NETDEV_DEV(dev, &cgdev->dev);
	if (register_netdev(dev) != 0) {
		claw_free_netdevice(dev, 1);
		CLAW_DBF_TEXT(2,trace,"regfail");
		goto out;
	}
	dev->flags &=~IFF_RUNNING;
	if (privptr->buffs_alloc == 0) {
	        ret=init_ccw_bk(dev);
		if (ret !=0) {
			printk(KERN_WARNING
			 "claw: init_ccw_bk failed with ret=%d\n", ret);
			unregister_netdev(dev);
			claw_free_netdevice(dev,1);
			CLAW_DBF_TEXT(2,trace,"ccwmem");
			goto out;
		}
	}
	privptr->channel[READ].ndev = dev;
	privptr->channel[WRITE].ndev = dev;
	privptr->p_env->ndev = dev;

	printk(KERN_INFO "%s:readsize=%d  writesize=%d "
		"readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
                dev->name, p_env->read_size,
		p_env->write_size, p_env->read_buffers,
                p_env->write_buffers, p_env->devno[READ],
		p_env->devno[WRITE]);
        printk(KERN_INFO "%s:host_name:%.8s, adapter_name "
		":%.8s api_type: %.8s\n",
                dev->name, p_env->host_name,
		p_env->adapter_name , p_env->api_type);
	return 0;
out:
	ccw_device_set_offline(cgdev->cdev[1]);
	ccw_device_set_offline(cgdev->cdev[0]);

	return -ENODEV;
}

static void
claw_purge_skb_queue(struct sk_buff_head *q)
{
        struct sk_buff *skb;

        CLAW_DBF_TEXT(4,trace,"purgque");

        while ((skb = skb_dequeue(q))) {
                atomic_dec(&skb->users);
                dev_kfree_skb_any(skb);
        }
}

/**
 * Shutdown an interface.
 *
 * @param cgdev  Device to be shut down.
 *
 * @returns 0 on success, !0 on failure.
 */
static int
claw_shutdown_device(struct ccwgroup_device *cgdev)
{
	struct claw_privbk *priv;
	struct net_device *ndev;
	int	ret;

	pr_debug("%s() called\n", __func__);
	CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
	priv = cgdev->dev.driver_data;
	if (!priv)
		return -ENODEV;
	ndev = priv->channel[READ].ndev;
	if (ndev) {
		/* Close the device */
		printk(KERN_INFO
			"%s: shuting down \n",ndev->name);
		if (ndev->flags & IFF_RUNNING)
			ret = claw_release(ndev);
		ndev->flags &=~IFF_RUNNING;
		unregister_netdev(ndev);
		ndev->priv = NULL;  /* cgdev data, not ndev's to free */
		claw_free_netdevice(ndev, 1);
		priv->channel[READ].ndev = NULL;
		priv->channel[WRITE].ndev = NULL;
		priv->p_env->ndev = NULL;
	}
	ccw_device_set_offline(cgdev->cdev[1]);
	ccw_device_set_offline(cgdev->cdev[0]);
	return 0;
}

static void
claw_remove_device(struct ccwgroup_device *cgdev)
{
	struct claw_privbk *priv;

	pr_debug("%s() called\n", __func__);
	CLAW_DBF_TEXT_(2,setup,"%s",cgdev->dev.bus_id);
	priv = cgdev->dev.driver_data;
	if (!priv) {
		printk(KERN_WARNING "claw: %s() no Priv exiting\n",__func__);
		return;
	}
	printk(KERN_INFO "claw: %s() called %s will be removed.\n",
			__func__,cgdev->cdev[0]->dev.bus_id);
	if (cgdev->state == CCWGROUP_ONLINE)
		claw_shutdown_device(cgdev);
	claw_remove_files(&cgdev->dev);
	kfree(priv->p_mtc_envelope);
	priv->p_mtc_envelope=NULL;
	kfree(priv->p_env);
	priv->p_env=NULL;
	kfree(priv->channel[0].irb);
	priv->channel[0].irb=NULL;
	kfree(priv->channel[1].irb);
	priv->channel[1].irb=NULL;
	kfree(priv);
	cgdev->dev.driver_data=NULL;
	cgdev->cdev[READ]->dev.driver_data = NULL;
	cgdev->cdev[WRITE]->dev.driver_data = NULL;
	put_device(&cgdev->dev);
}


/*
 * sysfs attributes
 */
static ssize_t
claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	return sprintf(buf, "%s\n",p_env->host_name);
}

static ssize_t
claw_hname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	if (count > MAX_NAME_LEN+1)
		return -EINVAL;
	memset(p_env->host_name, 0x20, MAX_NAME_LEN);
	strncpy(p_env->host_name,buf, count);
	p_env->host_name[count-1] = 0x20;  /* clear extra 0x0a */
	p_env->host_name[MAX_NAME_LEN] = 0x00;
	CLAW_DBF_TEXT(2,setup,"HstnSet");
        CLAW_DBF_TEXT_(2,setup,"%s",p_env->host_name);

	return count;
}

static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write);

static ssize_t
claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	return sprintf(buf, "%s\n",p_env->adapter_name);
}

static ssize_t
claw_adname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	if (count > MAX_NAME_LEN+1)
		return -EINVAL;
	memset(p_env->adapter_name, 0x20, MAX_NAME_LEN);
	strncpy(p_env->adapter_name,buf, count);
	p_env->adapter_name[count-1] = 0x20; /* clear extra 0x0a */
	p_env->adapter_name[MAX_NAME_LEN] = 0x00;
	CLAW_DBF_TEXT(2,setup,"AdnSet");
	CLAW_DBF_TEXT_(2,setup,"%s",p_env->adapter_name);

	return count;
}

static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write);

static ssize_t
claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	return sprintf(buf, "%s\n",
		       p_env->api_type);
}

static ssize_t
claw_apname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	if (count > MAX_NAME_LEN+1)
		return -EINVAL;
	memset(p_env->api_type, 0x20, MAX_NAME_LEN);
	strncpy(p_env->api_type,buf, count);
	p_env->api_type[count-1] = 0x20;  /* we get a loose 0x0a */
	p_env->api_type[MAX_NAME_LEN] = 0x00;
	if(strncmp(p_env->api_type,WS_APPL_NAME_PACKED,6) == 0) {
		p_env->read_size=DEF_PACK_BUFSIZE;
		p_env->write_size=DEF_PACK_BUFSIZE;
		p_env->packing=PACKING_ASK;
		CLAW_DBF_TEXT(2,setup,"PACKING");
	}
	else {
		p_env->packing=0;
		p_env->read_size=CLAW_FRAME_SIZE;
		p_env->write_size=CLAW_FRAME_SIZE;
		CLAW_DBF_TEXT(2,setup,"ApiSet");
	}
	CLAW_DBF_TEXT_(2,setup,"%s",p_env->api_type);
	return count;
}

static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write);

static ssize_t
claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct claw_privbk *priv;
	struct claw_env * p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	return sprintf(buf, "%d\n", p_env->write_buffers);
}

static ssize_t
claw_wbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;
	int nnn,max;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	sscanf(buf, "%i", &nnn);
	if (p_env->packing) {
		max = 64;
	}
	else {
		max = 512;
	}
	if ((nnn > max ) || (nnn < 2))
		return -EINVAL;
	p_env->write_buffers = nnn;
	CLAW_DBF_TEXT(2,setup,"Wbufset");
        CLAW_DBF_TEXT_(2,setup,"WB=%d",p_env->write_buffers);
	return count;
}

static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write);

static ssize_t
claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct claw_privbk *priv;
	struct claw_env *  p_env;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	return sprintf(buf, "%d\n", p_env->read_buffers);
}

static ssize_t
claw_rbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct claw_privbk *priv;
	struct claw_env *p_env;
	int nnn,max;

	priv = dev->driver_data;
	if (!priv)
		return -ENODEV;
	p_env = priv->p_env;
	sscanf(buf, "%i", &nnn);
	if (p_env->packing) {
		max = 64;
	}
	else {
		max = 512;
	}
	if ((nnn > max ) || (nnn < 2))
		return -EINVAL;
	p_env->read_buffers = nnn;
	CLAW_DBF_TEXT(2,setup,"Rbufset");
	CLAW_DBF_TEXT_(2,setup,"RB=%d",p_env->read_buffers);
	return count;
}

static DEVICE_ATTR(read_buffer, 0644, claw_rbuff_show, claw_rbuff_write);

static struct attribute *claw_attr[] = {
	&dev_attr_read_buffer.attr,
	&dev_attr_write_buffer.attr,
	&dev_attr_adapter_name.attr,
	&dev_attr_api_type.attr,
	&dev_attr_host_name.attr,
	NULL,
};

static struct attribute_group claw_attr_group = {
	.attrs = claw_attr,
};

static int
claw_add_files(struct device *dev)
{
	pr_debug("%s() called\n", __func__);
	CLAW_DBF_TEXT(2,setup,"add_file");
	return sysfs_create_group(&dev->kobj, &claw_attr_group);
}

static void
claw_remove_files(struct device *dev)
{
	pr_debug("%s() called\n", __func__);
	CLAW_DBF_TEXT(2,setup,"rem_file");
	sysfs_remove_group(&dev->kobj, &claw_attr_group);
}

/*--------------------------------------------------------------------*
*    claw_init  and cleanup                                           *
*---------------------------------------------------------------------*/

static void __exit
claw_cleanup(void)
{
	unregister_cu3088_discipline(&claw_group_driver);
	claw_unregister_debug_facility();
	printk(KERN_INFO "claw: Driver unloaded\n");

}

/**
 * Initialize module.
 * This is called just after the module is loaded.
 *
 * @return 0 on success, !0 on error.
 */
static int __init
claw_init(void)
{
	int ret = 0;
	printk(KERN_INFO "claw: starting driver\n");

#ifdef FUNCTRACE
	printk(KERN_INFO "claw: %s() enter \n",__func__);
#endif
	ret = claw_register_debug_facility();
	if (ret) {
		printk(KERN_WARNING "claw: %s() debug_register failed %d\n",
			__func__,ret);
		return ret;
	}
	CLAW_DBF_TEXT(2,setup,"init_mod");
	ret = register_cu3088_discipline(&claw_group_driver);
	if (ret) {
		claw_unregister_debug_facility();
		printk(KERN_WARNING "claw; %s() cu3088 register failed %d\n",
			__func__,ret);
	}
#ifdef FUNCTRACE
	printk(KERN_INFO "claw: %s() exit \n",__func__);
#endif
	return ret;
}

module_init(claw_init);
module_exit(claw_cleanup);



/*--------------------------------------------------------------------*
*    End of File                                                      *
*---------------------------------------------------------------------*/


