Lines Matching refs:sp

141 	struct sixpack *sp = (struct sixpack *) channel;  in sp_xmit_on_air()  local
142 int actual, when = sp->slottime; in sp_xmit_on_air()
147 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { in sp_xmit_on_air()
148 sp->led_state = 0x70; in sp_xmit_on_air()
149 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
150 sp->tx_enable = 1; in sp_xmit_on_air()
151 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in sp_xmit_on_air()
152 sp->xleft -= actual; in sp_xmit_on_air()
153 sp->xhead += actual; in sp_xmit_on_air()
154 sp->led_state = 0x60; in sp_xmit_on_air()
155 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
156 sp->status2 = 0; in sp_xmit_on_air()
158 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); in sp_xmit_on_air()
164 static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len) in sp_encaps() argument
169 if (len > sp->mtu) { /* sp->mtu = AX25_MTU = max. PACLEN = 256 */ in sp_encaps()
174 if (len > sp->mtu) { /* sp->mtu = AX25_MTU = max. PACLEN = 256 */ in sp_encaps()
194 count = encode_sixpack(p, sp->xbuff, len, sp->tx_delay); in sp_encaps()
195 set_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_encaps()
198 case 1: sp->tx_delay = p[1]; in sp_encaps()
200 case 2: sp->persistence = p[1]; in sp_encaps()
202 case 3: sp->slottime = p[1]; in sp_encaps()
206 case 5: sp->duplex = p[1]; in sp_encaps()
219 if (sp->duplex == 1) { in sp_encaps()
220 sp->led_state = 0x70; in sp_encaps()
221 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
222 sp->tx_enable = 1; in sp_encaps()
223 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count); in sp_encaps()
224 sp->xleft = count - actual; in sp_encaps()
225 sp->xhead = sp->xbuff + actual; in sp_encaps()
226 sp->led_state = 0x60; in sp_encaps()
227 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
229 sp->xleft = count; in sp_encaps()
230 sp->xhead = sp->xbuff; in sp_encaps()
231 sp->status2 = count; in sp_encaps()
232 sp_xmit_on_air((unsigned long)sp); in sp_encaps()
238 sp->dev->stats.tx_dropped++; in sp_encaps()
239 netif_start_queue(sp->dev); in sp_encaps()
241 printk(KERN_DEBUG "%s: %s - dropped.\n", sp->dev->name, msg); in sp_encaps()
248 struct sixpack *sp = netdev_priv(dev); in sp_xmit() local
253 spin_lock_bh(&sp->lock); in sp_xmit()
257 sp_encaps(sp, skb->data, skb->len); in sp_xmit()
258 spin_unlock_bh(&sp->lock); in sp_xmit()
267 struct sixpack *sp = netdev_priv(dev); in sp_open_dev() local
269 if (sp->tty == NULL) in sp_open_dev()
277 struct sixpack *sp = netdev_priv(dev); in sp_close() local
279 spin_lock_bh(&sp->lock); in sp_close()
280 if (sp->tty) { in sp_close()
282 clear_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_close()
285 spin_unlock_bh(&sp->lock); in sp_close()
337 static void sp_bump(struct sixpack *sp, char cmd) in sp_bump() argument
343 count = sp->rcount + 1; in sp_bump()
345 sp->dev->stats.rx_bytes += count; in sp_bump()
353 memcpy(ptr, sp->cooked_buf + 1, count); in sp_bump()
354 skb->protocol = ax25_type_trans(skb, sp->dev); in sp_bump()
356 sp->dev->stats.rx_packets++; in sp_bump()
361 sp->dev->stats.rx_dropped++; in sp_bump()
379 struct sixpack *sp; in sp_get() local
382 sp = tty->disc_data; in sp_get()
383 if (sp) in sp_get()
384 atomic_inc(&sp->refcnt); in sp_get()
387 return sp; in sp_get()
390 static void sp_put(struct sixpack *sp) in sp_put() argument
392 if (atomic_dec_and_test(&sp->refcnt)) in sp_put()
393 up(&sp->dead_sem); in sp_put()
402 struct sixpack *sp = sp_get(tty); in sixpack_write_wakeup() local
405 if (!sp) in sixpack_write_wakeup()
407 if (sp->xleft <= 0) { in sixpack_write_wakeup()
410 sp->dev->stats.tx_packets++; in sixpack_write_wakeup()
412 sp->tx_enable = 0; in sixpack_write_wakeup()
413 netif_wake_queue(sp->dev); in sixpack_write_wakeup()
417 if (sp->tx_enable) { in sixpack_write_wakeup()
418 actual = tty->ops->write(tty, sp->xhead, sp->xleft); in sixpack_write_wakeup()
419 sp->xleft -= actual; in sixpack_write_wakeup()
420 sp->xhead += actual; in sixpack_write_wakeup()
424 sp_put(sp); in sixpack_write_wakeup()
438 struct sixpack *sp; in sixpack_receive_buf() local
445 sp = sp_get(tty); in sixpack_receive_buf()
446 if (!sp) in sixpack_receive_buf()
457 if (!test_and_set_bit(SIXPF_ERROR, &sp->flags)) in sixpack_receive_buf()
458 sp->dev->stats.rx_errors++; in sixpack_receive_buf()
462 sixpack_decode(sp, buf, count1); in sixpack_receive_buf()
464 sp_put(sp); in sixpack_receive_buf()
478 static void __tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in __tnc_set_sync_state() argument
495 sp->tnc_state = new_tnc_state; in __tnc_set_sync_state()
496 printk(KERN_INFO "%s: %s\n", sp->dev->name, msg); in __tnc_set_sync_state()
499 static inline void tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in tnc_set_sync_state() argument
501 int old_tnc_state = sp->tnc_state; in tnc_set_sync_state()
504 __tnc_set_sync_state(sp, new_tnc_state); in tnc_set_sync_state()
509 struct sixpack *sp = (struct sixpack *) channel; in resync_tnc() local
514 sp->rx_count = 0; in resync_tnc()
515 sp->rx_count_cooked = 0; in resync_tnc()
519 sp->status = 1; in resync_tnc()
520 sp->status1 = 1; in resync_tnc()
521 sp->status2 = 0; in resync_tnc()
525 sp->led_state = 0x60; in resync_tnc()
526 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in resync_tnc()
527 sp->tty->ops->write(sp->tty, &resync_cmd, 1); in resync_tnc()
532 del_timer(&sp->resync_t); in resync_tnc()
533 sp->resync_t.data = (unsigned long) sp; in resync_tnc()
534 sp->resync_t.function = resync_tnc; in resync_tnc()
535 sp->resync_t.expires = jiffies + SIXP_RESYNC_TIMEOUT; in resync_tnc()
536 add_timer(&sp->resync_t); in resync_tnc()
539 static inline int tnc_init(struct sixpack *sp) in tnc_init() argument
543 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); in tnc_init()
545 sp->tty->ops->write(sp->tty, &inbyte, 1); in tnc_init()
547 del_timer(&sp->resync_t); in tnc_init()
548 sp->resync_t.data = (unsigned long) sp; in tnc_init()
549 sp->resync_t.function = resync_tnc; in tnc_init()
550 sp->resync_t.expires = jiffies + SIXP_RESYNC_TIMEOUT; in tnc_init()
551 add_timer(&sp->resync_t); in tnc_init()
567 struct sixpack *sp; in sixpack_open() local
583 sp = netdev_priv(dev); in sixpack_open()
584 sp->dev = dev; in sixpack_open()
586 spin_lock_init(&sp->lock); in sixpack_open()
587 atomic_set(&sp->refcnt, 1); in sixpack_open()
588 sema_init(&sp->dead_sem, 0); in sixpack_open()
602 spin_lock_bh(&sp->lock); in sixpack_open()
604 sp->tty = tty; in sixpack_open()
606 sp->rbuff = rbuff; in sixpack_open()
607 sp->xbuff = xbuff; in sixpack_open()
609 sp->mtu = AX25_MTU + 73; in sixpack_open()
610 sp->buffsize = len; in sixpack_open()
611 sp->rcount = 0; in sixpack_open()
612 sp->rx_count = 0; in sixpack_open()
613 sp->rx_count_cooked = 0; in sixpack_open()
614 sp->xleft = 0; in sixpack_open()
616 sp->flags = 0; /* Clear ESCAPE & ERROR flags */ in sixpack_open()
618 sp->duplex = 0; in sixpack_open()
619 sp->tx_delay = SIXP_TXDELAY; in sixpack_open()
620 sp->persistence = SIXP_PERSIST; in sixpack_open()
621 sp->slottime = SIXP_SLOTTIME; in sixpack_open()
622 sp->led_state = 0x60; in sixpack_open()
623 sp->status = 1; in sixpack_open()
624 sp->status1 = 1; in sixpack_open()
625 sp->status2 = 0; in sixpack_open()
626 sp->tx_enable = 0; in sixpack_open()
630 init_timer(&sp->tx_t); in sixpack_open()
631 sp->tx_t.function = sp_xmit_on_air; in sixpack_open()
632 sp->tx_t.data = (unsigned long) sp; in sixpack_open()
634 init_timer(&sp->resync_t); in sixpack_open()
636 spin_unlock_bh(&sp->lock); in sixpack_open()
639 tty->disc_data = sp; in sixpack_open()
647 tnc_init(sp); in sixpack_open()
670 struct sixpack *sp; in sixpack_close() local
673 sp = tty->disc_data; in sixpack_close()
676 if (!sp) in sixpack_close()
683 if (!atomic_dec_and_test(&sp->refcnt)) in sixpack_close()
684 down(&sp->dead_sem); in sixpack_close()
690 netif_stop_queue(sp->dev); in sixpack_close()
692 del_timer_sync(&sp->tx_t); in sixpack_close()
693 del_timer_sync(&sp->resync_t); in sixpack_close()
696 kfree(sp->rbuff); in sixpack_close()
697 kfree(sp->xbuff); in sixpack_close()
699 unregister_netdev(sp->dev); in sixpack_close()
706 struct sixpack *sp = sp_get(tty); in sixpack_ioctl() local
710 if (!sp) in sixpack_ioctl()
712 dev = sp->dev; in sixpack_ioctl()
730 sp->mode = tmp; in sixpack_ioctl()
760 sp_put(sp); in sixpack_ioctl()
867 static void decode_data(struct sixpack *sp, unsigned char inbyte) in decode_data() argument
871 if (sp->rx_count != 3) { in decode_data()
872 sp->raw_buf[sp->rx_count++] = inbyte; in decode_data()
877 buf = sp->raw_buf; in decode_data()
878 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
880 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
882 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
884 sp->rx_count = 0; in decode_data()
889 static void decode_prio_command(struct sixpack *sp, unsigned char cmd) in decode_prio_command() argument
904 if (((sp->status & SIXP_DCD_MASK) == 0) && in decode_prio_command()
906 if (sp->status != 1) in decode_prio_command()
909 sp->status = 0; in decode_prio_command()
912 sp->status = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
914 if ((sp->status2 != 0) && (sp->duplex == 1)) { in decode_prio_command()
915 sp->led_state = 0x70; in decode_prio_command()
916 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
917 sp->tx_enable = 1; in decode_prio_command()
918 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in decode_prio_command()
919 sp->xleft -= actual; in decode_prio_command()
920 sp->xhead += actual; in decode_prio_command()
921 sp->led_state = 0x60; in decode_prio_command()
922 sp->status2 = 0; in decode_prio_command()
928 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
933 if (sp->tnc_state == TNC_IN_SYNC) { in decode_prio_command()
934 del_timer(&sp->resync_t); in decode_prio_command()
935 sp->resync_t.data = (unsigned long) sp; in decode_prio_command()
936 sp->resync_t.function = resync_tnc; in decode_prio_command()
937 sp->resync_t.expires = jiffies + SIXP_INIT_RESYNC_TIMEOUT; in decode_prio_command()
938 add_timer(&sp->resync_t); in decode_prio_command()
941 sp->status1 = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
946 static void decode_std_command(struct sixpack *sp, unsigned char cmd) in decode_std_command() argument
954 if ((sp->rx_count == 0) && (sp->rx_count_cooked == 0)) { in decode_std_command()
955 if ((sp->status & SIXP_RX_DCD_MASK) == in decode_std_command()
957 sp->led_state = 0x68; in decode_std_command()
958 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
961 sp->led_state = 0x60; in decode_std_command()
963 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
964 rest = sp->rx_count; in decode_std_command()
967 decode_data(sp, 0); in decode_std_command()
969 sp->rx_count_cooked -= 2; in decode_std_command()
971 sp->rx_count_cooked -= 1; in decode_std_command()
972 for (i = 0; i < sp->rx_count_cooked; i++) in decode_std_command()
973 checksum += sp->cooked_buf[i]; in decode_std_command()
977 sp->rcount = sp->rx_count_cooked-2; in decode_std_command()
978 sp_bump(sp, 0); in decode_std_command()
980 sp->rx_count_cooked = 0; in decode_std_command()
995 sixpack_decode(struct sixpack *sp, unsigned char *pre_rbuff, int count) in sixpack_decode() argument
1003 tnc_set_sync_state(sp, TNC_IN_SYNC); in sixpack_decode()
1004 del_timer(&sp->resync_t); in sixpack_decode()
1007 decode_prio_command(sp, inbyte); in sixpack_decode()
1009 decode_std_command(sp, inbyte); in sixpack_decode()
1010 else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK) in sixpack_decode()
1011 decode_data(sp, inbyte); in sixpack_decode()