2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver
5 * $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $
7 * Linux for zSeries version
8 * Copyright (C) 2002,2005 IBM Corporation
9 * Author(s) Original code written by:
10 * Kazuo Iimura (iimura@jp.ibm.com)
12 * Andy Richter (richtera@us.ibm.com)
13 * Marc Price (mwprice@us.ibm.com)
16 * group x.x.rrrr,x.x.wwww
20 * adapter_name aaaaaaaa
24 * group 0.0.0200 0.0.0201
33 * The device id is decided by the order entries
34 * are added to the group the first is claw0 the second claw1
37 * rrrr - the first of 2 consecutive device addresses used for the
39 * The specified address is always used as the input (Read)
40 * channel and the next address is used as the output channel.
42 * wwww - the second of 2 consecutive device addresses used for
44 * The specified address is always used as the output
45 * channel and the previous address is used as the input channel.
47 * read_buffer - specifies number of input buffers to allocate.
48 * write_buffer - specifies number of output buffers to allocate.
49 * host_name - host name
50 * adaptor_name - adaptor name
51 * api_type - API type TCPIP or API will be sent and expected
54 * Note the following requirements:
55 * 1) host_name must match the configured adapter_name on the remote side
56 * 2) adaptor_name must match the configured host name on the remote side
59 * 1.00 Initial release shipped
60 * 1.10 Changes for Buffer allocation
61 * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower
62 * 1.25 Added Packing support
64 #include <asm/bitops.h>
65 #include <asm/ccwdev.h>
66 #include <asm/ccwgroup.h>
67 #include <asm/debug.h>
68 #include <asm/idals.h>
71 #include <linux/ctype.h>
72 #include <linux/delay.h>
73 #include <linux/errno.h>
74 #include <linux/if_arp.h>
75 #include <linux/init.h>
76 #include <linux/interrupt.h>
78 #include <linux/kernel.h>
79 #include <linux/module.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/proc_fs.h>
83 #include <linux/sched.h>
84 #include <linux/signal.h>
85 #include <linux/skbuff.h>
86 #include <linux/slab.h>
87 #include <linux/string.h>
88 #include <linux/tcp.h>
89 #include <linux/timer.h>
90 #include <linux/types.h>
91 #include <linux/version.h>
96 MODULE_AUTHOR("Andy Richter <richtera@us.ibm.com>");
97 MODULE_DESCRIPTION("Linux for zSeries CLAW Driver\n" \
98 "Copyright 2000,2005 IBM Corporation\n");
99 MODULE_LICENSE("GPL");
101 /* Debugging is based on DEBUGMSG, IOTRACE, or FUNCTRACE options:
102 DEBUGMSG - Enables output of various debug messages in the code
103 IOTRACE - Enables output of CCW and other IO related traces
104 FUNCTRACE - Enables output of function entry/exit trace
105 Define any combination of above options to enable tracing
107 CLAW also uses the s390dbf file system see claw_trace and claw_setup
110 /* following enables tracing */
127 char debug_buffer
[255];
129 * Debug Facility Stuff
131 static debug_info_t
*claw_dbf_setup
;
132 static debug_info_t
*claw_dbf_trace
;
135 * CLAW Debug Facility functions
138 claw_unregister_debug_facility(void)
141 debug_unregister(claw_dbf_setup
);
143 debug_unregister(claw_dbf_trace
);
147 claw_register_debug_facility(void)
149 claw_dbf_setup
= debug_register("claw_setup", 2, 1, 8);
150 claw_dbf_trace
= debug_register("claw_trace", 2, 2, 8);
151 if (claw_dbf_setup
== NULL
|| claw_dbf_trace
== NULL
) {
152 printk(KERN_WARNING
"Not enough memory for debug facility.\n");
153 claw_unregister_debug_facility();
156 debug_register_view(claw_dbf_setup
, &debug_hex_ascii_view
);
157 debug_set_level(claw_dbf_setup
, 2);
158 debug_register_view(claw_dbf_trace
, &debug_hex_ascii_view
);
159 debug_set_level(claw_dbf_trace
, 2);
164 claw_set_busy(struct net_device
*dev
)
166 ((struct claw_privbk
*) dev
->priv
)->tbusy
=1;
171 claw_clear_busy(struct net_device
*dev
)
173 clear_bit(0, &(((struct claw_privbk
*) dev
->priv
)->tbusy
));
174 netif_wake_queue(dev
);
179 claw_check_busy(struct net_device
*dev
)
182 return ((struct claw_privbk
*) dev
->priv
)->tbusy
;
186 claw_setbit_busy(int nr
,struct net_device
*dev
)
188 netif_stop_queue(dev
);
189 set_bit(nr
, (void *)&(((struct claw_privbk
*)dev
->priv
)->tbusy
));
193 claw_clearbit_busy(int nr
,struct net_device
*dev
)
195 clear_bit(nr
,(void *)&(((struct claw_privbk
*)dev
->priv
)->tbusy
));
196 netif_wake_queue(dev
);
200 claw_test_and_setbit_busy(int nr
,struct net_device
*dev
)
202 netif_stop_queue(dev
);
203 return test_and_set_bit(nr
,
204 (void *)&(((struct claw_privbk
*) dev
->priv
)->tbusy
));
208 /* Functions for the DEV methods */
210 static int claw_probe(struct ccwgroup_device
*cgdev
);
211 static void claw_remove_device(struct ccwgroup_device
*cgdev
);
212 static void claw_purge_skb_queue(struct sk_buff_head
*q
);
213 static int claw_new_device(struct ccwgroup_device
*cgdev
);
214 static int claw_shutdown_device(struct ccwgroup_device
*cgdev
);
215 static int claw_tx(struct sk_buff
*skb
, struct net_device
*dev
);
216 static int claw_change_mtu( struct net_device
*dev
, int new_mtu
);
217 static int claw_open(struct net_device
*dev
);
218 static void claw_irq_handler(struct ccw_device
*cdev
,
219 unsigned long intparm
, struct irb
*irb
);
220 static void claw_irq_tasklet ( unsigned long data
);
221 static int claw_release(struct net_device
*dev
);
222 static void claw_write_retry ( struct chbk
* p_ch
);
223 static void claw_write_next ( struct chbk
* p_ch
);
224 static void claw_timer ( struct chbk
* p_ch
);
227 static int add_claw_reads(struct net_device
*dev
,
228 struct ccwbk
* p_first
, struct ccwbk
* p_last
);
229 static void inline ccw_check_return_code (struct ccw_device
*cdev
,
231 static void inline ccw_check_unit_check (struct chbk
* p_ch
,
232 unsigned char sense
);
233 static int find_link(struct net_device
*dev
, char *host_name
, char *ws_name
);
234 static int claw_hw_tx(struct sk_buff
*skb
, struct net_device
*dev
, long linkid
);
235 static int init_ccw_bk(struct net_device
*dev
);
236 static void probe_error( struct ccwgroup_device
*cgdev
);
237 static struct net_device_stats
*claw_stats(struct net_device
*dev
);
238 static int inline pages_to_order_of_mag(int num_of_pages
);
239 static struct sk_buff
*claw_pack_skb(struct claw_privbk
*privptr
);
241 static void dumpit (char *buf
, int len
);
243 /* sysfs Functions */
244 static ssize_t
claw_hname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
245 static ssize_t
claw_hname_write(struct device
*dev
, struct device_attribute
*attr
,
246 const char *buf
, size_t count
);
247 static ssize_t
claw_adname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
248 static ssize_t
claw_adname_write(struct device
*dev
, struct device_attribute
*attr
,
249 const char *buf
, size_t count
);
250 static ssize_t
claw_apname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
251 static ssize_t
claw_apname_write(struct device
*dev
, struct device_attribute
*attr
,
252 const char *buf
, size_t count
);
253 static ssize_t
claw_wbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
254 static ssize_t
claw_wbuff_write(struct device
*dev
, struct device_attribute
*attr
,
255 const char *buf
, size_t count
);
256 static ssize_t
claw_rbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
257 static ssize_t
claw_rbuff_write(struct device
*dev
, struct device_attribute
*attr
,
258 const char *buf
, size_t count
);
259 static int claw_add_files(struct device
*dev
);
260 static void claw_remove_files(struct device
*dev
);
262 /* Functions for System Validate */
263 static int claw_process_control( struct net_device
*dev
, struct ccwbk
* p_ccw
);
264 static int claw_send_control(struct net_device
*dev
, __u8 type
, __u8 link
,
265 __u8 correlator
, __u8 rc
, char *local_name
, char *remote_name
);
266 static int claw_snd_conn_req(struct net_device
*dev
, __u8 link
);
267 static int claw_snd_disc(struct net_device
*dev
, struct clawctl
* p_ctl
);
268 static int claw_snd_sys_validate_rsp(struct net_device
*dev
,
269 struct clawctl
* p_ctl
, __u32 return_code
);
270 static int claw_strt_conn_req(struct net_device
*dev
);
271 static void claw_strt_read ( struct net_device
*dev
, int lock
);
272 static void claw_strt_out_IO( struct net_device
*dev
);
273 static void claw_free_wrt_buf( struct net_device
*dev
);
275 /* Functions for unpack reads */
276 static void unpack_read (struct net_device
*dev
);
280 static struct ccwgroup_driver claw_group_driver
= {
281 .owner
= THIS_MODULE
,
284 .driver_id
= 0xC3D3C1E6,
286 .remove
= claw_remove_device
,
287 .set_online
= claw_new_device
,
288 .set_offline
= claw_shutdown_device
,
296 /*----------------------------------------------------------------*
298 * this function is called for each CLAW device. *
299 *----------------------------------------------------------------*/
301 claw_probe(struct ccwgroup_device
*cgdev
)
304 struct claw_privbk
*privptr
=NULL
;
307 printk(KERN_INFO
"%s Enter\n",__FUNCTION__
);
309 CLAW_DBF_TEXT(2,setup
,"probe");
310 if (!get_device(&cgdev
->dev
))
313 printk(KERN_INFO
"claw: variable cgdev =\n");
314 dumpit((char *)cgdev
, sizeof(struct ccwgroup_device
));
316 privptr
= kmalloc(sizeof(struct claw_privbk
), GFP_KERNEL
);
317 if (privptr
== NULL
) {
319 put_device(&cgdev
->dev
);
320 printk(KERN_WARNING
"Out of memory %s %s Exit Line %d \n",
321 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
322 CLAW_DBF_TEXT_(2,setup
,"probex%d",-ENOMEM
);
325 memset(privptr
,0x00,sizeof(struct claw_privbk
));
326 privptr
->p_mtc_envelope
= kmalloc( MAX_ENVELOPE_SIZE
, GFP_KERNEL
);
327 privptr
->p_env
= kmalloc(sizeof(struct claw_env
), GFP_KERNEL
);
328 if ((privptr
->p_mtc_envelope
==NULL
) || (privptr
->p_env
==NULL
)) {
330 put_device(&cgdev
->dev
);
331 printk(KERN_WARNING
"Out of memory %s %s Exit Line %d \n",
332 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
333 CLAW_DBF_TEXT_(2,setup
,"probex%d",-ENOMEM
);
336 memset(privptr
->p_mtc_envelope
, 0x00, MAX_ENVELOPE_SIZE
);
337 memset(privptr
->p_env
, 0x00, sizeof(struct claw_env
));
338 memcpy(privptr
->p_env
->adapter_name
,WS_NAME_NOT_DEF
,8);
339 memcpy(privptr
->p_env
->host_name
,WS_NAME_NOT_DEF
,8);
340 memcpy(privptr
->p_env
->api_type
,WS_NAME_NOT_DEF
,8);
341 privptr
->p_env
->packing
= 0;
342 privptr
->p_env
->write_buffers
= 5;
343 privptr
->p_env
->read_buffers
= 5;
344 privptr
->p_env
->read_size
= CLAW_FRAME_SIZE
;
345 privptr
->p_env
->write_size
= CLAW_FRAME_SIZE
;
346 rc
= claw_add_files(&cgdev
->dev
);
349 put_device(&cgdev
->dev
);
350 printk(KERN_WARNING
"add_files failed %s %s Exit Line %d \n",
351 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
352 CLAW_DBF_TEXT_(2,setup
,"probex%d",rc
);
355 printk(KERN_INFO
"claw: sysfs files added for %s\n",cgdev
->cdev
[0]->dev
.bus_id
);
356 privptr
->p_env
->p_priv
= privptr
;
357 cgdev
->cdev
[0]->handler
= claw_irq_handler
;
358 cgdev
->cdev
[1]->handler
= claw_irq_handler
;
359 cgdev
->dev
.driver_data
= privptr
;
361 printk(KERN_INFO
"claw:%s exit on line %d, "
362 "rc = 0\n",__FUNCTION__
,__LINE__
);
364 CLAW_DBF_TEXT(2,setup
,"prbext 0");
367 } /* end of claw_probe */
369 /*-------------------------------------------------------------------*
371 *-------------------------------------------------------------------*/
374 claw_tx(struct sk_buff
*skb
, struct net_device
*dev
)
377 struct claw_privbk
*privptr
=dev
->priv
;
378 unsigned long saveflags
;
382 printk(KERN_INFO
"%s:%s enter\n",dev
->name
,__FUNCTION__
);
384 CLAW_DBF_TEXT(4,trace
,"claw_tx");
385 p_ch
=&privptr
->channel
[WRITE
];
387 printk(KERN_WARNING
"%s: null pointer passed as sk_buffer\n",
389 privptr
->stats
.tx_dropped
++;
391 printk(KERN_INFO
"%s: %s() exit on line %d, rc = EIO\n",
392 dev
->name
,__FUNCTION__
, __LINE__
);
394 CLAW_DBF_TEXT_(2,trace
,"clawtx%d",-EIO
);
399 printk(KERN_INFO
"%s: variable sk_buff=\n",dev
->name
);
400 dumpit((char *) skb
, sizeof(struct sk_buff
));
401 printk(KERN_INFO
"%s: variable dev=\n",dev
->name
);
402 dumpit((char *) dev
, sizeof(struct net_device
));
404 spin_lock_irqsave(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
405 rc
=claw_hw_tx( skb
, dev
, 1 );
406 spin_unlock_irqrestore(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
408 printk(KERN_INFO
"%s:%s exit on line %d, rc = %d\n",
409 dev
->name
, __FUNCTION__
, __LINE__
, rc
);
411 CLAW_DBF_TEXT_(4,trace
,"clawtx%d",rc
);
413 } /* end of claw_tx */
415 /*------------------------------------------------------------------*
416 * pack the collect queue into an skb and return it *
417 * If not packing just return the top skb from the queue *
418 *------------------------------------------------------------------*/
420 static struct sk_buff
*
421 claw_pack_skb(struct claw_privbk
*privptr
)
423 struct sk_buff
*new_skb
,*held_skb
;
424 struct chbk
*p_ch
= &privptr
->channel
[WRITE
];
425 struct claw_env
*p_env
= privptr
->p_env
;
426 int pkt_cnt
,pk_ind
,so_far
;
428 new_skb
= NULL
; /* assume no dice */
430 CLAW_DBF_TEXT(4,trace
,"PackSKBe");
431 if (!skb_queue_empty(&p_ch
->collect_queue
)) {
433 held_skb
= skb_dequeue(&p_ch
->collect_queue
);
435 dev_kfree_skb_any(held_skb
);
438 if (p_env
->packing
!= DO_PACKED
)
440 /* get a new SKB we will pack at least one */
441 new_skb
= dev_alloc_skb(p_env
->write_size
);
442 if (new_skb
== NULL
) {
443 atomic_inc(&held_skb
->users
);
444 skb_queue_head(&p_ch
->collect_queue
,held_skb
);
447 /* we have packed packet and a place to put it */
450 new_skb
->cb
[1] = 'P'; /* every skb on queue has pack header */
451 while ((pk_ind
) && (held_skb
!= NULL
)) {
452 if (held_skb
->len
+so_far
<= p_env
->write_size
-8) {
453 memcpy(skb_put(new_skb
,held_skb
->len
),
454 held_skb
->data
,held_skb
->len
);
455 privptr
->stats
.tx_packets
++;
456 so_far
+= held_skb
->len
;
458 dev_kfree_skb_any(held_skb
);
459 held_skb
= skb_dequeue(&p_ch
->collect_queue
);
461 atomic_dec(&held_skb
->users
);
464 atomic_inc(&held_skb
->users
);
465 skb_queue_head(&p_ch
->collect_queue
,held_skb
);
469 printk(KERN_INFO
"%s: %s() Packed %d len %d\n",
471 __FUNCTION__
,pkt_cnt
,new_skb
->len
);
474 CLAW_DBF_TEXT(4,trace
,"PackSKBx");
478 /*-------------------------------------------------------------------*
481 *-------------------------------------------------------------------*/
484 claw_change_mtu(struct net_device
*dev
, int new_mtu
)
486 struct claw_privbk
*privptr
=dev
->priv
;
489 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
492 printk(KERN_INFO
"variable dev =\n");
493 dumpit((char *) dev
, sizeof(struct net_device
));
494 printk(KERN_INFO
"variable new_mtu = %d\n", new_mtu
);
496 CLAW_DBF_TEXT(4,trace
,"setmtu");
497 buff_size
= privptr
->p_env
->write_size
;
498 if ((new_mtu
< 60) || (new_mtu
> buff_size
)) {
500 printk(KERN_INFO
"%s:%s Exit on line %d, rc=EINVAL\n",
502 __FUNCTION__
, __LINE__
);
508 printk(KERN_INFO
"%s:%s Exit on line %d\n",dev
->name
,
509 __FUNCTION__
, __LINE__
);
512 } /* end of claw_change_mtu */
515 /*-------------------------------------------------------------------*
518 *-------------------------------------------------------------------*/
520 claw_open(struct net_device
*dev
)
525 unsigned long saveflags
=0;
527 struct claw_privbk
*privptr
;
528 DECLARE_WAITQUEUE(wait
, current
);
529 struct timer_list timer
;
533 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
535 CLAW_DBF_TEXT(4,trace
,"open");
536 if (!dev
| (dev
->name
[0] == 0x00)) {
537 CLAW_DBF_TEXT(2,trace
,"BadDev");
538 printk(KERN_WARNING
"claw: Bad device at open failing \n");
541 privptr
= (struct claw_privbk
*)dev
->priv
;
542 /* allocate and initialize CCW blocks */
543 if (privptr
->buffs_alloc
== 0) {
546 printk(KERN_INFO
"%s:%s Exit on line %d, rc=ENOMEM\n",
548 __FUNCTION__
, __LINE__
);
549 CLAW_DBF_TEXT(2,trace
,"openmem");
553 privptr
->system_validate_comp
=0;
554 privptr
->release_pend
=0;
555 if(strncmp(privptr
->p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
556 privptr
->p_env
->read_size
=DEF_PACK_BUFSIZE
;
557 privptr
->p_env
->write_size
=DEF_PACK_BUFSIZE
;
558 privptr
->p_env
->packing
=PACKING_ASK
;
560 privptr
->p_env
->packing
=0;
561 privptr
->p_env
->read_size
=CLAW_FRAME_SIZE
;
562 privptr
->p_env
->write_size
=CLAW_FRAME_SIZE
;
565 tasklet_init(&privptr
->channel
[READ
].tasklet
, claw_irq_tasklet
,
566 (unsigned long) &privptr
->channel
[READ
]);
567 for ( i
= 0; i
< 2; i
++) {
568 CLAW_DBF_TEXT_(2,trace
,"opn_ch%d",i
);
569 init_waitqueue_head(&privptr
->channel
[i
].wait
);
570 /* skb_queue_head_init(&p_ch->io_queue); */
573 &privptr
->channel
[WRITE
].collect_queue
);
574 privptr
->channel
[i
].flag_a
= 0;
575 privptr
->channel
[i
].IO_active
= 0;
576 privptr
->channel
[i
].flag
&= ~CLAW_TIMER
;
578 timer
.function
= (void *)claw_timer
;
579 timer
.data
= (unsigned long)(&privptr
->channel
[i
]);
580 timer
.expires
= jiffies
+ 15*HZ
;
582 spin_lock_irqsave(get_ccwdev_lock(
583 privptr
->channel
[i
].cdev
), saveflags
);
584 parm
= (unsigned long) &privptr
->channel
[i
];
585 privptr
->channel
[i
].claw_state
= CLAW_START_HALT_IO
;
587 add_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
588 rc
= ccw_device_halt(
589 (struct ccw_device
*)privptr
->channel
[i
].cdev
,parm
);
590 set_current_state(TASK_INTERRUPTIBLE
);
591 spin_unlock_irqrestore(
592 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
594 set_current_state(TASK_RUNNING
);
595 remove_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
597 ccw_check_return_code(privptr
->channel
[i
].cdev
, rc
);
598 if((privptr
->channel
[i
].flag
& CLAW_TIMER
) == 0x00)
601 if ((((privptr
->channel
[READ
].last_dstat
|
602 privptr
->channel
[WRITE
].last_dstat
) &
603 ~(DEV_STAT_CHN_END
| DEV_STAT_DEV_END
)) != 0x00) ||
604 (((privptr
->channel
[READ
].flag
|
605 privptr
->channel
[WRITE
].flag
) & CLAW_TIMER
) != 0x00)) {
607 printk(KERN_INFO
"%s: channel problems during open - read:"
608 " %02x - write: %02x\n",
610 privptr
->channel
[READ
].last_dstat
,
611 privptr
->channel
[WRITE
].last_dstat
);
613 printk(KERN_INFO
"%s: remote side is not ready\n", dev
->name
);
614 CLAW_DBF_TEXT(2,trace
,"notrdy");
616 for ( i
= 0; i
< 2; i
++) {
618 get_ccwdev_lock(privptr
->channel
[i
].cdev
),
620 parm
= (unsigned long) &privptr
->channel
[i
];
621 privptr
->channel
[i
].claw_state
= CLAW_STOP
;
622 rc
= ccw_device_halt(
623 (struct ccw_device
*)&privptr
->channel
[i
].cdev
,
625 spin_unlock_irqrestore(
626 get_ccwdev_lock(privptr
->channel
[i
].cdev
),
629 ccw_check_return_code(
630 privptr
->channel
[i
].cdev
, rc
);
633 free_pages((unsigned long)privptr
->p_buff_ccw
,
634 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
635 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
636 free_pages((unsigned long)privptr
->p_buff_read
,
637 (int)pages_to_order_of_mag(
638 privptr
->p_buff_read_num
));
641 p_buf
=privptr
->p_read_active_first
;
642 while (p_buf
!=NULL
) {
643 free_pages((unsigned long)p_buf
->p_buffer
,
644 (int)pages_to_order_of_mag(
645 privptr
->p_buff_pages_perread
));
649 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
650 free_pages((unsigned long)privptr
->p_buff_write
,
651 (int)pages_to_order_of_mag(
652 privptr
->p_buff_write_num
));
655 p_buf
=privptr
->p_write_active_first
;
656 while (p_buf
!=NULL
) {
657 free_pages((unsigned long)p_buf
->p_buffer
,
658 (int)pages_to_order_of_mag(
659 privptr
->p_buff_pages_perwrite
));
663 privptr
->buffs_alloc
= 0;
664 privptr
->channel
[READ
].flag
= 0x00;
665 privptr
->channel
[WRITE
].flag
= 0x00;
666 privptr
->p_buff_ccw
=NULL
;
667 privptr
->p_buff_read
=NULL
;
668 privptr
->p_buff_write
=NULL
;
669 claw_clear_busy(dev
);
671 printk(KERN_INFO
"%s:%s Exit on line %d, rc=EIO\n",
672 dev
->name
,__FUNCTION__
,__LINE__
);
674 CLAW_DBF_TEXT(2,trace
,"open EIO");
678 /* Send SystemValidate command */
680 claw_clear_busy(dev
);
683 printk(KERN_INFO
"%s:%s Exit on line %d, rc=0\n",
684 dev
->name
,__FUNCTION__
,__LINE__
);
686 CLAW_DBF_TEXT(4,trace
,"openok");
688 } /* end of claw_open */
690 /*-------------------------------------------------------------------*
694 *--------------------------------------------------------------------*/
696 claw_irq_handler(struct ccw_device
*cdev
,
697 unsigned long intparm
, struct irb
*irb
)
699 struct chbk
*p_ch
= NULL
;
700 struct claw_privbk
*privptr
= NULL
;
701 struct net_device
*dev
= NULL
;
702 struct claw_env
*p_env
;
703 struct chbk
*p_ch_r
=NULL
;
707 printk(KERN_INFO
"%s enter \n",__FUNCTION__
);
709 CLAW_DBF_TEXT(4,trace
,"clawirq");
710 /* Bypass all 'unsolicited interrupts' */
711 if (!cdev
->dev
.driver_data
) {
712 printk(KERN_WARNING
"claw: unsolicited interrupt for device:"
713 "%s received c-%02x d-%02x\n",
714 cdev
->dev
.bus_id
,irb
->scsw
.cstat
, irb
->scsw
.dstat
);
716 printk(KERN_INFO
"claw: %s() "
717 "exit on line %d\n",__FUNCTION__
,__LINE__
);
719 CLAW_DBF_TEXT(2,trace
,"badirq");
722 privptr
= (struct claw_privbk
*)cdev
->dev
.driver_data
;
724 /* Try to extract channel from driver data. */
725 if (privptr
->channel
[READ
].cdev
== cdev
)
726 p_ch
= &privptr
->channel
[READ
];
727 else if (privptr
->channel
[WRITE
].cdev
== cdev
)
728 p_ch
= &privptr
->channel
[WRITE
];
730 printk(KERN_WARNING
"claw: Can't determine channel for "
731 "interrupt, device %s\n", cdev
->dev
.bus_id
);
732 CLAW_DBF_TEXT(2,trace
,"badchan");
735 CLAW_DBF_TEXT_(4,trace
,"IRQCH=%d",p_ch
->flag
);
737 dev
= (struct net_device
*) (p_ch
->ndev
);
738 p_env
=privptr
->p_env
;
741 printk(KERN_INFO
"%s: interrupt for device: %04x "
742 "received c-%02x d-%02x state-%02x\n",
743 dev
->name
, p_ch
->devno
, irb
->scsw
.cstat
,
744 irb
->scsw
.dstat
, p_ch
->claw_state
);
747 /* Copy interruption response block. */
748 memcpy(p_ch
->irb
, irb
, sizeof(struct irb
));
750 /* Check for good subchannel return code, otherwise error message */
751 if (irb
->scsw
.cstat
&& !(irb
->scsw
.cstat
& SCHN_STAT_PCI
)) {
752 printk(KERN_INFO
"%s: subchannel check for device: %04x -"
753 " Sch Stat %02x Dev Stat %02x CPA - %04x\n",
754 dev
->name
, p_ch
->devno
,
755 irb
->scsw
.cstat
, irb
->scsw
.dstat
,irb
->scsw
.cpa
);
757 dumpit((char *)irb
,sizeof(struct irb
));
758 dumpit((char *)(unsigned long)irb
->scsw
.cpa
,
759 sizeof(struct ccw1
));
762 printk(KERN_INFO
"%s:%s Exit on line %d\n",
763 dev
->name
,__FUNCTION__
,__LINE__
);
765 CLAW_DBF_TEXT(2,trace
,"chanchk");
769 /* Check the reason-code of a unit check */
770 if (irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
771 ccw_check_unit_check(p_ch
, irb
->ecw
[0]);
774 /* State machine to bring the connection up, down and to restart */
775 p_ch
->last_dstat
= irb
->scsw
.dstat
;
777 switch (p_ch
->claw_state
) {
778 case CLAW_STOP
:/* HALT_IO by claw_release (halt sequence) */
780 printk(KERN_INFO
"%s: CLAW_STOP enter\n", dev
->name
);
782 if (!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
783 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
784 (p_ch
->irb
->scsw
.stctl
==
785 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
787 printk(KERN_INFO
"%s:%s Exit on line %d\n",
788 dev
->name
,__FUNCTION__
,__LINE__
);
792 wake_up(&p_ch
->wait
); /* wake up claw_release */
795 printk(KERN_INFO
"%s: CLAW_STOP exit\n", dev
->name
);
798 printk(KERN_INFO
"%s:%s Exit on line %d\n",
799 dev
->name
,__FUNCTION__
,__LINE__
);
801 CLAW_DBF_TEXT(4,trace
,"stop");
804 case CLAW_START_HALT_IO
: /* HALT_IO issued by claw_open */
806 printk(KERN_INFO
"%s: process CLAW_STAT_HALT_IO\n",
809 if (!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
810 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
811 (p_ch
->irb
->scsw
.stctl
==
812 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
814 printk(KERN_INFO
"%s:%s Exit on line %d\n",
815 dev
->name
,__FUNCTION__
,__LINE__
);
817 CLAW_DBF_TEXT(4,trace
,"haltio");
820 if (p_ch
->flag
== CLAW_READ
) {
821 p_ch
->claw_state
= CLAW_START_READ
;
822 wake_up(&p_ch
->wait
); /* wake claw_open (READ)*/
825 if (p_ch
->flag
== CLAW_WRITE
) {
826 p_ch
->claw_state
= CLAW_START_WRITE
;
827 /* send SYSTEM_VALIDATE */
828 claw_strt_read(dev
, LOCK_NO
);
829 claw_send_control(dev
,
830 SYSTEM_VALIDATE_REQUEST
,
833 p_env
->adapter_name
);
835 printk(KERN_WARNING
"claw: unsolicited "
836 "interrupt for device:"
837 "%s received c-%02x d-%02x\n",
844 printk(KERN_INFO
"%s: process CLAW_STAT_HALT_IO exit\n",
848 printk(KERN_INFO
"%s:%s Exit on line %d\n",
849 dev
->name
,__FUNCTION__
,__LINE__
);
851 CLAW_DBF_TEXT(4,trace
,"haltio");
853 case CLAW_START_READ
:
854 CLAW_DBF_TEXT(4,trace
,"ReadIRQ");
855 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
856 clear_bit(0, (void *)&p_ch
->IO_active
);
857 if ((p_ch
->irb
->ecw
[0] & 0x41) == 0x41 ||
858 (p_ch
->irb
->ecw
[0] & 0x40) == 0x40 ||
859 (p_ch
->irb
->ecw
[0]) == 0)
861 privptr
->stats
.rx_errors
++;
862 printk(KERN_INFO
"%s: Restart is "
863 "required after remote "
868 printk(KERN_INFO
"%s:%s Exit on line %d\n",
869 dev
->name
,__FUNCTION__
,__LINE__
);
871 CLAW_DBF_TEXT(4,trace
,"notrdy");
874 if ((p_ch
->irb
->scsw
.cstat
& SCHN_STAT_PCI
) &&
875 (p_ch
->irb
->scsw
.dstat
==0)) {
876 if (test_and_set_bit(CLAW_BH_ACTIVE
,
877 (void *)&p_ch
->flag_a
) == 0) {
878 tasklet_schedule(&p_ch
->tasklet
);
881 CLAW_DBF_TEXT(4,trace
,"PCINoBH");
884 printk(KERN_INFO
"%s:%s Exit on line %d\n",
885 dev
->name
,__FUNCTION__
,__LINE__
);
887 CLAW_DBF_TEXT(4,trace
,"PCI_read");
890 if(!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
891 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
892 (p_ch
->irb
->scsw
.stctl
==
893 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
895 printk(KERN_INFO
"%s:%s Exit on line %d\n",
896 dev
->name
,__FUNCTION__
,__LINE__
);
898 CLAW_DBF_TEXT(4,trace
,"SPend_rd");
901 clear_bit(0, (void *)&p_ch
->IO_active
);
902 claw_clearbit_busy(TB_RETRY
,dev
);
903 if (test_and_set_bit(CLAW_BH_ACTIVE
,
904 (void *)&p_ch
->flag_a
) == 0) {
905 tasklet_schedule(&p_ch
->tasklet
);
908 CLAW_DBF_TEXT(4,trace
,"RdBHAct");
912 printk(KERN_INFO
"%s: process CLAW_START_READ exit\n",
916 printk(KERN_INFO
"%s:%s Exit on line %d\n",
917 dev
->name
,__FUNCTION__
,__LINE__
);
919 CLAW_DBF_TEXT(4,trace
,"RdIRQXit");
921 case CLAW_START_WRITE
:
922 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
923 printk(KERN_INFO
"%s: Unit Check Occured in "
924 "write channel\n",dev
->name
);
925 clear_bit(0, (void *)&p_ch
->IO_active
);
926 if (p_ch
->irb
->ecw
[0] & 0x80 ) {
927 printk(KERN_INFO
"%s: Resetting Event "
928 "occurred:\n",dev
->name
);
929 init_timer(&p_ch
->timer
);
930 p_ch
->timer
.function
=
931 (void *)claw_write_retry
;
932 p_ch
->timer
.data
= (unsigned long)p_ch
;
933 p_ch
->timer
.expires
= jiffies
+ 10*HZ
;
934 add_timer(&p_ch
->timer
);
935 printk(KERN_INFO
"%s: write connection "
936 "restarting\n",dev
->name
);
939 printk(KERN_INFO
"%s:%s Exit on line %d\n",
940 dev
->name
,__FUNCTION__
,__LINE__
);
942 CLAW_DBF_TEXT(4,trace
,"rstrtwrt");
945 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_EXCEP
) {
946 clear_bit(0, (void *)&p_ch
->IO_active
);
947 printk(KERN_INFO
"%s: Unit Exception "
948 "Occured in write channel\n",
951 if(!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
952 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
953 (p_ch
->irb
->scsw
.stctl
==
954 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
956 printk(KERN_INFO
"%s:%s Exit on line %d\n",
957 dev
->name
,__FUNCTION__
,__LINE__
);
959 CLAW_DBF_TEXT(4,trace
,"writeUE");
962 clear_bit(0, (void *)&p_ch
->IO_active
);
963 if (claw_test_and_setbit_busy(TB_TX
,dev
)==0) {
964 claw_write_next(p_ch
);
965 claw_clearbit_busy(TB_TX
,dev
);
966 claw_clear_busy(dev
);
968 p_ch_r
=(struct chbk
*)&privptr
->channel
[READ
];
969 if (test_and_set_bit(CLAW_BH_ACTIVE
,
970 (void *)&p_ch_r
->flag_a
) == 0) {
971 tasklet_schedule(&p_ch_r
->tasklet
);
975 printk(KERN_INFO
"%s: process CLAW_START_WRITE exit\n",
979 printk(KERN_INFO
"%s:%s Exit on line %d\n",
980 dev
->name
,__FUNCTION__
,__LINE__
);
982 CLAW_DBF_TEXT(4,trace
,"StWtExit");
985 printk(KERN_WARNING
"%s: wrong selection code - irq "
986 "state=%d\n",dev
->name
,p_ch
->claw_state
);
988 printk(KERN_INFO
"%s:%s Exit on line %d\n",
989 dev
->name
,__FUNCTION__
,__LINE__
);
991 CLAW_DBF_TEXT(2,trace
,"badIRQ");
995 } /* end of claw_irq_handler */
998 /*-------------------------------------------------------------------*
1001 *--------------------------------------------------------------------*/
1003 claw_irq_tasklet ( unsigned long data
)
1006 struct net_device
*dev
;
1007 struct claw_privbk
* privptr
;
1009 p_ch
= (struct chbk
*) data
;
1010 dev
= (struct net_device
*)p_ch
->ndev
;
1012 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1015 printk(KERN_INFO
"%s: variable p_ch =\n",dev
->name
);
1016 dumpit((char *) p_ch
, sizeof(struct chbk
));
1018 CLAW_DBF_TEXT(4,trace
,"IRQtask");
1020 privptr
= (struct claw_privbk
*) dev
->priv
;
1023 printk(KERN_INFO
"%s: bh routine - state-%02x\n" ,
1024 dev
->name
, p_ch
->claw_state
);
1028 clear_bit(CLAW_BH_ACTIVE
, (void *)&p_ch
->flag_a
);
1029 CLAW_DBF_TEXT(4,trace
,"TskletXt");
1031 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1032 dev
->name
,__FUNCTION__
,__LINE__
);
1035 } /* end of claw_irq_bh */
1037 /*-------------------------------------------------------------------*
1040 *--------------------------------------------------------------------*/
1042 claw_release(struct net_device
*dev
)
1046 unsigned long saveflags
;
1048 struct claw_privbk
*privptr
;
1049 DECLARE_WAITQUEUE(wait
, current
);
1050 struct ccwbk
* p_this_ccw
;
1051 struct ccwbk
* p_buf
;
1055 privptr
= (struct claw_privbk
*) dev
->priv
;
1059 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1061 CLAW_DBF_TEXT(4,trace
,"release");
1063 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1064 dumpit((char *) dev
, sizeof(struct net_device
));
1065 printk(KERN_INFO
"Priv Buffalloc %d\n",privptr
->buffs_alloc
);
1066 printk(KERN_INFO
"Priv p_buff_ccw = %p\n",&privptr
->p_buff_ccw
);
1068 privptr
->release_pend
=1;
1069 claw_setbit_busy(TB_STOP
,dev
);
1070 for ( i
= 1; i
>=0 ; i
--) {
1072 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
1073 /* del_timer(&privptr->channel[READ].timer); */
1074 privptr
->channel
[i
].claw_state
= CLAW_STOP
;
1075 privptr
->channel
[i
].IO_active
= 0;
1076 parm
= (unsigned long) &privptr
->channel
[i
];
1078 claw_purge_skb_queue(
1079 &privptr
->channel
[WRITE
].collect_queue
);
1080 rc
= ccw_device_halt (privptr
->channel
[i
].cdev
, parm
);
1081 if (privptr
->system_validate_comp
==0x00) /* never opened? */
1082 init_waitqueue_head(&privptr
->channel
[i
].wait
);
1083 add_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
1084 set_current_state(TASK_INTERRUPTIBLE
);
1085 spin_unlock_irqrestore(
1086 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
1088 set_current_state(TASK_RUNNING
);
1089 remove_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
1091 ccw_check_return_code(privptr
->channel
[i
].cdev
, rc
);
1094 if (privptr
->pk_skb
!= NULL
) {
1095 dev_kfree_skb_any(privptr
->pk_skb
);
1096 privptr
->pk_skb
= NULL
;
1098 if(privptr
->buffs_alloc
!= 1) {
1100 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1101 dev
->name
,__FUNCTION__
,__LINE__
);
1103 CLAW_DBF_TEXT(4,trace
,"none2fre");
1106 CLAW_DBF_TEXT(4,trace
,"freebufs");
1107 if (privptr
->p_buff_ccw
!= NULL
) {
1108 free_pages((unsigned long)privptr
->p_buff_ccw
,
1109 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
1111 CLAW_DBF_TEXT(4,trace
,"freeread");
1112 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
1113 if (privptr
->p_buff_read
!= NULL
) {
1114 free_pages((unsigned long)privptr
->p_buff_read
,
1115 (int)pages_to_order_of_mag(privptr
->p_buff_read_num
));
1119 p_buf
=privptr
->p_read_active_first
;
1120 while (p_buf
!=NULL
) {
1121 free_pages((unsigned long)p_buf
->p_buffer
,
1122 (int)pages_to_order_of_mag(
1123 privptr
->p_buff_pages_perread
));
1127 CLAW_DBF_TEXT(4,trace
,"freewrit");
1128 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
1129 free_pages((unsigned long)privptr
->p_buff_write
,
1130 (int)pages_to_order_of_mag(privptr
->p_buff_write_num
));
1133 p_buf
=privptr
->p_write_active_first
;
1134 while (p_buf
!=NULL
) {
1135 free_pages((unsigned long)p_buf
->p_buffer
,
1136 (int)pages_to_order_of_mag(
1137 privptr
->p_buff_pages_perwrite
));
1141 CLAW_DBF_TEXT(4,trace
,"clearptr");
1142 privptr
->buffs_alloc
= 0;
1143 privptr
->p_buff_ccw
=NULL
;
1144 privptr
->p_buff_read
=NULL
;
1145 privptr
->p_buff_write
=NULL
;
1146 privptr
->system_validate_comp
=0;
1147 privptr
->release_pend
=0;
1148 /* Remove any writes that were pending and reset all reads */
1149 p_this_ccw
=privptr
->p_read_active_first
;
1150 while (p_this_ccw
!=NULL
) {
1151 p_this_ccw
->header
.length
=0xffff;
1152 p_this_ccw
->header
.opcode
=0xff;
1153 p_this_ccw
->header
.flag
=0x00;
1154 p_this_ccw
=p_this_ccw
->next
;
1157 while (privptr
->p_write_active_first
!=NULL
) {
1158 p_this_ccw
=privptr
->p_write_active_first
;
1159 p_this_ccw
->header
.flag
=CLAW_PENDING
;
1160 privptr
->p_write_active_first
=p_this_ccw
->next
;
1161 p_this_ccw
->next
=privptr
->p_write_free_chain
;
1162 privptr
->p_write_free_chain
=p_this_ccw
;
1163 ++privptr
->write_free_count
;
1165 privptr
->p_write_active_last
=NULL
;
1166 privptr
->mtc_logical_link
= -1;
1167 privptr
->mtc_skipping
= 1;
1168 privptr
->mtc_offset
=0;
1170 if (((privptr
->channel
[READ
].last_dstat
|
1171 privptr
->channel
[WRITE
].last_dstat
) &
1172 ~(DEV_STAT_CHN_END
| DEV_STAT_DEV_END
)) != 0x00) {
1173 printk(KERN_WARNING
"%s: channel problems during close - "
1174 "read: %02x - write: %02x\n",
1176 privptr
->channel
[READ
].last_dstat
,
1177 privptr
->channel
[WRITE
].last_dstat
);
1178 CLAW_DBF_TEXT(2,trace
,"badclose");
1181 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1182 dev
->name
,__FUNCTION__
,__LINE__
);
1184 CLAW_DBF_TEXT(4,trace
,"rlsexit");
1186 } /* end of claw_release */
1190 /*-------------------------------------------------------------------*
1191 * claw_write_retry *
1193 *--------------------------------------------------------------------*/
1196 claw_write_retry ( struct chbk
*p_ch
)
1199 struct net_device
*dev
=p_ch
->ndev
;
1203 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
1204 printk(KERN_INFO
"claw: variable p_ch =\n");
1205 dumpit((char *) p_ch
, sizeof(struct chbk
));
1207 CLAW_DBF_TEXT(4,trace
,"w_retry");
1208 if (p_ch
->claw_state
== CLAW_STOP
) {
1210 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1211 dev
->name
,__FUNCTION__
,__LINE__
);
1216 printk( KERN_INFO
"%s:%s state-%02x\n" ,
1221 claw_strt_out_IO( dev
);
1223 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1224 dev
->name
,__FUNCTION__
,__LINE__
);
1226 CLAW_DBF_TEXT(4,trace
,"rtry_xit");
1228 } /* end of claw_write_retry */
1231 /*-------------------------------------------------------------------*
1234 *--------------------------------------------------------------------*/
1237 claw_write_next ( struct chbk
* p_ch
)
1240 struct net_device
*dev
;
1241 struct claw_privbk
*privptr
=NULL
;
1242 struct sk_buff
*pk_skb
;
1246 printk(KERN_INFO
"%s:%s Enter \n",p_ch
->ndev
->name
,__FUNCTION__
);
1247 printk(KERN_INFO
"%s: variable p_ch =\n",p_ch
->ndev
->name
);
1248 dumpit((char *) p_ch
, sizeof(struct chbk
));
1250 CLAW_DBF_TEXT(4,trace
,"claw_wrt");
1251 if (p_ch
->claw_state
== CLAW_STOP
)
1253 dev
= (struct net_device
*) p_ch
->ndev
;
1254 privptr
= (struct claw_privbk
*) dev
->priv
;
1255 claw_free_wrt_buf( dev
);
1256 if ((privptr
->write_free_count
> 0) &&
1257 !skb_queue_empty(&p_ch
->collect_queue
)) {
1258 pk_skb
= claw_pack_skb(privptr
);
1259 while (pk_skb
!= NULL
) {
1260 rc
= claw_hw_tx( pk_skb
, dev
,1);
1261 if (privptr
->write_free_count
> 0) {
1262 pk_skb
= claw_pack_skb(privptr
);
1267 if (privptr
->p_write_active_first
!=NULL
) {
1268 claw_strt_out_IO(dev
);
1272 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1273 dev
->name
,__FUNCTION__
,__LINE__
);
1276 } /* end of claw_write_next */
1278 /*-------------------------------------------------------------------*
1281 *--------------------------------------------------------------------*/
1284 claw_timer ( struct chbk
* p_ch
)
1287 printk(KERN_INFO
"%s:%s Entry\n",p_ch
->ndev
->name
,__FUNCTION__
);
1288 printk(KERN_INFO
"%s: variable p_ch =\n",p_ch
->ndev
->name
);
1289 dumpit((char *) p_ch
, sizeof(struct chbk
));
1291 CLAW_DBF_TEXT(4,trace
,"timer");
1292 p_ch
->flag
|= CLAW_TIMER
;
1293 wake_up(&p_ch
->wait
);
1295 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1296 p_ch
->ndev
->name
,__FUNCTION__
,__LINE__
);
1299 } /* end of claw_timer */
1308 /*-------------------------------------------------------------------*
1310 * pages_to_order_of_mag *
1312 * takes a number of pages from 1 to 512 and returns the *
1313 * log(num_pages)/log(2) get_free_pages() needs a base 2 order *
1314 * of magnitude get_free_pages() has an upper order of 9 *
1315 *--------------------------------------------------------------------*/
1318 pages_to_order_of_mag(int num_of_pages
)
1320 int order_of_mag
=1; /* assume 2 pages */
1323 printk(KERN_INFO
"%s Enter pages = %d \n",__FUNCTION__
,num_of_pages
);
1325 CLAW_DBF_TEXT_(5,trace
,"pages%d",num_of_pages
);
1326 if (num_of_pages
== 1) {return 0; } /* magnitude of 0 = 1 page */
1327 /* 512 pages = 2Meg on 4k page systems */
1328 if (num_of_pages
>= 512) {return 9; }
1329 /* we have two or more pages order is at least 1 */
1330 for (nump
=2 ;nump
<= 512;nump
*=2) {
1331 if (num_of_pages
<= nump
)
1335 if (order_of_mag
> 9) { order_of_mag
= 9; } /* I know it's paranoid */
1337 printk(KERN_INFO
"%s Exit on line %d, order = %d\n",
1338 __FUNCTION__
,__LINE__
, order_of_mag
);
1340 CLAW_DBF_TEXT_(5,trace
,"mag%d",order_of_mag
);
1341 return order_of_mag
;
1344 /*-------------------------------------------------------------------*
1348 *--------------------------------------------------------------------*/
1350 add_claw_reads(struct net_device
*dev
, struct ccwbk
* p_first
,
1351 struct ccwbk
* p_last
)
1353 struct claw_privbk
*privptr
;
1354 struct ccw1 temp_ccw
;
1355 struct endccw
* p_end
;
1357 struct ccwbk
* p_buf
;
1360 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1363 printk(KERN_INFO
"dev\n");
1364 dumpit((char *) dev
, sizeof(struct net_device
));
1365 printk(KERN_INFO
"p_first\n");
1366 dumpit((char *) p_first
, sizeof(struct ccwbk
));
1367 printk(KERN_INFO
"p_last\n");
1368 dumpit((char *) p_last
, sizeof(struct ccwbk
));
1370 CLAW_DBF_TEXT(4,trace
,"addreads");
1371 privptr
= dev
->priv
;
1372 p_end
= privptr
->p_end_ccw
;
1374 /* first CCW and last CCW contains a new set of read channel programs
1375 * to apend the running channel programs
1377 if ( p_first
==NULL
) {
1379 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1380 dev
->name
,__FUNCTION__
,__LINE__
);
1382 CLAW_DBF_TEXT(4,trace
,"addexit");
1386 /* set up ending CCW sequence for this segment */
1388 p_end
->read1
=0x00; /* second ending CCW is now active */
1389 /* reset ending CCWs and setup TIC CCWs */
1390 p_end
->read2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1391 p_end
->read2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1392 p_last
->r_TIC_1
.cda
=(__u32
)__pa(&p_end
->read2_nop1
);
1393 p_last
->r_TIC_2
.cda
=(__u32
)__pa(&p_end
->read2_nop1
);
1394 p_end
->read2_nop2
.cda
=0;
1395 p_end
->read2_nop2
.count
=1;
1398 p_end
->read1
=0x01; /* first ending CCW is now active */
1399 /* reset ending CCWs and setup TIC CCWs */
1400 p_end
->read1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1401 p_end
->read1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1402 p_last
->r_TIC_1
.cda
= (__u32
)__pa(&p_end
->read1_nop1
);
1403 p_last
->r_TIC_2
.cda
= (__u32
)__pa(&p_end
->read1_nop1
);
1404 p_end
->read1_nop2
.cda
=0;
1405 p_end
->read1_nop2
.count
=1;
1408 if ( privptr
-> p_read_active_first
==NULL
) {
1410 printk(KERN_INFO
"%s:%s p_read_active_frist == NULL \n",
1411 dev
->name
,__FUNCTION__
);
1412 printk(KERN_INFO
"%s:%s Read active first/last changed \n",
1413 dev
->name
,__FUNCTION__
);
1415 privptr
-> p_read_active_first
= p_first
; /* set new first */
1416 privptr
-> p_read_active_last
= p_last
; /* set new last */
1421 printk(KERN_INFO
"%s:%s Read in progress \n",
1422 dev
->name
,__FUNCTION__
);
1424 /* set up TIC ccw */
1425 temp_ccw
.cda
= (__u32
)__pa(&p_first
->read
);
1428 temp_ccw
.cmd_code
= CCW_CLAW_CMD_TIC
;
1433 /* first set of CCW's is chained to the new read */
1434 /* chain, so the second set is chained to the active chain. */
1435 /* Therefore modify the second set to point to the new */
1436 /* read chain set up TIC CCWs */
1437 /* make sure we update the CCW so channel doesn't fetch it */
1438 /* when it's only half done */
1439 memcpy( &p_end
->read2_nop2
, &temp_ccw
,
1440 sizeof(struct ccw1
));
1441 privptr
->p_read_active_last
->r_TIC_1
.cda
=
1442 (__u32
)__pa(&p_first
->read
);
1443 privptr
->p_read_active_last
->r_TIC_2
.cda
=
1444 (__u32
)__pa(&p_first
->read
);
1447 /* make sure we update the CCW so channel doesn't */
1448 /* fetch it when it is only half done */
1449 memcpy( &p_end
->read1_nop2
, &temp_ccw
,
1450 sizeof(struct ccw1
));
1451 privptr
->p_read_active_last
->r_TIC_1
.cda
=
1452 (__u32
)__pa(&p_first
->read
);
1453 privptr
->p_read_active_last
->r_TIC_2
.cda
=
1454 (__u32
)__pa(&p_first
->read
);
1456 /* chain in new set of blocks */
1457 privptr
->p_read_active_last
->next
= p_first
;
1458 privptr
->p_read_active_last
=p_last
;
1459 } /* end of if ( privptr-> p_read_active_first ==NULL) */
1461 printk(KERN_INFO
"%s:%s dump p_last CCW BK \n",dev
->name
,__FUNCTION__
);
1462 dumpit((char *)p_last
, sizeof(struct ccwbk
));
1463 printk(KERN_INFO
"%s:%s dump p_end CCW BK \n",dev
->name
,__FUNCTION__
);
1464 dumpit((char *)p_end
, sizeof(struct endccw
));
1466 printk(KERN_INFO
"%s:%s dump p_first CCW BK \n",dev
->name
,__FUNCTION__
);
1467 dumpit((char *)p_first
, sizeof(struct ccwbk
));
1468 printk(KERN_INFO
"%s:%s Dump Active CCW chain \n",
1469 dev
->name
,__FUNCTION__
);
1470 p_buf
=privptr
->p_read_active_first
;
1471 while (p_buf
!=NULL
) {
1472 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
1477 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1478 dev
->name
,__FUNCTION__
,__LINE__
);
1480 CLAW_DBF_TEXT(4,trace
,"addexit");
1482 } /* end of add_claw_reads */
1484 /*-------------------------------------------------------------------*
1485 * ccw_check_return_code *
1487 *-------------------------------------------------------------------*/
1490 ccw_check_return_code(struct ccw_device
*cdev
, int return_code
)
1493 printk(KERN_INFO
"%s: %s() > enter \n",
1494 cdev
->dev
.bus_id
,__FUNCTION__
);
1496 CLAW_DBF_TEXT(4,trace
,"ccwret");
1498 printk(KERN_INFO
"variable cdev =\n");
1499 dumpit((char *) cdev
, sizeof(struct ccw_device
));
1500 printk(KERN_INFO
"variable return_code = %d\n",return_code
);
1502 if (return_code
!= 0) {
1503 switch (return_code
) {
1505 printk(KERN_INFO
"%s: Busy !\n",
1509 printk(KERN_EMERG
"%s: Missing device called "
1510 "for IO ENODEV\n", cdev
->dev
.bus_id
);
1513 printk(KERN_EMERG
"%s: Status pending... EIO \n",
1517 printk(KERN_EMERG
"%s: Invalid Dev State EINVAL \n",
1521 printk(KERN_EMERG
"%s: Unknown error in "
1522 "Do_IO %d\n",cdev
->dev
.bus_id
, return_code
);
1526 printk(KERN_INFO
"%s: %s() > exit on line %d\n",
1527 cdev
->dev
.bus_id
,__FUNCTION__
,__LINE__
);
1529 CLAW_DBF_TEXT(4,trace
,"ccwret");
1530 } /* end of ccw_check_return_code */
1532 /*-------------------------------------------------------------------*
1533 * ccw_check_unit_check *
1534 *--------------------------------------------------------------------*/
1537 ccw_check_unit_check(struct chbk
* p_ch
, unsigned char sense
)
1539 struct net_device
*dev
= p_ch
->ndev
;
1542 printk(KERN_INFO
"%s: %s() > enter\n",dev
->name
,__FUNCTION__
);
1545 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1546 dumpit((char *)dev
, sizeof(struct net_device
));
1547 printk(KERN_INFO
"%s: variable sense =\n",dev
->name
);
1548 dumpit((char *)&sense
, 2);
1550 CLAW_DBF_TEXT(4,trace
,"unitchek");
1552 printk(KERN_INFO
"%s: Unit Check with sense byte:0x%04x\n",
1557 printk(KERN_WARNING
"%s: Interface disconnect or "
1559 "occurred (remote side)\n", dev
->name
);
1562 printk(KERN_WARNING
"%s: System reset occured"
1563 " (remote side)\n", dev
->name
);
1566 else if (sense
& 0x20) {
1568 printk(KERN_WARNING
"%s: Data-streaming "
1569 "timeout)\n", dev
->name
);
1572 printk(KERN_WARNING
"%s: Data-transfer parity"
1573 " error\n", dev
->name
);
1576 else if (sense
& 0x10) {
1578 printk(KERN_WARNING
"%s: Hardware malfunction "
1579 "(remote side)\n", dev
->name
);
1582 printk(KERN_WARNING
"%s: read-data parity error "
1583 "(remote side)\n", dev
->name
);
1588 printk(KERN_INFO
"%s: %s() exit on line %d\n",
1589 dev
->name
,__FUNCTION__
,__LINE__
);
1591 } /* end of ccw_check_unit_check */
1595 /*-------------------------------------------------------------------*
1596 * Dump buffer format *
1598 *--------------------------------------------------------------------*/
1601 dumpit(char* buf
, int len
)
1604 __u32 ct
, sw
, rm
, dup
;
1606 char tbuf
[82], tdup
[82];
1607 #if (CONFIG_ARCH_S390X)
1613 char bhex
[82], duphex
[82];
1621 for ( ct
=0; ct
< len
; ct
++, ptr
++, rptr
++ ) {
1623 #if (CONFIG_ARCH_S390X)
1624 sprintf(addr
, "%16.16lX",(unsigned long)rptr
);
1626 sprintf(addr
, "%8.8X",(__u32
)rptr
);
1628 sprintf(boff
, "%4.4X", (__u32
)ct
);
1632 if ((sw
== 4) || (sw
== 12)) {
1638 #if (CONFIG_ARCH_S390X)
1639 sprintf(tbuf
,"%2.2lX", (unsigned long)*ptr
);
1641 sprintf(tbuf
,"%2.2X", (__u32
)*ptr
);
1645 if ((0!=isprint(*ptr
)) && (*ptr
>= 0x20)) {
1655 if ((strcmp(duphex
, bhex
)) !=0) {
1657 sprintf(tdup
,"Duplicate as above to"
1659 printk( KERN_INFO
" "
1660 " --- %s ---\n",tdup
);
1662 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1663 addr
, boff
, bhex
, basc
);
1665 strcpy(duphex
, bhex
);
1676 for ( ; rm
> 0; rm
--, sw
++ ) {
1677 if ((sw
==4) || (sw
==12)) strcat(bhex
, " ");
1678 if (sw
==8) strcat(bhex
, " ");
1683 sprintf(tdup
,"Duplicate as above to %s", addr
);
1684 printk( KERN_INFO
" --- %s ---\n",
1687 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1688 addr
, boff
, bhex
, basc
);
1692 sprintf(tdup
,"Duplicate as above to %s", addr
);
1693 printk( KERN_INFO
" --- %s ---\n",
1697 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1698 addr
, boff
, bhex
, basc
);
1703 } /* end of dumpit */
1706 /*-------------------------------------------------------------------*
1708 *--------------------------------------------------------------------*/
1710 find_link(struct net_device
*dev
, char *host_name
, char *ws_name
)
1712 struct claw_privbk
*privptr
;
1713 struct claw_env
*p_env
;
1717 printk(KERN_INFO
"%s:%s > enter \n",dev
->name
,__FUNCTION__
);
1719 CLAW_DBF_TEXT(2,setup
,"findlink");
1721 printk(KERN_INFO
"%s: variable dev = \n",dev
->name
);
1722 dumpit((char *) dev
, sizeof(struct net_device
));
1723 printk(KERN_INFO
"%s: variable host_name = %s\n",dev
->name
, host_name
);
1724 printk(KERN_INFO
"%s: variable ws_name = %s\n",dev
->name
, ws_name
);
1727 p_env
=privptr
->p_env
;
1728 switch (p_env
->packing
)
1731 if ((memcmp(WS_APPL_NAME_PACKED
, host_name
, 8)!=0) ||
1732 (memcmp(WS_APPL_NAME_PACKED
, ws_name
, 8)!=0 ))
1737 if ((memcmp(WS_APPL_NAME_IP_NAME
, host_name
, 8)!=0) ||
1738 (memcmp(WS_APPL_NAME_IP_NAME
, ws_name
, 8)!=0 ))
1742 if ((memcmp(HOST_APPL_NAME
, host_name
, 8)!=0) ||
1743 (memcmp(p_env
->api_type
, ws_name
, 8)!=0))
1749 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1750 dev
->name
,__FUNCTION__
,__LINE__
);
1753 } /* end of find_link */
1755 /*-------------------------------------------------------------------*
1759 *-------------------------------------------------------------------*/
1762 claw_hw_tx(struct sk_buff
*skb
, struct net_device
*dev
, long linkid
)
1765 struct claw_privbk
*privptr
;
1766 struct ccwbk
*p_this_ccw
;
1767 struct ccwbk
*p_first_ccw
;
1768 struct ccwbk
*p_last_ccw
;
1770 signed long len_of_data
;
1771 unsigned long bytesInThisBuffer
;
1772 unsigned char *pDataAddress
;
1773 struct endccw
*pEnd
;
1774 struct ccw1 tempCCW
;
1776 struct claw_env
*p_env
;
1778 struct clawph
*pk_head
;
1781 struct ccwbk
*p_buf
;
1784 printk(KERN_INFO
"%s: %s() > enter\n",dev
->name
,__FUNCTION__
);
1786 CLAW_DBF_TEXT(4,trace
,"hw_tx");
1788 printk(KERN_INFO
"%s: variable dev skb =\n",dev
->name
);
1789 dumpit((char *) skb
, sizeof(struct sk_buff
));
1790 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1791 dumpit((char *) dev
, sizeof(struct net_device
));
1792 printk(KERN_INFO
"%s: variable linkid = %ld\n",dev
->name
,linkid
);
1794 privptr
= (struct claw_privbk
*) (dev
->priv
);
1795 p_ch
=(struct chbk
*)&privptr
->channel
[WRITE
];
1796 p_env
=privptr
->p_env
;
1798 printk(KERN_INFO
"%s: %s() dump sk_buff \n",dev
->name
,__FUNCTION__
);
1799 dumpit((char *)skb
,sizeof(struct sk_buff
));
1801 claw_free_wrt_buf(dev
); /* Clean up free chain if posible */
1802 /* scan the write queue to free any completed write packets */
1805 if ((p_env
->packing
>= PACK_SEND
) &&
1806 (skb
->cb
[1] != 'P')) {
1807 skb_push(skb
,sizeof(struct clawph
));
1808 pk_head
=(struct clawph
*)skb
->data
;
1809 pk_head
->len
=skb
->len
-sizeof(struct clawph
);
1810 if (pk_head
->len
%4) {
1811 pk_head
->len
+= 4-(pk_head
->len
%4);
1812 skb_pad(skb
,4-(pk_head
->len
%4));
1813 skb_put(skb
,4-(pk_head
->len
%4));
1815 if (p_env
->packing
== DO_PACKED
)
1816 pk_head
->link_num
= linkid
;
1818 pk_head
->link_num
= 0;
1819 pk_head
->flag
= 0x00;
1824 if (claw_check_busy(dev
)) {
1825 if (privptr
->write_free_count
!=0) {
1826 claw_clear_busy(dev
);
1829 claw_strt_out_IO(dev
);
1830 claw_free_wrt_buf( dev
);
1831 if (privptr
->write_free_count
==0) {
1833 printk(KERN_INFO
"%s: "
1834 "(claw_check_busy) no free write "
1835 "buffers\n", dev
->name
);
1837 ch
= &privptr
->channel
[WRITE
];
1838 atomic_inc(&skb
->users
);
1839 skb_queue_tail(&ch
->collect_queue
, skb
);
1843 claw_clear_busy(dev
);
1848 if (claw_test_and_setbit_busy(TB_TX
,dev
)) { /* set to busy */
1850 printk(KERN_INFO
"%s: busy (claw_test_and_setbit_"
1851 "busy)\n", dev
->name
);
1853 ch
= &privptr
->channel
[WRITE
];
1854 atomic_inc(&skb
->users
);
1855 skb_queue_tail(&ch
->collect_queue
, skb
);
1856 claw_strt_out_IO(dev
);
1861 /* See how many write buffers are required to hold this data */
1862 numBuffers
= ( skb
->len
+ privptr
->p_env
->write_size
- 1) /
1863 ( privptr
->p_env
->write_size
);
1865 /* If that number of buffers isn't available, give up for now */
1866 if (privptr
->write_free_count
< numBuffers
||
1867 privptr
->p_write_free_chain
== NULL
) {
1869 claw_setbit_busy(TB_NOBUFFER
,dev
);
1872 printk(KERN_INFO
"%s: busy (claw_setbit_busy"
1873 "(TB_NOBUFFER))\n", dev
->name
);
1874 printk(KERN_INFO
" free_count: %d, numBuffers : %d\n",
1875 (int)privptr
->write_free_count
,(int) numBuffers
);
1877 ch
= &privptr
->channel
[WRITE
];
1878 atomic_inc(&skb
->users
);
1879 skb_queue_tail(&ch
->collect_queue
, skb
);
1880 CLAW_DBF_TEXT(2,trace
,"clawbusy");
1883 pDataAddress
=skb
->data
;
1884 len_of_data
=skb
->len
;
1886 while (len_of_data
> 0) {
1888 printk(KERN_INFO
"%s: %s() length-of-data is %ld \n",
1889 dev
->name
,__FUNCTION__
,len_of_data
);
1890 dumpit((char *)pDataAddress
,64);
1892 p_this_ccw
=privptr
->p_write_free_chain
; /* get a block */
1893 if (p_this_ccw
== NULL
) { /* lost the race */
1894 ch
= &privptr
->channel
[WRITE
];
1895 atomic_inc(&skb
->users
);
1896 skb_queue_tail(&ch
->collect_queue
, skb
);
1899 privptr
->p_write_free_chain
=p_this_ccw
->next
;
1900 p_this_ccw
->next
=NULL
;
1901 --privptr
->write_free_count
; /* -1 */
1902 bytesInThisBuffer
=len_of_data
;
1903 memcpy( p_this_ccw
->p_buffer
,pDataAddress
, bytesInThisBuffer
);
1904 len_of_data
-=bytesInThisBuffer
;
1905 pDataAddress
+=(unsigned long)bytesInThisBuffer
;
1906 /* setup write CCW */
1907 p_this_ccw
->write
.cmd_code
= (linkid
* 8) +1;
1908 if (len_of_data
>0) {
1909 p_this_ccw
->write
.cmd_code
+=MORE_to_COME_FLAG
;
1911 p_this_ccw
->write
.count
=bytesInThisBuffer
;
1912 /* now add to end of this chain */
1913 if (p_first_ccw
==NULL
) {
1914 p_first_ccw
=p_this_ccw
;
1916 if (p_last_ccw
!=NULL
) {
1917 p_last_ccw
->next
=p_this_ccw
;
1918 /* set up TIC ccws */
1919 p_last_ccw
->w_TIC_1
.cda
=
1920 (__u32
)__pa(&p_this_ccw
->write
);
1922 p_last_ccw
=p_this_ccw
; /* save new last block */
1924 printk(KERN_INFO
"%s: %s() > CCW and Buffer %ld bytes long \n",
1925 dev
->name
,__FUNCTION__
,bytesInThisBuffer
);
1926 dumpit((char *)p_this_ccw
, sizeof(struct ccwbk
));
1927 dumpit((char *)p_this_ccw
->p_buffer
, 64);
1931 /* FirstCCW and LastCCW now contain a new set of write channel
1932 * programs to append to the running channel program
1935 if (p_first_ccw
!=NULL
) {
1936 /* setup ending ccw sequence for this segment */
1937 pEnd
=privptr
->p_end_ccw
;
1939 pEnd
->write1
=0x00; /* second end ccw is now active */
1940 /* set up Tic CCWs */
1941 p_last_ccw
->w_TIC_1
.cda
=
1942 (__u32
)__pa(&pEnd
->write2_nop1
);
1943 pEnd
->write2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1944 pEnd
->write2_nop2
.flags
=
1945 CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1946 pEnd
->write2_nop2
.cda
=0;
1947 pEnd
->write2_nop2
.count
=1;
1949 else { /* end of if (pEnd->write1)*/
1950 pEnd
->write1
=0x01; /* first end ccw is now active */
1951 /* set up Tic CCWs */
1952 p_last_ccw
->w_TIC_1
.cda
=
1953 (__u32
)__pa(&pEnd
->write1_nop1
);
1954 pEnd
->write1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1955 pEnd
->write1_nop2
.flags
=
1956 CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1957 pEnd
->write1_nop2
.cda
=0;
1958 pEnd
->write1_nop2
.count
=1;
1959 } /* end if if (pEnd->write1) */
1962 if (privptr
->p_write_active_first
==NULL
) {
1963 privptr
->p_write_active_first
=p_first_ccw
;
1964 privptr
->p_write_active_last
=p_last_ccw
;
1968 /* set up Tic CCWs */
1970 tempCCW
.cda
=(__u32
)__pa(&p_first_ccw
->write
);
1973 tempCCW
.cmd_code
=CCW_CLAW_CMD_TIC
;
1978 * first set of ending CCW's is chained to the new write
1979 * chain, so the second set is chained to the active chain
1980 * Therefore modify the second set to point the new write chain.
1981 * make sure we update the CCW atomically
1982 * so channel does not fetch it when it's only half done
1984 memcpy( &pEnd
->write2_nop2
, &tempCCW
,
1985 sizeof(struct ccw1
));
1986 privptr
->p_write_active_last
->w_TIC_1
.cda
=
1987 (__u32
)__pa(&p_first_ccw
->write
);
1991 /*make sure we update the CCW atomically
1992 *so channel does not fetch it when it's only half done
1994 memcpy(&pEnd
->write1_nop2
, &tempCCW
,
1995 sizeof(struct ccw1
));
1996 privptr
->p_write_active_last
->w_TIC_1
.cda
=
1997 (__u32
)__pa(&p_first_ccw
->write
);
1999 } /* end if if (pEnd->write1) */
2001 privptr
->p_write_active_last
->next
=p_first_ccw
;
2002 privptr
->p_write_active_last
=p_last_ccw
;
2005 } /* endif (p_first_ccw!=NULL) */
2009 printk(KERN_INFO
"%s: %s() > Dump Active CCW chain \n",
2010 dev
->name
,__FUNCTION__
);
2011 p_buf
=privptr
->p_write_active_first
;
2012 while (p_buf
!=NULL
) {
2013 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2016 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
2017 dumpit((char *)p_buf
, sizeof(struct endccw
));
2019 dev_kfree_skb_any(skb
);
2026 claw_strt_out_IO(dev
);
2027 /* if write free count is zero , set NOBUFFER */
2029 printk(KERN_INFO
"%s: %s() > free_count is %d\n",
2030 dev
->name
,__FUNCTION__
,
2031 (int) privptr
->write_free_count
);
2033 if (privptr
->write_free_count
==0) {
2034 claw_setbit_busy(TB_NOBUFFER
,dev
);
2037 claw_clearbit_busy(TB_TX
,dev
);
2040 printk(KERN_INFO
"%s: %s() > exit on line %d, rc = %d \n",
2041 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
2044 } /* end of claw_hw_tx */
2046 /*-------------------------------------------------------------------*
2050 *--------------------------------------------------------------------*/
2053 init_ccw_bk(struct net_device
*dev
)
2056 __u32 ccw_blocks_required
;
2057 __u32 ccw_blocks_perpage
;
2058 __u32 ccw_pages_required
;
2059 __u32 claw_reads_perpage
=1;
2060 __u32 claw_read_pages
;
2061 __u32 claw_writes_perpage
=1;
2062 __u32 claw_write_pages
;
2064 struct ccwbk
*p_free_chain
;
2066 struct ccwbk
*p_last_CCWB
;
2067 struct ccwbk
*p_first_CCWB
;
2068 struct endccw
*p_endccw
=NULL
;
2069 addr_t real_address
;
2070 struct claw_privbk
*privptr
=dev
->priv
;
2071 struct clawh
*pClawH
=NULL
;
2072 addr_t real_TIC_address
;
2075 printk(KERN_INFO
"%s: %s() enter \n",dev
->name
,__FUNCTION__
);
2077 CLAW_DBF_TEXT(4,trace
,"init_ccw");
2079 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
2080 dumpit((char *) dev
, sizeof(struct net_device
));
2083 /* initialize statistics field */
2084 privptr
->active_link_ID
=0;
2085 /* initialize ccwbk pointers */
2086 privptr
->p_write_free_chain
=NULL
; /* pointer to free ccw chain*/
2087 privptr
->p_write_active_first
=NULL
; /* pointer to the first write ccw*/
2088 privptr
->p_write_active_last
=NULL
; /* pointer to the last write ccw*/
2089 privptr
->p_read_active_first
=NULL
; /* pointer to the first read ccw*/
2090 privptr
->p_read_active_last
=NULL
; /* pointer to the last read ccw */
2091 privptr
->p_end_ccw
=NULL
; /* pointer to ending ccw */
2092 privptr
->p_claw_signal_blk
=NULL
; /* pointer to signal block */
2093 privptr
->buffs_alloc
= 0;
2094 memset(&privptr
->end_ccw
, 0x00, sizeof(struct endccw
));
2095 memset(&privptr
->ctl_bk
, 0x00, sizeof(struct clawctl
));
2096 /* initialize free write ccwbk counter */
2097 privptr
->write_free_count
=0; /* number of free bufs on write chain */
2101 * We need 1 CCW block for each read buffer, 1 for each
2102 * write buffer, plus 1 for ClawSignalBlock
2104 ccw_blocks_required
=
2105 privptr
->p_env
->read_buffers
+privptr
->p_env
->write_buffers
+1;
2107 printk(KERN_INFO
"%s: %s() "
2108 "ccw_blocks_required=%d\n",
2109 dev
->name
,__FUNCTION__
,
2110 ccw_blocks_required
);
2111 printk(KERN_INFO
"%s: %s() "
2113 dev
->name
,__FUNCTION__
,
2114 (unsigned int)PAGE_SIZE
);
2115 printk(KERN_INFO
"%s: %s() > "
2117 dev
->name
,__FUNCTION__
,
2118 (unsigned int)PAGE_MASK
);
2121 * compute number of CCW blocks that will fit in a page
2123 ccw_blocks_perpage
= PAGE_SIZE
/ CCWBK_SIZE
;
2125 (ccw_blocks_required
+ccw_blocks_perpage
-1) /
2129 printk(KERN_INFO
"%s: %s() > ccw_blocks_perpage=%d\n",
2130 dev
->name
,__FUNCTION__
,
2131 ccw_blocks_perpage
);
2132 printk(KERN_INFO
"%s: %s() > ccw_pages_required=%d\n",
2133 dev
->name
,__FUNCTION__
,
2134 ccw_pages_required
);
2137 * read and write sizes are set by 2 constants in claw.h
2138 * 4k and 32k. Unpacked values other than 4k are not going to
2139 * provide good performance. With packing buffers support 32k
2142 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2143 claw_reads_perpage
= PAGE_SIZE
/ privptr
->p_env
->read_size
;
2144 claw_read_pages
= (privptr
->p_env
->read_buffers
+
2145 claw_reads_perpage
-1) / claw_reads_perpage
;
2147 else { /* > or equal */
2148 privptr
->p_buff_pages_perread
=
2149 (privptr
->p_env
->read_size
+ PAGE_SIZE
- 1) / PAGE_SIZE
;
2151 privptr
->p_env
->read_buffers
* privptr
->p_buff_pages_perread
;
2153 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2154 claw_writes_perpage
=
2155 PAGE_SIZE
/ privptr
->p_env
->write_size
;
2157 (privptr
->p_env
->write_buffers
+ claw_writes_perpage
-1) /
2158 claw_writes_perpage
;
2161 else { /* > or equal */
2162 privptr
->p_buff_pages_perwrite
=
2163 (privptr
->p_env
->read_size
+ PAGE_SIZE
- 1) / PAGE_SIZE
;
2165 privptr
->p_env
->write_buffers
* privptr
->p_buff_pages_perwrite
;
2168 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2169 printk(KERN_INFO
"%s: %s() reads_perpage=%d\n",
2170 dev
->name
,__FUNCTION__
,
2171 claw_reads_perpage
);
2174 printk(KERN_INFO
"%s: %s() pages_perread=%d\n",
2175 dev
->name
,__FUNCTION__
,
2176 privptr
->p_buff_pages_perread
);
2178 printk(KERN_INFO
"%s: %s() read_pages=%d\n",
2179 dev
->name
,__FUNCTION__
,
2181 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2182 printk(KERN_INFO
"%s: %s() writes_perpage=%d\n",
2183 dev
->name
,__FUNCTION__
,
2184 claw_writes_perpage
);
2187 printk(KERN_INFO
"%s: %s() pages_perwrite=%d\n",
2188 dev
->name
,__FUNCTION__
,
2189 privptr
->p_buff_pages_perwrite
);
2191 printk(KERN_INFO
"%s: %s() write_pages=%d\n",
2192 dev
->name
,__FUNCTION__
,
2198 * allocate ccw_pages_required
2200 if (privptr
->p_buff_ccw
==NULL
) {
2201 privptr
->p_buff_ccw
=
2202 (void *)__get_free_pages(__GFP_DMA
,
2203 (int)pages_to_order_of_mag(ccw_pages_required
));
2204 if (privptr
->p_buff_ccw
==NULL
) {
2205 printk(KERN_INFO
"%s: %s() "
2206 "__get_free_pages for CCWs failed : "
2208 dev
->name
,__FUNCTION__
,
2209 ccw_pages_required
);
2211 printk(KERN_INFO
"%s: %s() > "
2212 "exit on line %d, rc = ENOMEM\n",
2213 dev
->name
,__FUNCTION__
,
2218 privptr
->p_buff_ccw_num
=ccw_pages_required
;
2220 memset(privptr
->p_buff_ccw
, 0x00,
2221 privptr
->p_buff_ccw_num
* PAGE_SIZE
);
2224 * obtain ending ccw block address
2227 privptr
->p_end_ccw
= (struct endccw
*)&privptr
->end_ccw
;
2228 real_address
= (__u32
)__pa(privptr
->p_end_ccw
);
2229 /* Initialize ending CCW block */
2231 printk(KERN_INFO
"%s: %s() begin initialize ending CCW blocks\n",
2232 dev
->name
,__FUNCTION__
);
2235 p_endccw
=privptr
->p_end_ccw
;
2236 p_endccw
->real
=real_address
;
2237 p_endccw
->write1
=0x00;
2238 p_endccw
->read1
=0x00;
2241 p_endccw
->write1_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2242 p_endccw
->write1_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2243 p_endccw
->write1_nop1
.count
= 1;
2244 p_endccw
->write1_nop1
.cda
= 0;
2247 p_endccw
->write1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2248 p_endccw
->write1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2249 p_endccw
->write1_nop2
.count
= 1;
2250 p_endccw
->write1_nop2
.cda
= 0;
2253 p_endccw
->write2_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2254 p_endccw
->write2_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2255 p_endccw
->write2_nop1
.count
= 1;
2256 p_endccw
->write2_nop1
.cda
= 0;
2259 p_endccw
->write2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2260 p_endccw
->write2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2261 p_endccw
->write2_nop2
.count
= 1;
2262 p_endccw
->write2_nop2
.cda
= 0;
2265 p_endccw
->read1_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2266 p_endccw
->read1_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2267 p_endccw
->read1_nop1
.count
= 1;
2268 p_endccw
->read1_nop1
.cda
= 0;
2271 p_endccw
->read1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2272 p_endccw
->read1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2273 p_endccw
->read1_nop2
.count
= 1;
2274 p_endccw
->read1_nop2
.cda
= 0;
2277 p_endccw
->read2_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2278 p_endccw
->read2_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2279 p_endccw
->read2_nop1
.count
= 1;
2280 p_endccw
->read2_nop1
.cda
= 0;
2283 p_endccw
->read2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2284 p_endccw
->read2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2285 p_endccw
->read2_nop2
.count
= 1;
2286 p_endccw
->read2_nop2
.cda
= 0;
2289 printk(KERN_INFO
"%s: %s() dump claw ending CCW BK \n",
2290 dev
->name
,__FUNCTION__
);
2291 dumpit((char *)p_endccw
, sizeof(struct endccw
));
2295 * Build a chain of CCWs
2300 printk(KERN_INFO
"%s: %s() Begin build a chain of CCW buffer \n",
2301 dev
->name
,__FUNCTION__
);
2303 p_buff
=privptr
->p_buff_ccw
;
2306 for (i
=0 ; i
< ccw_pages_required
; i
++ ) {
2307 real_address
= (__u32
)__pa(p_buff
);
2309 for (j
=0 ; j
< ccw_blocks_perpage
; j
++) {
2310 p_buf
->next
= p_free_chain
;
2311 p_free_chain
= p_buf
;
2312 p_buf
->real
=(__u32
)__pa(p_buf
);
2318 printk(KERN_INFO
"%s: %s() "
2319 "End build a chain of CCW buffer \n",
2320 dev
->name
,__FUNCTION__
);
2322 while (p_buf
!=NULL
) {
2323 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2329 * Initialize ClawSignalBlock
2333 printk(KERN_INFO
"%s: %s() "
2334 "Begin initialize ClawSignalBlock \n",
2335 dev
->name
,__FUNCTION__
);
2337 if (privptr
->p_claw_signal_blk
==NULL
) {
2338 privptr
->p_claw_signal_blk
=p_free_chain
;
2339 p_free_chain
=p_free_chain
->next
;
2340 pClawH
=(struct clawh
*)privptr
->p_claw_signal_blk
;
2341 pClawH
->length
=0xffff;
2342 pClawH
->opcode
=0xff;
2343 pClawH
->flag
=CLAW_BUSY
;
2346 printk(KERN_INFO
"%s: %s() > End initialize "
2347 "ClawSignalBlock\n",
2348 dev
->name
,__FUNCTION__
);
2349 dumpit((char *)privptr
->p_claw_signal_blk
, sizeof(struct ccwbk
));
2353 * allocate write_pages_required and add to free chain
2355 if (privptr
->p_buff_write
==NULL
) {
2356 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2357 privptr
->p_buff_write
=
2358 (void *)__get_free_pages(__GFP_DMA
,
2359 (int)pages_to_order_of_mag(claw_write_pages
));
2360 if (privptr
->p_buff_write
==NULL
) {
2361 printk(KERN_INFO
"%s: %s() __get_free_pages for write"
2362 " bufs failed : get is for %d pages\n",
2363 dev
->name
,__FUNCTION__
,claw_write_pages
);
2364 free_pages((unsigned long)privptr
->p_buff_ccw
,
2365 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
2366 privptr
->p_buff_ccw
=NULL
;
2368 printk(KERN_INFO
"%s: %s() > exit on line %d,"
2370 dev
->name
,__FUNCTION__
,__LINE__
);
2375 * Build CLAW write free chain
2379 memset(privptr
->p_buff_write
, 0x00,
2380 ccw_pages_required
* PAGE_SIZE
);
2382 printk(KERN_INFO
"%s: %s() Begin build claw write free "
2383 "chain \n",dev
->name
,__FUNCTION__
);
2385 privptr
->p_write_free_chain
=NULL
;
2387 p_buff
=privptr
->p_buff_write
;
2389 for (i
=0 ; i
< privptr
->p_env
->write_buffers
; i
++) {
2390 p_buf
= p_free_chain
; /* get a CCW */
2391 p_free_chain
= p_buf
->next
;
2392 p_buf
->next
=privptr
->p_write_free_chain
;
2393 privptr
->p_write_free_chain
= p_buf
;
2394 p_buf
-> p_buffer
= (struct clawbuf
*)p_buff
;
2395 p_buf
-> write
.cda
= (__u32
)__pa(p_buff
);
2396 p_buf
-> write
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2397 p_buf
-> w_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2398 p_buf
-> w_read_FF
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2399 p_buf
-> w_read_FF
.count
= 1;
2400 p_buf
-> w_read_FF
.cda
=
2401 (__u32
)__pa(&p_buf
-> header
.flag
);
2402 p_buf
-> w_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2403 p_buf
-> w_TIC_1
.flags
= 0;
2404 p_buf
-> w_TIC_1
.count
= 0;
2406 if (((unsigned long)p_buff
+privptr
->p_env
->write_size
) >=
2407 ((unsigned long)(p_buff
+2*
2408 (privptr
->p_env
->write_size
) -1) & PAGE_MASK
)) {
2409 p_buff
= p_buff
+privptr
->p_env
->write_size
;
2413 else /* Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
2415 privptr
->p_write_free_chain
=NULL
;
2416 for (i
= 0; i
< privptr
->p_env
->write_buffers
; i
++) {
2417 p_buff
=(void *)__get_free_pages(__GFP_DMA
,
2418 (int)pages_to_order_of_mag(
2419 privptr
->p_buff_pages_perwrite
) );
2421 printk(KERN_INFO
"%s:%s __get_free_pages "
2422 "for writes buf: get for %d pages\n",
2423 dev
->name
,__FUNCTION__
,
2424 privptr
->p_buff_pages_perwrite
);
2427 printk(KERN_INFO
"%s:%s __get_free_pages"
2428 "for writes buf failed : get is for %d pages\n",
2431 privptr
->p_buff_pages_perwrite
);
2432 free_pages((unsigned long)privptr
->p_buff_ccw
,
2433 (int)pages_to_order_of_mag(
2434 privptr
->p_buff_ccw_num
));
2435 privptr
->p_buff_ccw
=NULL
;
2436 p_buf
=privptr
->p_buff_write
;
2437 while (p_buf
!=NULL
) {
2438 free_pages((unsigned long)
2440 (int)pages_to_order_of_mag(
2441 privptr
->p_buff_pages_perwrite
));
2445 printk(KERN_INFO
"%s: %s exit on line %d, rc = ENOMEM\n",
2451 } /* Error on get_pages */
2452 memset(p_buff
, 0x00, privptr
->p_env
->write_size
);
2453 p_buf
= p_free_chain
;
2454 p_free_chain
= p_buf
->next
;
2455 p_buf
->next
= privptr
->p_write_free_chain
;
2456 privptr
->p_write_free_chain
= p_buf
;
2457 privptr
->p_buff_write
= p_buf
;
2458 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2459 p_buf
-> write
.cda
= (__u32
)__pa(p_buff
);
2460 p_buf
-> write
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2461 p_buf
-> w_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2462 p_buf
-> w_read_FF
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2463 p_buf
-> w_read_FF
.count
= 1;
2464 p_buf
-> w_read_FF
.cda
=
2465 (__u32
)__pa(&p_buf
-> header
.flag
);
2466 p_buf
-> w_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2467 p_buf
-> w_TIC_1
.flags
= 0;
2468 p_buf
-> w_TIC_1
.count
= 0;
2469 } /* for all write_buffers */
2471 } /* else buffers are PAGE_SIZE or bigger */
2474 privptr
->p_buff_write_num
=claw_write_pages
;
2475 privptr
->write_free_count
=privptr
->p_env
->write_buffers
;
2479 printk(KERN_INFO
"%s:%s End build claw write free chain \n",
2480 dev
->name
,__FUNCTION__
);
2481 p_buf
=privptr
->p_write_free_chain
;
2482 while (p_buf
!=NULL
) {
2483 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2488 * allocate read_pages_required and chain to free chain
2490 if (privptr
->p_buff_read
==NULL
) {
2491 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2492 privptr
->p_buff_read
=
2493 (void *)__get_free_pages(__GFP_DMA
,
2494 (int)pages_to_order_of_mag(claw_read_pages
) );
2495 if (privptr
->p_buff_read
==NULL
) {
2496 printk(KERN_INFO
"%s: %s() "
2497 "__get_free_pages for read buf failed : "
2498 "get is for %d pages\n",
2499 dev
->name
,__FUNCTION__
,claw_read_pages
);
2500 free_pages((unsigned long)privptr
->p_buff_ccw
,
2501 (int)pages_to_order_of_mag(
2502 privptr
->p_buff_ccw_num
));
2503 /* free the write pages size is < page size */
2504 free_pages((unsigned long)privptr
->p_buff_write
,
2505 (int)pages_to_order_of_mag(
2506 privptr
->p_buff_write_num
));
2507 privptr
->p_buff_ccw
=NULL
;
2508 privptr
->p_buff_write
=NULL
;
2510 printk(KERN_INFO
"%s: %s() > exit on line %d, rc ="
2511 " ENOMEM\n",dev
->name
,__FUNCTION__
,__LINE__
);
2515 memset(privptr
->p_buff_read
, 0x00, claw_read_pages
* PAGE_SIZE
);
2516 privptr
->p_buff_read_num
=claw_read_pages
;
2518 * Build CLAW read free chain
2522 printk(KERN_INFO
"%s: %s() Begin build claw read free chain \n",
2523 dev
->name
,__FUNCTION__
);
2525 p_buff
=privptr
->p_buff_read
;
2526 for (i
=0 ; i
< privptr
->p_env
->read_buffers
; i
++) {
2527 p_buf
= p_free_chain
;
2528 p_free_chain
= p_buf
->next
;
2530 if (p_last_CCWB
==NULL
) {
2536 p_buf
->next
=p_first_CCWB
;
2538 (__u32
)__pa(&p_first_CCWB
-> read
);
2543 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2544 /* initialize read command */
2545 p_buf
-> read
.cmd_code
= CCW_CLAW_CMD_READ
;
2546 p_buf
-> read
.cda
= (__u32
)__pa(p_buff
);
2547 p_buf
-> read
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2548 p_buf
-> read
.count
= privptr
->p_env
->read_size
;
2550 /* initialize read_h command */
2551 p_buf
-> read_h
.cmd_code
= CCW_CLAW_CMD_READHEADER
;
2552 p_buf
-> read_h
.cda
=
2553 (__u32
)__pa(&(p_buf
->header
));
2554 p_buf
-> read_h
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2555 p_buf
-> read_h
.count
= sizeof(struct clawh
);
2557 /* initialize Signal command */
2558 p_buf
-> signal
.cmd_code
= CCW_CLAW_CMD_SIGNAL_SMOD
;
2559 p_buf
-> signal
.cda
=
2560 (__u32
)__pa(&(pClawH
->flag
));
2561 p_buf
-> signal
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2562 p_buf
-> signal
.count
= 1;
2564 /* initialize r_TIC_1 command */
2565 p_buf
-> r_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2566 p_buf
-> r_TIC_1
.cda
= (__u32
)real_TIC_address
;
2567 p_buf
-> r_TIC_1
.flags
= 0;
2568 p_buf
-> r_TIC_1
.count
= 0;
2570 /* initialize r_read_FF command */
2571 p_buf
-> r_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2572 p_buf
-> r_read_FF
.cda
=
2573 (__u32
)__pa(&(pClawH
->flag
));
2574 p_buf
-> r_read_FF
.flags
=
2575 CCW_FLAG_SLI
| CCW_FLAG_CC
| CCW_FLAG_PCI
;
2576 p_buf
-> r_read_FF
.count
= 1;
2578 /* initialize r_TIC_2 */
2579 memcpy(&p_buf
->r_TIC_2
,
2580 &p_buf
->r_TIC_1
, sizeof(struct ccw1
));
2582 /* initialize Header */
2583 p_buf
->header
.length
=0xffff;
2584 p_buf
->header
.opcode
=0xff;
2585 p_buf
->header
.flag
=CLAW_PENDING
;
2587 if (((unsigned long)p_buff
+privptr
->p_env
->read_size
) >=
2588 ((unsigned long)(p_buff
+2*(privptr
->p_env
->read_size
) -1)
2590 p_buff
= p_buff
+privptr
->p_env
->read_size
;
2594 (void *)((unsigned long)
2595 (p_buff
+2*(privptr
->p_env
->read_size
) -1)
2598 } /* for read_buffers */
2599 } /* read_size < PAGE_SIZE */
2600 else { /* read Size >= PAGE_SIZE */
2603 printk(KERN_INFO
"%s: %s() Begin build claw read free chain \n",
2604 dev
->name
,__FUNCTION__
);
2606 for (i
=0 ; i
< privptr
->p_env
->read_buffers
; i
++) {
2607 p_buff
= (void *)__get_free_pages(__GFP_DMA
,
2608 (int)pages_to_order_of_mag(privptr
->p_buff_pages_perread
) );
2610 printk(KERN_INFO
"%s: %s() __get_free_pages for read "
2611 "buf failed : get is for %d pages\n",
2612 dev
->name
,__FUNCTION__
,
2613 privptr
->p_buff_pages_perread
);
2614 free_pages((unsigned long)privptr
->p_buff_ccw
,
2615 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
2616 /* free the write pages */
2617 p_buf
=privptr
->p_buff_write
;
2618 while (p_buf
!=NULL
) {
2619 free_pages((unsigned long)p_buf
->p_buffer
,
2620 (int)pages_to_order_of_mag(
2621 privptr
->p_buff_pages_perwrite
));
2624 /* free any read pages already alloc */
2625 p_buf
=privptr
->p_buff_read
;
2626 while (p_buf
!=NULL
) {
2627 free_pages((unsigned long)p_buf
->p_buffer
,
2628 (int)pages_to_order_of_mag(
2629 privptr
->p_buff_pages_perread
));
2632 privptr
->p_buff_ccw
=NULL
;
2633 privptr
->p_buff_write
=NULL
;
2635 printk(KERN_INFO
"%s: %s() exit on line %d, rc = ENOMEM\n",
2636 dev
->name
,__FUNCTION__
,
2641 memset(p_buff
, 0x00, privptr
->p_env
->read_size
);
2642 p_buf
= p_free_chain
;
2643 privptr
->p_buff_read
= p_buf
;
2644 p_free_chain
= p_buf
->next
;
2646 if (p_last_CCWB
==NULL
) {
2652 p_buf
->next
=p_first_CCWB
;
2655 &p_first_CCWB
-> read
);
2659 /* save buff address */
2660 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2661 /* initialize read command */
2662 p_buf
-> read
.cmd_code
= CCW_CLAW_CMD_READ
;
2663 p_buf
-> read
.cda
= (__u32
)__pa(p_buff
);
2664 p_buf
-> read
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2665 p_buf
-> read
.count
= privptr
->p_env
->read_size
;
2667 /* initialize read_h command */
2668 p_buf
-> read_h
.cmd_code
= CCW_CLAW_CMD_READHEADER
;
2669 p_buf
-> read_h
.cda
=
2670 (__u32
)__pa(&(p_buf
->header
));
2671 p_buf
-> read_h
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2672 p_buf
-> read_h
.count
= sizeof(struct clawh
);
2674 /* initialize Signal command */
2675 p_buf
-> signal
.cmd_code
= CCW_CLAW_CMD_SIGNAL_SMOD
;
2676 p_buf
-> signal
.cda
=
2677 (__u32
)__pa(&(pClawH
->flag
));
2678 p_buf
-> signal
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2679 p_buf
-> signal
.count
= 1;
2681 /* initialize r_TIC_1 command */
2682 p_buf
-> r_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2683 p_buf
-> r_TIC_1
.cda
= (__u32
)real_TIC_address
;
2684 p_buf
-> r_TIC_1
.flags
= 0;
2685 p_buf
-> r_TIC_1
.count
= 0;
2687 /* initialize r_read_FF command */
2688 p_buf
-> r_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2689 p_buf
-> r_read_FF
.cda
=
2690 (__u32
)__pa(&(pClawH
->flag
));
2691 p_buf
-> r_read_FF
.flags
=
2692 CCW_FLAG_SLI
| CCW_FLAG_CC
| CCW_FLAG_PCI
;
2693 p_buf
-> r_read_FF
.count
= 1;
2695 /* initialize r_TIC_2 */
2696 memcpy(&p_buf
->r_TIC_2
, &p_buf
->r_TIC_1
,
2697 sizeof(struct ccw1
));
2699 /* initialize Header */
2700 p_buf
->header
.length
=0xffff;
2701 p_buf
->header
.opcode
=0xff;
2702 p_buf
->header
.flag
=CLAW_PENDING
;
2704 } /* For read_buffers */
2705 } /* read_size >= PAGE_SIZE */
2706 } /* pBuffread = NULL */
2708 printk(KERN_INFO
"%s: %s() > End build claw read free chain \n",
2709 dev
->name
,__FUNCTION__
);
2711 while (p_buf
!=NULL
) {
2712 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2717 add_claw_reads( dev
,p_first_CCWB
, p_last_CCWB
);
2718 privptr
->buffs_alloc
= 1;
2720 printk(KERN_INFO
"%s: %s() exit on line %d\n",
2721 dev
->name
,__FUNCTION__
,__LINE__
);
2724 } /* end of init_ccw_bk */
2726 /*-------------------------------------------------------------------*
2730 *--------------------------------------------------------------------*/
2733 probe_error( struct ccwgroup_device
*cgdev
)
2735 struct claw_privbk
*privptr
;
2737 printk(KERN_INFO
"%s enter \n",__FUNCTION__
);
2739 CLAW_DBF_TEXT(4,trace
,"proberr");
2741 printk(KERN_INFO
"%s variable cgdev =\n",__FUNCTION__
);
2742 dumpit((char *) cgdev
, sizeof(struct ccwgroup_device
));
2744 privptr
=(struct claw_privbk
*)cgdev
->dev
.driver_data
;
2745 if (privptr
!=NULL
) {
2746 if (privptr
->p_env
!= NULL
) {
2747 kfree(privptr
->p_env
);
2748 privptr
->p_env
=NULL
;
2750 if (privptr
->p_mtc_envelope
!=NULL
) {
2751 kfree(privptr
->p_mtc_envelope
);
2752 privptr
->p_mtc_envelope
=NULL
;
2758 printk(KERN_INFO
"%s > exit on line %d\n",
2759 __FUNCTION__
,__LINE__
);
2767 /*-------------------------------------------------------------------*
2768 * claw_process_control *
2771 *--------------------------------------------------------------------*/
2774 claw_process_control( struct net_device
*dev
, struct ccwbk
* p_ccw
)
2777 struct clawbuf
*p_buf
;
2778 struct clawctl ctlbk
;
2779 struct clawctl
*p_ctlbk
;
2780 char temp_host_name
[8];
2781 char temp_ws_name
[8];
2782 struct claw_privbk
*privptr
;
2783 struct claw_env
*p_env
;
2784 struct sysval
*p_sysval
;
2785 struct conncmd
*p_connect
=NULL
;
2787 struct chbk
*p_ch
= NULL
;
2789 printk(KERN_INFO
"%s: %s() > enter \n",
2790 dev
->name
,__FUNCTION__
);
2792 CLAW_DBF_TEXT(2,setup
,"clw_cntl");
2794 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
2795 dumpit((char *) dev
, sizeof(struct net_device
));
2796 printk(KERN_INFO
"%s: variable p_ccw =\n",dev
->name
);
2797 dumpit((char *) p_ccw
, sizeof(struct ccwbk
*));
2799 udelay(1000); /* Wait a ms for the control packets to
2800 *catch up to each other */
2802 p_env
=privptr
->p_env
;
2803 memcpy( &temp_host_name
, p_env
->host_name
, 8);
2804 memcpy( &temp_ws_name
, p_env
->adapter_name
, 8);
2805 printk(KERN_INFO
"%s: CLAW device %.8s: "
2806 "Received Control Packet\n",
2807 dev
->name
, temp_ws_name
);
2808 if (privptr
->release_pend
==1) {
2810 printk(KERN_INFO
"%s: %s() > "
2811 "exit on line %d, rc=0\n",
2812 dev
->name
,__FUNCTION__
,__LINE__
);
2816 p_buf
=p_ccw
->p_buffer
;
2818 if (p_env
->packing
== DO_PACKED
) { /* packing in progress?*/
2819 memcpy(p_ctlbk
, &p_buf
->buffer
[4], sizeof(struct clawctl
));
2821 memcpy(p_ctlbk
, p_buf
, sizeof(struct clawctl
));
2824 printk(KERN_INFO
"%s: dump claw control data inbound\n",dev
->name
);
2825 dumpit((char *)p_ctlbk
, sizeof(struct clawctl
));
2827 switch (p_ctlbk
->command
)
2829 case SYSTEM_VALIDATE_REQUEST
:
2830 if (p_ctlbk
->version
!=CLAW_VERSION_ID
) {
2831 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2832 CLAW_RC_WRONG_VERSION
);
2833 printk("%s: %d is wrong version id. "
2835 dev
->name
, p_ctlbk
->version
,
2838 p_sysval
=(struct sysval
*)&(p_ctlbk
->data
);
2839 printk( "%s: Recv Sys Validate Request: "
2840 "Vers=%d,link_id=%d,Corr=%d,WS name=%."
2841 "8s,Host name=%.8s\n",
2842 dev
->name
, p_ctlbk
->version
,
2844 p_ctlbk
->correlator
,
2846 p_sysval
->host_name
);
2847 if (0!=memcmp(temp_host_name
,p_sysval
->host_name
,8)) {
2848 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2849 CLAW_RC_NAME_MISMATCH
);
2850 CLAW_DBF_TEXT(2,setup
,"HSTBAD");
2851 CLAW_DBF_TEXT_(2,setup
,"%s",p_sysval
->host_name
);
2852 CLAW_DBF_TEXT_(2,setup
,"%s",temp_host_name
);
2853 printk(KERN_INFO
"%s: Host name mismatch\n",
2855 printk(KERN_INFO
"%s: Received :%s: "
2858 p_sysval
->host_name
,
2861 if (0!=memcmp(temp_ws_name
,p_sysval
->WS_name
,8)) {
2862 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2863 CLAW_RC_NAME_MISMATCH
);
2864 CLAW_DBF_TEXT(2,setup
,"WSNBAD");
2865 CLAW_DBF_TEXT_(2,setup
,"%s",p_sysval
->WS_name
);
2866 CLAW_DBF_TEXT_(2,setup
,"%s",temp_ws_name
);
2867 printk(KERN_INFO
"%s: WS name mismatch\n",
2869 printk(KERN_INFO
"%s: Received :%s: "
2875 if (( p_sysval
->write_frame_size
< p_env
->write_size
) &&
2876 ( p_env
->packing
== 0)) {
2877 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2878 CLAW_RC_HOST_RCV_TOO_SMALL
);
2879 printk(KERN_INFO
"%s: host write size is too "
2880 "small\n", dev
->name
);
2881 CLAW_DBF_TEXT(2,setup
,"wrtszbad");
2883 if (( p_sysval
->read_frame_size
< p_env
->read_size
) &&
2884 ( p_env
->packing
== 0)) {
2885 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2886 CLAW_RC_HOST_RCV_TOO_SMALL
);
2887 printk(KERN_INFO
"%s: host read size is too "
2888 "small\n", dev
->name
);
2889 CLAW_DBF_TEXT(2,setup
,"rdsizbad");
2891 claw_snd_sys_validate_rsp(dev
, p_ctlbk
, 0 );
2892 printk("%s: CLAW device %.8s: System validate"
2893 " completed.\n",dev
->name
, temp_ws_name
);
2894 printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev
->name
,
2895 p_sysval
->read_frame_size
,p_sysval
->write_frame_size
);
2896 privptr
->system_validate_comp
=1;
2897 if(strncmp(p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
2898 p_env
->packing
= PACKING_ASK
;
2900 claw_strt_conn_req(dev
);
2903 case SYSTEM_VALIDATE_RESPONSE
:
2904 p_sysval
=(struct sysval
*)&(p_ctlbk
->data
);
2905 printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
2906 "WS name=%.8s,Host name=%.8s\n",
2909 p_ctlbk
->correlator
,
2912 p_sysval
->host_name
);
2913 switch (p_ctlbk
->rc
)
2916 printk(KERN_INFO
"%s: CLAW device "
2917 "%.8s: System validate "
2919 dev
->name
, temp_ws_name
);
2920 if (privptr
->system_validate_comp
== 0)
2921 claw_strt_conn_req(dev
);
2922 privptr
->system_validate_comp
=1;
2924 case CLAW_RC_NAME_MISMATCH
:
2925 printk(KERN_INFO
"%s: Sys Validate "
2926 "Resp : Host, WS name is "
2930 case CLAW_RC_WRONG_VERSION
:
2931 printk(KERN_INFO
"%s: Sys Validate "
2932 "Resp : Wrong version\n",
2935 case CLAW_RC_HOST_RCV_TOO_SMALL
:
2936 printk(KERN_INFO
"%s: Sys Validate "
2937 "Resp : bad frame size\n",
2941 printk(KERN_INFO
"%s: Sys Validate "
2943 dev
->name
, p_ctlbk
->rc
);
2948 case CONNECTION_REQUEST
:
2949 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
2950 printk(KERN_INFO
"%s: Recv Conn Req: Vers=%d,link_id=%d,"
2951 "Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
2955 p_ctlbk
->correlator
,
2956 p_connect
->host_name
,
2957 p_connect
->WS_name
);
2958 if (privptr
->active_link_ID
!=0 ) {
2959 claw_snd_disc(dev
, p_ctlbk
);
2960 printk(KERN_INFO
"%s: Conn Req error : "
2961 "already logical link is active \n",
2964 if (p_ctlbk
->linkid
!=1 ) {
2965 claw_snd_disc(dev
, p_ctlbk
);
2966 printk(KERN_INFO
"%s: Conn Req error : "
2967 "req logical link id is not 1\n",
2971 p_connect
->host_name
, p_connect
->WS_name
);
2973 claw_snd_disc(dev
, p_ctlbk
);
2974 printk(KERN_INFO
"%s: Conn Req error : "
2975 "req appl name does not match\n",
2978 claw_send_control(dev
,
2979 CONNECTION_CONFIRM
, p_ctlbk
->linkid
,
2980 p_ctlbk
->correlator
,
2981 0, p_connect
->host_name
,
2982 p_connect
->WS_name
);
2983 if (p_env
->packing
== PACKING_ASK
) {
2984 printk("%s: Now Pack ask\n",dev
->name
);
2985 p_env
->packing
= PACK_SEND
;
2986 claw_snd_conn_req(dev
,0);
2988 printk(KERN_INFO
"%s: CLAW device %.8s: Connection "
2989 "completed link_id=%d.\n",
2990 dev
->name
, temp_ws_name
,
2992 privptr
->active_link_ID
=p_ctlbk
->linkid
;
2993 p_ch
=&privptr
->channel
[WRITE
];
2994 wake_up(&p_ch
->wait
); /* wake up claw_open ( WRITE) */
2996 case CONNECTION_RESPONSE
:
2997 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
2998 printk(KERN_INFO
"%s: Revc Conn Resp: Vers=%d,link_id=%d,"
2999 "Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
3003 p_ctlbk
->correlator
,
3005 p_connect
->host_name
,
3006 p_connect
->WS_name
);
3008 if (p_ctlbk
->rc
!=0 ) {
3009 printk(KERN_INFO
"%s: Conn Resp error: rc=%d \n",
3010 dev
->name
, p_ctlbk
->rc
);
3014 p_connect
->host_name
, p_connect
->WS_name
);
3016 claw_snd_disc(dev
, p_ctlbk
);
3017 printk(KERN_INFO
"%s: Conn Resp error: "
3018 "req appl name does not match\n",
3021 /* should be until CONNECTION_CONFIRM */
3022 privptr
->active_link_ID
= - (p_ctlbk
->linkid
);
3024 case CONNECTION_CONFIRM
:
3025 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
3026 printk(KERN_INFO
"%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
3027 "Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
3031 p_ctlbk
->correlator
,
3032 p_connect
->host_name
,
3033 p_connect
->WS_name
);
3034 if (p_ctlbk
->linkid
== -(privptr
->active_link_ID
)) {
3035 privptr
->active_link_ID
=p_ctlbk
->linkid
;
3036 if (p_env
->packing
> PACKING_ASK
) {
3037 printk(KERN_INFO
"%s: Confirmed Now packing\n",dev
->name
);
3038 p_env
->packing
= DO_PACKED
;
3040 p_ch
=&privptr
->channel
[WRITE
];
3041 wake_up(&p_ch
->wait
);
3044 printk(KERN_INFO
"%s: Conn confirm: "
3045 "unexpected linkid=%d \n",
3046 dev
->name
, p_ctlbk
->linkid
);
3047 claw_snd_disc(dev
, p_ctlbk
);
3051 printk(KERN_INFO
"%s: Disconnect: "
3052 "Vers=%d,link_id=%d,Corr=%d\n",
3053 dev
->name
, p_ctlbk
->version
,
3054 p_ctlbk
->linkid
, p_ctlbk
->correlator
);
3055 if ((p_ctlbk
->linkid
== 2) &&
3056 (p_env
->packing
== PACK_SEND
)) {
3057 privptr
->active_link_ID
= 1;
3058 p_env
->packing
= DO_PACKED
;
3061 privptr
->active_link_ID
=0;
3064 printk(KERN_INFO
"%s: CLAW ERROR detected\n",
3068 printk(KERN_INFO
"%s: Unexpected command code=%d \n",
3069 dev
->name
, p_ctlbk
->command
);
3074 printk(KERN_INFO
"%s: %s() exit on line %d, rc = 0\n",
3075 dev
->name
,__FUNCTION__
,__LINE__
);
3079 } /* end of claw_process_control */
3082 /*-------------------------------------------------------------------*
3083 * claw_send_control *
3085 *--------------------------------------------------------------------*/
3088 claw_send_control(struct net_device
*dev
, __u8 type
, __u8 link
,
3089 __u8 correlator
, __u8 rc
, char *local_name
, char *remote_name
)
3091 struct claw_privbk
*privptr
;
3092 struct clawctl
*p_ctl
;
3093 struct sysval
*p_sysval
;
3094 struct conncmd
*p_connect
;
3095 struct sk_buff
*skb
;
3098 printk(KERN_INFO
"%s:%s > enter \n",dev
->name
,__FUNCTION__
);
3100 CLAW_DBF_TEXT(2,setup
,"sndcntl");
3102 printk(KERN_INFO
"%s: Sending Control Packet \n",dev
->name
);
3103 printk(KERN_INFO
"%s: variable type = 0x%X, link = "
3104 "%d, correlator = %d, rc = %d\n",
3105 dev
->name
,type
, link
, correlator
, rc
);
3106 printk(KERN_INFO
"%s: variable local_name = %s, "
3107 "remote_name = %s\n",dev
->name
, local_name
, remote_name
);
3110 p_ctl
=(struct clawctl
*)&privptr
->ctl_bk
;
3112 p_ctl
->command
=type
;
3113 p_ctl
->version
=CLAW_VERSION_ID
;
3115 p_ctl
->correlator
=correlator
;
3118 p_sysval
=(struct sysval
*)&p_ctl
->data
;
3119 p_connect
=(struct conncmd
*)&p_ctl
->data
;
3121 switch (p_ctl
->command
) {
3122 case SYSTEM_VALIDATE_REQUEST
:
3123 case SYSTEM_VALIDATE_RESPONSE
:
3124 memcpy(&p_sysval
->host_name
, local_name
, 8);
3125 memcpy(&p_sysval
->WS_name
, remote_name
, 8);
3126 if (privptr
->p_env
->packing
> 0) {
3127 p_sysval
->read_frame_size
=DEF_PACK_BUFSIZE
;
3128 p_sysval
->write_frame_size
=DEF_PACK_BUFSIZE
;
3130 /* how big is the piggest group of packets */
3131 p_sysval
->read_frame_size
=privptr
->p_env
->read_size
;
3132 p_sysval
->write_frame_size
=privptr
->p_env
->write_size
;
3134 memset(&p_sysval
->reserved
, 0x00, 4);
3136 case CONNECTION_REQUEST
:
3137 case CONNECTION_RESPONSE
:
3138 case CONNECTION_CONFIRM
:
3140 memcpy(&p_sysval
->host_name
, local_name
, 8);
3141 memcpy(&p_sysval
->WS_name
, remote_name
, 8);
3142 if (privptr
->p_env
->packing
> 0) {
3143 /* How big is the biggest packet */
3144 p_connect
->reserved1
[0]=CLAW_FRAME_SIZE
;
3145 p_connect
->reserved1
[1]=CLAW_FRAME_SIZE
;
3147 memset(&p_connect
->reserved1
, 0x00, 4);
3148 memset(&p_connect
->reserved2
, 0x00, 4);
3155 /* write Control Record to the device */
3158 skb
= dev_alloc_skb(sizeof(struct clawctl
));
3160 printk( "%s:%s low on mem, returning...\n",
3161 dev
->name
,__FUNCTION__
);
3163 printk(KERN_INFO
"%s:%s Exit, rc = ENOMEM\n",
3164 dev
->name
,__FUNCTION__
);
3168 memcpy(skb_put(skb
, sizeof(struct clawctl
)),
3169 p_ctl
, sizeof(struct clawctl
));
3171 printk(KERN_INFO
"%s: outbnd claw cntl data \n",dev
->name
);
3172 dumpit((char *)p_ctl
,sizeof(struct clawctl
));
3174 if (privptr
->p_env
->packing
>= PACK_SEND
)
3175 claw_hw_tx(skb
, dev
, 1);
3177 claw_hw_tx(skb
, dev
, 0);
3179 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3180 dev
->name
,__FUNCTION__
,__LINE__
);
3184 } /* end of claw_send_control */
3186 /*-------------------------------------------------------------------*
3187 * claw_snd_conn_req *
3189 *--------------------------------------------------------------------*/
3191 claw_snd_conn_req(struct net_device
*dev
, __u8 link
)
3194 struct claw_privbk
*privptr
=dev
->priv
;
3195 struct clawctl
*p_ctl
;
3198 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
3200 CLAW_DBF_TEXT(2,setup
,"snd_conn");
3202 printk(KERN_INFO
"%s: variable link = %X, dev =\n",dev
->name
, link
);
3203 dumpit((char *) dev
, sizeof(struct net_device
));
3206 p_ctl
=(struct clawctl
*)&privptr
->ctl_bk
;
3207 p_ctl
->linkid
= link
;
3208 if ( privptr
->system_validate_comp
==0x00 ) {
3210 printk(KERN_INFO
"%s:%s Exit on line %d, rc = 1\n",
3211 dev
->name
,__FUNCTION__
,__LINE__
);
3215 if (privptr
->p_env
->packing
== PACKING_ASK
)
3216 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3217 WS_APPL_NAME_PACKED
, WS_APPL_NAME_PACKED
);
3218 if (privptr
->p_env
->packing
== PACK_SEND
) {
3219 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3220 WS_APPL_NAME_IP_NAME
, WS_APPL_NAME_IP_NAME
);
3222 if (privptr
->p_env
->packing
== 0)
3223 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3224 HOST_APPL_NAME
, privptr
->p_env
->api_type
);
3226 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3227 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3231 } /* end of claw_snd_conn_req */
3234 /*-------------------------------------------------------------------*
3237 *--------------------------------------------------------------------*/
3240 claw_snd_disc(struct net_device
*dev
, struct clawctl
* p_ctl
)
3243 struct conncmd
* p_connect
;
3246 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3248 CLAW_DBF_TEXT(2,setup
,"snd_dsc");
3250 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
3251 dumpit((char *) dev
, sizeof(struct net_device
));
3252 printk(KERN_INFO
"%s: variable p_ctl",dev
->name
);
3253 dumpit((char *) p_ctl
, sizeof(struct clawctl
));
3255 p_connect
=(struct conncmd
*)&p_ctl
->data
;
3257 rc
=claw_send_control(dev
, DISCONNECT
, p_ctl
->linkid
,
3258 p_ctl
->correlator
, 0,
3259 p_connect
->host_name
, p_connect
->WS_name
);
3261 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3262 dev
->name
,__FUNCTION__
, __LINE__
, rc
);
3265 } /* end of claw_snd_disc */
3268 /*-------------------------------------------------------------------*
3269 * claw_snd_sys_validate_rsp *
3271 *--------------------------------------------------------------------*/
3274 claw_snd_sys_validate_rsp(struct net_device
*dev
,
3275 struct clawctl
*p_ctl
, __u32 return_code
)
3277 struct claw_env
* p_env
;
3278 struct claw_privbk
*privptr
;
3282 printk(KERN_INFO
"%s:%s Enter\n",
3283 dev
->name
,__FUNCTION__
);
3285 CLAW_DBF_TEXT(2,setup
,"chkresp");
3287 printk(KERN_INFO
"%s: variable return_code = %d, dev =\n",
3288 dev
->name
, return_code
);
3289 dumpit((char *) dev
, sizeof(struct net_device
));
3290 printk(KERN_INFO
"%s: variable p_ctl =\n",dev
->name
);
3291 dumpit((char *) p_ctl
, sizeof(struct clawctl
));
3293 privptr
= dev
->priv
;
3294 p_env
=privptr
->p_env
;
3295 rc
=claw_send_control(dev
, SYSTEM_VALIDATE_RESPONSE
,
3300 p_env
->adapter_name
);
3302 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3303 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3306 } /* end of claw_snd_sys_validate_rsp */
3308 /*-------------------------------------------------------------------*
3309 * claw_strt_conn_req *
3311 *--------------------------------------------------------------------*/
3314 claw_strt_conn_req(struct net_device
*dev
)
3319 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3321 CLAW_DBF_TEXT(2,setup
,"conn_req");
3323 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
3324 dumpit((char *) dev
, sizeof(struct net_device
));
3326 rc
=claw_snd_conn_req(dev
, 1);
3328 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3329 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3332 } /* end of claw_strt_conn_req */
3336 /*-------------------------------------------------------------------*
3338 *-------------------------------------------------------------------*/
3341 net_device_stats
*claw_stats(struct net_device
*dev
)
3343 struct claw_privbk
*privptr
;
3345 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3347 CLAW_DBF_TEXT(4,trace
,"stats");
3348 privptr
= dev
->priv
;
3350 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3351 dev
->name
,__FUNCTION__
,__LINE__
);
3353 return &privptr
->stats
;
3354 } /* end of claw_stats */
3357 /*-------------------------------------------------------------------*
3360 *--------------------------------------------------------------------*/
3362 unpack_read(struct net_device
*dev
)
3364 struct sk_buff
*skb
;
3365 struct claw_privbk
*privptr
;
3366 struct claw_env
*p_env
;
3367 struct ccwbk
*p_this_ccw
;
3368 struct ccwbk
*p_first_ccw
;
3369 struct ccwbk
*p_last_ccw
;
3370 struct clawph
*p_packh
;
3372 struct clawctl
*p_ctlrec
=NULL
;
3377 __u8 mtc_this_frm
=0;
3379 struct chbk
*p_ch
= NULL
;
3384 printk(KERN_INFO
"%s:%s enter \n",dev
->name
,__FUNCTION__
);
3386 CLAW_DBF_TEXT(4,trace
,"unpkread");
3392 p_env
= privptr
->p_env
;
3393 p_this_ccw
=privptr
->p_read_active_first
;
3395 while (p_this_ccw
!=NULL
&& p_this_ccw
->header
.flag
!=CLAW_PENDING
) {
3397 printk(KERN_INFO
"%s p_this_ccw \n",dev
->name
);
3398 dumpit((char*)p_this_ccw
, sizeof(struct ccwbk
));
3399 printk(KERN_INFO
"%s Inbound p_this_ccw->p_buffer(64)"
3400 " pk=%d \n",dev
->name
,p_env
->packing
);
3401 dumpit((char *)p_this_ccw
->p_buffer
, 64 );
3405 p_this_ccw
->header
.flag
=CLAW_PENDING
;
3406 privptr
->p_read_active_first
=p_this_ccw
->next
;
3407 p_this_ccw
->next
=NULL
;
3408 p_packh
= (struct clawph
*)p_this_ccw
->p_buffer
;
3409 if ((p_env
->packing
== PACK_SEND
) &&
3410 (p_packh
->len
== 32) &&
3411 (p_packh
->link_num
== 0)) { /* is it a packed ctl rec? */
3412 p_packh
++; /* peek past pack header */
3413 p_ctlrec
= (struct clawctl
*)p_packh
;
3414 p_packh
--; /* un peek */
3415 if ((p_ctlrec
->command
== CONNECTION_RESPONSE
) ||
3416 (p_ctlrec
->command
== CONNECTION_CONFIRM
))
3417 p_env
->packing
= DO_PACKED
;
3419 if (p_env
->packing
== DO_PACKED
)
3420 link_num
=p_packh
->link_num
;
3422 link_num
=p_this_ccw
->header
.opcode
/ 8;
3423 if ((p_this_ccw
->header
.opcode
& MORE_to_COME_FLAG
)!=0) {
3425 printk(KERN_INFO
"%s: %s > More_to_come is ON\n",
3426 dev
->name
,__FUNCTION__
);
3429 if (p_this_ccw
->header
.length
!=
3430 privptr
->p_env
->read_size
) {
3431 printk(KERN_INFO
" %s: Invalid frame detected "
3432 "length is %02x\n" ,
3433 dev
->name
, p_this_ccw
->header
.length
);
3437 if (privptr
->mtc_skipping
) {
3439 * We're in the mode of skipping past a
3440 * multi-frame message
3441 * that we can't process for some reason or other.
3442 * The first frame without the More-To-Come flag is
3443 * the last frame of the skipped message.
3445 /* in case of More-To-Come not set in this frame */
3446 if (mtc_this_frm
==0) {
3447 privptr
->mtc_skipping
=0; /* Ok, the end */
3448 privptr
->mtc_logical_link
=-1;
3451 printk(KERN_INFO
"%s:%s goto next "
3452 "frame from MoretoComeSkip \n",
3453 dev
->name
,__FUNCTION__
);
3459 claw_process_control(dev
, p_this_ccw
);
3461 printk(KERN_INFO
"%s:%s goto next "
3462 "frame from claw_process_control \n",
3463 dev
->name
,__FUNCTION__
);
3465 CLAW_DBF_TEXT(4,trace
,"UnpkCntl");
3469 if (p_env
->packing
== DO_PACKED
) {
3470 if (pack_off
> p_env
->read_size
)
3472 p_packd
= p_this_ccw
->p_buffer
+pack_off
;
3473 p_packh
= (struct clawph
*) p_packd
;
3474 if ((p_packh
->len
== 0) || /* all done with this frame? */
3475 (p_packh
->flag
!= 0))
3477 bytes_to_mov
= p_packh
->len
;
3478 pack_off
+= bytes_to_mov
+sizeof(struct clawph
);
3481 bytes_to_mov
=p_this_ccw
->header
.length
;
3483 if (privptr
->mtc_logical_link
<0) {
3485 printk(KERN_INFO
"%s: %s mtc_logical_link < 0 \n",
3486 dev
->name
,__FUNCTION__
);
3490 * if More-To-Come is set in this frame then we don't know
3491 * length of entire message, and hence have to allocate
3494 /* We are starting a new envelope */
3495 privptr
->mtc_offset
=0;
3496 privptr
->mtc_logical_link
=link_num
;
3499 if (bytes_to_mov
> (MAX_ENVELOPE_SIZE
- privptr
->mtc_offset
) ) {
3502 printk(KERN_INFO
"%s: %s > goto next "
3503 "frame from MoretoComeSkip \n",
3506 printk(KERN_INFO
" bytes_to_mov %d > (MAX_ENVELOPE_"
3507 "SIZE-privptr->mtc_offset %d)\n",
3508 bytes_to_mov
,(MAX_ENVELOPE_SIZE
- privptr
->mtc_offset
));
3510 privptr
->stats
.rx_frame_errors
++;
3513 if (p_env
->packing
== DO_PACKED
) {
3514 memcpy( privptr
->p_mtc_envelope
+ privptr
->mtc_offset
,
3515 p_packd
+sizeof(struct clawph
), bytes_to_mov
);
3518 memcpy( privptr
->p_mtc_envelope
+ privptr
->mtc_offset
,
3519 p_this_ccw
->p_buffer
, bytes_to_mov
);
3522 printk(KERN_INFO
"%s: %s() received data \n",
3523 dev
->name
,__FUNCTION__
);
3524 if (p_env
->packing
== DO_PACKED
)
3525 dumpit((char *)p_packd
+sizeof(struct clawph
),32);
3527 dumpit((char *)p_this_ccw
->p_buffer
, 32);
3528 printk(KERN_INFO
"%s: %s() bytelength %d \n",
3529 dev
->name
,__FUNCTION__
,bytes_to_mov
);
3531 if (mtc_this_frm
==0) {
3532 len_of_data
=privptr
->mtc_offset
+bytes_to_mov
;
3533 skb
=dev_alloc_skb(len_of_data
);
3535 memcpy(skb_put(skb
,len_of_data
),
3536 privptr
->p_mtc_envelope
,
3538 skb
->mac
.raw
=skb
->data
;
3540 skb
->protocol
=htons(ETH_P_IP
);
3541 skb
->ip_summed
=CHECKSUM_UNNECESSARY
;
3542 privptr
->stats
.rx_packets
++;
3543 privptr
->stats
.rx_bytes
+=len_of_data
;
3546 printk(KERN_INFO
"%s: %s() netif_"
3547 "rx(skb) completed \n",
3548 dev
->name
,__FUNCTION__
);
3552 privptr
->stats
.rx_dropped
++;
3553 printk(KERN_WARNING
"%s: %s() low on memory\n",
3554 dev
->name
,__FUNCTION__
);
3556 privptr
->mtc_offset
=0;
3557 privptr
->mtc_logical_link
=-1;
3560 privptr
->mtc_offset
+=bytes_to_mov
;
3562 if (p_env
->packing
== DO_PACKED
)
3566 * Remove ThisCCWblock from active read queue, and add it
3567 * to queue of free blocks to be reused.
3570 p_this_ccw
->header
.length
=0xffff;
3571 p_this_ccw
->header
.opcode
=0xff;
3573 * add this one to the free queue for later reuse
3575 if (p_first_ccw
==NULL
) {
3576 p_first_ccw
= p_this_ccw
;
3579 p_last_ccw
->next
= p_this_ccw
;
3581 p_last_ccw
= p_this_ccw
;
3583 * chain to next block on active read queue
3585 p_this_ccw
= privptr
->p_read_active_first
;
3586 CLAW_DBF_TEXT_(4,trace
,"rxpkt %d",p
);
3587 } /* end of while */
3589 /* check validity */
3592 printk(KERN_INFO
"%s:%s processed frame is %d \n",
3593 dev
->name
,__FUNCTION__
,i
);
3594 printk(KERN_INFO
"%s:%s F:%lx L:%lx\n",
3597 (unsigned long)p_first_ccw
,
3598 (unsigned long)p_last_ccw
);
3600 CLAW_DBF_TEXT_(4,trace
,"rxfrm %d",i
);
3601 add_claw_reads(dev
, p_first_ccw
, p_last_ccw
);
3602 p_ch
=&privptr
->channel
[READ
];
3603 claw_strt_read(dev
, LOCK_YES
);
3605 printk(KERN_INFO
"%s: %s exit on line %d\n",
3606 dev
->name
, __FUNCTION__
, __LINE__
);
3609 } /* end of unpack_read */
3611 /*-------------------------------------------------------------------*
3614 *--------------------------------------------------------------------*/
3616 claw_strt_read (struct net_device
*dev
, int lock
)
3620 unsigned long saveflags
= 0;
3621 struct claw_privbk
*privptr
=dev
->priv
;
3622 struct ccwbk
*p_ccwbk
;
3624 struct clawh
*p_clawh
;
3625 p_ch
=&privptr
->channel
[READ
];
3628 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
3629 printk(KERN_INFO
"%s: variable lock = %d, dev =\n",dev
->name
, lock
);
3630 dumpit((char *) dev
, sizeof(struct net_device
));
3632 CLAW_DBF_TEXT(4,trace
,"StRdNter");
3633 p_clawh
=(struct clawh
*)privptr
->p_claw_signal_blk
;
3634 p_clawh
->flag
=CLAW_IDLE
; /* 0x00 */
3636 if ((privptr
->p_write_active_first
!=NULL
&&
3637 privptr
->p_write_active_first
->header
.flag
!=CLAW_PENDING
) ||
3638 (privptr
->p_read_active_first
!=NULL
&&
3639 privptr
->p_read_active_first
->header
.flag
!=CLAW_PENDING
)) {
3640 p_clawh
->flag
=CLAW_BUSY
; /* 0xff */
3643 printk(KERN_INFO
"%s:%s state-%02x\n" ,
3644 dev
->name
,__FUNCTION__
, p_ch
->claw_state
);
3646 if (lock
==LOCK_YES
) {
3647 spin_lock_irqsave(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
3649 if (test_and_set_bit(0, (void *)&p_ch
->IO_active
) == 0) {
3651 printk(KERN_INFO
"%s: HOT READ started in %s\n" ,
3652 dev
->name
,__FUNCTION__
);
3653 p_clawh
=(struct clawh
*)privptr
->p_claw_signal_blk
;
3654 dumpit((char *)&p_clawh
->flag
, 1);
3656 CLAW_DBF_TEXT(4,trace
,"HotRead");
3657 p_ccwbk
=privptr
->p_read_active_first
;
3658 parm
= (unsigned long) p_ch
;
3659 rc
= ccw_device_start (p_ch
->cdev
, &p_ccwbk
->read
, parm
,
3662 ccw_check_return_code(p_ch
->cdev
, rc
);
3667 printk(KERN_INFO
"%s: No READ started by %s() In progress\n" ,
3668 dev
->name
,__FUNCTION__
);
3670 CLAW_DBF_TEXT(2,trace
,"ReadAct");
3673 if (lock
==LOCK_YES
) {
3674 spin_unlock_irqrestore(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
3677 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3678 dev
->name
,__FUNCTION__
,__LINE__
);
3680 CLAW_DBF_TEXT(4,trace
,"StRdExit");
3682 } /* end of claw_strt_read */
3684 /*-------------------------------------------------------------------*
3685 * claw_strt_out_IO *
3687 *--------------------------------------------------------------------*/
3690 claw_strt_out_IO( struct net_device
*dev
)
3694 struct claw_privbk
*privptr
;
3696 struct ccwbk
*p_first_ccw
;
3699 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3704 privptr
=(struct claw_privbk
*)dev
->priv
;
3705 p_ch
=&privptr
->channel
[WRITE
];
3708 printk(KERN_INFO
"%s:%s state-%02x\n" ,
3709 dev
->name
,__FUNCTION__
,p_ch
->claw_state
);
3711 CLAW_DBF_TEXT(4,trace
,"strt_io");
3712 p_first_ccw
=privptr
->p_write_active_first
;
3714 if (p_ch
->claw_state
== CLAW_STOP
)
3716 if (p_first_ccw
== NULL
) {
3718 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3719 dev
->name
,__FUNCTION__
,__LINE__
);
3723 if (test_and_set_bit(0, (void *)&p_ch
->IO_active
) == 0) {
3724 parm
= (unsigned long) p_ch
;
3726 printk(KERN_INFO
"%s:%s do_io \n" ,dev
->name
,__FUNCTION__
);
3727 dumpit((char *)p_first_ccw
, sizeof(struct ccwbk
));
3729 CLAW_DBF_TEXT(2,trace
,"StWrtIO");
3730 rc
= ccw_device_start (p_ch
->cdev
,&p_first_ccw
->write
, parm
,
3733 ccw_check_return_code(p_ch
->cdev
, rc
);
3736 dev
->trans_start
= jiffies
;
3738 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3739 dev
->name
,__FUNCTION__
,__LINE__
);
3743 } /* end of claw_strt_out_IO */
3745 /*-------------------------------------------------------------------*
3746 * Free write buffers *
3748 *--------------------------------------------------------------------*/
3751 claw_free_wrt_buf( struct net_device
*dev
)
3754 struct claw_privbk
*privptr
=(struct claw_privbk
*)dev
->priv
;
3755 struct ccwbk
*p_first_ccw
;
3756 struct ccwbk
*p_last_ccw
;
3757 struct ccwbk
*p_this_ccw
;
3758 struct ccwbk
*p_next_ccw
;
3763 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3764 printk(KERN_INFO
"%s: free count = %d variable dev =\n",
3765 dev
->name
,privptr
->write_free_count
);
3767 CLAW_DBF_TEXT(4,trace
,"freewrtb");
3768 /* scan the write queue to free any completed write packets */
3772 printk(KERN_INFO
"%s: Dump current CCW chain \n",dev
->name
);
3773 p_buf
=privptr
->p_write_active_first
;
3774 while (p_buf
!=NULL
) {
3775 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
3779 printk(KERN_INFO
"%s: privptr->p_write_"
3780 "active_first==NULL\n",dev
->name
);
3782 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
3783 dumpit((char *)p_buf
, sizeof(struct endccw
));
3785 p_this_ccw
=privptr
->p_write_active_first
;
3786 while ( (p_this_ccw
!=NULL
) && (p_this_ccw
->header
.flag
!=CLAW_PENDING
))
3788 p_next_ccw
= p_this_ccw
->next
;
3789 if (((p_next_ccw
!=NULL
) &&
3790 (p_next_ccw
->header
.flag
!=CLAW_PENDING
)) ||
3791 ((p_this_ccw
== privptr
->p_write_active_last
) &&
3792 (p_this_ccw
->header
.flag
!=CLAW_PENDING
))) {
3793 /* The next CCW is OK or this is */
3794 /* the last CCW...free it @A1A */
3795 privptr
->p_write_active_first
=p_this_ccw
->next
;
3796 p_this_ccw
->header
.flag
=CLAW_PENDING
;
3797 p_this_ccw
->next
=privptr
->p_write_free_chain
;
3798 privptr
->p_write_free_chain
=p_this_ccw
;
3799 ++privptr
->write_free_count
;
3800 privptr
->stats
.tx_bytes
+= p_this_ccw
->write
.count
;
3801 p_this_ccw
=privptr
->p_write_active_first
;
3802 privptr
->stats
.tx_packets
++;
3808 if (privptr
->write_free_count
!=0) {
3809 claw_clearbit_busy(TB_NOBUFFER
,dev
);
3811 /* whole chain removed? */
3812 if (privptr
->p_write_active_first
==NULL
) {
3813 privptr
->p_write_active_last
=NULL
;
3815 printk(KERN_INFO
"%s:%s p_write_"
3816 "active_first==NULL\n",dev
->name
,__FUNCTION__
);
3820 printk(KERN_INFO
"%s: Dump arranged CCW chain \n",dev
->name
);
3821 p_buf
=privptr
->p_write_active_first
;
3822 while (p_buf
!=NULL
) {
3823 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
3827 printk(KERN_INFO
"%s: privptr->p_write_active_"
3828 "first==NULL\n",dev
->name
);
3830 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
3831 dumpit((char *)p_buf
, sizeof(struct endccw
));
3834 CLAW_DBF_TEXT_(4,trace
,"FWC=%d",privptr
->write_free_count
);
3836 printk(KERN_INFO
"%s:%s Exit on line %d free_count =%d\n",
3837 dev
->name
,__FUNCTION__
, __LINE__
,privptr
->write_free_count
);
3842 /*-------------------------------------------------------------------*
3843 * claw free netdevice *
3845 *--------------------------------------------------------------------*/
3847 claw_free_netdevice(struct net_device
* dev
, int free_dev
)
3849 struct claw_privbk
*privptr
;
3851 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3853 CLAW_DBF_TEXT(2,setup
,"free_dev");
3857 CLAW_DBF_TEXT_(2,setup
,"%s",dev
->name
);
3858 privptr
= dev
->priv
;
3859 if (dev
->flags
& IFF_RUNNING
)
3862 privptr
->channel
[READ
].ndev
= NULL
; /* say it's free */
3870 CLAW_DBF_TEXT(2,setup
,"feee_ok");
3872 printk(KERN_INFO
"%s:%s Exit\n",dev
->name
,__FUNCTION__
);
3877 * Claw init netdevice
3878 * Initialize everything of the net device except the name and the
3882 claw_init_netdevice(struct net_device
* dev
)
3885 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3887 CLAW_DBF_TEXT(2,setup
,"init_dev");
3888 CLAW_DBF_TEXT_(2,setup
,"%s",dev
->name
);
3890 printk(KERN_WARNING
"claw:%s BAD Device exit line %d\n",
3891 __FUNCTION__
,__LINE__
);
3892 CLAW_DBF_TEXT(2,setup
,"baddev");
3895 dev
->mtu
= CLAW_DEFAULT_MTU_SIZE
;
3896 dev
->hard_start_xmit
= claw_tx
;
3897 dev
->open
= claw_open
;
3898 dev
->stop
= claw_release
;
3899 dev
->get_stats
= claw_stats
;
3900 dev
->change_mtu
= claw_change_mtu
;
3901 dev
->hard_header_len
= 0;
3903 dev
->type
= ARPHRD_SLIP
;
3904 dev
->tx_queue_len
= 1300;
3905 dev
->flags
= IFF_POINTOPOINT
| IFF_NOARP
;
3906 SET_MODULE_OWNER(dev
);
3908 printk(KERN_INFO
"%s:%s Exit\n",dev
->name
,__FUNCTION__
);
3910 CLAW_DBF_TEXT(2,setup
,"initok");
3915 * Init a new channel in the privptr->channel[i].
3917 * @param cdev The ccw_device to be added.
3919 * @return 0 on success, !0 on error.
3922 add_channel(struct ccw_device
*cdev
,int i
,struct claw_privbk
*privptr
)
3927 printk(KERN_INFO
"%s:%s Enter\n",cdev
->dev
.bus_id
,__FUNCTION__
);
3929 CLAW_DBF_TEXT_(2,setup
,"%s",cdev
->dev
.bus_id
);
3930 privptr
->channel
[i
].flag
= i
+1; /* Read is 1 Write is 2 */
3931 p_ch
= &privptr
->channel
[i
];
3933 snprintf(p_ch
->id
, CLAW_ID_SIZE
, "cl-%s", cdev
->dev
.bus_id
);
3934 sscanf(cdev
->dev
.bus_id
+4,"%x",&p_ch
->devno
);
3935 if ((p_ch
->irb
= kmalloc(sizeof (struct irb
),GFP_KERNEL
)) == NULL
) {
3936 printk(KERN_WARNING
"%s Out of memory in %s for irb\n",
3937 p_ch
->id
,__FUNCTION__
);
3939 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3940 p_ch
->id
,__FUNCTION__
,__LINE__
);
3944 memset(p_ch
->irb
, 0, sizeof (struct irb
));
3946 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3947 cdev
->dev
.bus_id
,__FUNCTION__
,__LINE__
);
3955 * Setup an interface.
3957 * @param cgdev Device to be setup.
3959 * @returns 0 on success, !0 on failure.
3962 claw_new_device(struct ccwgroup_device
*cgdev
)
3964 struct claw_privbk
*privptr
;
3965 struct claw_env
*p_env
;
3966 struct net_device
*dev
;
3969 pr_debug("%s() called\n", __FUNCTION__
);
3970 printk(KERN_INFO
"claw: add for %s\n",cgdev
->cdev
[READ
]->dev
.bus_id
);
3971 CLAW_DBF_TEXT(2,setup
,"new_dev");
3972 privptr
= cgdev
->dev
.driver_data
;
3973 cgdev
->cdev
[READ
]->dev
.driver_data
= privptr
;
3974 cgdev
->cdev
[WRITE
]->dev
.driver_data
= privptr
;
3977 p_env
= privptr
->p_env
;
3978 sscanf(cgdev
->cdev
[READ
]->dev
.bus_id
+4,"%x",
3979 &p_env
->devno
[READ
]);
3980 sscanf(cgdev
->cdev
[WRITE
]->dev
.bus_id
+4,"%x",
3981 &p_env
->devno
[WRITE
]);
3982 ret
= add_channel(cgdev
->cdev
[0],0,privptr
);
3984 ret
= add_channel(cgdev
->cdev
[1],1,privptr
);
3987 "add channel failed "
3988 "with ret = %d\n", ret
);
3991 ret
= ccw_device_set_online(cgdev
->cdev
[READ
]);
3994 "claw: ccw_device_set_online %s READ failed "
3995 "with ret = %d\n",cgdev
->cdev
[READ
]->dev
.bus_id
,ret
);
3998 ret
= ccw_device_set_online(cgdev
->cdev
[WRITE
]);
4001 "claw: ccw_device_set_online %s WRITE failed "
4002 "with ret = %d\n",cgdev
->cdev
[WRITE
]->dev
.bus_id
, ret
);
4005 dev
= alloc_netdev(0,"claw%d",claw_init_netdevice
);
4007 printk(KERN_WARNING
"%s:alloc_netdev failed\n",__FUNCTION__
);
4010 dev
->priv
= privptr
;
4011 cgdev
->dev
.driver_data
= privptr
;
4012 cgdev
->cdev
[READ
]->dev
.driver_data
= privptr
;
4013 cgdev
->cdev
[WRITE
]->dev
.driver_data
= privptr
;
4015 SET_NETDEV_DEV(dev
, &cgdev
->dev
);
4016 if (register_netdev(dev
) != 0) {
4017 claw_free_netdevice(dev
, 1);
4018 CLAW_DBF_TEXT(2,trace
,"regfail");
4021 dev
->flags
&=~IFF_RUNNING
;
4022 if (privptr
->buffs_alloc
== 0) {
4023 ret
=init_ccw_bk(dev
);
4026 "claw: init_ccw_bk failed with ret=%d\n", ret
);
4027 unregister_netdev(dev
);
4028 claw_free_netdevice(dev
,1);
4029 CLAW_DBF_TEXT(2,trace
,"ccwmem");
4033 privptr
->channel
[READ
].ndev
= dev
;
4034 privptr
->channel
[WRITE
].ndev
= dev
;
4035 privptr
->p_env
->ndev
= dev
;
4037 printk(KERN_INFO
"%s:readsize=%d writesize=%d "
4038 "readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
4039 dev
->name
, p_env
->read_size
,
4040 p_env
->write_size
, p_env
->read_buffers
,
4041 p_env
->write_buffers
, p_env
->devno
[READ
],
4042 p_env
->devno
[WRITE
]);
4043 printk(KERN_INFO
"%s:host_name:%.8s, adapter_name "
4044 ":%.8s api_type: %.8s\n",
4045 dev
->name
, p_env
->host_name
,
4046 p_env
->adapter_name
, p_env
->api_type
);
4049 ccw_device_set_offline(cgdev
->cdev
[1]);
4050 ccw_device_set_offline(cgdev
->cdev
[0]);
4056 claw_purge_skb_queue(struct sk_buff_head
*q
)
4058 struct sk_buff
*skb
;
4060 CLAW_DBF_TEXT(4,trace
,"purgque");
4062 while ((skb
= skb_dequeue(q
))) {
4063 atomic_dec(&skb
->users
);
4064 dev_kfree_skb_any(skb
);
4069 * Shutdown an interface.
4071 * @param cgdev Device to be shut down.
4073 * @returns 0 on success, !0 on failure.
4076 claw_shutdown_device(struct ccwgroup_device
*cgdev
)
4078 struct claw_privbk
*priv
;
4079 struct net_device
*ndev
;
4082 pr_debug("%s() called\n", __FUNCTION__
);
4083 CLAW_DBF_TEXT_(2,setup
,"%s",cgdev
->dev
.bus_id
);
4084 priv
= cgdev
->dev
.driver_data
;
4087 ndev
= priv
->channel
[READ
].ndev
;
4089 /* Close the device */
4091 "%s: shuting down \n",ndev
->name
);
4092 if (ndev
->flags
& IFF_RUNNING
)
4093 ret
= claw_release(ndev
);
4094 ndev
->flags
&=~IFF_RUNNING
;
4095 unregister_netdev(ndev
);
4096 ndev
->priv
= NULL
; /* cgdev data, not ndev's to free */
4097 claw_free_netdevice(ndev
, 1);
4098 priv
->channel
[READ
].ndev
= NULL
;
4099 priv
->channel
[WRITE
].ndev
= NULL
;
4100 priv
->p_env
->ndev
= NULL
;
4102 ccw_device_set_offline(cgdev
->cdev
[1]);
4103 ccw_device_set_offline(cgdev
->cdev
[0]);
4108 claw_remove_device(struct ccwgroup_device
*cgdev
)
4110 struct claw_privbk
*priv
;
4112 pr_debug("%s() called\n", __FUNCTION__
);
4113 CLAW_DBF_TEXT_(2,setup
,"%s",cgdev
->dev
.bus_id
);
4114 priv
= cgdev
->dev
.driver_data
;
4116 printk(KERN_WARNING
"claw: %s() no Priv exiting\n",__FUNCTION__
);
4119 printk(KERN_INFO
"claw: %s() called %s will be removed.\n",
4120 __FUNCTION__
,cgdev
->cdev
[0]->dev
.bus_id
);
4121 if (cgdev
->state
== CCWGROUP_ONLINE
)
4122 claw_shutdown_device(cgdev
);
4123 claw_remove_files(&cgdev
->dev
);
4124 if (priv
->p_mtc_envelope
!=NULL
) {
4125 kfree(priv
->p_mtc_envelope
);
4126 priv
->p_mtc_envelope
=NULL
;
4128 if (priv
->p_env
!= NULL
) {
4132 if (priv
->channel
[0].irb
!= NULL
) {
4133 kfree(priv
->channel
[0].irb
);
4134 priv
->channel
[0].irb
=NULL
;
4136 if (priv
->channel
[1].irb
!= NULL
) {
4137 kfree(priv
->channel
[1].irb
);
4138 priv
->channel
[1].irb
=NULL
;
4141 cgdev
->dev
.driver_data
=NULL
;
4142 cgdev
->cdev
[READ
]->dev
.driver_data
= NULL
;
4143 cgdev
->cdev
[WRITE
]->dev
.driver_data
= NULL
;
4144 put_device(&cgdev
->dev
);
4152 claw_hname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4154 struct claw_privbk
*priv
;
4155 struct claw_env
* p_env
;
4157 priv
= dev
->driver_data
;
4160 p_env
= priv
->p_env
;
4161 return sprintf(buf
, "%s\n",p_env
->host_name
);
4165 claw_hname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4167 struct claw_privbk
*priv
;
4168 struct claw_env
* p_env
;
4170 priv
= dev
->driver_data
;
4173 p_env
= priv
->p_env
;
4174 if (count
> MAX_NAME_LEN
+1)
4176 memset(p_env
->host_name
, 0x20, MAX_NAME_LEN
);
4177 strncpy(p_env
->host_name
,buf
, count
);
4178 p_env
->host_name
[count
-1] = 0x20; /* clear extra 0x0a */
4179 p_env
->host_name
[MAX_NAME_LEN
] = 0x00;
4180 CLAW_DBF_TEXT(2,setup
,"HstnSet");
4181 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->host_name
);
4186 static DEVICE_ATTR(host_name
, 0644, claw_hname_show
, claw_hname_write
);
4189 claw_adname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4191 struct claw_privbk
*priv
;
4192 struct claw_env
* p_env
;
4194 priv
= dev
->driver_data
;
4197 p_env
= priv
->p_env
;
4198 return sprintf(buf
, "%s\n",p_env
->adapter_name
);
4202 claw_adname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4204 struct claw_privbk
*priv
;
4205 struct claw_env
* p_env
;
4207 priv
= dev
->driver_data
;
4210 p_env
= priv
->p_env
;
4211 if (count
> MAX_NAME_LEN
+1)
4213 memset(p_env
->adapter_name
, 0x20, MAX_NAME_LEN
);
4214 strncpy(p_env
->adapter_name
,buf
, count
);
4215 p_env
->adapter_name
[count
-1] = 0x20; /* clear extra 0x0a */
4216 p_env
->adapter_name
[MAX_NAME_LEN
] = 0x00;
4217 CLAW_DBF_TEXT(2,setup
,"AdnSet");
4218 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->adapter_name
);
4223 static DEVICE_ATTR(adapter_name
, 0644, claw_adname_show
, claw_adname_write
);
4226 claw_apname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4228 struct claw_privbk
*priv
;
4229 struct claw_env
* p_env
;
4231 priv
= dev
->driver_data
;
4234 p_env
= priv
->p_env
;
4235 return sprintf(buf
, "%s\n",
4240 claw_apname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4242 struct claw_privbk
*priv
;
4243 struct claw_env
* p_env
;
4245 priv
= dev
->driver_data
;
4248 p_env
= priv
->p_env
;
4249 if (count
> MAX_NAME_LEN
+1)
4251 memset(p_env
->api_type
, 0x20, MAX_NAME_LEN
);
4252 strncpy(p_env
->api_type
,buf
, count
);
4253 p_env
->api_type
[count
-1] = 0x20; /* we get a loose 0x0a */
4254 p_env
->api_type
[MAX_NAME_LEN
] = 0x00;
4255 if(strncmp(p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
4256 p_env
->read_size
=DEF_PACK_BUFSIZE
;
4257 p_env
->write_size
=DEF_PACK_BUFSIZE
;
4258 p_env
->packing
=PACKING_ASK
;
4259 CLAW_DBF_TEXT(2,setup
,"PACKING");
4263 p_env
->read_size
=CLAW_FRAME_SIZE
;
4264 p_env
->write_size
=CLAW_FRAME_SIZE
;
4265 CLAW_DBF_TEXT(2,setup
,"ApiSet");
4267 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->api_type
);
4271 static DEVICE_ATTR(api_type
, 0644, claw_apname_show
, claw_apname_write
);
4274 claw_wbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4276 struct claw_privbk
*priv
;
4277 struct claw_env
* p_env
;
4279 priv
= dev
->driver_data
;
4282 p_env
= priv
->p_env
;
4283 return sprintf(buf
, "%d\n", p_env
->write_buffers
);
4287 claw_wbuff_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4289 struct claw_privbk
*priv
;
4290 struct claw_env
* p_env
;
4293 priv
= dev
->driver_data
;
4296 p_env
= priv
->p_env
;
4297 sscanf(buf
, "%i", &nnn
);
4298 if (p_env
->packing
) {
4304 if ((nnn
> max
) || (nnn
< 2))
4306 p_env
->write_buffers
= nnn
;
4307 CLAW_DBF_TEXT(2,setup
,"Wbufset");
4308 CLAW_DBF_TEXT_(2,setup
,"WB=%d",p_env
->write_buffers
);
4312 static DEVICE_ATTR(write_buffer
, 0644, claw_wbuff_show
, claw_wbuff_write
);
4315 claw_rbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4317 struct claw_privbk
*priv
;
4318 struct claw_env
* p_env
;
4320 priv
= dev
->driver_data
;
4323 p_env
= priv
->p_env
;
4324 return sprintf(buf
, "%d\n", p_env
->read_buffers
);
4328 claw_rbuff_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4330 struct claw_privbk
*priv
;
4331 struct claw_env
*p_env
;
4334 priv
= dev
->driver_data
;
4337 p_env
= priv
->p_env
;
4338 sscanf(buf
, "%i", &nnn
);
4339 if (p_env
->packing
) {
4345 if ((nnn
> max
) || (nnn
< 2))
4347 p_env
->read_buffers
= nnn
;
4348 CLAW_DBF_TEXT(2,setup
,"Rbufset");
4349 CLAW_DBF_TEXT_(2,setup
,"RB=%d",p_env
->read_buffers
);
4353 static DEVICE_ATTR(read_buffer
, 0644, claw_rbuff_show
, claw_rbuff_write
);
4355 static struct attribute
*claw_attr
[] = {
4356 &dev_attr_read_buffer
.attr
,
4357 &dev_attr_write_buffer
.attr
,
4358 &dev_attr_adapter_name
.attr
,
4359 &dev_attr_api_type
.attr
,
4360 &dev_attr_host_name
.attr
,
4364 static struct attribute_group claw_attr_group
= {
4369 claw_add_files(struct device
*dev
)
4371 pr_debug("%s() called\n", __FUNCTION__
);
4372 CLAW_DBF_TEXT(2,setup
,"add_file");
4373 return sysfs_create_group(&dev
->kobj
, &claw_attr_group
);
4377 claw_remove_files(struct device
*dev
)
4379 pr_debug("%s() called\n", __FUNCTION__
);
4380 CLAW_DBF_TEXT(2,setup
,"rem_file");
4381 sysfs_remove_group(&dev
->kobj
, &claw_attr_group
);
4384 /*--------------------------------------------------------------------*
4385 * claw_init and cleanup *
4386 *---------------------------------------------------------------------*/
4391 unregister_cu3088_discipline(&claw_group_driver
);
4392 claw_unregister_debug_facility();
4393 printk(KERN_INFO
"claw: Driver unloaded\n");
4398 * Initialize module.
4399 * This is called just after the module is loaded.
4401 * @return 0 on success, !0 on error.
4407 printk(KERN_INFO
"claw: starting driver "
4411 "compiled into kernel "
4413 " $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $ \n");
4417 printk(KERN_INFO
"claw: %s() enter \n",__FUNCTION__
);
4419 ret
= claw_register_debug_facility();
4421 printk(KERN_WARNING
"claw: %s() debug_register failed %d\n",
4425 CLAW_DBF_TEXT(2,setup
,"init_mod");
4426 ret
= register_cu3088_discipline(&claw_group_driver
);
4428 claw_unregister_debug_facility();
4429 printk(KERN_WARNING
"claw; %s() cu3088 register failed %d\n",
4433 printk(KERN_INFO
"claw: %s() exit \n",__FUNCTION__
);
4438 module_init(claw_init
);
4439 module_exit(claw_cleanup
);
4443 /*--------------------------------------------------------------------*
4445 *---------------------------------------------------------------------*/