2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver
5 * Linux for zSeries version
6 * Copyright (C) 2002,2005 IBM Corporation
7 * Author(s) Original code written by:
8 * Kazuo Iimura (iimura@jp.ibm.com)
10 * Andy Richter (richtera@us.ibm.com)
11 * Marc Price (mwprice@us.ibm.com)
14 * group x.x.rrrr,x.x.wwww
18 * adapter_name aaaaaaaa
22 * group 0.0.0200 0.0.0201
31 * The device id is decided by the order entries
32 * are added to the group the first is claw0 the second claw1
35 * rrrr - the first of 2 consecutive device addresses used for the
37 * The specified address is always used as the input (Read)
38 * channel and the next address is used as the output channel.
40 * wwww - the second of 2 consecutive device addresses used for
42 * The specified address is always used as the output
43 * channel and the previous address is used as the input channel.
45 * read_buffer - specifies number of input buffers to allocate.
46 * write_buffer - specifies number of output buffers to allocate.
47 * host_name - host name
48 * adaptor_name - adaptor name
49 * api_type - API type TCPIP or API will be sent and expected
52 * Note the following requirements:
53 * 1) host_name must match the configured adapter_name on the remote side
54 * 2) adaptor_name must match the configured host name on the remote side
57 * 1.00 Initial release shipped
58 * 1.10 Changes for Buffer allocation
59 * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower
60 * 1.25 Added Packing support
62 #include <asm/ccwdev.h>
63 #include <asm/ccwgroup.h>
64 #include <asm/debug.h>
65 #include <asm/idals.h>
68 #include <linux/bitops.h>
69 #include <linux/ctype.h>
70 #include <linux/delay.h>
71 #include <linux/errno.h>
72 #include <linux/if_arp.h>
73 #include <linux/init.h>
74 #include <linux/interrupt.h>
76 #include <linux/kernel.h>
77 #include <linux/module.h>
78 #include <linux/netdevice.h>
79 #include <linux/etherdevice.h>
80 #include <linux/proc_fs.h>
81 #include <linux/sched.h>
82 #include <linux/signal.h>
83 #include <linux/skbuff.h>
84 #include <linux/slab.h>
85 #include <linux/string.h>
86 #include <linux/tcp.h>
87 #include <linux/timer.h>
88 #include <linux/types.h>
93 MODULE_AUTHOR("Andy Richter <richtera@us.ibm.com>");
94 MODULE_DESCRIPTION("Linux for zSeries CLAW Driver\n" \
95 "Copyright 2000,2005 IBM Corporation\n");
96 MODULE_LICENSE("GPL");
98 /* Debugging is based on DEBUGMSG, IOTRACE, or FUNCTRACE options:
99 DEBUGMSG - Enables output of various debug messages in the code
100 IOTRACE - Enables output of CCW and other IO related traces
101 FUNCTRACE - Enables output of function entry/exit trace
102 Define any combination of above options to enable tracing
104 CLAW also uses the s390dbf file system see claw_trace and claw_setup
107 /* following enables tracing */
124 static char debug_buffer
[255];
126 * Debug Facility Stuff
128 static debug_info_t
*claw_dbf_setup
;
129 static debug_info_t
*claw_dbf_trace
;
132 * CLAW Debug Facility functions
135 claw_unregister_debug_facility(void)
138 debug_unregister(claw_dbf_setup
);
140 debug_unregister(claw_dbf_trace
);
144 claw_register_debug_facility(void)
146 claw_dbf_setup
= debug_register("claw_setup", 2, 1, 8);
147 claw_dbf_trace
= debug_register("claw_trace", 2, 2, 8);
148 if (claw_dbf_setup
== NULL
|| claw_dbf_trace
== NULL
) {
149 printk(KERN_WARNING
"Not enough memory for debug facility.\n");
150 claw_unregister_debug_facility();
153 debug_register_view(claw_dbf_setup
, &debug_hex_ascii_view
);
154 debug_set_level(claw_dbf_setup
, 2);
155 debug_register_view(claw_dbf_trace
, &debug_hex_ascii_view
);
156 debug_set_level(claw_dbf_trace
, 2);
161 claw_set_busy(struct net_device
*dev
)
163 ((struct claw_privbk
*) dev
->priv
)->tbusy
=1;
168 claw_clear_busy(struct net_device
*dev
)
170 clear_bit(0, &(((struct claw_privbk
*) dev
->priv
)->tbusy
));
171 netif_wake_queue(dev
);
176 claw_check_busy(struct net_device
*dev
)
179 return ((struct claw_privbk
*) dev
->priv
)->tbusy
;
183 claw_setbit_busy(int nr
,struct net_device
*dev
)
185 netif_stop_queue(dev
);
186 set_bit(nr
, (void *)&(((struct claw_privbk
*)dev
->priv
)->tbusy
));
190 claw_clearbit_busy(int nr
,struct net_device
*dev
)
192 clear_bit(nr
,(void *)&(((struct claw_privbk
*)dev
->priv
)->tbusy
));
193 netif_wake_queue(dev
);
197 claw_test_and_setbit_busy(int nr
,struct net_device
*dev
)
199 netif_stop_queue(dev
);
200 return test_and_set_bit(nr
,
201 (void *)&(((struct claw_privbk
*) dev
->priv
)->tbusy
));
205 /* Functions for the DEV methods */
207 static int claw_probe(struct ccwgroup_device
*cgdev
);
208 static void claw_remove_device(struct ccwgroup_device
*cgdev
);
209 static void claw_purge_skb_queue(struct sk_buff_head
*q
);
210 static int claw_new_device(struct ccwgroup_device
*cgdev
);
211 static int claw_shutdown_device(struct ccwgroup_device
*cgdev
);
212 static int claw_tx(struct sk_buff
*skb
, struct net_device
*dev
);
213 static int claw_change_mtu( struct net_device
*dev
, int new_mtu
);
214 static int claw_open(struct net_device
*dev
);
215 static void claw_irq_handler(struct ccw_device
*cdev
,
216 unsigned long intparm
, struct irb
*irb
);
217 static void claw_irq_tasklet ( unsigned long data
);
218 static int claw_release(struct net_device
*dev
);
219 static void claw_write_retry ( struct chbk
* p_ch
);
220 static void claw_write_next ( struct chbk
* p_ch
);
221 static void claw_timer ( struct chbk
* p_ch
);
224 static int add_claw_reads(struct net_device
*dev
,
225 struct ccwbk
* p_first
, struct ccwbk
* p_last
);
226 static void ccw_check_return_code (struct ccw_device
*cdev
, int return_code
);
227 static void ccw_check_unit_check (struct chbk
* p_ch
, unsigned char sense
);
228 static int find_link(struct net_device
*dev
, char *host_name
, char *ws_name
);
229 static int claw_hw_tx(struct sk_buff
*skb
, struct net_device
*dev
, long linkid
);
230 static int init_ccw_bk(struct net_device
*dev
);
231 static void probe_error( struct ccwgroup_device
*cgdev
);
232 static struct net_device_stats
*claw_stats(struct net_device
*dev
);
233 static int pages_to_order_of_mag(int num_of_pages
);
234 static struct sk_buff
*claw_pack_skb(struct claw_privbk
*privptr
);
236 static void dumpit (char *buf
, int len
);
238 /* sysfs Functions */
239 static ssize_t
claw_hname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
240 static ssize_t
claw_hname_write(struct device
*dev
, struct device_attribute
*attr
,
241 const char *buf
, size_t count
);
242 static ssize_t
claw_adname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
243 static ssize_t
claw_adname_write(struct device
*dev
, struct device_attribute
*attr
,
244 const char *buf
, size_t count
);
245 static ssize_t
claw_apname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
246 static ssize_t
claw_apname_write(struct device
*dev
, struct device_attribute
*attr
,
247 const char *buf
, size_t count
);
248 static ssize_t
claw_wbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
249 static ssize_t
claw_wbuff_write(struct device
*dev
, struct device_attribute
*attr
,
250 const char *buf
, size_t count
);
251 static ssize_t
claw_rbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
);
252 static ssize_t
claw_rbuff_write(struct device
*dev
, struct device_attribute
*attr
,
253 const char *buf
, size_t count
);
254 static int claw_add_files(struct device
*dev
);
255 static void claw_remove_files(struct device
*dev
);
257 /* Functions for System Validate */
258 static int claw_process_control( struct net_device
*dev
, struct ccwbk
* p_ccw
);
259 static int claw_send_control(struct net_device
*dev
, __u8 type
, __u8 link
,
260 __u8 correlator
, __u8 rc
, char *local_name
, char *remote_name
);
261 static int claw_snd_conn_req(struct net_device
*dev
, __u8 link
);
262 static int claw_snd_disc(struct net_device
*dev
, struct clawctl
* p_ctl
);
263 static int claw_snd_sys_validate_rsp(struct net_device
*dev
,
264 struct clawctl
* p_ctl
, __u32 return_code
);
265 static int claw_strt_conn_req(struct net_device
*dev
);
266 static void claw_strt_read ( struct net_device
*dev
, int lock
);
267 static void claw_strt_out_IO( struct net_device
*dev
);
268 static void claw_free_wrt_buf( struct net_device
*dev
);
270 /* Functions for unpack reads */
271 static void unpack_read (struct net_device
*dev
);
275 static struct ccwgroup_driver claw_group_driver
= {
276 .owner
= THIS_MODULE
,
279 .driver_id
= 0xC3D3C1E6,
281 .remove
= claw_remove_device
,
282 .set_online
= claw_new_device
,
283 .set_offline
= claw_shutdown_device
,
291 /*----------------------------------------------------------------*
293 * this function is called for each CLAW device. *
294 *----------------------------------------------------------------*/
296 claw_probe(struct ccwgroup_device
*cgdev
)
299 struct claw_privbk
*privptr
=NULL
;
302 printk(KERN_INFO
"%s Enter\n",__FUNCTION__
);
304 CLAW_DBF_TEXT(2,setup
,"probe");
305 if (!get_device(&cgdev
->dev
))
308 printk(KERN_INFO
"claw: variable cgdev =\n");
309 dumpit((char *)cgdev
, sizeof(struct ccwgroup_device
));
311 privptr
= kzalloc(sizeof(struct claw_privbk
), GFP_KERNEL
);
312 if (privptr
== NULL
) {
314 put_device(&cgdev
->dev
);
315 printk(KERN_WARNING
"Out of memory %s %s Exit Line %d \n",
316 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
317 CLAW_DBF_TEXT_(2,setup
,"probex%d",-ENOMEM
);
320 privptr
->p_mtc_envelope
= kzalloc( MAX_ENVELOPE_SIZE
, GFP_KERNEL
);
321 privptr
->p_env
= kzalloc(sizeof(struct claw_env
), GFP_KERNEL
);
322 if ((privptr
->p_mtc_envelope
==NULL
) || (privptr
->p_env
==NULL
)) {
324 put_device(&cgdev
->dev
);
325 printk(KERN_WARNING
"Out of memory %s %s Exit Line %d \n",
326 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
327 CLAW_DBF_TEXT_(2,setup
,"probex%d",-ENOMEM
);
330 memcpy(privptr
->p_env
->adapter_name
,WS_NAME_NOT_DEF
,8);
331 memcpy(privptr
->p_env
->host_name
,WS_NAME_NOT_DEF
,8);
332 memcpy(privptr
->p_env
->api_type
,WS_NAME_NOT_DEF
,8);
333 privptr
->p_env
->packing
= 0;
334 privptr
->p_env
->write_buffers
= 5;
335 privptr
->p_env
->read_buffers
= 5;
336 privptr
->p_env
->read_size
= CLAW_FRAME_SIZE
;
337 privptr
->p_env
->write_size
= CLAW_FRAME_SIZE
;
338 rc
= claw_add_files(&cgdev
->dev
);
341 put_device(&cgdev
->dev
);
342 printk(KERN_WARNING
"add_files failed %s %s Exit Line %d \n",
343 cgdev
->cdev
[0]->dev
.bus_id
,__FUNCTION__
,__LINE__
);
344 CLAW_DBF_TEXT_(2,setup
,"probex%d",rc
);
347 printk(KERN_INFO
"claw: sysfs files added for %s\n",cgdev
->cdev
[0]->dev
.bus_id
);
348 privptr
->p_env
->p_priv
= privptr
;
349 cgdev
->cdev
[0]->handler
= claw_irq_handler
;
350 cgdev
->cdev
[1]->handler
= claw_irq_handler
;
351 cgdev
->dev
.driver_data
= privptr
;
353 printk(KERN_INFO
"claw:%s exit on line %d, "
354 "rc = 0\n",__FUNCTION__
,__LINE__
);
356 CLAW_DBF_TEXT(2,setup
,"prbext 0");
359 } /* end of claw_probe */
361 /*-------------------------------------------------------------------*
363 *-------------------------------------------------------------------*/
366 claw_tx(struct sk_buff
*skb
, struct net_device
*dev
)
369 struct claw_privbk
*privptr
=dev
->priv
;
370 unsigned long saveflags
;
374 printk(KERN_INFO
"%s:%s enter\n",dev
->name
,__FUNCTION__
);
376 CLAW_DBF_TEXT(4,trace
,"claw_tx");
377 p_ch
=&privptr
->channel
[WRITE
];
379 printk(KERN_WARNING
"%s: null pointer passed as sk_buffer\n",
381 privptr
->stats
.tx_dropped
++;
383 printk(KERN_INFO
"%s: %s() exit on line %d, rc = EIO\n",
384 dev
->name
,__FUNCTION__
, __LINE__
);
386 CLAW_DBF_TEXT_(2,trace
,"clawtx%d",-EIO
);
391 printk(KERN_INFO
"%s: variable sk_buff=\n",dev
->name
);
392 dumpit((char *) skb
, sizeof(struct sk_buff
));
393 printk(KERN_INFO
"%s: variable dev=\n",dev
->name
);
394 dumpit((char *) dev
, sizeof(struct net_device
));
396 spin_lock_irqsave(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
397 rc
=claw_hw_tx( skb
, dev
, 1 );
398 spin_unlock_irqrestore(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
400 printk(KERN_INFO
"%s:%s exit on line %d, rc = %d\n",
401 dev
->name
, __FUNCTION__
, __LINE__
, rc
);
403 CLAW_DBF_TEXT_(4,trace
,"clawtx%d",rc
);
405 } /* end of claw_tx */
407 /*------------------------------------------------------------------*
408 * pack the collect queue into an skb and return it *
409 * If not packing just return the top skb from the queue *
410 *------------------------------------------------------------------*/
412 static struct sk_buff
*
413 claw_pack_skb(struct claw_privbk
*privptr
)
415 struct sk_buff
*new_skb
,*held_skb
;
416 struct chbk
*p_ch
= &privptr
->channel
[WRITE
];
417 struct claw_env
*p_env
= privptr
->p_env
;
418 int pkt_cnt
,pk_ind
,so_far
;
420 new_skb
= NULL
; /* assume no dice */
422 CLAW_DBF_TEXT(4,trace
,"PackSKBe");
423 if (!skb_queue_empty(&p_ch
->collect_queue
)) {
425 held_skb
= skb_dequeue(&p_ch
->collect_queue
);
427 dev_kfree_skb_any(held_skb
);
430 if (p_env
->packing
!= DO_PACKED
)
432 /* get a new SKB we will pack at least one */
433 new_skb
= dev_alloc_skb(p_env
->write_size
);
434 if (new_skb
== NULL
) {
435 atomic_inc(&held_skb
->users
);
436 skb_queue_head(&p_ch
->collect_queue
,held_skb
);
439 /* we have packed packet and a place to put it */
442 new_skb
->cb
[1] = 'P'; /* every skb on queue has pack header */
443 while ((pk_ind
) && (held_skb
!= NULL
)) {
444 if (held_skb
->len
+so_far
<= p_env
->write_size
-8) {
445 memcpy(skb_put(new_skb
,held_skb
->len
),
446 held_skb
->data
,held_skb
->len
);
447 privptr
->stats
.tx_packets
++;
448 so_far
+= held_skb
->len
;
450 dev_kfree_skb_any(held_skb
);
451 held_skb
= skb_dequeue(&p_ch
->collect_queue
);
453 atomic_dec(&held_skb
->users
);
456 atomic_inc(&held_skb
->users
);
457 skb_queue_head(&p_ch
->collect_queue
,held_skb
);
461 printk(KERN_INFO
"%s: %s() Packed %d len %d\n",
463 __FUNCTION__
,pkt_cnt
,new_skb
->len
);
466 CLAW_DBF_TEXT(4,trace
,"PackSKBx");
470 /*-------------------------------------------------------------------*
473 *-------------------------------------------------------------------*/
476 claw_change_mtu(struct net_device
*dev
, int new_mtu
)
478 struct claw_privbk
*privptr
=dev
->priv
;
481 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
484 printk(KERN_INFO
"variable dev =\n");
485 dumpit((char *) dev
, sizeof(struct net_device
));
486 printk(KERN_INFO
"variable new_mtu = %d\n", new_mtu
);
488 CLAW_DBF_TEXT(4,trace
,"setmtu");
489 buff_size
= privptr
->p_env
->write_size
;
490 if ((new_mtu
< 60) || (new_mtu
> buff_size
)) {
492 printk(KERN_INFO
"%s:%s Exit on line %d, rc=EINVAL\n",
494 __FUNCTION__
, __LINE__
);
500 printk(KERN_INFO
"%s:%s Exit on line %d\n",dev
->name
,
501 __FUNCTION__
, __LINE__
);
504 } /* end of claw_change_mtu */
507 /*-------------------------------------------------------------------*
510 *-------------------------------------------------------------------*/
512 claw_open(struct net_device
*dev
)
517 unsigned long saveflags
=0;
519 struct claw_privbk
*privptr
;
520 DECLARE_WAITQUEUE(wait
, current
);
521 struct timer_list timer
;
525 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
527 CLAW_DBF_TEXT(4,trace
,"open");
528 if (!dev
|| (dev
->name
[0] == 0x00)) {
529 CLAW_DBF_TEXT(2,trace
,"BadDev");
530 printk(KERN_WARNING
"claw: Bad device at open failing \n");
533 privptr
= (struct claw_privbk
*)dev
->priv
;
534 /* allocate and initialize CCW blocks */
535 if (privptr
->buffs_alloc
== 0) {
538 printk(KERN_INFO
"%s:%s Exit on line %d, rc=ENOMEM\n",
540 __FUNCTION__
, __LINE__
);
541 CLAW_DBF_TEXT(2,trace
,"openmem");
545 privptr
->system_validate_comp
=0;
546 privptr
->release_pend
=0;
547 if(strncmp(privptr
->p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
548 privptr
->p_env
->read_size
=DEF_PACK_BUFSIZE
;
549 privptr
->p_env
->write_size
=DEF_PACK_BUFSIZE
;
550 privptr
->p_env
->packing
=PACKING_ASK
;
552 privptr
->p_env
->packing
=0;
553 privptr
->p_env
->read_size
=CLAW_FRAME_SIZE
;
554 privptr
->p_env
->write_size
=CLAW_FRAME_SIZE
;
557 tasklet_init(&privptr
->channel
[READ
].tasklet
, claw_irq_tasklet
,
558 (unsigned long) &privptr
->channel
[READ
]);
559 for ( i
= 0; i
< 2; i
++) {
560 CLAW_DBF_TEXT_(2,trace
,"opn_ch%d",i
);
561 init_waitqueue_head(&privptr
->channel
[i
].wait
);
562 /* skb_queue_head_init(&p_ch->io_queue); */
565 &privptr
->channel
[WRITE
].collect_queue
);
566 privptr
->channel
[i
].flag_a
= 0;
567 privptr
->channel
[i
].IO_active
= 0;
568 privptr
->channel
[i
].flag
&= ~CLAW_TIMER
;
570 timer
.function
= (void *)claw_timer
;
571 timer
.data
= (unsigned long)(&privptr
->channel
[i
]);
572 timer
.expires
= jiffies
+ 15*HZ
;
574 spin_lock_irqsave(get_ccwdev_lock(
575 privptr
->channel
[i
].cdev
), saveflags
);
576 parm
= (unsigned long) &privptr
->channel
[i
];
577 privptr
->channel
[i
].claw_state
= CLAW_START_HALT_IO
;
579 add_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
580 rc
= ccw_device_halt(
581 (struct ccw_device
*)privptr
->channel
[i
].cdev
,parm
);
582 set_current_state(TASK_INTERRUPTIBLE
);
583 spin_unlock_irqrestore(
584 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
586 set_current_state(TASK_RUNNING
);
587 remove_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
589 ccw_check_return_code(privptr
->channel
[i
].cdev
, rc
);
590 if((privptr
->channel
[i
].flag
& CLAW_TIMER
) == 0x00)
593 if ((((privptr
->channel
[READ
].last_dstat
|
594 privptr
->channel
[WRITE
].last_dstat
) &
595 ~(DEV_STAT_CHN_END
| DEV_STAT_DEV_END
)) != 0x00) ||
596 (((privptr
->channel
[READ
].flag
|
597 privptr
->channel
[WRITE
].flag
) & CLAW_TIMER
) != 0x00)) {
599 printk(KERN_INFO
"%s: channel problems during open - read:"
600 " %02x - write: %02x\n",
602 privptr
->channel
[READ
].last_dstat
,
603 privptr
->channel
[WRITE
].last_dstat
);
605 printk(KERN_INFO
"%s: remote side is not ready\n", dev
->name
);
606 CLAW_DBF_TEXT(2,trace
,"notrdy");
608 for ( i
= 0; i
< 2; i
++) {
610 get_ccwdev_lock(privptr
->channel
[i
].cdev
),
612 parm
= (unsigned long) &privptr
->channel
[i
];
613 privptr
->channel
[i
].claw_state
= CLAW_STOP
;
614 rc
= ccw_device_halt(
615 (struct ccw_device
*)&privptr
->channel
[i
].cdev
,
617 spin_unlock_irqrestore(
618 get_ccwdev_lock(privptr
->channel
[i
].cdev
),
621 ccw_check_return_code(
622 privptr
->channel
[i
].cdev
, rc
);
625 free_pages((unsigned long)privptr
->p_buff_ccw
,
626 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
627 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
628 free_pages((unsigned long)privptr
->p_buff_read
,
629 (int)pages_to_order_of_mag(
630 privptr
->p_buff_read_num
));
633 p_buf
=privptr
->p_read_active_first
;
634 while (p_buf
!=NULL
) {
635 free_pages((unsigned long)p_buf
->p_buffer
,
636 (int)pages_to_order_of_mag(
637 privptr
->p_buff_pages_perread
));
641 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
642 free_pages((unsigned long)privptr
->p_buff_write
,
643 (int)pages_to_order_of_mag(
644 privptr
->p_buff_write_num
));
647 p_buf
=privptr
->p_write_active_first
;
648 while (p_buf
!=NULL
) {
649 free_pages((unsigned long)p_buf
->p_buffer
,
650 (int)pages_to_order_of_mag(
651 privptr
->p_buff_pages_perwrite
));
655 privptr
->buffs_alloc
= 0;
656 privptr
->channel
[READ
].flag
= 0x00;
657 privptr
->channel
[WRITE
].flag
= 0x00;
658 privptr
->p_buff_ccw
=NULL
;
659 privptr
->p_buff_read
=NULL
;
660 privptr
->p_buff_write
=NULL
;
661 claw_clear_busy(dev
);
663 printk(KERN_INFO
"%s:%s Exit on line %d, rc=EIO\n",
664 dev
->name
,__FUNCTION__
,__LINE__
);
666 CLAW_DBF_TEXT(2,trace
,"open EIO");
670 /* Send SystemValidate command */
672 claw_clear_busy(dev
);
675 printk(KERN_INFO
"%s:%s Exit on line %d, rc=0\n",
676 dev
->name
,__FUNCTION__
,__LINE__
);
678 CLAW_DBF_TEXT(4,trace
,"openok");
680 } /* end of claw_open */
682 /*-------------------------------------------------------------------*
686 *--------------------------------------------------------------------*/
688 claw_irq_handler(struct ccw_device
*cdev
,
689 unsigned long intparm
, struct irb
*irb
)
691 struct chbk
*p_ch
= NULL
;
692 struct claw_privbk
*privptr
= NULL
;
693 struct net_device
*dev
= NULL
;
694 struct claw_env
*p_env
;
695 struct chbk
*p_ch_r
=NULL
;
699 printk(KERN_INFO
"%s enter \n",__FUNCTION__
);
701 CLAW_DBF_TEXT(4,trace
,"clawirq");
702 /* Bypass all 'unsolicited interrupts' */
703 if (!cdev
->dev
.driver_data
) {
704 printk(KERN_WARNING
"claw: unsolicited interrupt for device:"
705 "%s received c-%02x d-%02x\n",
706 cdev
->dev
.bus_id
,irb
->scsw
.cstat
, irb
->scsw
.dstat
);
708 printk(KERN_INFO
"claw: %s() "
709 "exit on line %d\n",__FUNCTION__
,__LINE__
);
711 CLAW_DBF_TEXT(2,trace
,"badirq");
714 privptr
= (struct claw_privbk
*)cdev
->dev
.driver_data
;
716 /* Try to extract channel from driver data. */
717 if (privptr
->channel
[READ
].cdev
== cdev
)
718 p_ch
= &privptr
->channel
[READ
];
719 else if (privptr
->channel
[WRITE
].cdev
== cdev
)
720 p_ch
= &privptr
->channel
[WRITE
];
722 printk(KERN_WARNING
"claw: Can't determine channel for "
723 "interrupt, device %s\n", cdev
->dev
.bus_id
);
724 CLAW_DBF_TEXT(2,trace
,"badchan");
727 CLAW_DBF_TEXT_(4,trace
,"IRQCH=%d",p_ch
->flag
);
729 dev
= (struct net_device
*) (p_ch
->ndev
);
730 p_env
=privptr
->p_env
;
733 printk(KERN_INFO
"%s: interrupt for device: %04x "
734 "received c-%02x d-%02x state-%02x\n",
735 dev
->name
, p_ch
->devno
, irb
->scsw
.cstat
,
736 irb
->scsw
.dstat
, p_ch
->claw_state
);
739 /* Copy interruption response block. */
740 memcpy(p_ch
->irb
, irb
, sizeof(struct irb
));
742 /* Check for good subchannel return code, otherwise error message */
743 if (irb
->scsw
.cstat
&& !(irb
->scsw
.cstat
& SCHN_STAT_PCI
)) {
744 printk(KERN_INFO
"%s: subchannel check for device: %04x -"
745 " Sch Stat %02x Dev Stat %02x CPA - %04x\n",
746 dev
->name
, p_ch
->devno
,
747 irb
->scsw
.cstat
, irb
->scsw
.dstat
,irb
->scsw
.cpa
);
749 dumpit((char *)irb
,sizeof(struct irb
));
750 dumpit((char *)(unsigned long)irb
->scsw
.cpa
,
751 sizeof(struct ccw1
));
754 printk(KERN_INFO
"%s:%s Exit on line %d\n",
755 dev
->name
,__FUNCTION__
,__LINE__
);
757 CLAW_DBF_TEXT(2,trace
,"chanchk");
761 /* Check the reason-code of a unit check */
762 if (irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
763 ccw_check_unit_check(p_ch
, irb
->ecw
[0]);
766 /* State machine to bring the connection up, down and to restart */
767 p_ch
->last_dstat
= irb
->scsw
.dstat
;
769 switch (p_ch
->claw_state
) {
770 case CLAW_STOP
:/* HALT_IO by claw_release (halt sequence) */
772 printk(KERN_INFO
"%s: CLAW_STOP enter\n", dev
->name
);
774 if (!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
775 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
776 (p_ch
->irb
->scsw
.stctl
==
777 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
779 printk(KERN_INFO
"%s:%s Exit on line %d\n",
780 dev
->name
,__FUNCTION__
,__LINE__
);
784 wake_up(&p_ch
->wait
); /* wake up claw_release */
787 printk(KERN_INFO
"%s: CLAW_STOP exit\n", dev
->name
);
790 printk(KERN_INFO
"%s:%s Exit on line %d\n",
791 dev
->name
,__FUNCTION__
,__LINE__
);
793 CLAW_DBF_TEXT(4,trace
,"stop");
796 case CLAW_START_HALT_IO
: /* HALT_IO issued by claw_open */
798 printk(KERN_INFO
"%s: process CLAW_STAT_HALT_IO\n",
801 if (!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
802 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
803 (p_ch
->irb
->scsw
.stctl
==
804 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
806 printk(KERN_INFO
"%s:%s Exit on line %d\n",
807 dev
->name
,__FUNCTION__
,__LINE__
);
809 CLAW_DBF_TEXT(4,trace
,"haltio");
812 if (p_ch
->flag
== CLAW_READ
) {
813 p_ch
->claw_state
= CLAW_START_READ
;
814 wake_up(&p_ch
->wait
); /* wake claw_open (READ)*/
817 if (p_ch
->flag
== CLAW_WRITE
) {
818 p_ch
->claw_state
= CLAW_START_WRITE
;
819 /* send SYSTEM_VALIDATE */
820 claw_strt_read(dev
, LOCK_NO
);
821 claw_send_control(dev
,
822 SYSTEM_VALIDATE_REQUEST
,
825 p_env
->adapter_name
);
827 printk(KERN_WARNING
"claw: unsolicited "
828 "interrupt for device:"
829 "%s received c-%02x d-%02x\n",
836 printk(KERN_INFO
"%s: process CLAW_STAT_HALT_IO exit\n",
840 printk(KERN_INFO
"%s:%s Exit on line %d\n",
841 dev
->name
,__FUNCTION__
,__LINE__
);
843 CLAW_DBF_TEXT(4,trace
,"haltio");
845 case CLAW_START_READ
:
846 CLAW_DBF_TEXT(4,trace
,"ReadIRQ");
847 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
848 clear_bit(0, (void *)&p_ch
->IO_active
);
849 if ((p_ch
->irb
->ecw
[0] & 0x41) == 0x41 ||
850 (p_ch
->irb
->ecw
[0] & 0x40) == 0x40 ||
851 (p_ch
->irb
->ecw
[0]) == 0)
853 privptr
->stats
.rx_errors
++;
854 printk(KERN_INFO
"%s: Restart is "
855 "required after remote "
860 printk(KERN_INFO
"%s:%s Exit on line %d\n",
861 dev
->name
,__FUNCTION__
,__LINE__
);
863 CLAW_DBF_TEXT(4,trace
,"notrdy");
866 if ((p_ch
->irb
->scsw
.cstat
& SCHN_STAT_PCI
) &&
867 (p_ch
->irb
->scsw
.dstat
==0)) {
868 if (test_and_set_bit(CLAW_BH_ACTIVE
,
869 (void *)&p_ch
->flag_a
) == 0) {
870 tasklet_schedule(&p_ch
->tasklet
);
873 CLAW_DBF_TEXT(4,trace
,"PCINoBH");
876 printk(KERN_INFO
"%s:%s Exit on line %d\n",
877 dev
->name
,__FUNCTION__
,__LINE__
);
879 CLAW_DBF_TEXT(4,trace
,"PCI_read");
882 if(!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
883 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
884 (p_ch
->irb
->scsw
.stctl
==
885 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
887 printk(KERN_INFO
"%s:%s Exit on line %d\n",
888 dev
->name
,__FUNCTION__
,__LINE__
);
890 CLAW_DBF_TEXT(4,trace
,"SPend_rd");
893 clear_bit(0, (void *)&p_ch
->IO_active
);
894 claw_clearbit_busy(TB_RETRY
,dev
);
895 if (test_and_set_bit(CLAW_BH_ACTIVE
,
896 (void *)&p_ch
->flag_a
) == 0) {
897 tasklet_schedule(&p_ch
->tasklet
);
900 CLAW_DBF_TEXT(4,trace
,"RdBHAct");
904 printk(KERN_INFO
"%s: process CLAW_START_READ exit\n",
908 printk(KERN_INFO
"%s:%s Exit on line %d\n",
909 dev
->name
,__FUNCTION__
,__LINE__
);
911 CLAW_DBF_TEXT(4,trace
,"RdIRQXit");
913 case CLAW_START_WRITE
:
914 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_CHECK
) {
915 printk(KERN_INFO
"%s: Unit Check Occured in "
916 "write channel\n",dev
->name
);
917 clear_bit(0, (void *)&p_ch
->IO_active
);
918 if (p_ch
->irb
->ecw
[0] & 0x80 ) {
919 printk(KERN_INFO
"%s: Resetting Event "
920 "occurred:\n",dev
->name
);
921 init_timer(&p_ch
->timer
);
922 p_ch
->timer
.function
=
923 (void *)claw_write_retry
;
924 p_ch
->timer
.data
= (unsigned long)p_ch
;
925 p_ch
->timer
.expires
= jiffies
+ 10*HZ
;
926 add_timer(&p_ch
->timer
);
927 printk(KERN_INFO
"%s: write connection "
928 "restarting\n",dev
->name
);
931 printk(KERN_INFO
"%s:%s Exit on line %d\n",
932 dev
->name
,__FUNCTION__
,__LINE__
);
934 CLAW_DBF_TEXT(4,trace
,"rstrtwrt");
937 if (p_ch
->irb
->scsw
.dstat
& DEV_STAT_UNIT_EXCEP
) {
938 clear_bit(0, (void *)&p_ch
->IO_active
);
939 printk(KERN_INFO
"%s: Unit Exception "
940 "Occured in write channel\n",
943 if(!((p_ch
->irb
->scsw
.stctl
& SCSW_STCTL_SEC_STATUS
) ||
944 (p_ch
->irb
->scsw
.stctl
== SCSW_STCTL_STATUS_PEND
) ||
945 (p_ch
->irb
->scsw
.stctl
==
946 (SCSW_STCTL_ALERT_STATUS
| SCSW_STCTL_STATUS_PEND
)))) {
948 printk(KERN_INFO
"%s:%s Exit on line %d\n",
949 dev
->name
,__FUNCTION__
,__LINE__
);
951 CLAW_DBF_TEXT(4,trace
,"writeUE");
954 clear_bit(0, (void *)&p_ch
->IO_active
);
955 if (claw_test_and_setbit_busy(TB_TX
,dev
)==0) {
956 claw_write_next(p_ch
);
957 claw_clearbit_busy(TB_TX
,dev
);
958 claw_clear_busy(dev
);
960 p_ch_r
=(struct chbk
*)&privptr
->channel
[READ
];
961 if (test_and_set_bit(CLAW_BH_ACTIVE
,
962 (void *)&p_ch_r
->flag_a
) == 0) {
963 tasklet_schedule(&p_ch_r
->tasklet
);
967 printk(KERN_INFO
"%s: process CLAW_START_WRITE exit\n",
971 printk(KERN_INFO
"%s:%s Exit on line %d\n",
972 dev
->name
,__FUNCTION__
,__LINE__
);
974 CLAW_DBF_TEXT(4,trace
,"StWtExit");
977 printk(KERN_WARNING
"%s: wrong selection code - irq "
978 "state=%d\n",dev
->name
,p_ch
->claw_state
);
980 printk(KERN_INFO
"%s:%s Exit on line %d\n",
981 dev
->name
,__FUNCTION__
,__LINE__
);
983 CLAW_DBF_TEXT(2,trace
,"badIRQ");
987 } /* end of claw_irq_handler */
990 /*-------------------------------------------------------------------*
993 *--------------------------------------------------------------------*/
995 claw_irq_tasklet ( unsigned long data
)
998 struct net_device
*dev
;
999 struct claw_privbk
* privptr
;
1001 p_ch
= (struct chbk
*) data
;
1002 dev
= (struct net_device
*)p_ch
->ndev
;
1004 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1007 printk(KERN_INFO
"%s: variable p_ch =\n",dev
->name
);
1008 dumpit((char *) p_ch
, sizeof(struct chbk
));
1010 CLAW_DBF_TEXT(4,trace
,"IRQtask");
1012 privptr
= (struct claw_privbk
*) dev
->priv
;
1015 printk(KERN_INFO
"%s: bh routine - state-%02x\n" ,
1016 dev
->name
, p_ch
->claw_state
);
1020 clear_bit(CLAW_BH_ACTIVE
, (void *)&p_ch
->flag_a
);
1021 CLAW_DBF_TEXT(4,trace
,"TskletXt");
1023 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1024 dev
->name
,__FUNCTION__
,__LINE__
);
1027 } /* end of claw_irq_bh */
1029 /*-------------------------------------------------------------------*
1032 *--------------------------------------------------------------------*/
1034 claw_release(struct net_device
*dev
)
1038 unsigned long saveflags
;
1040 struct claw_privbk
*privptr
;
1041 DECLARE_WAITQUEUE(wait
, current
);
1042 struct ccwbk
* p_this_ccw
;
1043 struct ccwbk
* p_buf
;
1047 privptr
= (struct claw_privbk
*) dev
->priv
;
1051 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1053 CLAW_DBF_TEXT(4,trace
,"release");
1055 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1056 dumpit((char *) dev
, sizeof(struct net_device
));
1057 printk(KERN_INFO
"Priv Buffalloc %d\n",privptr
->buffs_alloc
);
1058 printk(KERN_INFO
"Priv p_buff_ccw = %p\n",&privptr
->p_buff_ccw
);
1060 privptr
->release_pend
=1;
1061 claw_setbit_busy(TB_STOP
,dev
);
1062 for ( i
= 1; i
>=0 ; i
--) {
1064 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
1065 /* del_timer(&privptr->channel[READ].timer); */
1066 privptr
->channel
[i
].claw_state
= CLAW_STOP
;
1067 privptr
->channel
[i
].IO_active
= 0;
1068 parm
= (unsigned long) &privptr
->channel
[i
];
1070 claw_purge_skb_queue(
1071 &privptr
->channel
[WRITE
].collect_queue
);
1072 rc
= ccw_device_halt (privptr
->channel
[i
].cdev
, parm
);
1073 if (privptr
->system_validate_comp
==0x00) /* never opened? */
1074 init_waitqueue_head(&privptr
->channel
[i
].wait
);
1075 add_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
1076 set_current_state(TASK_INTERRUPTIBLE
);
1077 spin_unlock_irqrestore(
1078 get_ccwdev_lock(privptr
->channel
[i
].cdev
), saveflags
);
1080 set_current_state(TASK_RUNNING
);
1081 remove_wait_queue(&privptr
->channel
[i
].wait
, &wait
);
1083 ccw_check_return_code(privptr
->channel
[i
].cdev
, rc
);
1086 if (privptr
->pk_skb
!= NULL
) {
1087 dev_kfree_skb_any(privptr
->pk_skb
);
1088 privptr
->pk_skb
= NULL
;
1090 if(privptr
->buffs_alloc
!= 1) {
1092 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1093 dev
->name
,__FUNCTION__
,__LINE__
);
1095 CLAW_DBF_TEXT(4,trace
,"none2fre");
1098 CLAW_DBF_TEXT(4,trace
,"freebufs");
1099 if (privptr
->p_buff_ccw
!= NULL
) {
1100 free_pages((unsigned long)privptr
->p_buff_ccw
,
1101 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
1103 CLAW_DBF_TEXT(4,trace
,"freeread");
1104 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
1105 if (privptr
->p_buff_read
!= NULL
) {
1106 free_pages((unsigned long)privptr
->p_buff_read
,
1107 (int)pages_to_order_of_mag(privptr
->p_buff_read_num
));
1111 p_buf
=privptr
->p_read_active_first
;
1112 while (p_buf
!=NULL
) {
1113 free_pages((unsigned long)p_buf
->p_buffer
,
1114 (int)pages_to_order_of_mag(
1115 privptr
->p_buff_pages_perread
));
1119 CLAW_DBF_TEXT(4,trace
,"freewrit");
1120 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
1121 free_pages((unsigned long)privptr
->p_buff_write
,
1122 (int)pages_to_order_of_mag(privptr
->p_buff_write_num
));
1125 p_buf
=privptr
->p_write_active_first
;
1126 while (p_buf
!=NULL
) {
1127 free_pages((unsigned long)p_buf
->p_buffer
,
1128 (int)pages_to_order_of_mag(
1129 privptr
->p_buff_pages_perwrite
));
1133 CLAW_DBF_TEXT(4,trace
,"clearptr");
1134 privptr
->buffs_alloc
= 0;
1135 privptr
->p_buff_ccw
=NULL
;
1136 privptr
->p_buff_read
=NULL
;
1137 privptr
->p_buff_write
=NULL
;
1138 privptr
->system_validate_comp
=0;
1139 privptr
->release_pend
=0;
1140 /* Remove any writes that were pending and reset all reads */
1141 p_this_ccw
=privptr
->p_read_active_first
;
1142 while (p_this_ccw
!=NULL
) {
1143 p_this_ccw
->header
.length
=0xffff;
1144 p_this_ccw
->header
.opcode
=0xff;
1145 p_this_ccw
->header
.flag
=0x00;
1146 p_this_ccw
=p_this_ccw
->next
;
1149 while (privptr
->p_write_active_first
!=NULL
) {
1150 p_this_ccw
=privptr
->p_write_active_first
;
1151 p_this_ccw
->header
.flag
=CLAW_PENDING
;
1152 privptr
->p_write_active_first
=p_this_ccw
->next
;
1153 p_this_ccw
->next
=privptr
->p_write_free_chain
;
1154 privptr
->p_write_free_chain
=p_this_ccw
;
1155 ++privptr
->write_free_count
;
1157 privptr
->p_write_active_last
=NULL
;
1158 privptr
->mtc_logical_link
= -1;
1159 privptr
->mtc_skipping
= 1;
1160 privptr
->mtc_offset
=0;
1162 if (((privptr
->channel
[READ
].last_dstat
|
1163 privptr
->channel
[WRITE
].last_dstat
) &
1164 ~(DEV_STAT_CHN_END
| DEV_STAT_DEV_END
)) != 0x00) {
1165 printk(KERN_WARNING
"%s: channel problems during close - "
1166 "read: %02x - write: %02x\n",
1168 privptr
->channel
[READ
].last_dstat
,
1169 privptr
->channel
[WRITE
].last_dstat
);
1170 CLAW_DBF_TEXT(2,trace
,"badclose");
1173 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1174 dev
->name
,__FUNCTION__
,__LINE__
);
1176 CLAW_DBF_TEXT(4,trace
,"rlsexit");
1178 } /* end of claw_release */
1182 /*-------------------------------------------------------------------*
1183 * claw_write_retry *
1185 *--------------------------------------------------------------------*/
1188 claw_write_retry ( struct chbk
*p_ch
)
1191 struct net_device
*dev
=p_ch
->ndev
;
1195 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
1196 printk(KERN_INFO
"claw: variable p_ch =\n");
1197 dumpit((char *) p_ch
, sizeof(struct chbk
));
1199 CLAW_DBF_TEXT(4,trace
,"w_retry");
1200 if (p_ch
->claw_state
== CLAW_STOP
) {
1202 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1203 dev
->name
,__FUNCTION__
,__LINE__
);
1208 printk( KERN_INFO
"%s:%s state-%02x\n" ,
1213 claw_strt_out_IO( dev
);
1215 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1216 dev
->name
,__FUNCTION__
,__LINE__
);
1218 CLAW_DBF_TEXT(4,trace
,"rtry_xit");
1220 } /* end of claw_write_retry */
1223 /*-------------------------------------------------------------------*
1226 *--------------------------------------------------------------------*/
1229 claw_write_next ( struct chbk
* p_ch
)
1232 struct net_device
*dev
;
1233 struct claw_privbk
*privptr
=NULL
;
1234 struct sk_buff
*pk_skb
;
1238 printk(KERN_INFO
"%s:%s Enter \n",p_ch
->ndev
->name
,__FUNCTION__
);
1239 printk(KERN_INFO
"%s: variable p_ch =\n",p_ch
->ndev
->name
);
1240 dumpit((char *) p_ch
, sizeof(struct chbk
));
1242 CLAW_DBF_TEXT(4,trace
,"claw_wrt");
1243 if (p_ch
->claw_state
== CLAW_STOP
)
1245 dev
= (struct net_device
*) p_ch
->ndev
;
1246 privptr
= (struct claw_privbk
*) dev
->priv
;
1247 claw_free_wrt_buf( dev
);
1248 if ((privptr
->write_free_count
> 0) &&
1249 !skb_queue_empty(&p_ch
->collect_queue
)) {
1250 pk_skb
= claw_pack_skb(privptr
);
1251 while (pk_skb
!= NULL
) {
1252 rc
= claw_hw_tx( pk_skb
, dev
,1);
1253 if (privptr
->write_free_count
> 0) {
1254 pk_skb
= claw_pack_skb(privptr
);
1259 if (privptr
->p_write_active_first
!=NULL
) {
1260 claw_strt_out_IO(dev
);
1264 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1265 dev
->name
,__FUNCTION__
,__LINE__
);
1268 } /* end of claw_write_next */
1270 /*-------------------------------------------------------------------*
1273 *--------------------------------------------------------------------*/
1276 claw_timer ( struct chbk
* p_ch
)
1279 printk(KERN_INFO
"%s:%s Entry\n",p_ch
->ndev
->name
,__FUNCTION__
);
1280 printk(KERN_INFO
"%s: variable p_ch =\n",p_ch
->ndev
->name
);
1281 dumpit((char *) p_ch
, sizeof(struct chbk
));
1283 CLAW_DBF_TEXT(4,trace
,"timer");
1284 p_ch
->flag
|= CLAW_TIMER
;
1285 wake_up(&p_ch
->wait
);
1287 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1288 p_ch
->ndev
->name
,__FUNCTION__
,__LINE__
);
1291 } /* end of claw_timer */
1300 /*-------------------------------------------------------------------*
1302 * pages_to_order_of_mag *
1304 * takes a number of pages from 1 to 512 and returns the *
1305 * log(num_pages)/log(2) get_free_pages() needs a base 2 order *
1306 * of magnitude get_free_pages() has an upper order of 9 *
1307 *--------------------------------------------------------------------*/
1310 pages_to_order_of_mag(int num_of_pages
)
1312 int order_of_mag
=1; /* assume 2 pages */
1315 printk(KERN_INFO
"%s Enter pages = %d \n",__FUNCTION__
,num_of_pages
);
1317 CLAW_DBF_TEXT_(5,trace
,"pages%d",num_of_pages
);
1318 if (num_of_pages
== 1) {return 0; } /* magnitude of 0 = 1 page */
1319 /* 512 pages = 2Meg on 4k page systems */
1320 if (num_of_pages
>= 512) {return 9; }
1321 /* we have two or more pages order is at least 1 */
1322 for (nump
=2 ;nump
<= 512;nump
*=2) {
1323 if (num_of_pages
<= nump
)
1327 if (order_of_mag
> 9) { order_of_mag
= 9; } /* I know it's paranoid */
1329 printk(KERN_INFO
"%s Exit on line %d, order = %d\n",
1330 __FUNCTION__
,__LINE__
, order_of_mag
);
1332 CLAW_DBF_TEXT_(5,trace
,"mag%d",order_of_mag
);
1333 return order_of_mag
;
1336 /*-------------------------------------------------------------------*
1340 *--------------------------------------------------------------------*/
1342 add_claw_reads(struct net_device
*dev
, struct ccwbk
* p_first
,
1343 struct ccwbk
* p_last
)
1345 struct claw_privbk
*privptr
;
1346 struct ccw1 temp_ccw
;
1347 struct endccw
* p_end
;
1349 struct ccwbk
* p_buf
;
1352 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
1355 printk(KERN_INFO
"dev\n");
1356 dumpit((char *) dev
, sizeof(struct net_device
));
1357 printk(KERN_INFO
"p_first\n");
1358 dumpit((char *) p_first
, sizeof(struct ccwbk
));
1359 printk(KERN_INFO
"p_last\n");
1360 dumpit((char *) p_last
, sizeof(struct ccwbk
));
1362 CLAW_DBF_TEXT(4,trace
,"addreads");
1363 privptr
= dev
->priv
;
1364 p_end
= privptr
->p_end_ccw
;
1366 /* first CCW and last CCW contains a new set of read channel programs
1367 * to apend the running channel programs
1369 if ( p_first
==NULL
) {
1371 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1372 dev
->name
,__FUNCTION__
,__LINE__
);
1374 CLAW_DBF_TEXT(4,trace
,"addexit");
1378 /* set up ending CCW sequence for this segment */
1380 p_end
->read1
=0x00; /* second ending CCW is now active */
1381 /* reset ending CCWs and setup TIC CCWs */
1382 p_end
->read2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1383 p_end
->read2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1384 p_last
->r_TIC_1
.cda
=(__u32
)__pa(&p_end
->read2_nop1
);
1385 p_last
->r_TIC_2
.cda
=(__u32
)__pa(&p_end
->read2_nop1
);
1386 p_end
->read2_nop2
.cda
=0;
1387 p_end
->read2_nop2
.count
=1;
1390 p_end
->read1
=0x01; /* first ending CCW is now active */
1391 /* reset ending CCWs and setup TIC CCWs */
1392 p_end
->read1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1393 p_end
->read1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1394 p_last
->r_TIC_1
.cda
= (__u32
)__pa(&p_end
->read1_nop1
);
1395 p_last
->r_TIC_2
.cda
= (__u32
)__pa(&p_end
->read1_nop1
);
1396 p_end
->read1_nop2
.cda
=0;
1397 p_end
->read1_nop2
.count
=1;
1400 if ( privptr
-> p_read_active_first
==NULL
) {
1402 printk(KERN_INFO
"%s:%s p_read_active_first == NULL \n",
1403 dev
->name
,__FUNCTION__
);
1404 printk(KERN_INFO
"%s:%s Read active first/last changed \n",
1405 dev
->name
,__FUNCTION__
);
1407 privptr
-> p_read_active_first
= p_first
; /* set new first */
1408 privptr
-> p_read_active_last
= p_last
; /* set new last */
1413 printk(KERN_INFO
"%s:%s Read in progress \n",
1414 dev
->name
,__FUNCTION__
);
1416 /* set up TIC ccw */
1417 temp_ccw
.cda
= (__u32
)__pa(&p_first
->read
);
1420 temp_ccw
.cmd_code
= CCW_CLAW_CMD_TIC
;
1425 /* first set of CCW's is chained to the new read */
1426 /* chain, so the second set is chained to the active chain. */
1427 /* Therefore modify the second set to point to the new */
1428 /* read chain set up TIC CCWs */
1429 /* make sure we update the CCW so channel doesn't fetch it */
1430 /* when it's only half done */
1431 memcpy( &p_end
->read2_nop2
, &temp_ccw
,
1432 sizeof(struct ccw1
));
1433 privptr
->p_read_active_last
->r_TIC_1
.cda
=
1434 (__u32
)__pa(&p_first
->read
);
1435 privptr
->p_read_active_last
->r_TIC_2
.cda
=
1436 (__u32
)__pa(&p_first
->read
);
1439 /* make sure we update the CCW so channel doesn't */
1440 /* fetch it when it is only half done */
1441 memcpy( &p_end
->read1_nop2
, &temp_ccw
,
1442 sizeof(struct ccw1
));
1443 privptr
->p_read_active_last
->r_TIC_1
.cda
=
1444 (__u32
)__pa(&p_first
->read
);
1445 privptr
->p_read_active_last
->r_TIC_2
.cda
=
1446 (__u32
)__pa(&p_first
->read
);
1448 /* chain in new set of blocks */
1449 privptr
->p_read_active_last
->next
= p_first
;
1450 privptr
->p_read_active_last
=p_last
;
1451 } /* end of if ( privptr-> p_read_active_first ==NULL) */
1453 printk(KERN_INFO
"%s:%s dump p_last CCW BK \n",dev
->name
,__FUNCTION__
);
1454 dumpit((char *)p_last
, sizeof(struct ccwbk
));
1455 printk(KERN_INFO
"%s:%s dump p_end CCW BK \n",dev
->name
,__FUNCTION__
);
1456 dumpit((char *)p_end
, sizeof(struct endccw
));
1458 printk(KERN_INFO
"%s:%s dump p_first CCW BK \n",dev
->name
,__FUNCTION__
);
1459 dumpit((char *)p_first
, sizeof(struct ccwbk
));
1460 printk(KERN_INFO
"%s:%s Dump Active CCW chain \n",
1461 dev
->name
,__FUNCTION__
);
1462 p_buf
=privptr
->p_read_active_first
;
1463 while (p_buf
!=NULL
) {
1464 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
1469 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1470 dev
->name
,__FUNCTION__
,__LINE__
);
1472 CLAW_DBF_TEXT(4,trace
,"addexit");
1474 } /* end of add_claw_reads */
1476 /*-------------------------------------------------------------------*
1477 * ccw_check_return_code *
1479 *-------------------------------------------------------------------*/
1482 ccw_check_return_code(struct ccw_device
*cdev
, int return_code
)
1485 printk(KERN_INFO
"%s: %s() > enter \n",
1486 cdev
->dev
.bus_id
,__FUNCTION__
);
1488 CLAW_DBF_TEXT(4,trace
,"ccwret");
1490 printk(KERN_INFO
"variable cdev =\n");
1491 dumpit((char *) cdev
, sizeof(struct ccw_device
));
1492 printk(KERN_INFO
"variable return_code = %d\n",return_code
);
1494 if (return_code
!= 0) {
1495 switch (return_code
) {
1497 printk(KERN_INFO
"%s: Busy !\n",
1501 printk(KERN_EMERG
"%s: Missing device called "
1502 "for IO ENODEV\n", cdev
->dev
.bus_id
);
1505 printk(KERN_EMERG
"%s: Status pending... EIO \n",
1509 printk(KERN_EMERG
"%s: Invalid Dev State EINVAL \n",
1513 printk(KERN_EMERG
"%s: Unknown error in "
1514 "Do_IO %d\n",cdev
->dev
.bus_id
, return_code
);
1518 printk(KERN_INFO
"%s: %s() > exit on line %d\n",
1519 cdev
->dev
.bus_id
,__FUNCTION__
,__LINE__
);
1521 CLAW_DBF_TEXT(4,trace
,"ccwret");
1522 } /* end of ccw_check_return_code */
1524 /*-------------------------------------------------------------------*
1525 * ccw_check_unit_check *
1526 *--------------------------------------------------------------------*/
1529 ccw_check_unit_check(struct chbk
* p_ch
, unsigned char sense
)
1531 struct net_device
*dev
= p_ch
->ndev
;
1534 printk(KERN_INFO
"%s: %s() > enter\n",dev
->name
,__FUNCTION__
);
1537 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1538 dumpit((char *)dev
, sizeof(struct net_device
));
1539 printk(KERN_INFO
"%s: variable sense =\n",dev
->name
);
1540 dumpit((char *)&sense
, 2);
1542 CLAW_DBF_TEXT(4,trace
,"unitchek");
1544 printk(KERN_INFO
"%s: Unit Check with sense byte:0x%04x\n",
1549 printk(KERN_WARNING
"%s: Interface disconnect or "
1551 "occurred (remote side)\n", dev
->name
);
1554 printk(KERN_WARNING
"%s: System reset occured"
1555 " (remote side)\n", dev
->name
);
1558 else if (sense
& 0x20) {
1560 printk(KERN_WARNING
"%s: Data-streaming "
1561 "timeout)\n", dev
->name
);
1564 printk(KERN_WARNING
"%s: Data-transfer parity"
1565 " error\n", dev
->name
);
1568 else if (sense
& 0x10) {
1570 printk(KERN_WARNING
"%s: Hardware malfunction "
1571 "(remote side)\n", dev
->name
);
1574 printk(KERN_WARNING
"%s: read-data parity error "
1575 "(remote side)\n", dev
->name
);
1580 printk(KERN_INFO
"%s: %s() exit on line %d\n",
1581 dev
->name
,__FUNCTION__
,__LINE__
);
1583 } /* end of ccw_check_unit_check */
1587 /*-------------------------------------------------------------------*
1588 * Dump buffer format *
1590 *--------------------------------------------------------------------*/
1593 dumpit(char* buf
, int len
)
1596 __u32 ct
, sw
, rm
, dup
;
1598 char tbuf
[82], tdup
[82];
1605 char bhex
[82], duphex
[82];
1613 for ( ct
=0; ct
< len
; ct
++, ptr
++, rptr
++ ) {
1616 sprintf(addr
, "%16.16lX",(unsigned long)rptr
);
1618 sprintf(addr
, "%8.8X",(__u32
)rptr
);
1620 sprintf(boff
, "%4.4X", (__u32
)ct
);
1624 if ((sw
== 4) || (sw
== 12)) {
1631 sprintf(tbuf
,"%2.2lX", (unsigned long)*ptr
);
1633 sprintf(tbuf
,"%2.2X", (__u32
)*ptr
);
1637 if ((0!=isprint(*ptr
)) && (*ptr
>= 0x20)) {
1647 if ((strcmp(duphex
, bhex
)) !=0) {
1649 sprintf(tdup
,"Duplicate as above to"
1651 printk( KERN_INFO
" "
1652 " --- %s ---\n",tdup
);
1654 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1655 addr
, boff
, bhex
, basc
);
1657 strcpy(duphex
, bhex
);
1668 for ( ; rm
> 0; rm
--, sw
++ ) {
1669 if ((sw
==4) || (sw
==12)) strcat(bhex
, " ");
1670 if (sw
==8) strcat(bhex
, " ");
1675 sprintf(tdup
,"Duplicate as above to %s", addr
);
1676 printk( KERN_INFO
" --- %s ---\n",
1679 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1680 addr
, boff
, bhex
, basc
);
1684 sprintf(tdup
,"Duplicate as above to %s", addr
);
1685 printk( KERN_INFO
" --- %s ---\n",
1689 printk( KERN_INFO
" %s (+%s) : %s [%s]\n",
1690 addr
, boff
, bhex
, basc
);
1695 } /* end of dumpit */
1698 /*-------------------------------------------------------------------*
1700 *--------------------------------------------------------------------*/
1702 find_link(struct net_device
*dev
, char *host_name
, char *ws_name
)
1704 struct claw_privbk
*privptr
;
1705 struct claw_env
*p_env
;
1709 printk(KERN_INFO
"%s:%s > enter \n",dev
->name
,__FUNCTION__
);
1711 CLAW_DBF_TEXT(2,setup
,"findlink");
1713 printk(KERN_INFO
"%s: variable dev = \n",dev
->name
);
1714 dumpit((char *) dev
, sizeof(struct net_device
));
1715 printk(KERN_INFO
"%s: variable host_name = %s\n",dev
->name
, host_name
);
1716 printk(KERN_INFO
"%s: variable ws_name = %s\n",dev
->name
, ws_name
);
1719 p_env
=privptr
->p_env
;
1720 switch (p_env
->packing
)
1723 if ((memcmp(WS_APPL_NAME_PACKED
, host_name
, 8)!=0) ||
1724 (memcmp(WS_APPL_NAME_PACKED
, ws_name
, 8)!=0 ))
1729 if ((memcmp(WS_APPL_NAME_IP_NAME
, host_name
, 8)!=0) ||
1730 (memcmp(WS_APPL_NAME_IP_NAME
, ws_name
, 8)!=0 ))
1734 if ((memcmp(HOST_APPL_NAME
, host_name
, 8)!=0) ||
1735 (memcmp(p_env
->api_type
, ws_name
, 8)!=0))
1741 printk(KERN_INFO
"%s:%s Exit on line %d\n",
1742 dev
->name
,__FUNCTION__
,__LINE__
);
1745 } /* end of find_link */
1747 /*-------------------------------------------------------------------*
1751 *-------------------------------------------------------------------*/
1754 claw_hw_tx(struct sk_buff
*skb
, struct net_device
*dev
, long linkid
)
1757 struct claw_privbk
*privptr
;
1758 struct ccwbk
*p_this_ccw
;
1759 struct ccwbk
*p_first_ccw
;
1760 struct ccwbk
*p_last_ccw
;
1762 signed long len_of_data
;
1763 unsigned long bytesInThisBuffer
;
1764 unsigned char *pDataAddress
;
1765 struct endccw
*pEnd
;
1766 struct ccw1 tempCCW
;
1768 struct claw_env
*p_env
;
1770 struct clawph
*pk_head
;
1773 struct ccwbk
*p_buf
;
1776 printk(KERN_INFO
"%s: %s() > enter\n",dev
->name
,__FUNCTION__
);
1778 CLAW_DBF_TEXT(4,trace
,"hw_tx");
1780 printk(KERN_INFO
"%s: variable dev skb =\n",dev
->name
);
1781 dumpit((char *) skb
, sizeof(struct sk_buff
));
1782 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
1783 dumpit((char *) dev
, sizeof(struct net_device
));
1784 printk(KERN_INFO
"%s: variable linkid = %ld\n",dev
->name
,linkid
);
1786 privptr
= (struct claw_privbk
*) (dev
->priv
);
1787 p_ch
=(struct chbk
*)&privptr
->channel
[WRITE
];
1788 p_env
=privptr
->p_env
;
1790 printk(KERN_INFO
"%s: %s() dump sk_buff \n",dev
->name
,__FUNCTION__
);
1791 dumpit((char *)skb
,sizeof(struct sk_buff
));
1793 claw_free_wrt_buf(dev
); /* Clean up free chain if posible */
1794 /* scan the write queue to free any completed write packets */
1797 if ((p_env
->packing
>= PACK_SEND
) &&
1798 (skb
->cb
[1] != 'P')) {
1799 skb_push(skb
,sizeof(struct clawph
));
1800 pk_head
=(struct clawph
*)skb
->data
;
1801 pk_head
->len
=skb
->len
-sizeof(struct clawph
);
1802 if (pk_head
->len
%4) {
1803 pk_head
->len
+= 4-(pk_head
->len
%4);
1804 skb_pad(skb
,4-(pk_head
->len
%4));
1805 skb_put(skb
,4-(pk_head
->len
%4));
1807 if (p_env
->packing
== DO_PACKED
)
1808 pk_head
->link_num
= linkid
;
1810 pk_head
->link_num
= 0;
1811 pk_head
->flag
= 0x00;
1816 if (claw_check_busy(dev
)) {
1817 if (privptr
->write_free_count
!=0) {
1818 claw_clear_busy(dev
);
1821 claw_strt_out_IO(dev
);
1822 claw_free_wrt_buf( dev
);
1823 if (privptr
->write_free_count
==0) {
1825 printk(KERN_INFO
"%s: "
1826 "(claw_check_busy) no free write "
1827 "buffers\n", dev
->name
);
1829 ch
= &privptr
->channel
[WRITE
];
1830 atomic_inc(&skb
->users
);
1831 skb_queue_tail(&ch
->collect_queue
, skb
);
1835 claw_clear_busy(dev
);
1840 if (claw_test_and_setbit_busy(TB_TX
,dev
)) { /* set to busy */
1842 printk(KERN_INFO
"%s: busy (claw_test_and_setbit_"
1843 "busy)\n", dev
->name
);
1845 ch
= &privptr
->channel
[WRITE
];
1846 atomic_inc(&skb
->users
);
1847 skb_queue_tail(&ch
->collect_queue
, skb
);
1848 claw_strt_out_IO(dev
);
1853 /* See how many write buffers are required to hold this data */
1854 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
1855 numBuffers
= ( skb
->len
+ privptr
->p_env
->write_size
- 1) /
1856 ( privptr
->p_env
->write_size
);
1858 numBuffers
= DIV_ROUND_UP(skb
->len
, privptr
->p_env
->write_size
);
1859 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
1861 /* If that number of buffers isn't available, give up for now */
1862 if (privptr
->write_free_count
< numBuffers
||
1863 privptr
->p_write_free_chain
== NULL
) {
1865 claw_setbit_busy(TB_NOBUFFER
,dev
);
1868 printk(KERN_INFO
"%s: busy (claw_setbit_busy"
1869 "(TB_NOBUFFER))\n", dev
->name
);
1870 printk(KERN_INFO
" free_count: %d, numBuffers : %d\n",
1871 (int)privptr
->write_free_count
,(int) numBuffers
);
1873 ch
= &privptr
->channel
[WRITE
];
1874 atomic_inc(&skb
->users
);
1875 skb_queue_tail(&ch
->collect_queue
, skb
);
1876 CLAW_DBF_TEXT(2,trace
,"clawbusy");
1879 pDataAddress
=skb
->data
;
1880 len_of_data
=skb
->len
;
1882 while (len_of_data
> 0) {
1884 printk(KERN_INFO
"%s: %s() length-of-data is %ld \n",
1885 dev
->name
,__FUNCTION__
,len_of_data
);
1886 dumpit((char *)pDataAddress
,64);
1888 p_this_ccw
=privptr
->p_write_free_chain
; /* get a block */
1889 if (p_this_ccw
== NULL
) { /* lost the race */
1890 ch
= &privptr
->channel
[WRITE
];
1891 atomic_inc(&skb
->users
);
1892 skb_queue_tail(&ch
->collect_queue
, skb
);
1895 privptr
->p_write_free_chain
=p_this_ccw
->next
;
1896 p_this_ccw
->next
=NULL
;
1897 --privptr
->write_free_count
; /* -1 */
1898 bytesInThisBuffer
=len_of_data
;
1899 memcpy( p_this_ccw
->p_buffer
,pDataAddress
, bytesInThisBuffer
);
1900 len_of_data
-=bytesInThisBuffer
;
1901 pDataAddress
+=(unsigned long)bytesInThisBuffer
;
1902 /* setup write CCW */
1903 p_this_ccw
->write
.cmd_code
= (linkid
* 8) +1;
1904 if (len_of_data
>0) {
1905 p_this_ccw
->write
.cmd_code
+=MORE_to_COME_FLAG
;
1907 p_this_ccw
->write
.count
=bytesInThisBuffer
;
1908 /* now add to end of this chain */
1909 if (p_first_ccw
==NULL
) {
1910 p_first_ccw
=p_this_ccw
;
1912 if (p_last_ccw
!=NULL
) {
1913 p_last_ccw
->next
=p_this_ccw
;
1914 /* set up TIC ccws */
1915 p_last_ccw
->w_TIC_1
.cda
=
1916 (__u32
)__pa(&p_this_ccw
->write
);
1918 p_last_ccw
=p_this_ccw
; /* save new last block */
1920 printk(KERN_INFO
"%s: %s() > CCW and Buffer %ld bytes long \n",
1921 dev
->name
,__FUNCTION__
,bytesInThisBuffer
);
1922 dumpit((char *)p_this_ccw
, sizeof(struct ccwbk
));
1923 dumpit((char *)p_this_ccw
->p_buffer
, 64);
1927 /* FirstCCW and LastCCW now contain a new set of write channel
1928 * programs to append to the running channel program
1931 if (p_first_ccw
!=NULL
) {
1932 /* setup ending ccw sequence for this segment */
1933 pEnd
=privptr
->p_end_ccw
;
1935 pEnd
->write1
=0x00; /* second end ccw is now active */
1936 /* set up Tic CCWs */
1937 p_last_ccw
->w_TIC_1
.cda
=
1938 (__u32
)__pa(&pEnd
->write2_nop1
);
1939 pEnd
->write2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1940 pEnd
->write2_nop2
.flags
=
1941 CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1942 pEnd
->write2_nop2
.cda
=0;
1943 pEnd
->write2_nop2
.count
=1;
1945 else { /* end of if (pEnd->write1)*/
1946 pEnd
->write1
=0x01; /* first end ccw is now active */
1947 /* set up Tic CCWs */
1948 p_last_ccw
->w_TIC_1
.cda
=
1949 (__u32
)__pa(&pEnd
->write1_nop1
);
1950 pEnd
->write1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
1951 pEnd
->write1_nop2
.flags
=
1952 CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
1953 pEnd
->write1_nop2
.cda
=0;
1954 pEnd
->write1_nop2
.count
=1;
1955 } /* end if if (pEnd->write1) */
1958 if (privptr
->p_write_active_first
==NULL
) {
1959 privptr
->p_write_active_first
=p_first_ccw
;
1960 privptr
->p_write_active_last
=p_last_ccw
;
1964 /* set up Tic CCWs */
1966 tempCCW
.cda
=(__u32
)__pa(&p_first_ccw
->write
);
1969 tempCCW
.cmd_code
=CCW_CLAW_CMD_TIC
;
1974 * first set of ending CCW's is chained to the new write
1975 * chain, so the second set is chained to the active chain
1976 * Therefore modify the second set to point the new write chain.
1977 * make sure we update the CCW atomically
1978 * so channel does not fetch it when it's only half done
1980 memcpy( &pEnd
->write2_nop2
, &tempCCW
,
1981 sizeof(struct ccw1
));
1982 privptr
->p_write_active_last
->w_TIC_1
.cda
=
1983 (__u32
)__pa(&p_first_ccw
->write
);
1987 /*make sure we update the CCW atomically
1988 *so channel does not fetch it when it's only half done
1990 memcpy(&pEnd
->write1_nop2
, &tempCCW
,
1991 sizeof(struct ccw1
));
1992 privptr
->p_write_active_last
->w_TIC_1
.cda
=
1993 (__u32
)__pa(&p_first_ccw
->write
);
1995 } /* end if if (pEnd->write1) */
1997 privptr
->p_write_active_last
->next
=p_first_ccw
;
1998 privptr
->p_write_active_last
=p_last_ccw
;
2001 } /* endif (p_first_ccw!=NULL) */
2005 printk(KERN_INFO
"%s: %s() > Dump Active CCW chain \n",
2006 dev
->name
,__FUNCTION__
);
2007 p_buf
=privptr
->p_write_active_first
;
2008 while (p_buf
!=NULL
) {
2009 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2012 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
2013 dumpit((char *)p_buf
, sizeof(struct endccw
));
2015 dev_kfree_skb_any(skb
);
2022 claw_strt_out_IO(dev
);
2023 /* if write free count is zero , set NOBUFFER */
2025 printk(KERN_INFO
"%s: %s() > free_count is %d\n",
2026 dev
->name
,__FUNCTION__
,
2027 (int) privptr
->write_free_count
);
2029 if (privptr
->write_free_count
==0) {
2030 claw_setbit_busy(TB_NOBUFFER
,dev
);
2033 claw_clearbit_busy(TB_TX
,dev
);
2036 printk(KERN_INFO
"%s: %s() > exit on line %d, rc = %d \n",
2037 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
2040 } /* end of claw_hw_tx */
2042 /*-------------------------------------------------------------------*
2046 *--------------------------------------------------------------------*/
2049 init_ccw_bk(struct net_device
*dev
)
2052 __u32 ccw_blocks_required
;
2053 __u32 ccw_blocks_perpage
;
2054 __u32 ccw_pages_required
;
2055 __u32 claw_reads_perpage
=1;
2056 __u32 claw_read_pages
;
2057 __u32 claw_writes_perpage
=1;
2058 __u32 claw_write_pages
;
2060 struct ccwbk
*p_free_chain
;
2062 struct ccwbk
*p_last_CCWB
;
2063 struct ccwbk
*p_first_CCWB
;
2064 struct endccw
*p_endccw
=NULL
;
2065 addr_t real_address
;
2066 struct claw_privbk
*privptr
=dev
->priv
;
2067 struct clawh
*pClawH
=NULL
;
2068 addr_t real_TIC_address
;
2071 printk(KERN_INFO
"%s: %s() enter \n",dev
->name
,__FUNCTION__
);
2073 CLAW_DBF_TEXT(4,trace
,"init_ccw");
2075 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
2076 dumpit((char *) dev
, sizeof(struct net_device
));
2079 /* initialize statistics field */
2080 privptr
->active_link_ID
=0;
2081 /* initialize ccwbk pointers */
2082 privptr
->p_write_free_chain
=NULL
; /* pointer to free ccw chain*/
2083 privptr
->p_write_active_first
=NULL
; /* pointer to the first write ccw*/
2084 privptr
->p_write_active_last
=NULL
; /* pointer to the last write ccw*/
2085 privptr
->p_read_active_first
=NULL
; /* pointer to the first read ccw*/
2086 privptr
->p_read_active_last
=NULL
; /* pointer to the last read ccw */
2087 privptr
->p_end_ccw
=NULL
; /* pointer to ending ccw */
2088 privptr
->p_claw_signal_blk
=NULL
; /* pointer to signal block */
2089 privptr
->buffs_alloc
= 0;
2090 memset(&privptr
->end_ccw
, 0x00, sizeof(struct endccw
));
2091 memset(&privptr
->ctl_bk
, 0x00, sizeof(struct clawctl
));
2092 /* initialize free write ccwbk counter */
2093 privptr
->write_free_count
=0; /* number of free bufs on write chain */
2097 * We need 1 CCW block for each read buffer, 1 for each
2098 * write buffer, plus 1 for ClawSignalBlock
2100 ccw_blocks_required
=
2101 privptr
->p_env
->read_buffers
+privptr
->p_env
->write_buffers
+1;
2103 printk(KERN_INFO
"%s: %s() "
2104 "ccw_blocks_required=%d\n",
2105 dev
->name
,__FUNCTION__
,
2106 ccw_blocks_required
);
2107 printk(KERN_INFO
"%s: %s() "
2109 dev
->name
,__FUNCTION__
,
2110 (unsigned int)PAGE_SIZE
);
2111 printk(KERN_INFO
"%s: %s() > "
2113 dev
->name
,__FUNCTION__
,
2114 (unsigned int)PAGE_MASK
);
2117 * compute number of CCW blocks that will fit in a page
2119 ccw_blocks_perpage
= PAGE_SIZE
/ CCWBK_SIZE
;
2121 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
2122 (ccw_blocks_required
+ccw_blocks_perpage
-1) /
2125 DIV_ROUND_UP(ccw_blocks_required
, ccw_blocks_perpage
);
2126 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
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 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
2143 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2144 claw_reads_perpage
= PAGE_SIZE
/ privptr
->p_env
->read_size
;
2145 claw_read_pages
= (privptr
->p_env
->read_buffers
+
2146 claw_reads_perpage
-1) / claw_reads_perpage
;
2148 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2149 claw_reads_perpage
= PAGE_SIZE
/ privptr
->p_env
->read_size
;
2150 claw_read_pages
= DIV_ROUND_UP(privptr
->p_env
->read_buffers
,
2151 claw_reads_perpage
);
2152 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
2154 else { /* > or equal */
2155 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
2156 privptr
->p_buff_pages_perread
=
2157 (privptr
->p_env
->read_size
+ PAGE_SIZE
- 1) / PAGE_SIZE
;
2159 privptr
->p_env
->read_buffers
* privptr
->p_buff_pages_perread
;
2161 privptr
->p_buff_pages_perread
=
2162 DIV_ROUND_UP(privptr
->p_env
->read_size
, PAGE_SIZE
);
2163 claw_read_pages
= privptr
->p_env
->read_buffers
*
2164 privptr
->p_buff_pages_perread
;
2165 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
2167 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2168 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
2169 claw_writes_perpage
=
2170 PAGE_SIZE
/ privptr
->p_env
->write_size
;
2172 (privptr
->p_env
->write_buffers
+ claw_writes_perpage
-1) /
2173 claw_writes_perpage
;
2175 claw_writes_perpage
=
2176 PAGE_SIZE
/ privptr
->p_env
->write_size
;
2177 claw_write_pages
= DIV_ROUND_UP(privptr
->p_env
->write_buffers
,
2178 claw_writes_perpage
);
2179 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
2182 else { /* > or equal */
2183 <<<<<<< HEAD
:drivers
/s390
/net
/claw
.c
2184 privptr
->p_buff_pages_perwrite
=
2185 (privptr
->p_env
->read_size
+ PAGE_SIZE
- 1) / PAGE_SIZE
;
2187 privptr
->p_env
->write_buffers
* privptr
->p_buff_pages_perwrite
;
2189 privptr
->p_buff_pages_perwrite
=
2190 DIV_ROUND_UP(privptr
->p_env
->read_size
, PAGE_SIZE
);
2191 claw_write_pages
= privptr
->p_env
->write_buffers
*
2192 privptr
->p_buff_pages_perwrite
;
2193 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/s390
/net
/claw
.c
2196 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2197 printk(KERN_INFO
"%s: %s() reads_perpage=%d\n",
2198 dev
->name
,__FUNCTION__
,
2199 claw_reads_perpage
);
2202 printk(KERN_INFO
"%s: %s() pages_perread=%d\n",
2203 dev
->name
,__FUNCTION__
,
2204 privptr
->p_buff_pages_perread
);
2206 printk(KERN_INFO
"%s: %s() read_pages=%d\n",
2207 dev
->name
,__FUNCTION__
,
2209 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2210 printk(KERN_INFO
"%s: %s() writes_perpage=%d\n",
2211 dev
->name
,__FUNCTION__
,
2212 claw_writes_perpage
);
2215 printk(KERN_INFO
"%s: %s() pages_perwrite=%d\n",
2216 dev
->name
,__FUNCTION__
,
2217 privptr
->p_buff_pages_perwrite
);
2219 printk(KERN_INFO
"%s: %s() write_pages=%d\n",
2220 dev
->name
,__FUNCTION__
,
2226 * allocate ccw_pages_required
2228 if (privptr
->p_buff_ccw
==NULL
) {
2229 privptr
->p_buff_ccw
=
2230 (void *)__get_free_pages(__GFP_DMA
,
2231 (int)pages_to_order_of_mag(ccw_pages_required
));
2232 if (privptr
->p_buff_ccw
==NULL
) {
2233 printk(KERN_INFO
"%s: %s() "
2234 "__get_free_pages for CCWs failed : "
2236 dev
->name
,__FUNCTION__
,
2237 ccw_pages_required
);
2239 printk(KERN_INFO
"%s: %s() > "
2240 "exit on line %d, rc = ENOMEM\n",
2241 dev
->name
,__FUNCTION__
,
2246 privptr
->p_buff_ccw_num
=ccw_pages_required
;
2248 memset(privptr
->p_buff_ccw
, 0x00,
2249 privptr
->p_buff_ccw_num
* PAGE_SIZE
);
2252 * obtain ending ccw block address
2255 privptr
->p_end_ccw
= (struct endccw
*)&privptr
->end_ccw
;
2256 real_address
= (__u32
)__pa(privptr
->p_end_ccw
);
2257 /* Initialize ending CCW block */
2259 printk(KERN_INFO
"%s: %s() begin initialize ending CCW blocks\n",
2260 dev
->name
,__FUNCTION__
);
2263 p_endccw
=privptr
->p_end_ccw
;
2264 p_endccw
->real
=real_address
;
2265 p_endccw
->write1
=0x00;
2266 p_endccw
->read1
=0x00;
2269 p_endccw
->write1_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2270 p_endccw
->write1_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2271 p_endccw
->write1_nop1
.count
= 1;
2272 p_endccw
->write1_nop1
.cda
= 0;
2275 p_endccw
->write1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2276 p_endccw
->write1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2277 p_endccw
->write1_nop2
.count
= 1;
2278 p_endccw
->write1_nop2
.cda
= 0;
2281 p_endccw
->write2_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2282 p_endccw
->write2_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2283 p_endccw
->write2_nop1
.count
= 1;
2284 p_endccw
->write2_nop1
.cda
= 0;
2287 p_endccw
->write2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2288 p_endccw
->write2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2289 p_endccw
->write2_nop2
.count
= 1;
2290 p_endccw
->write2_nop2
.cda
= 0;
2293 p_endccw
->read1_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2294 p_endccw
->read1_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2295 p_endccw
->read1_nop1
.count
= 1;
2296 p_endccw
->read1_nop1
.cda
= 0;
2299 p_endccw
->read1_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2300 p_endccw
->read1_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2301 p_endccw
->read1_nop2
.count
= 1;
2302 p_endccw
->read1_nop2
.cda
= 0;
2305 p_endccw
->read2_nop1
.cmd_code
= CCW_CLAW_CMD_NOP
;
2306 p_endccw
->read2_nop1
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2307 p_endccw
->read2_nop1
.count
= 1;
2308 p_endccw
->read2_nop1
.cda
= 0;
2311 p_endccw
->read2_nop2
.cmd_code
= CCW_CLAW_CMD_READFF
;
2312 p_endccw
->read2_nop2
.flags
= CCW_FLAG_SLI
| CCW_FLAG_SKIP
;
2313 p_endccw
->read2_nop2
.count
= 1;
2314 p_endccw
->read2_nop2
.cda
= 0;
2317 printk(KERN_INFO
"%s: %s() dump claw ending CCW BK \n",
2318 dev
->name
,__FUNCTION__
);
2319 dumpit((char *)p_endccw
, sizeof(struct endccw
));
2323 * Build a chain of CCWs
2328 printk(KERN_INFO
"%s: %s() Begin build a chain of CCW buffer \n",
2329 dev
->name
,__FUNCTION__
);
2331 p_buff
=privptr
->p_buff_ccw
;
2334 for (i
=0 ; i
< ccw_pages_required
; i
++ ) {
2335 real_address
= (__u32
)__pa(p_buff
);
2337 for (j
=0 ; j
< ccw_blocks_perpage
; j
++) {
2338 p_buf
->next
= p_free_chain
;
2339 p_free_chain
= p_buf
;
2340 p_buf
->real
=(__u32
)__pa(p_buf
);
2346 printk(KERN_INFO
"%s: %s() "
2347 "End build a chain of CCW buffer \n",
2348 dev
->name
,__FUNCTION__
);
2350 while (p_buf
!=NULL
) {
2351 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2357 * Initialize ClawSignalBlock
2361 printk(KERN_INFO
"%s: %s() "
2362 "Begin initialize ClawSignalBlock \n",
2363 dev
->name
,__FUNCTION__
);
2365 if (privptr
->p_claw_signal_blk
==NULL
) {
2366 privptr
->p_claw_signal_blk
=p_free_chain
;
2367 p_free_chain
=p_free_chain
->next
;
2368 pClawH
=(struct clawh
*)privptr
->p_claw_signal_blk
;
2369 pClawH
->length
=0xffff;
2370 pClawH
->opcode
=0xff;
2371 pClawH
->flag
=CLAW_BUSY
;
2374 printk(KERN_INFO
"%s: %s() > End initialize "
2375 "ClawSignalBlock\n",
2376 dev
->name
,__FUNCTION__
);
2377 dumpit((char *)privptr
->p_claw_signal_blk
, sizeof(struct ccwbk
));
2381 * allocate write_pages_required and add to free chain
2383 if (privptr
->p_buff_write
==NULL
) {
2384 if (privptr
->p_env
->write_size
< PAGE_SIZE
) {
2385 privptr
->p_buff_write
=
2386 (void *)__get_free_pages(__GFP_DMA
,
2387 (int)pages_to_order_of_mag(claw_write_pages
));
2388 if (privptr
->p_buff_write
==NULL
) {
2389 printk(KERN_INFO
"%s: %s() __get_free_pages for write"
2390 " bufs failed : get is for %d pages\n",
2391 dev
->name
,__FUNCTION__
,claw_write_pages
);
2392 free_pages((unsigned long)privptr
->p_buff_ccw
,
2393 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
2394 privptr
->p_buff_ccw
=NULL
;
2396 printk(KERN_INFO
"%s: %s() > exit on line %d,"
2398 dev
->name
,__FUNCTION__
,__LINE__
);
2403 * Build CLAW write free chain
2407 memset(privptr
->p_buff_write
, 0x00,
2408 ccw_pages_required
* PAGE_SIZE
);
2410 printk(KERN_INFO
"%s: %s() Begin build claw write free "
2411 "chain \n",dev
->name
,__FUNCTION__
);
2413 privptr
->p_write_free_chain
=NULL
;
2415 p_buff
=privptr
->p_buff_write
;
2417 for (i
=0 ; i
< privptr
->p_env
->write_buffers
; i
++) {
2418 p_buf
= p_free_chain
; /* get a CCW */
2419 p_free_chain
= p_buf
->next
;
2420 p_buf
->next
=privptr
->p_write_free_chain
;
2421 privptr
->p_write_free_chain
= p_buf
;
2422 p_buf
-> p_buffer
= (struct clawbuf
*)p_buff
;
2423 p_buf
-> write
.cda
= (__u32
)__pa(p_buff
);
2424 p_buf
-> write
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2425 p_buf
-> w_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2426 p_buf
-> w_read_FF
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2427 p_buf
-> w_read_FF
.count
= 1;
2428 p_buf
-> w_read_FF
.cda
=
2429 (__u32
)__pa(&p_buf
-> header
.flag
);
2430 p_buf
-> w_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2431 p_buf
-> w_TIC_1
.flags
= 0;
2432 p_buf
-> w_TIC_1
.count
= 0;
2434 if (((unsigned long)p_buff
+privptr
->p_env
->write_size
) >=
2435 ((unsigned long)(p_buff
+2*
2436 (privptr
->p_env
->write_size
) -1) & PAGE_MASK
)) {
2437 p_buff
= p_buff
+privptr
->p_env
->write_size
;
2441 else /* Buffers are => PAGE_SIZE. 1 buff per get_free_pages */
2443 privptr
->p_write_free_chain
=NULL
;
2444 for (i
= 0; i
< privptr
->p_env
->write_buffers
; i
++) {
2445 p_buff
=(void *)__get_free_pages(__GFP_DMA
,
2446 (int)pages_to_order_of_mag(
2447 privptr
->p_buff_pages_perwrite
) );
2449 printk(KERN_INFO
"%s:%s __get_free_pages "
2450 "for writes buf: get for %d pages\n",
2451 dev
->name
,__FUNCTION__
,
2452 privptr
->p_buff_pages_perwrite
);
2455 printk(KERN_INFO
"%s:%s __get_free_pages "
2456 "for writes buf failed : get is for %d pages\n",
2459 privptr
->p_buff_pages_perwrite
);
2460 free_pages((unsigned long)privptr
->p_buff_ccw
,
2461 (int)pages_to_order_of_mag(
2462 privptr
->p_buff_ccw_num
));
2463 privptr
->p_buff_ccw
=NULL
;
2464 p_buf
=privptr
->p_buff_write
;
2465 while (p_buf
!=NULL
) {
2466 free_pages((unsigned long)
2468 (int)pages_to_order_of_mag(
2469 privptr
->p_buff_pages_perwrite
));
2473 printk(KERN_INFO
"%s: %s exit on line %d, rc = ENOMEM\n",
2479 } /* Error on get_pages */
2480 memset(p_buff
, 0x00, privptr
->p_env
->write_size
);
2481 p_buf
= p_free_chain
;
2482 p_free_chain
= p_buf
->next
;
2483 p_buf
->next
= privptr
->p_write_free_chain
;
2484 privptr
->p_write_free_chain
= p_buf
;
2485 privptr
->p_buff_write
= p_buf
;
2486 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2487 p_buf
-> write
.cda
= (__u32
)__pa(p_buff
);
2488 p_buf
-> write
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2489 p_buf
-> w_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2490 p_buf
-> w_read_FF
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2491 p_buf
-> w_read_FF
.count
= 1;
2492 p_buf
-> w_read_FF
.cda
=
2493 (__u32
)__pa(&p_buf
-> header
.flag
);
2494 p_buf
-> w_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2495 p_buf
-> w_TIC_1
.flags
= 0;
2496 p_buf
-> w_TIC_1
.count
= 0;
2497 } /* for all write_buffers */
2499 } /* else buffers are PAGE_SIZE or bigger */
2502 privptr
->p_buff_write_num
=claw_write_pages
;
2503 privptr
->write_free_count
=privptr
->p_env
->write_buffers
;
2507 printk(KERN_INFO
"%s:%s End build claw write free chain \n",
2508 dev
->name
,__FUNCTION__
);
2509 p_buf
=privptr
->p_write_free_chain
;
2510 while (p_buf
!=NULL
) {
2511 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2516 * allocate read_pages_required and chain to free chain
2518 if (privptr
->p_buff_read
==NULL
) {
2519 if (privptr
->p_env
->read_size
< PAGE_SIZE
) {
2520 privptr
->p_buff_read
=
2521 (void *)__get_free_pages(__GFP_DMA
,
2522 (int)pages_to_order_of_mag(claw_read_pages
) );
2523 if (privptr
->p_buff_read
==NULL
) {
2524 printk(KERN_INFO
"%s: %s() "
2525 "__get_free_pages for read buf failed : "
2526 "get is for %d pages\n",
2527 dev
->name
,__FUNCTION__
,claw_read_pages
);
2528 free_pages((unsigned long)privptr
->p_buff_ccw
,
2529 (int)pages_to_order_of_mag(
2530 privptr
->p_buff_ccw_num
));
2531 /* free the write pages size is < page size */
2532 free_pages((unsigned long)privptr
->p_buff_write
,
2533 (int)pages_to_order_of_mag(
2534 privptr
->p_buff_write_num
));
2535 privptr
->p_buff_ccw
=NULL
;
2536 privptr
->p_buff_write
=NULL
;
2538 printk(KERN_INFO
"%s: %s() > exit on line %d, rc ="
2539 " ENOMEM\n",dev
->name
,__FUNCTION__
,__LINE__
);
2543 memset(privptr
->p_buff_read
, 0x00, claw_read_pages
* PAGE_SIZE
);
2544 privptr
->p_buff_read_num
=claw_read_pages
;
2546 * Build CLAW read free chain
2550 printk(KERN_INFO
"%s: %s() Begin build claw read free chain \n",
2551 dev
->name
,__FUNCTION__
);
2553 p_buff
=privptr
->p_buff_read
;
2554 for (i
=0 ; i
< privptr
->p_env
->read_buffers
; i
++) {
2555 p_buf
= p_free_chain
;
2556 p_free_chain
= p_buf
->next
;
2558 if (p_last_CCWB
==NULL
) {
2564 p_buf
->next
=p_first_CCWB
;
2566 (__u32
)__pa(&p_first_CCWB
-> read
);
2571 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2572 /* initialize read command */
2573 p_buf
-> read
.cmd_code
= CCW_CLAW_CMD_READ
;
2574 p_buf
-> read
.cda
= (__u32
)__pa(p_buff
);
2575 p_buf
-> read
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2576 p_buf
-> read
.count
= privptr
->p_env
->read_size
;
2578 /* initialize read_h command */
2579 p_buf
-> read_h
.cmd_code
= CCW_CLAW_CMD_READHEADER
;
2580 p_buf
-> read_h
.cda
=
2581 (__u32
)__pa(&(p_buf
->header
));
2582 p_buf
-> read_h
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2583 p_buf
-> read_h
.count
= sizeof(struct clawh
);
2585 /* initialize Signal command */
2586 p_buf
-> signal
.cmd_code
= CCW_CLAW_CMD_SIGNAL_SMOD
;
2587 p_buf
-> signal
.cda
=
2588 (__u32
)__pa(&(pClawH
->flag
));
2589 p_buf
-> signal
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2590 p_buf
-> signal
.count
= 1;
2592 /* initialize r_TIC_1 command */
2593 p_buf
-> r_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2594 p_buf
-> r_TIC_1
.cda
= (__u32
)real_TIC_address
;
2595 p_buf
-> r_TIC_1
.flags
= 0;
2596 p_buf
-> r_TIC_1
.count
= 0;
2598 /* initialize r_read_FF command */
2599 p_buf
-> r_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2600 p_buf
-> r_read_FF
.cda
=
2601 (__u32
)__pa(&(pClawH
->flag
));
2602 p_buf
-> r_read_FF
.flags
=
2603 CCW_FLAG_SLI
| CCW_FLAG_CC
| CCW_FLAG_PCI
;
2604 p_buf
-> r_read_FF
.count
= 1;
2606 /* initialize r_TIC_2 */
2607 memcpy(&p_buf
->r_TIC_2
,
2608 &p_buf
->r_TIC_1
, sizeof(struct ccw1
));
2610 /* initialize Header */
2611 p_buf
->header
.length
=0xffff;
2612 p_buf
->header
.opcode
=0xff;
2613 p_buf
->header
.flag
=CLAW_PENDING
;
2615 if (((unsigned long)p_buff
+privptr
->p_env
->read_size
) >=
2616 ((unsigned long)(p_buff
+2*(privptr
->p_env
->read_size
) -1)
2618 p_buff
= p_buff
+privptr
->p_env
->read_size
;
2622 (void *)((unsigned long)
2623 (p_buff
+2*(privptr
->p_env
->read_size
) -1)
2626 } /* for read_buffers */
2627 } /* read_size < PAGE_SIZE */
2628 else { /* read Size >= PAGE_SIZE */
2631 printk(KERN_INFO
"%s: %s() Begin build claw read free chain \n",
2632 dev
->name
,__FUNCTION__
);
2634 for (i
=0 ; i
< privptr
->p_env
->read_buffers
; i
++) {
2635 p_buff
= (void *)__get_free_pages(__GFP_DMA
,
2636 (int)pages_to_order_of_mag(privptr
->p_buff_pages_perread
) );
2638 printk(KERN_INFO
"%s: %s() __get_free_pages for read "
2639 "buf failed : get is for %d pages\n",
2640 dev
->name
,__FUNCTION__
,
2641 privptr
->p_buff_pages_perread
);
2642 free_pages((unsigned long)privptr
->p_buff_ccw
,
2643 (int)pages_to_order_of_mag(privptr
->p_buff_ccw_num
));
2644 /* free the write pages */
2645 p_buf
=privptr
->p_buff_write
;
2646 while (p_buf
!=NULL
) {
2647 free_pages((unsigned long)p_buf
->p_buffer
,
2648 (int)pages_to_order_of_mag(
2649 privptr
->p_buff_pages_perwrite
));
2652 /* free any read pages already alloc */
2653 p_buf
=privptr
->p_buff_read
;
2654 while (p_buf
!=NULL
) {
2655 free_pages((unsigned long)p_buf
->p_buffer
,
2656 (int)pages_to_order_of_mag(
2657 privptr
->p_buff_pages_perread
));
2660 privptr
->p_buff_ccw
=NULL
;
2661 privptr
->p_buff_write
=NULL
;
2663 printk(KERN_INFO
"%s: %s() exit on line %d, rc = ENOMEM\n",
2664 dev
->name
,__FUNCTION__
,
2669 memset(p_buff
, 0x00, privptr
->p_env
->read_size
);
2670 p_buf
= p_free_chain
;
2671 privptr
->p_buff_read
= p_buf
;
2672 p_free_chain
= p_buf
->next
;
2674 if (p_last_CCWB
==NULL
) {
2680 p_buf
->next
=p_first_CCWB
;
2683 &p_first_CCWB
-> read
);
2687 /* save buff address */
2688 p_buf
->p_buffer
=(struct clawbuf
*)p_buff
;
2689 /* initialize read command */
2690 p_buf
-> read
.cmd_code
= CCW_CLAW_CMD_READ
;
2691 p_buf
-> read
.cda
= (__u32
)__pa(p_buff
);
2692 p_buf
-> read
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2693 p_buf
-> read
.count
= privptr
->p_env
->read_size
;
2695 /* initialize read_h command */
2696 p_buf
-> read_h
.cmd_code
= CCW_CLAW_CMD_READHEADER
;
2697 p_buf
-> read_h
.cda
=
2698 (__u32
)__pa(&(p_buf
->header
));
2699 p_buf
-> read_h
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2700 p_buf
-> read_h
.count
= sizeof(struct clawh
);
2702 /* initialize Signal command */
2703 p_buf
-> signal
.cmd_code
= CCW_CLAW_CMD_SIGNAL_SMOD
;
2704 p_buf
-> signal
.cda
=
2705 (__u32
)__pa(&(pClawH
->flag
));
2706 p_buf
-> signal
.flags
= CCW_FLAG_SLI
| CCW_FLAG_CC
;
2707 p_buf
-> signal
.count
= 1;
2709 /* initialize r_TIC_1 command */
2710 p_buf
-> r_TIC_1
.cmd_code
= CCW_CLAW_CMD_TIC
;
2711 p_buf
-> r_TIC_1
.cda
= (__u32
)real_TIC_address
;
2712 p_buf
-> r_TIC_1
.flags
= 0;
2713 p_buf
-> r_TIC_1
.count
= 0;
2715 /* initialize r_read_FF command */
2716 p_buf
-> r_read_FF
.cmd_code
= CCW_CLAW_CMD_READFF
;
2717 p_buf
-> r_read_FF
.cda
=
2718 (__u32
)__pa(&(pClawH
->flag
));
2719 p_buf
-> r_read_FF
.flags
=
2720 CCW_FLAG_SLI
| CCW_FLAG_CC
| CCW_FLAG_PCI
;
2721 p_buf
-> r_read_FF
.count
= 1;
2723 /* initialize r_TIC_2 */
2724 memcpy(&p_buf
->r_TIC_2
, &p_buf
->r_TIC_1
,
2725 sizeof(struct ccw1
));
2727 /* initialize Header */
2728 p_buf
->header
.length
=0xffff;
2729 p_buf
->header
.opcode
=0xff;
2730 p_buf
->header
.flag
=CLAW_PENDING
;
2732 } /* For read_buffers */
2733 } /* read_size >= PAGE_SIZE */
2734 } /* pBuffread = NULL */
2736 printk(KERN_INFO
"%s: %s() > End build claw read free chain \n",
2737 dev
->name
,__FUNCTION__
);
2739 while (p_buf
!=NULL
) {
2740 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
2745 add_claw_reads( dev
,p_first_CCWB
, p_last_CCWB
);
2746 privptr
->buffs_alloc
= 1;
2748 printk(KERN_INFO
"%s: %s() exit on line %d\n",
2749 dev
->name
,__FUNCTION__
,__LINE__
);
2752 } /* end of init_ccw_bk */
2754 /*-------------------------------------------------------------------*
2758 *--------------------------------------------------------------------*/
2761 probe_error( struct ccwgroup_device
*cgdev
)
2763 struct claw_privbk
*privptr
;
2765 printk(KERN_INFO
"%s enter \n",__FUNCTION__
);
2767 CLAW_DBF_TEXT(4,trace
,"proberr");
2769 printk(KERN_INFO
"%s variable cgdev =\n",__FUNCTION__
);
2770 dumpit((char *) cgdev
, sizeof(struct ccwgroup_device
));
2772 privptr
=(struct claw_privbk
*)cgdev
->dev
.driver_data
;
2773 if (privptr
!=NULL
) {
2774 kfree(privptr
->p_env
);
2775 privptr
->p_env
=NULL
;
2776 kfree(privptr
->p_mtc_envelope
);
2777 privptr
->p_mtc_envelope
=NULL
;
2782 printk(KERN_INFO
"%s > exit on line %d\n",
2783 __FUNCTION__
,__LINE__
);
2791 /*-------------------------------------------------------------------*
2792 * claw_process_control *
2795 *--------------------------------------------------------------------*/
2798 claw_process_control( struct net_device
*dev
, struct ccwbk
* p_ccw
)
2801 struct clawbuf
*p_buf
;
2802 struct clawctl ctlbk
;
2803 struct clawctl
*p_ctlbk
;
2804 char temp_host_name
[8];
2805 char temp_ws_name
[8];
2806 struct claw_privbk
*privptr
;
2807 struct claw_env
*p_env
;
2808 struct sysval
*p_sysval
;
2809 struct conncmd
*p_connect
=NULL
;
2811 struct chbk
*p_ch
= NULL
;
2813 printk(KERN_INFO
"%s: %s() > enter \n",
2814 dev
->name
,__FUNCTION__
);
2816 CLAW_DBF_TEXT(2,setup
,"clw_cntl");
2818 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
2819 dumpit((char *) dev
, sizeof(struct net_device
));
2820 printk(KERN_INFO
"%s: variable p_ccw =\n",dev
->name
);
2821 dumpit((char *) p_ccw
, sizeof(struct ccwbk
*));
2823 udelay(1000); /* Wait a ms for the control packets to
2824 *catch up to each other */
2826 p_env
=privptr
->p_env
;
2827 memcpy( &temp_host_name
, p_env
->host_name
, 8);
2828 memcpy( &temp_ws_name
, p_env
->adapter_name
, 8);
2829 printk(KERN_INFO
"%s: CLAW device %.8s: "
2830 "Received Control Packet\n",
2831 dev
->name
, temp_ws_name
);
2832 if (privptr
->release_pend
==1) {
2834 printk(KERN_INFO
"%s: %s() > "
2835 "exit on line %d, rc=0\n",
2836 dev
->name
,__FUNCTION__
,__LINE__
);
2840 p_buf
=p_ccw
->p_buffer
;
2842 if (p_env
->packing
== DO_PACKED
) { /* packing in progress?*/
2843 memcpy(p_ctlbk
, &p_buf
->buffer
[4], sizeof(struct clawctl
));
2845 memcpy(p_ctlbk
, p_buf
, sizeof(struct clawctl
));
2848 printk(KERN_INFO
"%s: dump claw control data inbound\n",dev
->name
);
2849 dumpit((char *)p_ctlbk
, sizeof(struct clawctl
));
2851 switch (p_ctlbk
->command
)
2853 case SYSTEM_VALIDATE_REQUEST
:
2854 if (p_ctlbk
->version
!=CLAW_VERSION_ID
) {
2855 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2856 CLAW_RC_WRONG_VERSION
);
2857 printk("%s: %d is wrong version id. "
2859 dev
->name
, p_ctlbk
->version
,
2862 p_sysval
=(struct sysval
*)&(p_ctlbk
->data
);
2863 printk( "%s: Recv Sys Validate Request: "
2864 "Vers=%d,link_id=%d,Corr=%d,WS name=%."
2865 "8s,Host name=%.8s\n",
2866 dev
->name
, p_ctlbk
->version
,
2868 p_ctlbk
->correlator
,
2870 p_sysval
->host_name
);
2871 if (0!=memcmp(temp_host_name
,p_sysval
->host_name
,8)) {
2872 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2873 CLAW_RC_NAME_MISMATCH
);
2874 CLAW_DBF_TEXT(2,setup
,"HSTBAD");
2875 CLAW_DBF_TEXT_(2,setup
,"%s",p_sysval
->host_name
);
2876 CLAW_DBF_TEXT_(2,setup
,"%s",temp_host_name
);
2877 printk(KERN_INFO
"%s: Host name mismatch\n",
2879 printk(KERN_INFO
"%s: Received :%s: "
2882 p_sysval
->host_name
,
2885 if (0!=memcmp(temp_ws_name
,p_sysval
->WS_name
,8)) {
2886 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2887 CLAW_RC_NAME_MISMATCH
);
2888 CLAW_DBF_TEXT(2,setup
,"WSNBAD");
2889 CLAW_DBF_TEXT_(2,setup
,"%s",p_sysval
->WS_name
);
2890 CLAW_DBF_TEXT_(2,setup
,"%s",temp_ws_name
);
2891 printk(KERN_INFO
"%s: WS name mismatch\n",
2893 printk(KERN_INFO
"%s: Received :%s: "
2899 if (( p_sysval
->write_frame_size
< p_env
->write_size
) &&
2900 ( p_env
->packing
== 0)) {
2901 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2902 CLAW_RC_HOST_RCV_TOO_SMALL
);
2903 printk(KERN_INFO
"%s: host write size is too "
2904 "small\n", dev
->name
);
2905 CLAW_DBF_TEXT(2,setup
,"wrtszbad");
2907 if (( p_sysval
->read_frame_size
< p_env
->read_size
) &&
2908 ( p_env
->packing
== 0)) {
2909 claw_snd_sys_validate_rsp(dev
, p_ctlbk
,
2910 CLAW_RC_HOST_RCV_TOO_SMALL
);
2911 printk(KERN_INFO
"%s: host read size is too "
2912 "small\n", dev
->name
);
2913 CLAW_DBF_TEXT(2,setup
,"rdsizbad");
2915 claw_snd_sys_validate_rsp(dev
, p_ctlbk
, 0 );
2916 printk("%s: CLAW device %.8s: System validate"
2917 " completed.\n",dev
->name
, temp_ws_name
);
2918 printk("%s: sys Validate Rsize:%d Wsize:%d\n",dev
->name
,
2919 p_sysval
->read_frame_size
,p_sysval
->write_frame_size
);
2920 privptr
->system_validate_comp
=1;
2921 if(strncmp(p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
2922 p_env
->packing
= PACKING_ASK
;
2924 claw_strt_conn_req(dev
);
2927 case SYSTEM_VALIDATE_RESPONSE
:
2928 p_sysval
=(struct sysval
*)&(p_ctlbk
->data
);
2929 printk("%s: Recv Sys Validate Resp: Vers=%d,Corr=%d,RC=%d,"
2930 "WS name=%.8s,Host name=%.8s\n",
2933 p_ctlbk
->correlator
,
2936 p_sysval
->host_name
);
2937 switch (p_ctlbk
->rc
)
2940 printk(KERN_INFO
"%s: CLAW device "
2941 "%.8s: System validate "
2943 dev
->name
, temp_ws_name
);
2944 if (privptr
->system_validate_comp
== 0)
2945 claw_strt_conn_req(dev
);
2946 privptr
->system_validate_comp
=1;
2948 case CLAW_RC_NAME_MISMATCH
:
2949 printk(KERN_INFO
"%s: Sys Validate "
2950 "Resp : Host, WS name is "
2954 case CLAW_RC_WRONG_VERSION
:
2955 printk(KERN_INFO
"%s: Sys Validate "
2956 "Resp : Wrong version\n",
2959 case CLAW_RC_HOST_RCV_TOO_SMALL
:
2960 printk(KERN_INFO
"%s: Sys Validate "
2961 "Resp : bad frame size\n",
2965 printk(KERN_INFO
"%s: Sys Validate "
2967 dev
->name
, p_ctlbk
->rc
);
2972 case CONNECTION_REQUEST
:
2973 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
2974 printk(KERN_INFO
"%s: Recv Conn Req: Vers=%d,link_id=%d,"
2975 "Corr=%d,HOST appl=%.8s,WS appl=%.8s\n",
2979 p_ctlbk
->correlator
,
2980 p_connect
->host_name
,
2981 p_connect
->WS_name
);
2982 if (privptr
->active_link_ID
!=0 ) {
2983 claw_snd_disc(dev
, p_ctlbk
);
2984 printk(KERN_INFO
"%s: Conn Req error : "
2985 "already logical link is active \n",
2988 if (p_ctlbk
->linkid
!=1 ) {
2989 claw_snd_disc(dev
, p_ctlbk
);
2990 printk(KERN_INFO
"%s: Conn Req error : "
2991 "req logical link id is not 1\n",
2995 p_connect
->host_name
, p_connect
->WS_name
);
2997 claw_snd_disc(dev
, p_ctlbk
);
2998 printk(KERN_INFO
"%s: Conn Req error : "
2999 "req appl name does not match\n",
3002 claw_send_control(dev
,
3003 CONNECTION_CONFIRM
, p_ctlbk
->linkid
,
3004 p_ctlbk
->correlator
,
3005 0, p_connect
->host_name
,
3006 p_connect
->WS_name
);
3007 if (p_env
->packing
== PACKING_ASK
) {
3008 printk("%s: Now Pack ask\n",dev
->name
);
3009 p_env
->packing
= PACK_SEND
;
3010 claw_snd_conn_req(dev
,0);
3012 printk(KERN_INFO
"%s: CLAW device %.8s: Connection "
3013 "completed link_id=%d.\n",
3014 dev
->name
, temp_ws_name
,
3016 privptr
->active_link_ID
=p_ctlbk
->linkid
;
3017 p_ch
=&privptr
->channel
[WRITE
];
3018 wake_up(&p_ch
->wait
); /* wake up claw_open ( WRITE) */
3020 case CONNECTION_RESPONSE
:
3021 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
3022 printk(KERN_INFO
"%s: Revc Conn Resp: Vers=%d,link_id=%d,"
3023 "Corr=%d,RC=%d,Host appl=%.8s, WS appl=%.8s\n",
3027 p_ctlbk
->correlator
,
3029 p_connect
->host_name
,
3030 p_connect
->WS_name
);
3032 if (p_ctlbk
->rc
!=0 ) {
3033 printk(KERN_INFO
"%s: Conn Resp error: rc=%d \n",
3034 dev
->name
, p_ctlbk
->rc
);
3038 p_connect
->host_name
, p_connect
->WS_name
);
3040 claw_snd_disc(dev
, p_ctlbk
);
3041 printk(KERN_INFO
"%s: Conn Resp error: "
3042 "req appl name does not match\n",
3045 /* should be until CONNECTION_CONFIRM */
3046 privptr
->active_link_ID
= - (p_ctlbk
->linkid
);
3048 case CONNECTION_CONFIRM
:
3049 p_connect
=(struct conncmd
*)&(p_ctlbk
->data
);
3050 printk(KERN_INFO
"%s: Recv Conn Confirm:Vers=%d,link_id=%d,"
3051 "Corr=%d,Host appl=%.8s,WS appl=%.8s\n",
3055 p_ctlbk
->correlator
,
3056 p_connect
->host_name
,
3057 p_connect
->WS_name
);
3058 if (p_ctlbk
->linkid
== -(privptr
->active_link_ID
)) {
3059 privptr
->active_link_ID
=p_ctlbk
->linkid
;
3060 if (p_env
->packing
> PACKING_ASK
) {
3061 printk(KERN_INFO
"%s: Confirmed Now packing\n",dev
->name
);
3062 p_env
->packing
= DO_PACKED
;
3064 p_ch
=&privptr
->channel
[WRITE
];
3065 wake_up(&p_ch
->wait
);
3068 printk(KERN_INFO
"%s: Conn confirm: "
3069 "unexpected linkid=%d \n",
3070 dev
->name
, p_ctlbk
->linkid
);
3071 claw_snd_disc(dev
, p_ctlbk
);
3075 printk(KERN_INFO
"%s: Disconnect: "
3076 "Vers=%d,link_id=%d,Corr=%d\n",
3077 dev
->name
, p_ctlbk
->version
,
3078 p_ctlbk
->linkid
, p_ctlbk
->correlator
);
3079 if ((p_ctlbk
->linkid
== 2) &&
3080 (p_env
->packing
== PACK_SEND
)) {
3081 privptr
->active_link_ID
= 1;
3082 p_env
->packing
= DO_PACKED
;
3085 privptr
->active_link_ID
=0;
3088 printk(KERN_INFO
"%s: CLAW ERROR detected\n",
3092 printk(KERN_INFO
"%s: Unexpected command code=%d \n",
3093 dev
->name
, p_ctlbk
->command
);
3098 printk(KERN_INFO
"%s: %s() exit on line %d, rc = 0\n",
3099 dev
->name
,__FUNCTION__
,__LINE__
);
3103 } /* end of claw_process_control */
3106 /*-------------------------------------------------------------------*
3107 * claw_send_control *
3109 *--------------------------------------------------------------------*/
3112 claw_send_control(struct net_device
*dev
, __u8 type
, __u8 link
,
3113 __u8 correlator
, __u8 rc
, char *local_name
, char *remote_name
)
3115 struct claw_privbk
*privptr
;
3116 struct clawctl
*p_ctl
;
3117 struct sysval
*p_sysval
;
3118 struct conncmd
*p_connect
;
3119 struct sk_buff
*skb
;
3122 printk(KERN_INFO
"%s:%s > enter \n",dev
->name
,__FUNCTION__
);
3124 CLAW_DBF_TEXT(2,setup
,"sndcntl");
3126 printk(KERN_INFO
"%s: Sending Control Packet \n",dev
->name
);
3127 printk(KERN_INFO
"%s: variable type = 0x%X, link = "
3128 "%d, correlator = %d, rc = %d\n",
3129 dev
->name
,type
, link
, correlator
, rc
);
3130 printk(KERN_INFO
"%s: variable local_name = %s, "
3131 "remote_name = %s\n",dev
->name
, local_name
, remote_name
);
3134 p_ctl
=(struct clawctl
*)&privptr
->ctl_bk
;
3136 p_ctl
->command
=type
;
3137 p_ctl
->version
=CLAW_VERSION_ID
;
3139 p_ctl
->correlator
=correlator
;
3142 p_sysval
=(struct sysval
*)&p_ctl
->data
;
3143 p_connect
=(struct conncmd
*)&p_ctl
->data
;
3145 switch (p_ctl
->command
) {
3146 case SYSTEM_VALIDATE_REQUEST
:
3147 case SYSTEM_VALIDATE_RESPONSE
:
3148 memcpy(&p_sysval
->host_name
, local_name
, 8);
3149 memcpy(&p_sysval
->WS_name
, remote_name
, 8);
3150 if (privptr
->p_env
->packing
> 0) {
3151 p_sysval
->read_frame_size
=DEF_PACK_BUFSIZE
;
3152 p_sysval
->write_frame_size
=DEF_PACK_BUFSIZE
;
3154 /* how big is the piggest group of packets */
3155 p_sysval
->read_frame_size
=privptr
->p_env
->read_size
;
3156 p_sysval
->write_frame_size
=privptr
->p_env
->write_size
;
3158 memset(&p_sysval
->reserved
, 0x00, 4);
3160 case CONNECTION_REQUEST
:
3161 case CONNECTION_RESPONSE
:
3162 case CONNECTION_CONFIRM
:
3164 memcpy(&p_sysval
->host_name
, local_name
, 8);
3165 memcpy(&p_sysval
->WS_name
, remote_name
, 8);
3166 if (privptr
->p_env
->packing
> 0) {
3167 /* How big is the biggest packet */
3168 p_connect
->reserved1
[0]=CLAW_FRAME_SIZE
;
3169 p_connect
->reserved1
[1]=CLAW_FRAME_SIZE
;
3171 memset(&p_connect
->reserved1
, 0x00, 4);
3172 memset(&p_connect
->reserved2
, 0x00, 4);
3179 /* write Control Record to the device */
3182 skb
= dev_alloc_skb(sizeof(struct clawctl
));
3184 printk( "%s:%s low on mem, returning...\n",
3185 dev
->name
,__FUNCTION__
);
3187 printk(KERN_INFO
"%s:%s Exit, rc = ENOMEM\n",
3188 dev
->name
,__FUNCTION__
);
3192 memcpy(skb_put(skb
, sizeof(struct clawctl
)),
3193 p_ctl
, sizeof(struct clawctl
));
3195 printk(KERN_INFO
"%s: outbnd claw cntl data \n",dev
->name
);
3196 dumpit((char *)p_ctl
,sizeof(struct clawctl
));
3198 if (privptr
->p_env
->packing
>= PACK_SEND
)
3199 claw_hw_tx(skb
, dev
, 1);
3201 claw_hw_tx(skb
, dev
, 0);
3203 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3204 dev
->name
,__FUNCTION__
,__LINE__
);
3208 } /* end of claw_send_control */
3210 /*-------------------------------------------------------------------*
3211 * claw_snd_conn_req *
3213 *--------------------------------------------------------------------*/
3215 claw_snd_conn_req(struct net_device
*dev
, __u8 link
)
3218 struct claw_privbk
*privptr
=dev
->priv
;
3219 struct clawctl
*p_ctl
;
3222 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
3224 CLAW_DBF_TEXT(2,setup
,"snd_conn");
3226 printk(KERN_INFO
"%s: variable link = %X, dev =\n",dev
->name
, link
);
3227 dumpit((char *) dev
, sizeof(struct net_device
));
3230 p_ctl
=(struct clawctl
*)&privptr
->ctl_bk
;
3231 p_ctl
->linkid
= link
;
3232 if ( privptr
->system_validate_comp
==0x00 ) {
3234 printk(KERN_INFO
"%s:%s Exit on line %d, rc = 1\n",
3235 dev
->name
,__FUNCTION__
,__LINE__
);
3239 if (privptr
->p_env
->packing
== PACKING_ASK
)
3240 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3241 WS_APPL_NAME_PACKED
, WS_APPL_NAME_PACKED
);
3242 if (privptr
->p_env
->packing
== PACK_SEND
) {
3243 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3244 WS_APPL_NAME_IP_NAME
, WS_APPL_NAME_IP_NAME
);
3246 if (privptr
->p_env
->packing
== 0)
3247 rc
=claw_send_control(dev
, CONNECTION_REQUEST
,0,0,0,
3248 HOST_APPL_NAME
, privptr
->p_env
->api_type
);
3250 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3251 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3255 } /* end of claw_snd_conn_req */
3258 /*-------------------------------------------------------------------*
3261 *--------------------------------------------------------------------*/
3264 claw_snd_disc(struct net_device
*dev
, struct clawctl
* p_ctl
)
3267 struct conncmd
* p_connect
;
3270 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3272 CLAW_DBF_TEXT(2,setup
,"snd_dsc");
3274 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
3275 dumpit((char *) dev
, sizeof(struct net_device
));
3276 printk(KERN_INFO
"%s: variable p_ctl",dev
->name
);
3277 dumpit((char *) p_ctl
, sizeof(struct clawctl
));
3279 p_connect
=(struct conncmd
*)&p_ctl
->data
;
3281 rc
=claw_send_control(dev
, DISCONNECT
, p_ctl
->linkid
,
3282 p_ctl
->correlator
, 0,
3283 p_connect
->host_name
, p_connect
->WS_name
);
3285 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3286 dev
->name
,__FUNCTION__
, __LINE__
, rc
);
3289 } /* end of claw_snd_disc */
3292 /*-------------------------------------------------------------------*
3293 * claw_snd_sys_validate_rsp *
3295 *--------------------------------------------------------------------*/
3298 claw_snd_sys_validate_rsp(struct net_device
*dev
,
3299 struct clawctl
*p_ctl
, __u32 return_code
)
3301 struct claw_env
* p_env
;
3302 struct claw_privbk
*privptr
;
3306 printk(KERN_INFO
"%s:%s Enter\n",
3307 dev
->name
,__FUNCTION__
);
3309 CLAW_DBF_TEXT(2,setup
,"chkresp");
3311 printk(KERN_INFO
"%s: variable return_code = %d, dev =\n",
3312 dev
->name
, return_code
);
3313 dumpit((char *) dev
, sizeof(struct net_device
));
3314 printk(KERN_INFO
"%s: variable p_ctl =\n",dev
->name
);
3315 dumpit((char *) p_ctl
, sizeof(struct clawctl
));
3317 privptr
= dev
->priv
;
3318 p_env
=privptr
->p_env
;
3319 rc
=claw_send_control(dev
, SYSTEM_VALIDATE_RESPONSE
,
3324 p_env
->adapter_name
);
3326 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3327 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3330 } /* end of claw_snd_sys_validate_rsp */
3332 /*-------------------------------------------------------------------*
3333 * claw_strt_conn_req *
3335 *--------------------------------------------------------------------*/
3338 claw_strt_conn_req(struct net_device
*dev
)
3343 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3345 CLAW_DBF_TEXT(2,setup
,"conn_req");
3347 printk(KERN_INFO
"%s: variable dev =\n",dev
->name
);
3348 dumpit((char *) dev
, sizeof(struct net_device
));
3350 rc
=claw_snd_conn_req(dev
, 1);
3352 printk(KERN_INFO
"%s:%s Exit on line %d, rc = %d\n",
3353 dev
->name
,__FUNCTION__
,__LINE__
, rc
);
3356 } /* end of claw_strt_conn_req */
3360 /*-------------------------------------------------------------------*
3362 *-------------------------------------------------------------------*/
3365 net_device_stats
*claw_stats(struct net_device
*dev
)
3367 struct claw_privbk
*privptr
;
3369 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3371 CLAW_DBF_TEXT(4,trace
,"stats");
3372 privptr
= dev
->priv
;
3374 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3375 dev
->name
,__FUNCTION__
,__LINE__
);
3377 return &privptr
->stats
;
3378 } /* end of claw_stats */
3381 /*-------------------------------------------------------------------*
3384 *--------------------------------------------------------------------*/
3386 unpack_read(struct net_device
*dev
)
3388 struct sk_buff
*skb
;
3389 struct claw_privbk
*privptr
;
3390 struct claw_env
*p_env
;
3391 struct ccwbk
*p_this_ccw
;
3392 struct ccwbk
*p_first_ccw
;
3393 struct ccwbk
*p_last_ccw
;
3394 struct clawph
*p_packh
;
3396 struct clawctl
*p_ctlrec
=NULL
;
3401 __u8 mtc_this_frm
=0;
3403 struct chbk
*p_ch
= NULL
;
3408 printk(KERN_INFO
"%s:%s enter \n",dev
->name
,__FUNCTION__
);
3410 CLAW_DBF_TEXT(4,trace
,"unpkread");
3416 p_env
= privptr
->p_env
;
3417 p_this_ccw
=privptr
->p_read_active_first
;
3419 while (p_this_ccw
!=NULL
&& p_this_ccw
->header
.flag
!=CLAW_PENDING
) {
3421 printk(KERN_INFO
"%s p_this_ccw \n",dev
->name
);
3422 dumpit((char*)p_this_ccw
, sizeof(struct ccwbk
));
3423 printk(KERN_INFO
"%s Inbound p_this_ccw->p_buffer(64)"
3424 " pk=%d \n",dev
->name
,p_env
->packing
);
3425 dumpit((char *)p_this_ccw
->p_buffer
, 64 );
3429 p_this_ccw
->header
.flag
=CLAW_PENDING
;
3430 privptr
->p_read_active_first
=p_this_ccw
->next
;
3431 p_this_ccw
->next
=NULL
;
3432 p_packh
= (struct clawph
*)p_this_ccw
->p_buffer
;
3433 if ((p_env
->packing
== PACK_SEND
) &&
3434 (p_packh
->len
== 32) &&
3435 (p_packh
->link_num
== 0)) { /* is it a packed ctl rec? */
3436 p_packh
++; /* peek past pack header */
3437 p_ctlrec
= (struct clawctl
*)p_packh
;
3438 p_packh
--; /* un peek */
3439 if ((p_ctlrec
->command
== CONNECTION_RESPONSE
) ||
3440 (p_ctlrec
->command
== CONNECTION_CONFIRM
))
3441 p_env
->packing
= DO_PACKED
;
3443 if (p_env
->packing
== DO_PACKED
)
3444 link_num
=p_packh
->link_num
;
3446 link_num
=p_this_ccw
->header
.opcode
/ 8;
3447 if ((p_this_ccw
->header
.opcode
& MORE_to_COME_FLAG
)!=0) {
3449 printk(KERN_INFO
"%s: %s > More_to_come is ON\n",
3450 dev
->name
,__FUNCTION__
);
3453 if (p_this_ccw
->header
.length
!=
3454 privptr
->p_env
->read_size
) {
3455 printk(KERN_INFO
" %s: Invalid frame detected "
3456 "length is %02x\n" ,
3457 dev
->name
, p_this_ccw
->header
.length
);
3461 if (privptr
->mtc_skipping
) {
3463 * We're in the mode of skipping past a
3464 * multi-frame message
3465 * that we can't process for some reason or other.
3466 * The first frame without the More-To-Come flag is
3467 * the last frame of the skipped message.
3469 /* in case of More-To-Come not set in this frame */
3470 if (mtc_this_frm
==0) {
3471 privptr
->mtc_skipping
=0; /* Ok, the end */
3472 privptr
->mtc_logical_link
=-1;
3475 printk(KERN_INFO
"%s:%s goto next "
3476 "frame from MoretoComeSkip \n",
3477 dev
->name
,__FUNCTION__
);
3483 claw_process_control(dev
, p_this_ccw
);
3485 printk(KERN_INFO
"%s:%s goto next "
3486 "frame from claw_process_control \n",
3487 dev
->name
,__FUNCTION__
);
3489 CLAW_DBF_TEXT(4,trace
,"UnpkCntl");
3493 if (p_env
->packing
== DO_PACKED
) {
3494 if (pack_off
> p_env
->read_size
)
3496 p_packd
= p_this_ccw
->p_buffer
+pack_off
;
3497 p_packh
= (struct clawph
*) p_packd
;
3498 if ((p_packh
->len
== 0) || /* all done with this frame? */
3499 (p_packh
->flag
!= 0))
3501 bytes_to_mov
= p_packh
->len
;
3502 pack_off
+= bytes_to_mov
+sizeof(struct clawph
);
3505 bytes_to_mov
=p_this_ccw
->header
.length
;
3507 if (privptr
->mtc_logical_link
<0) {
3509 printk(KERN_INFO
"%s: %s mtc_logical_link < 0 \n",
3510 dev
->name
,__FUNCTION__
);
3514 * if More-To-Come is set in this frame then we don't know
3515 * length of entire message, and hence have to allocate
3518 /* We are starting a new envelope */
3519 privptr
->mtc_offset
=0;
3520 privptr
->mtc_logical_link
=link_num
;
3523 if (bytes_to_mov
> (MAX_ENVELOPE_SIZE
- privptr
->mtc_offset
) ) {
3526 printk(KERN_INFO
"%s: %s > goto next "
3527 "frame from MoretoComeSkip \n",
3530 printk(KERN_INFO
" bytes_to_mov %d > (MAX_ENVELOPE_"
3531 "SIZE-privptr->mtc_offset %d)\n",
3532 bytes_to_mov
,(MAX_ENVELOPE_SIZE
- privptr
->mtc_offset
));
3534 privptr
->stats
.rx_frame_errors
++;
3537 if (p_env
->packing
== DO_PACKED
) {
3538 memcpy( privptr
->p_mtc_envelope
+ privptr
->mtc_offset
,
3539 p_packd
+sizeof(struct clawph
), bytes_to_mov
);
3542 memcpy( privptr
->p_mtc_envelope
+ privptr
->mtc_offset
,
3543 p_this_ccw
->p_buffer
, bytes_to_mov
);
3546 printk(KERN_INFO
"%s: %s() received data \n",
3547 dev
->name
,__FUNCTION__
);
3548 if (p_env
->packing
== DO_PACKED
)
3549 dumpit((char *)p_packd
+sizeof(struct clawph
),32);
3551 dumpit((char *)p_this_ccw
->p_buffer
, 32);
3552 printk(KERN_INFO
"%s: %s() bytelength %d \n",
3553 dev
->name
,__FUNCTION__
,bytes_to_mov
);
3555 if (mtc_this_frm
==0) {
3556 len_of_data
=privptr
->mtc_offset
+bytes_to_mov
;
3557 skb
=dev_alloc_skb(len_of_data
);
3559 memcpy(skb_put(skb
,len_of_data
),
3560 privptr
->p_mtc_envelope
,
3563 skb_reset_mac_header(skb
);
3564 skb
->protocol
=htons(ETH_P_IP
);
3565 skb
->ip_summed
=CHECKSUM_UNNECESSARY
;
3566 privptr
->stats
.rx_packets
++;
3567 privptr
->stats
.rx_bytes
+=len_of_data
;
3570 printk(KERN_INFO
"%s: %s() netif_"
3571 "rx(skb) completed \n",
3572 dev
->name
,__FUNCTION__
);
3576 privptr
->stats
.rx_dropped
++;
3577 printk(KERN_WARNING
"%s: %s() low on memory\n",
3578 dev
->name
,__FUNCTION__
);
3580 privptr
->mtc_offset
=0;
3581 privptr
->mtc_logical_link
=-1;
3584 privptr
->mtc_offset
+=bytes_to_mov
;
3586 if (p_env
->packing
== DO_PACKED
)
3590 * Remove ThisCCWblock from active read queue, and add it
3591 * to queue of free blocks to be reused.
3594 p_this_ccw
->header
.length
=0xffff;
3595 p_this_ccw
->header
.opcode
=0xff;
3597 * add this one to the free queue for later reuse
3599 if (p_first_ccw
==NULL
) {
3600 p_first_ccw
= p_this_ccw
;
3603 p_last_ccw
->next
= p_this_ccw
;
3605 p_last_ccw
= p_this_ccw
;
3607 * chain to next block on active read queue
3609 p_this_ccw
= privptr
->p_read_active_first
;
3610 CLAW_DBF_TEXT_(4,trace
,"rxpkt %d",p
);
3611 } /* end of while */
3613 /* check validity */
3616 printk(KERN_INFO
"%s:%s processed frame is %d \n",
3617 dev
->name
,__FUNCTION__
,i
);
3618 printk(KERN_INFO
"%s:%s F:%lx L:%lx\n",
3621 (unsigned long)p_first_ccw
,
3622 (unsigned long)p_last_ccw
);
3624 CLAW_DBF_TEXT_(4,trace
,"rxfrm %d",i
);
3625 add_claw_reads(dev
, p_first_ccw
, p_last_ccw
);
3626 p_ch
=&privptr
->channel
[READ
];
3627 claw_strt_read(dev
, LOCK_YES
);
3629 printk(KERN_INFO
"%s: %s exit on line %d\n",
3630 dev
->name
, __FUNCTION__
, __LINE__
);
3633 } /* end of unpack_read */
3635 /*-------------------------------------------------------------------*
3638 *--------------------------------------------------------------------*/
3640 claw_strt_read (struct net_device
*dev
, int lock
)
3644 unsigned long saveflags
= 0;
3645 struct claw_privbk
*privptr
=dev
->priv
;
3646 struct ccwbk
*p_ccwbk
;
3648 struct clawh
*p_clawh
;
3649 p_ch
=&privptr
->channel
[READ
];
3652 printk(KERN_INFO
"%s:%s Enter \n",dev
->name
,__FUNCTION__
);
3653 printk(KERN_INFO
"%s: variable lock = %d, dev =\n",dev
->name
, lock
);
3654 dumpit((char *) dev
, sizeof(struct net_device
));
3656 CLAW_DBF_TEXT(4,trace
,"StRdNter");
3657 p_clawh
=(struct clawh
*)privptr
->p_claw_signal_blk
;
3658 p_clawh
->flag
=CLAW_IDLE
; /* 0x00 */
3660 if ((privptr
->p_write_active_first
!=NULL
&&
3661 privptr
->p_write_active_first
->header
.flag
!=CLAW_PENDING
) ||
3662 (privptr
->p_read_active_first
!=NULL
&&
3663 privptr
->p_read_active_first
->header
.flag
!=CLAW_PENDING
)) {
3664 p_clawh
->flag
=CLAW_BUSY
; /* 0xff */
3667 printk(KERN_INFO
"%s:%s state-%02x\n" ,
3668 dev
->name
,__FUNCTION__
, p_ch
->claw_state
);
3670 if (lock
==LOCK_YES
) {
3671 spin_lock_irqsave(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
3673 if (test_and_set_bit(0, (void *)&p_ch
->IO_active
) == 0) {
3675 printk(KERN_INFO
"%s: HOT READ started in %s\n" ,
3676 dev
->name
,__FUNCTION__
);
3677 p_clawh
=(struct clawh
*)privptr
->p_claw_signal_blk
;
3678 dumpit((char *)&p_clawh
->flag
, 1);
3680 CLAW_DBF_TEXT(4,trace
,"HotRead");
3681 p_ccwbk
=privptr
->p_read_active_first
;
3682 parm
= (unsigned long) p_ch
;
3683 rc
= ccw_device_start (p_ch
->cdev
, &p_ccwbk
->read
, parm
,
3686 ccw_check_return_code(p_ch
->cdev
, rc
);
3691 printk(KERN_INFO
"%s: No READ started by %s() In progress\n" ,
3692 dev
->name
,__FUNCTION__
);
3694 CLAW_DBF_TEXT(2,trace
,"ReadAct");
3697 if (lock
==LOCK_YES
) {
3698 spin_unlock_irqrestore(get_ccwdev_lock(p_ch
->cdev
), saveflags
);
3701 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3702 dev
->name
,__FUNCTION__
,__LINE__
);
3704 CLAW_DBF_TEXT(4,trace
,"StRdExit");
3706 } /* end of claw_strt_read */
3708 /*-------------------------------------------------------------------*
3709 * claw_strt_out_IO *
3711 *--------------------------------------------------------------------*/
3714 claw_strt_out_IO( struct net_device
*dev
)
3718 struct claw_privbk
*privptr
;
3720 struct ccwbk
*p_first_ccw
;
3723 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3728 privptr
=(struct claw_privbk
*)dev
->priv
;
3729 p_ch
=&privptr
->channel
[WRITE
];
3732 printk(KERN_INFO
"%s:%s state-%02x\n" ,
3733 dev
->name
,__FUNCTION__
,p_ch
->claw_state
);
3735 CLAW_DBF_TEXT(4,trace
,"strt_io");
3736 p_first_ccw
=privptr
->p_write_active_first
;
3738 if (p_ch
->claw_state
== CLAW_STOP
)
3740 if (p_first_ccw
== NULL
) {
3742 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3743 dev
->name
,__FUNCTION__
,__LINE__
);
3747 if (test_and_set_bit(0, (void *)&p_ch
->IO_active
) == 0) {
3748 parm
= (unsigned long) p_ch
;
3750 printk(KERN_INFO
"%s:%s do_io \n" ,dev
->name
,__FUNCTION__
);
3751 dumpit((char *)p_first_ccw
, sizeof(struct ccwbk
));
3753 CLAW_DBF_TEXT(2,trace
,"StWrtIO");
3754 rc
= ccw_device_start (p_ch
->cdev
,&p_first_ccw
->write
, parm
,
3757 ccw_check_return_code(p_ch
->cdev
, rc
);
3760 dev
->trans_start
= jiffies
;
3762 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3763 dev
->name
,__FUNCTION__
,__LINE__
);
3767 } /* end of claw_strt_out_IO */
3769 /*-------------------------------------------------------------------*
3770 * Free write buffers *
3772 *--------------------------------------------------------------------*/
3775 claw_free_wrt_buf( struct net_device
*dev
)
3778 struct claw_privbk
*privptr
=(struct claw_privbk
*)dev
->priv
;
3779 struct ccwbk
*p_first_ccw
;
3780 struct ccwbk
*p_last_ccw
;
3781 struct ccwbk
*p_this_ccw
;
3782 struct ccwbk
*p_next_ccw
;
3787 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3788 printk(KERN_INFO
"%s: free count = %d variable dev =\n",
3789 dev
->name
,privptr
->write_free_count
);
3791 CLAW_DBF_TEXT(4,trace
,"freewrtb");
3792 /* scan the write queue to free any completed write packets */
3796 printk(KERN_INFO
"%s: Dump current CCW chain \n",dev
->name
);
3797 p_buf
=privptr
->p_write_active_first
;
3798 while (p_buf
!=NULL
) {
3799 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
3803 printk(KERN_INFO
"%s: privptr->p_write_"
3804 "active_first==NULL\n",dev
->name
);
3806 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
3807 dumpit((char *)p_buf
, sizeof(struct endccw
));
3809 p_this_ccw
=privptr
->p_write_active_first
;
3810 while ( (p_this_ccw
!=NULL
) && (p_this_ccw
->header
.flag
!=CLAW_PENDING
))
3812 p_next_ccw
= p_this_ccw
->next
;
3813 if (((p_next_ccw
!=NULL
) &&
3814 (p_next_ccw
->header
.flag
!=CLAW_PENDING
)) ||
3815 ((p_this_ccw
== privptr
->p_write_active_last
) &&
3816 (p_this_ccw
->header
.flag
!=CLAW_PENDING
))) {
3817 /* The next CCW is OK or this is */
3818 /* the last CCW...free it @A1A */
3819 privptr
->p_write_active_first
=p_this_ccw
->next
;
3820 p_this_ccw
->header
.flag
=CLAW_PENDING
;
3821 p_this_ccw
->next
=privptr
->p_write_free_chain
;
3822 privptr
->p_write_free_chain
=p_this_ccw
;
3823 ++privptr
->write_free_count
;
3824 privptr
->stats
.tx_bytes
+= p_this_ccw
->write
.count
;
3825 p_this_ccw
=privptr
->p_write_active_first
;
3826 privptr
->stats
.tx_packets
++;
3832 if (privptr
->write_free_count
!=0) {
3833 claw_clearbit_busy(TB_NOBUFFER
,dev
);
3835 /* whole chain removed? */
3836 if (privptr
->p_write_active_first
==NULL
) {
3837 privptr
->p_write_active_last
=NULL
;
3839 printk(KERN_INFO
"%s:%s p_write_"
3840 "active_first==NULL\n",dev
->name
,__FUNCTION__
);
3844 printk(KERN_INFO
"%s: Dump arranged CCW chain \n",dev
->name
);
3845 p_buf
=privptr
->p_write_active_first
;
3846 while (p_buf
!=NULL
) {
3847 dumpit((char *)p_buf
, sizeof(struct ccwbk
));
3851 printk(KERN_INFO
"%s: privptr->p_write_active_"
3852 "first==NULL\n",dev
->name
);
3854 p_buf
=(struct ccwbk
*)privptr
->p_end_ccw
;
3855 dumpit((char *)p_buf
, sizeof(struct endccw
));
3858 CLAW_DBF_TEXT_(4,trace
,"FWC=%d",privptr
->write_free_count
);
3860 printk(KERN_INFO
"%s:%s Exit on line %d free_count =%d\n",
3861 dev
->name
,__FUNCTION__
, __LINE__
,privptr
->write_free_count
);
3866 /*-------------------------------------------------------------------*
3867 * claw free netdevice *
3869 *--------------------------------------------------------------------*/
3871 claw_free_netdevice(struct net_device
* dev
, int free_dev
)
3873 struct claw_privbk
*privptr
;
3875 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3877 CLAW_DBF_TEXT(2,setup
,"free_dev");
3881 CLAW_DBF_TEXT_(2,setup
,"%s",dev
->name
);
3882 privptr
= dev
->priv
;
3883 if (dev
->flags
& IFF_RUNNING
)
3886 privptr
->channel
[READ
].ndev
= NULL
; /* say it's free */
3894 CLAW_DBF_TEXT(2,setup
,"feee_ok");
3896 printk(KERN_INFO
"%s:%s Exit\n",dev
->name
,__FUNCTION__
);
3901 * Claw init netdevice
3902 * Initialize everything of the net device except the name and the
3906 claw_init_netdevice(struct net_device
* dev
)
3909 printk(KERN_INFO
"%s:%s Enter\n",dev
->name
,__FUNCTION__
);
3911 CLAW_DBF_TEXT(2,setup
,"init_dev");
3912 CLAW_DBF_TEXT_(2,setup
,"%s",dev
->name
);
3914 printk(KERN_WARNING
"claw:%s BAD Device exit line %d\n",
3915 __FUNCTION__
,__LINE__
);
3916 CLAW_DBF_TEXT(2,setup
,"baddev");
3919 dev
->mtu
= CLAW_DEFAULT_MTU_SIZE
;
3920 dev
->hard_start_xmit
= claw_tx
;
3921 dev
->open
= claw_open
;
3922 dev
->stop
= claw_release
;
3923 dev
->get_stats
= claw_stats
;
3924 dev
->change_mtu
= claw_change_mtu
;
3925 dev
->hard_header_len
= 0;
3927 dev
->type
= ARPHRD_SLIP
;
3928 dev
->tx_queue_len
= 1300;
3929 dev
->flags
= IFF_POINTOPOINT
| IFF_NOARP
;
3931 printk(KERN_INFO
"%s:%s Exit\n",dev
->name
,__FUNCTION__
);
3933 CLAW_DBF_TEXT(2,setup
,"initok");
3938 * Init a new channel in the privptr->channel[i].
3940 * @param cdev The ccw_device to be added.
3942 * @return 0 on success, !0 on error.
3945 add_channel(struct ccw_device
*cdev
,int i
,struct claw_privbk
*privptr
)
3948 struct ccw_dev_id dev_id
;
3951 printk(KERN_INFO
"%s:%s Enter\n",cdev
->dev
.bus_id
,__FUNCTION__
);
3953 CLAW_DBF_TEXT_(2,setup
,"%s",cdev
->dev
.bus_id
);
3954 privptr
->channel
[i
].flag
= i
+1; /* Read is 1 Write is 2 */
3955 p_ch
= &privptr
->channel
[i
];
3957 snprintf(p_ch
->id
, CLAW_ID_SIZE
, "cl-%s", cdev
->dev
.bus_id
);
3958 ccw_device_get_id(cdev
, &dev_id
);
3959 p_ch
->devno
= dev_id
.devno
;
3960 if ((p_ch
->irb
= kzalloc(sizeof (struct irb
),GFP_KERNEL
)) == NULL
) {
3961 printk(KERN_WARNING
"%s Out of memory in %s for irb\n",
3962 p_ch
->id
,__FUNCTION__
);
3964 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3965 p_ch
->id
,__FUNCTION__
,__LINE__
);
3970 printk(KERN_INFO
"%s:%s Exit on line %d\n",
3971 cdev
->dev
.bus_id
,__FUNCTION__
,__LINE__
);
3979 * Setup an interface.
3981 * @param cgdev Device to be setup.
3983 * @returns 0 on success, !0 on failure.
3986 claw_new_device(struct ccwgroup_device
*cgdev
)
3988 struct claw_privbk
*privptr
;
3989 struct claw_env
*p_env
;
3990 struct net_device
*dev
;
3992 struct ccw_dev_id dev_id
;
3994 pr_debug("%s() called\n", __FUNCTION__
);
3995 printk(KERN_INFO
"claw: add for %s\n",cgdev
->cdev
[READ
]->dev
.bus_id
);
3996 CLAW_DBF_TEXT(2,setup
,"new_dev");
3997 privptr
= cgdev
->dev
.driver_data
;
3998 cgdev
->cdev
[READ
]->dev
.driver_data
= privptr
;
3999 cgdev
->cdev
[WRITE
]->dev
.driver_data
= privptr
;
4002 p_env
= privptr
->p_env
;
4003 ccw_device_get_id(cgdev
->cdev
[READ
], &dev_id
);
4004 p_env
->devno
[READ
] = dev_id
.devno
;
4005 ccw_device_get_id(cgdev
->cdev
[WRITE
], &dev_id
);
4006 p_env
->devno
[WRITE
] = dev_id
.devno
;
4007 ret
= add_channel(cgdev
->cdev
[0],0,privptr
);
4009 ret
= add_channel(cgdev
->cdev
[1],1,privptr
);
4012 "add channel failed "
4013 "with ret = %d\n", ret
);
4016 ret
= ccw_device_set_online(cgdev
->cdev
[READ
]);
4019 "claw: ccw_device_set_online %s READ failed "
4020 "with ret = %d\n",cgdev
->cdev
[READ
]->dev
.bus_id
,ret
);
4023 ret
= ccw_device_set_online(cgdev
->cdev
[WRITE
]);
4026 "claw: ccw_device_set_online %s WRITE failed "
4027 "with ret = %d\n",cgdev
->cdev
[WRITE
]->dev
.bus_id
, ret
);
4030 dev
= alloc_netdev(0,"claw%d",claw_init_netdevice
);
4032 printk(KERN_WARNING
"%s:alloc_netdev failed\n",__FUNCTION__
);
4035 dev
->priv
= privptr
;
4036 cgdev
->dev
.driver_data
= privptr
;
4037 cgdev
->cdev
[READ
]->dev
.driver_data
= privptr
;
4038 cgdev
->cdev
[WRITE
]->dev
.driver_data
= privptr
;
4040 SET_NETDEV_DEV(dev
, &cgdev
->dev
);
4041 if (register_netdev(dev
) != 0) {
4042 claw_free_netdevice(dev
, 1);
4043 CLAW_DBF_TEXT(2,trace
,"regfail");
4046 dev
->flags
&=~IFF_RUNNING
;
4047 if (privptr
->buffs_alloc
== 0) {
4048 ret
=init_ccw_bk(dev
);
4051 "claw: init_ccw_bk failed with ret=%d\n", ret
);
4052 unregister_netdev(dev
);
4053 claw_free_netdevice(dev
,1);
4054 CLAW_DBF_TEXT(2,trace
,"ccwmem");
4058 privptr
->channel
[READ
].ndev
= dev
;
4059 privptr
->channel
[WRITE
].ndev
= dev
;
4060 privptr
->p_env
->ndev
= dev
;
4062 printk(KERN_INFO
"%s:readsize=%d writesize=%d "
4063 "readbuffer=%d writebuffer=%d read=0x%04x write=0x%04x\n",
4064 dev
->name
, p_env
->read_size
,
4065 p_env
->write_size
, p_env
->read_buffers
,
4066 p_env
->write_buffers
, p_env
->devno
[READ
],
4067 p_env
->devno
[WRITE
]);
4068 printk(KERN_INFO
"%s:host_name:%.8s, adapter_name "
4069 ":%.8s api_type: %.8s\n",
4070 dev
->name
, p_env
->host_name
,
4071 p_env
->adapter_name
, p_env
->api_type
);
4074 ccw_device_set_offline(cgdev
->cdev
[1]);
4075 ccw_device_set_offline(cgdev
->cdev
[0]);
4081 claw_purge_skb_queue(struct sk_buff_head
*q
)
4083 struct sk_buff
*skb
;
4085 CLAW_DBF_TEXT(4,trace
,"purgque");
4087 while ((skb
= skb_dequeue(q
))) {
4088 atomic_dec(&skb
->users
);
4089 dev_kfree_skb_any(skb
);
4094 * Shutdown an interface.
4096 * @param cgdev Device to be shut down.
4098 * @returns 0 on success, !0 on failure.
4101 claw_shutdown_device(struct ccwgroup_device
*cgdev
)
4103 struct claw_privbk
*priv
;
4104 struct net_device
*ndev
;
4107 pr_debug("%s() called\n", __FUNCTION__
);
4108 CLAW_DBF_TEXT_(2,setup
,"%s",cgdev
->dev
.bus_id
);
4109 priv
= cgdev
->dev
.driver_data
;
4112 ndev
= priv
->channel
[READ
].ndev
;
4114 /* Close the device */
4116 "%s: shuting down \n",ndev
->name
);
4117 if (ndev
->flags
& IFF_RUNNING
)
4118 ret
= claw_release(ndev
);
4119 ndev
->flags
&=~IFF_RUNNING
;
4120 unregister_netdev(ndev
);
4121 ndev
->priv
= NULL
; /* cgdev data, not ndev's to free */
4122 claw_free_netdevice(ndev
, 1);
4123 priv
->channel
[READ
].ndev
= NULL
;
4124 priv
->channel
[WRITE
].ndev
= NULL
;
4125 priv
->p_env
->ndev
= NULL
;
4127 ccw_device_set_offline(cgdev
->cdev
[1]);
4128 ccw_device_set_offline(cgdev
->cdev
[0]);
4133 claw_remove_device(struct ccwgroup_device
*cgdev
)
4135 struct claw_privbk
*priv
;
4137 pr_debug("%s() called\n", __FUNCTION__
);
4138 CLAW_DBF_TEXT_(2,setup
,"%s",cgdev
->dev
.bus_id
);
4139 priv
= cgdev
->dev
.driver_data
;
4141 printk(KERN_WARNING
"claw: %s() no Priv exiting\n",__FUNCTION__
);
4144 printk(KERN_INFO
"claw: %s() called %s will be removed.\n",
4145 __FUNCTION__
,cgdev
->cdev
[0]->dev
.bus_id
);
4146 if (cgdev
->state
== CCWGROUP_ONLINE
)
4147 claw_shutdown_device(cgdev
);
4148 claw_remove_files(&cgdev
->dev
);
4149 kfree(priv
->p_mtc_envelope
);
4150 priv
->p_mtc_envelope
=NULL
;
4153 kfree(priv
->channel
[0].irb
);
4154 priv
->channel
[0].irb
=NULL
;
4155 kfree(priv
->channel
[1].irb
);
4156 priv
->channel
[1].irb
=NULL
;
4158 cgdev
->dev
.driver_data
=NULL
;
4159 cgdev
->cdev
[READ
]->dev
.driver_data
= NULL
;
4160 cgdev
->cdev
[WRITE
]->dev
.driver_data
= NULL
;
4161 put_device(&cgdev
->dev
);
4169 claw_hname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4171 struct claw_privbk
*priv
;
4172 struct claw_env
* p_env
;
4174 priv
= dev
->driver_data
;
4177 p_env
= priv
->p_env
;
4178 return sprintf(buf
, "%s\n",p_env
->host_name
);
4182 claw_hname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4184 struct claw_privbk
*priv
;
4185 struct claw_env
* p_env
;
4187 priv
= dev
->driver_data
;
4190 p_env
= priv
->p_env
;
4191 if (count
> MAX_NAME_LEN
+1)
4193 memset(p_env
->host_name
, 0x20, MAX_NAME_LEN
);
4194 strncpy(p_env
->host_name
,buf
, count
);
4195 p_env
->host_name
[count
-1] = 0x20; /* clear extra 0x0a */
4196 p_env
->host_name
[MAX_NAME_LEN
] = 0x00;
4197 CLAW_DBF_TEXT(2,setup
,"HstnSet");
4198 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->host_name
);
4203 static DEVICE_ATTR(host_name
, 0644, claw_hname_show
, claw_hname_write
);
4206 claw_adname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4208 struct claw_privbk
*priv
;
4209 struct claw_env
* p_env
;
4211 priv
= dev
->driver_data
;
4214 p_env
= priv
->p_env
;
4215 return sprintf(buf
, "%s\n",p_env
->adapter_name
);
4219 claw_adname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4221 struct claw_privbk
*priv
;
4222 struct claw_env
* p_env
;
4224 priv
= dev
->driver_data
;
4227 p_env
= priv
->p_env
;
4228 if (count
> MAX_NAME_LEN
+1)
4230 memset(p_env
->adapter_name
, 0x20, MAX_NAME_LEN
);
4231 strncpy(p_env
->adapter_name
,buf
, count
);
4232 p_env
->adapter_name
[count
-1] = 0x20; /* clear extra 0x0a */
4233 p_env
->adapter_name
[MAX_NAME_LEN
] = 0x00;
4234 CLAW_DBF_TEXT(2,setup
,"AdnSet");
4235 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->adapter_name
);
4240 static DEVICE_ATTR(adapter_name
, 0644, claw_adname_show
, claw_adname_write
);
4243 claw_apname_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4245 struct claw_privbk
*priv
;
4246 struct claw_env
* p_env
;
4248 priv
= dev
->driver_data
;
4251 p_env
= priv
->p_env
;
4252 return sprintf(buf
, "%s\n",
4257 claw_apname_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4259 struct claw_privbk
*priv
;
4260 struct claw_env
* p_env
;
4262 priv
= dev
->driver_data
;
4265 p_env
= priv
->p_env
;
4266 if (count
> MAX_NAME_LEN
+1)
4268 memset(p_env
->api_type
, 0x20, MAX_NAME_LEN
);
4269 strncpy(p_env
->api_type
,buf
, count
);
4270 p_env
->api_type
[count
-1] = 0x20; /* we get a loose 0x0a */
4271 p_env
->api_type
[MAX_NAME_LEN
] = 0x00;
4272 if(strncmp(p_env
->api_type
,WS_APPL_NAME_PACKED
,6) == 0) {
4273 p_env
->read_size
=DEF_PACK_BUFSIZE
;
4274 p_env
->write_size
=DEF_PACK_BUFSIZE
;
4275 p_env
->packing
=PACKING_ASK
;
4276 CLAW_DBF_TEXT(2,setup
,"PACKING");
4280 p_env
->read_size
=CLAW_FRAME_SIZE
;
4281 p_env
->write_size
=CLAW_FRAME_SIZE
;
4282 CLAW_DBF_TEXT(2,setup
,"ApiSet");
4284 CLAW_DBF_TEXT_(2,setup
,"%s",p_env
->api_type
);
4288 static DEVICE_ATTR(api_type
, 0644, claw_apname_show
, claw_apname_write
);
4291 claw_wbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4293 struct claw_privbk
*priv
;
4294 struct claw_env
* p_env
;
4296 priv
= dev
->driver_data
;
4299 p_env
= priv
->p_env
;
4300 return sprintf(buf
, "%d\n", p_env
->write_buffers
);
4304 claw_wbuff_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4306 struct claw_privbk
*priv
;
4307 struct claw_env
* p_env
;
4310 priv
= dev
->driver_data
;
4313 p_env
= priv
->p_env
;
4314 sscanf(buf
, "%i", &nnn
);
4315 if (p_env
->packing
) {
4321 if ((nnn
> max
) || (nnn
< 2))
4323 p_env
->write_buffers
= nnn
;
4324 CLAW_DBF_TEXT(2,setup
,"Wbufset");
4325 CLAW_DBF_TEXT_(2,setup
,"WB=%d",p_env
->write_buffers
);
4329 static DEVICE_ATTR(write_buffer
, 0644, claw_wbuff_show
, claw_wbuff_write
);
4332 claw_rbuff_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
4334 struct claw_privbk
*priv
;
4335 struct claw_env
* p_env
;
4337 priv
= dev
->driver_data
;
4340 p_env
= priv
->p_env
;
4341 return sprintf(buf
, "%d\n", p_env
->read_buffers
);
4345 claw_rbuff_write(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
4347 struct claw_privbk
*priv
;
4348 struct claw_env
*p_env
;
4351 priv
= dev
->driver_data
;
4354 p_env
= priv
->p_env
;
4355 sscanf(buf
, "%i", &nnn
);
4356 if (p_env
->packing
) {
4362 if ((nnn
> max
) || (nnn
< 2))
4364 p_env
->read_buffers
= nnn
;
4365 CLAW_DBF_TEXT(2,setup
,"Rbufset");
4366 CLAW_DBF_TEXT_(2,setup
,"RB=%d",p_env
->read_buffers
);
4370 static DEVICE_ATTR(read_buffer
, 0644, claw_rbuff_show
, claw_rbuff_write
);
4372 static struct attribute
*claw_attr
[] = {
4373 &dev_attr_read_buffer
.attr
,
4374 &dev_attr_write_buffer
.attr
,
4375 &dev_attr_adapter_name
.attr
,
4376 &dev_attr_api_type
.attr
,
4377 &dev_attr_host_name
.attr
,
4381 static struct attribute_group claw_attr_group
= {
4386 claw_add_files(struct device
*dev
)
4388 pr_debug("%s() called\n", __FUNCTION__
);
4389 CLAW_DBF_TEXT(2,setup
,"add_file");
4390 return sysfs_create_group(&dev
->kobj
, &claw_attr_group
);
4394 claw_remove_files(struct device
*dev
)
4396 pr_debug("%s() called\n", __FUNCTION__
);
4397 CLAW_DBF_TEXT(2,setup
,"rem_file");
4398 sysfs_remove_group(&dev
->kobj
, &claw_attr_group
);
4401 /*--------------------------------------------------------------------*
4402 * claw_init and cleanup *
4403 *---------------------------------------------------------------------*/
4408 unregister_cu3088_discipline(&claw_group_driver
);
4409 claw_unregister_debug_facility();
4410 printk(KERN_INFO
"claw: Driver unloaded\n");
4415 * Initialize module.
4416 * This is called just after the module is loaded.
4418 * @return 0 on success, !0 on error.
4424 printk(KERN_INFO
"claw: starting driver\n");
4427 printk(KERN_INFO
"claw: %s() enter \n",__FUNCTION__
);
4429 ret
= claw_register_debug_facility();
4431 printk(KERN_WARNING
"claw: %s() debug_register failed %d\n",
4435 CLAW_DBF_TEXT(2,setup
,"init_mod");
4436 ret
= register_cu3088_discipline(&claw_group_driver
);
4438 claw_unregister_debug_facility();
4439 printk(KERN_WARNING
"claw; %s() cu3088 register failed %d\n",
4443 printk(KERN_INFO
"claw: %s() exit \n",__FUNCTION__
);
4448 module_init(claw_init
);
4449 module_exit(claw_cleanup
);
4453 /*--------------------------------------------------------------------*
4455 *---------------------------------------------------------------------*/