Lines Matching refs:ch

131 	struct comx_channel *ch = dev->priv;  in comx_debug()  local
136 if (!ch->debug_area) return 0; in comx_debug()
152 int free = (ch->debug_start - ch->debug_end + ch->debug_size) in comx_debug()
153 % ch->debug_size; in comx_debug()
155 to_copy = min_t(int, free ? free : ch->debug_size, in comx_debug()
156 min_t(int, ch->debug_size - ch->debug_end, len)); in comx_debug()
157 memcpy(ch->debug_area + ch->debug_end, str, to_copy); in comx_debug()
160 ch->debug_end = (ch->debug_end + to_copy) % ch->debug_size; in comx_debug()
161 if (ch->debug_start == ch->debug_end) // Full ? push start away in comx_debug()
162 ch->debug_start = (ch->debug_start + len + 1) % in comx_debug()
163 ch->debug_size; in comx_debug()
164 ch->debug_file->size = (ch->debug_end - ch->debug_start + in comx_debug()
165 ch->debug_size) % ch->debug_size; in comx_debug()
174 struct comx_channel *ch = dev->priv; in comx_debug_skb() local
176 if (!ch->debug_area) return 0; in comx_debug_skb()
187 struct comx_channel *ch = dev->priv; in comx_debug_bytes() local
189 if (!ch->debug_area) return 0; in comx_debug_bytes()
219 struct comx_channel *ch = dev->priv; in comx_loadavg_timerfun() local
221 ch->avg_bytes[ch->loadavg_counter] = ch->current_stats->rx_bytes; in comx_loadavg_timerfun()
222 ch->avg_bytes[ch->loadavg_counter + ch->loadavg_size] = in comx_loadavg_timerfun()
223 ch->current_stats->tx_bytes; in comx_loadavg_timerfun()
225 ch->loadavg_counter = (ch->loadavg_counter + 1) % ch->loadavg_size; in comx_loadavg_timerfun()
227 mod_timer(&ch->loadavg_timer,jiffies + HZ * ch->loadavg[0]); in comx_loadavg_timerfun()
234 struct comx_channel *ch = dev->priv;
236 if(!(ch->line_status & (PROTO_LOOP | PROTO_UP))) {
237 if(test_and_set_bit(0,&ch->reset_pending) && ch->HW_reset) {
238 ch->HW_reset(dev);
242 mod_timer(&ch->reset_timer, jiffies + HZ * ch->reset_timeout);
248 struct comx_channel *ch = dev->priv; in comx_open() local
249 struct proc_dir_entry *comxdir = ch->procdir->subdir; in comx_open()
252 if (!ch->protocol || !ch->hardware) return -ENODEV; in comx_open()
254 if ((ret = ch->HW_open(dev))) return ret; in comx_open()
255 if ((ret = ch->LINE_open(dev))) { in comx_open()
256 ch->HW_close(dev); in comx_open()
267 ch->reset_pending = 1; in comx_open()
268 ch->reset_timeout = 30; in comx_open()
269 ch->reset_timer.function = comx_reset_timerfun; in comx_open()
270 ch->reset_timer.data = (unsigned long)dev; in comx_open()
271 ch->reset_timer.expires = jiffies + HZ * ch->reset_timeout; in comx_open()
272 add_timer(&ch->reset_timer); in comx_open()
280 struct comx_channel *ch = dev->priv; in comx_close() local
281 struct proc_dir_entry *comxdir = ch->procdir->subdir; in comx_close()
284 if (test_and_clear_bit(0, &ch->lineup_pending)) { in comx_close()
285 del_timer(&ch->lineup_timer); in comx_close()
289 del_timer(&ch->reset_timer); in comx_close()
292 if (ch->init_status & LINE_OPEN && ch->protocol && ch->LINE_close) { in comx_close()
293 ret = ch->LINE_close(dev); in comx_close()
298 if (ch->init_status & HW_OPEN && ch->hardware && ch->HW_close) { in comx_close()
299 ret = ch->HW_close(dev); in comx_close()
302 ch->line_status=0; in comx_close()
315 struct comx_channel *ch = dev->priv; in comx_status() local
319 clear_bit(0,&ch->reset_pending); in comx_status()
328 ch->line_status = status; in comx_status()
333 struct comx_channel *ch = dev->priv; in comx_xmit() local
341 if (ch->debug_flags & DEBUG_COMX_TX) { in comx_xmit()
345 rc=ch->LINE_xmit(skb, dev); in comx_xmit()
354 struct comx_channel *ch = dev->priv; in comx_header() local
356 if (ch->LINE_header) { in comx_header()
357 return (ch->LINE_header(skb, dev, type, daddr, saddr, len)); in comx_header()
366 struct comx_channel *ch = dev->priv; in comx_rebuild_header() local
368 if (ch->LINE_rebuild_header) { in comx_rebuild_header()
369 return(ch->LINE_rebuild_header(skb)); in comx_rebuild_header()
377 struct comx_channel *ch = dev->priv; in comx_rx() local
379 if (ch->debug_flags & DEBUG_COMX_RX) { in comx_rx()
391 struct comx_channel *ch = (struct comx_channel *)dev->priv; in comx_stats() local
393 return ch->current_stats; in comx_stats()
399 struct comx_channel *ch = dev->priv; in comx_lineup_func() local
401 del_timer(&ch->lineup_timer); in comx_lineup_func()
402 clear_bit(0, &ch->lineup_pending); in comx_lineup_func()
404 if (ch->LINE_status) { in comx_lineup_func()
405 ch->LINE_status(dev, ch->line_status |= LINE_UP); in comx_lineup_func()
410 ((ch->avg_bytes[(ch->loadavg_counter - 1 + ch->loadavg_size * 2) \
411 % ch->loadavg_size + off] - ch->avg_bytes[(ch->loadavg_counter - 1 \
412 - ch->loadavg[avg] / ch->loadavg[0] + ch->loadavg_size * 2) \
413 % ch->loadavg_size + off]) / ch->loadavg[avg] * 8)
417 struct comx_channel *ch = dev->priv; in comx_statistics() local
427 ch->line_status & LINE_UP ? "UP" : "DOWN", in comx_statistics()
428 ch->line_status & PROTO_LOOP ? "LOOP" : in comx_statistics()
429 ch->line_status & PROTO_UP ? "UP" : "DOWN"); in comx_statistics()
431 "is %s, tbusy: %d\n", ch->current_stats->tx_carrier_errors, ch->HW_txe ? in comx_statistics()
432 ch->HW_txe(dev) ? "IDLE" : "BUSY" : "NOT READY", netif_running(dev)); in comx_statistics()
439 tf = ch->loadavg[i] % 60 == 0 && in comx_statistics()
440 ch->loadavg[i] / 60 > 0 ? 'm' : 's'; in comx_statistics()
442 ch->loadavg[i] / (tf == 'm' ? 60 : 1), tf, in comx_statistics()
447 LOADAVG(0,ch->loadavg_size), LOADAVG(1, ch->loadavg_size), in comx_statistics()
448 LOADAVG(2, ch->loadavg_size), tmpstr); in comx_statistics()
453 if (ch->debug_flags & comx_debugflags[i].value) in comx_statistics()
463 ch->current_stats->rx_length_errors, ch->current_stats->rx_over_errors, in comx_statistics()
464 ch->current_stats->rx_crc_errors, ch->current_stats->rx_frame_errors, in comx_statistics()
465 ch->current_stats->rx_missed_errors, ch->current_stats->rx_fifo_errors, in comx_statistics()
466 ch->current_stats->tx_fifo_errors); in comx_statistics()
468 if (ch->LINE_statistics && (ch->init_status & LINE_OPEN)) { in comx_statistics()
469 len += ch->LINE_statistics(dev, page + len); in comx_statistics()
473 if (ch->HW_statistics && (ch->init_status & HW_OPEN)) { in comx_statistics()
474 len += ch->HW_statistics(dev, page + len); in comx_statistics()
484 struct comx_channel *ch = dev->priv; in comx_ioctl() local
486 if (ch->LINE_ioctl) { in comx_ioctl()
487 return(ch->LINE_ioctl(dev, ifr, cmd)); in comx_ioctl()
508 struct comx_channel *ch; in comx_init_dev() local
510 if ((ch = kmalloc(sizeof(struct comx_channel), GFP_KERNEL)) == NULL) { in comx_init_dev()
513 memset(ch, 0, sizeof(struct comx_channel)); in comx_init_dev()
515 ch->loadavg[0] = 5; in comx_init_dev()
516 ch->loadavg[1] = 300; in comx_init_dev()
517 ch->loadavg[2] = 900; in comx_init_dev()
518 ch->loadavg_size = ch->loadavg[2] / ch->loadavg[0] + 1; in comx_init_dev()
519 if ((ch->avg_bytes = kmalloc(ch->loadavg_size * in comx_init_dev()
521 kfree(ch); in comx_init_dev()
525 memset(ch->avg_bytes, 0, ch->loadavg_size * sizeof(unsigned long) * 2); in comx_init_dev()
526 ch->loadavg_counter = 0; in comx_init_dev()
527 ch->loadavg_timer.function = comx_loadavg_timerfun; in comx_init_dev()
528 ch->loadavg_timer.data = (unsigned long)dev; in comx_init_dev()
529 ch->loadavg_timer.expires = jiffies + HZ * ch->loadavg[0]; in comx_init_dev()
530 add_timer(&ch->loadavg_timer); in comx_init_dev()
532 dev->priv = (void *)ch; in comx_init_dev()
533 ch->dev = dev; in comx_init_dev()
534 ch->line_status &= ~LINE_UP; in comx_init_dev()
536 ch->current_stats = &ch->stats; in comx_init_dev()
547 struct comx_channel *ch=(struct comx_channel *)dev->priv; in comx_read_proc() local
553 len = sprintf(page, "%s\n", ch->hardware ? in comx_read_proc()
554 ch->hardware->name : HWNAME_NONE); in comx_read_proc()
556 len = sprintf(page, "%s\n", ch->protocol ? in comx_read_proc()
557 ch->protocol->name : PROTONAME_NONE); in comx_read_proc()
559 len = sprintf(page, "%01d\n", ch->lineup_delay); in comx_read_proc()
611 struct comx_channel *ch=(struct comx_channel *)dev->priv; in comx_write_proc() local
648 if (ch->debug_area) kfree(ch->debug_area); in comx_write_proc()
649 if ((ch->debug_area = kmalloc(ch->debug_size = i, in comx_write_proc()
653 ch->debug_start = ch->debug_end = 0; in comx_write_proc()
675 ch->debug_flags |= comx_debugflags[i].value; in comx_write_proc()
677 ch->debug_flags &= ~comx_debugflags[i].value; in comx_write_proc()
710 if (ch->init_status & HW_OPEN) { in comx_write_proc()
714 if (ch->hardware && ch->hardware->hw_exit && in comx_write_proc()
715 (ret=ch->hardware->hw_exit(dev))) { in comx_write_proc()
719 ch->hardware = hw; in comx_write_proc()
754 if (ch->init_status & LINE_OPEN) { in comx_write_proc()
759 if (ch->protocol && ch->protocol->line_exit && in comx_write_proc()
760 (ret=ch->protocol->line_exit(dev))) { in comx_write_proc()
764 ch->protocol = line; in comx_write_proc()
773 ch->lineup_delay = i; in comx_write_proc()
788 struct comx_channel *ch; in comx_mkdir() local
835 ch=dev->priv; in comx_mkdir()
836 if((ch->if_ptr = (void *)kmalloc(sizeof(struct ppp_device), in comx_mkdir()
840 memset(ch->if_ptr, 0, sizeof(struct ppp_device)); in comx_mkdir()
841 ch->debug_file = debug_file; in comx_mkdir()
842 ch->procdir = new_dir; in comx_mkdir()
845 ch->debug_start = ch->debug_end = 0; in comx_mkdir()
846 if ((ch->debug_area = kmalloc(ch->debug_size = DEFAULT_DEBUG_SIZE, in comx_mkdir()
852 ch->lineup_delay = DEFAULT_LINEUP_DELAY; in comx_mkdir()
857 kfree(ch->if_ptr); in comx_mkdir()
881 struct comx_channel *ch = dev->priv; in comx_rmdir() local
889 if (ch->protocol && ch->protocol->line_exit && in comx_rmdir()
890 (ret=ch->protocol->line_exit(dev))) { in comx_rmdir()
893 if (ch->hardware && ch->hardware->hw_exit && in comx_rmdir()
894 (ret=ch->hardware->hw_exit(dev))) { in comx_rmdir()
895 if(ch->protocol && ch->protocol->line_init) { in comx_rmdir()
896 ch->protocol->line_init(dev); in comx_rmdir()
900 ch->protocol = NULL; in comx_rmdir()
901 ch->hardware = NULL; in comx_rmdir()
903 del_timer(&ch->loadavg_timer); in comx_rmdir()
904 kfree(ch->avg_bytes); in comx_rmdir()
907 if (ch->debug_area) { in comx_rmdir()
908 kfree(ch->debug_area); in comx_rmdir()