/*
 *  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",__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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",__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__, __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, __FUNCTION__, __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,
			__FUNCTION__,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,__FUNCTION__);
#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,
		__FUNCTION__, __LINE__);
#endif
                return -EINVAL;
        }
        dev->mtu = new_mtu;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",dev->name,
	__FUNCTION__, __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,__FUNCTION__);
#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,
			__FUNCTION__, __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,__FUNCTION__,__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,__FUNCTION__,__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",__FUNCTION__);
#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",__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__);
        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,__FUNCTION__,__LINE__);
#endif
        	return;
        }
#ifdef DEBUGMSG
        printk( KERN_INFO "%s:%s  state-%02x\n" ,
		dev->name,
		__FUNCTION__,
		p_ch->claw_state);
#endif
	claw_strt_out_IO( dev );
#ifdef FUNCTRACE
	printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__FUNCTION__,__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,__FUNCTION__);
        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,__FUNCTION__,__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,__FUNCTION__);
        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,__FUNCTION__,__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",__FUNCTION__,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",
	__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
                printk(KERN_INFO "%s:%s Read active first/last changed \n",
			dev->name,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
        dumpit((char *)p_last, sizeof(struct ccwbk));
        printk(KERN_INFO "%s:%s  dump p_end CCW BK \n",dev->name,__FUNCTION__);
        dumpit((char *)p_end, sizeof(struct endccw));

        printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__FUNCTION__);
        dumpit((char *)p_first, sizeof(struct ccwbk));
        printk(KERN_INFO "%s:%s Dump Active CCW chain \n",
		dev->name,__FUNCTION__);
        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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__);
        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= ( skb->len + privptr->p_env->write_size - 1) /
			( 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 ,__FUNCTION__,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,__FUNCTION__,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,__FUNCTION__);
        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,__FUNCTION__,
		(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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,
		ccw_blocks_required);
        printk(KERN_INFO "%s: %s() "
		"PAGE_SIZE=0x%x\n",
		dev->name,__FUNCTION__,
		(unsigned int)PAGE_SIZE);
        printk(KERN_INFO "%s: %s() > "
		"PAGE_MASK=0x%x\n",
		dev->name,__FUNCTION__,
		(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=
		(ccw_blocks_required+ccw_blocks_perpage -1) /
			 ccw_blocks_perpage;

#ifdef DEBUGMSG
        printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
		dev->name,__FUNCTION__,
		ccw_blocks_perpage);
        printk(KERN_INFO "%s: %s() > ccw_pages_required=%d\n",
		dev->name,__FUNCTION__,
		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= (privptr->p_env->read_buffers +
	    	claw_reads_perpage -1) / claw_reads_perpage;
         }
         else {       /* > or equal  */
            privptr->p_buff_pages_perread=
	    	(privptr->p_env->read_size + PAGE_SIZE - 1) / 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=
	    	(privptr->p_env->write_buffers + claw_writes_perpage -1) /
			claw_writes_perpage;

        }
        else {      /* >  or equal  */
            privptr->p_buff_pages_perwrite=
	    	 (privptr->p_env->read_size + PAGE_SIZE - 1) / 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,__FUNCTION__,
		claw_reads_perpage);
        }
        else {
            printk(KERN_INFO "%s: %s() pages_perread=%d\n",
	    	dev->name,__FUNCTION__,
		privptr->p_buff_pages_perread);
        }
        printk(KERN_INFO "%s: %s() read_pages=%d\n",
		dev->name,__FUNCTION__,
		claw_read_pages);
        if (privptr->p_env->write_size < PAGE_SIZE) {
            printk(KERN_INFO "%s: %s() writes_perpage=%d\n",
	    	dev->name,__FUNCTION__,
		claw_writes_perpage);
        }
        else {
            printk(KERN_INFO "%s: %s() pages_perwrite=%d\n",
	    	dev->name,__FUNCTION__,
		privptr->p_buff_pages_perwrite);
        }
        printk(KERN_INFO "%s: %s() write_pages=%d\n",
		dev->name,__FUNCTION__,
		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,__FUNCTION__,
				ccw_pages_required );
#ifdef FUNCTRACE
                        printk(KERN_INFO "%s: %s() > "
				"exit on line %d, rc = ENOMEM\n",
				dev->name,__FUNCTION__,
				 __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,__FUNCTION__);
#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,__FUNCTION__);
        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,__FUNCTION__);
#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,__FUNCTION__);
        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,__FUNCTION__);
#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,__FUNCTION__);
        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,__FUNCTION__,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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,
		    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,
				__FUNCTION__,
				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,
			__FUNCTION__,
			__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,__FUNCTION__);
        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,__FUNCTION__,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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__,
                                        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,__FUNCTION__,
					__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,__FUNCTION__);
        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,__FUNCTION__,__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",__FUNCTION__);
#endif
	CLAW_DBF_TEXT(4,trace,"proberr");
#ifdef DEBUGMSG
        printk(KERN_INFO "%s variable cgdev =\n",__FUNCTION__);
        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",
		 __FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__);
#ifdef DEBUG
                printk(KERN_INFO "%s:%s Exit, rc = ENOMEM\n",
			dev->name,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__, __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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#endif
	CLAW_DBF_TEXT(4,trace,"stats");
        privptr = dev->priv;
#ifdef FUNCTRACE
        printk(KERN_INFO "%s:%s Exit on line %d\n",
		dev->name,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
#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,
				__FUNCTION__);
                        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,__FUNCTION__);
		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,__FUNCTION__,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,__FUNCTION__);
#endif
                        }
                        else {
                                privptr->stats.rx_dropped++;
                                printk(KERN_WARNING "%s: %s() low on memory\n",
				dev->name,__FUNCTION__);
                        }
                        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,__FUNCTION__,i);
        printk(KERN_INFO "%s:%s  F:%lx L:%lx\n",
		dev->name,
		__FUNCTION__,
		(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, __FUNCTION__, __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,__FUNCTION__);
        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,__FUNCTION__, 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,__FUNCTION__);
                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,__FUNCTION__);
#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,__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__,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,__FUNCTION__,__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,__FUNCTION__);
                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,__FUNCTION__,__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,__FUNCTION__);
        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,__FUNCTION__);
#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,__FUNCTION__, __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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
#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",
		__FUNCTION__,__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,__FUNCTION__);
#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,__FUNCTION__);
#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,__FUNCTION__);
#ifdef FUNCTRACE
        	printk(KERN_INFO "%s:%s Exit on line %d\n",
			p_ch->id,__FUNCTION__,__LINE__);
#endif
		return -ENOMEM;
	}
#ifdef FUNCTRACE
        	printk(KERN_INFO "%s:%s Exit on line %d\n",
			cdev->dev.bus_id,__FUNCTION__,__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", __FUNCTION__);
	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",__FUNCTION__);
		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", __FUNCTION__);
	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", __FUNCTION__);
	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",__FUNCTION__);
		return;
	}
	printk(KERN_INFO "claw: %s() called %s will be removed.\n",
			__FUNCTION__,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", __FUNCTION__);
	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", __FUNCTION__);
	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",__FUNCTION__);
#endif
	ret = claw_register_debug_facility();
	if (ret) {
		printk(KERN_WARNING "claw: %s() debug_register failed %d\n",
			__FUNCTION__,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",
			__FUNCTION__,ret);
	}
#ifdef FUNCTRACE
        printk(KERN_INFO "claw: %s() exit \n",__FUNCTION__);
#endif
	return ret;
}

module_init(claw_init);
module_exit(claw_cleanup);



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


