Lines Matching refs:sp

142 	struct sixpack *sp = from_timer(sp, t, tx_t);  in sp_xmit_on_air()  local
143 int actual, when = sp->slottime; in sp_xmit_on_air()
148 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { in sp_xmit_on_air()
149 sp->led_state = 0x70; in sp_xmit_on_air()
150 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
151 sp->tx_enable = 1; in sp_xmit_on_air()
152 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in sp_xmit_on_air()
153 sp->xleft -= actual; in sp_xmit_on_air()
154 sp->xhead += actual; in sp_xmit_on_air()
155 sp->led_state = 0x60; in sp_xmit_on_air()
156 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
157 sp->status2 = 0; in sp_xmit_on_air()
159 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); in sp_xmit_on_air()
165 static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len) in sp_encaps() argument
170 if (len > sp->mtu) { /* sp->mtu = AX25_MTU = max. PACLEN = 256 */ in sp_encaps()
190 count = encode_sixpack(p, sp->xbuff, len, sp->tx_delay); in sp_encaps()
191 set_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_encaps()
194 case 1: sp->tx_delay = p[1]; in sp_encaps()
196 case 2: sp->persistence = p[1]; in sp_encaps()
198 case 3: sp->slottime = p[1]; in sp_encaps()
202 case 5: sp->duplex = p[1]; in sp_encaps()
215 if (sp->duplex == 1) { in sp_encaps()
216 sp->led_state = 0x70; in sp_encaps()
217 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
218 sp->tx_enable = 1; in sp_encaps()
219 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count); in sp_encaps()
220 sp->xleft = count - actual; in sp_encaps()
221 sp->xhead = sp->xbuff + actual; in sp_encaps()
222 sp->led_state = 0x60; in sp_encaps()
223 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
225 sp->xleft = count; in sp_encaps()
226 sp->xhead = sp->xbuff; in sp_encaps()
227 sp->status2 = count; in sp_encaps()
228 sp_xmit_on_air(&sp->tx_t); in sp_encaps()
234 sp->dev->stats.tx_dropped++; in sp_encaps()
235 netif_start_queue(sp->dev); in sp_encaps()
237 printk(KERN_DEBUG "%s: %s - dropped.\n", sp->dev->name, msg); in sp_encaps()
244 struct sixpack *sp = netdev_priv(dev); in sp_xmit() local
249 spin_lock_bh(&sp->lock); in sp_xmit()
253 sp_encaps(sp, skb->data, skb->len); in sp_xmit()
254 spin_unlock_bh(&sp->lock); in sp_xmit()
263 struct sixpack *sp = netdev_priv(dev); in sp_open_dev() local
265 if (sp->tty == NULL) in sp_open_dev()
273 struct sixpack *sp = netdev_priv(dev); in sp_close() local
275 spin_lock_bh(&sp->lock); in sp_close()
276 if (sp->tty) { in sp_close()
278 clear_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_close()
281 spin_unlock_bh(&sp->lock); in sp_close()
332 static void sp_bump(struct sixpack *sp, char cmd) in sp_bump() argument
338 count = sp->rcount + 1; in sp_bump()
340 sp->dev->stats.rx_bytes += count; in sp_bump()
348 memcpy(ptr, sp->cooked_buf + 1, count); in sp_bump()
349 skb->protocol = ax25_type_trans(skb, sp->dev); in sp_bump()
351 sp->dev->stats.rx_packets++; in sp_bump()
356 sp->dev->stats.rx_dropped++; in sp_bump()
374 struct sixpack *sp; in sp_get() local
377 sp = tty->disc_data; in sp_get()
378 if (sp) in sp_get()
379 refcount_inc(&sp->refcnt); in sp_get()
382 return sp; in sp_get()
385 static void sp_put(struct sixpack *sp) in sp_put() argument
387 if (refcount_dec_and_test(&sp->refcnt)) in sp_put()
388 complete(&sp->dead); in sp_put()
397 struct sixpack *sp = sp_get(tty); in sixpack_write_wakeup() local
400 if (!sp) in sixpack_write_wakeup()
402 if (sp->xleft <= 0) { in sixpack_write_wakeup()
405 sp->dev->stats.tx_packets++; in sixpack_write_wakeup()
407 sp->tx_enable = 0; in sixpack_write_wakeup()
408 netif_wake_queue(sp->dev); in sixpack_write_wakeup()
412 if (sp->tx_enable) { in sixpack_write_wakeup()
413 actual = tty->ops->write(tty, sp->xhead, sp->xleft); in sixpack_write_wakeup()
414 sp->xleft -= actual; in sixpack_write_wakeup()
415 sp->xhead += actual; in sixpack_write_wakeup()
419 sp_put(sp); in sixpack_write_wakeup()
433 struct sixpack *sp; in sixpack_receive_buf() local
439 sp = sp_get(tty); in sixpack_receive_buf()
440 if (!sp) in sixpack_receive_buf()
448 if (!test_and_set_bit(SIXPF_ERROR, &sp->flags)) in sixpack_receive_buf()
449 sp->dev->stats.rx_errors++; in sixpack_receive_buf()
453 sixpack_decode(sp, cp, count1); in sixpack_receive_buf()
455 sp_put(sp); in sixpack_receive_buf()
469 static void __tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in __tnc_set_sync_state() argument
486 sp->tnc_state = new_tnc_state; in __tnc_set_sync_state()
487 printk(KERN_INFO "%s: %s\n", sp->dev->name, msg); in __tnc_set_sync_state()
490 static inline void tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in tnc_set_sync_state() argument
492 int old_tnc_state = sp->tnc_state; in tnc_set_sync_state()
495 __tnc_set_sync_state(sp, new_tnc_state); in tnc_set_sync_state()
500 struct sixpack *sp = from_timer(sp, t, resync_t); in resync_tnc() local
505 sp->rx_count = 0; in resync_tnc()
506 sp->rx_count_cooked = 0; in resync_tnc()
510 sp->status = 1; in resync_tnc()
511 sp->status1 = 1; in resync_tnc()
512 sp->status2 = 0; in resync_tnc()
516 sp->led_state = 0x60; in resync_tnc()
517 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in resync_tnc()
518 sp->tty->ops->write(sp->tty, &resync_cmd, 1); in resync_tnc()
522 mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT); in resync_tnc()
525 static inline int tnc_init(struct sixpack *sp) in tnc_init() argument
529 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); in tnc_init()
531 sp->tty->ops->write(sp->tty, &inbyte, 1); in tnc_init()
533 mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT); in tnc_init()
549 struct sixpack *sp; in sixpack_open() local
565 sp = netdev_priv(dev); in sixpack_open()
566 sp->dev = dev; in sixpack_open()
568 spin_lock_init(&sp->lock); in sixpack_open()
569 spin_lock_init(&sp->rxlock); in sixpack_open()
570 refcount_set(&sp->refcnt, 1); in sixpack_open()
571 init_completion(&sp->dead); in sixpack_open()
585 spin_lock_bh(&sp->lock); in sixpack_open()
587 sp->tty = tty; in sixpack_open()
589 sp->rbuff = rbuff; in sixpack_open()
590 sp->xbuff = xbuff; in sixpack_open()
592 sp->mtu = AX25_MTU + 73; in sixpack_open()
593 sp->buffsize = len; in sixpack_open()
594 sp->rcount = 0; in sixpack_open()
595 sp->rx_count = 0; in sixpack_open()
596 sp->rx_count_cooked = 0; in sixpack_open()
597 sp->xleft = 0; in sixpack_open()
599 sp->flags = 0; /* Clear ESCAPE & ERROR flags */ in sixpack_open()
601 sp->duplex = 0; in sixpack_open()
602 sp->tx_delay = SIXP_TXDELAY; in sixpack_open()
603 sp->persistence = SIXP_PERSIST; in sixpack_open()
604 sp->slottime = SIXP_SLOTTIME; in sixpack_open()
605 sp->led_state = 0x60; in sixpack_open()
606 sp->status = 1; in sixpack_open()
607 sp->status1 = 1; in sixpack_open()
608 sp->status2 = 0; in sixpack_open()
609 sp->tx_enable = 0; in sixpack_open()
613 timer_setup(&sp->tx_t, sp_xmit_on_air, 0); in sixpack_open()
615 timer_setup(&sp->resync_t, resync_tnc, 0); in sixpack_open()
617 spin_unlock_bh(&sp->lock); in sixpack_open()
620 tty->disc_data = sp; in sixpack_open()
628 tnc_init(sp); in sixpack_open()
651 struct sixpack *sp; in sixpack_close() local
654 sp = tty->disc_data; in sixpack_close()
657 if (!sp) in sixpack_close()
664 if (!refcount_dec_and_test(&sp->refcnt)) in sixpack_close()
665 wait_for_completion(&sp->dead); in sixpack_close()
671 netif_stop_queue(sp->dev); in sixpack_close()
673 unregister_netdev(sp->dev); in sixpack_close()
675 del_timer_sync(&sp->tx_t); in sixpack_close()
676 del_timer_sync(&sp->resync_t); in sixpack_close()
679 kfree(sp->rbuff); in sixpack_close()
680 kfree(sp->xbuff); in sixpack_close()
682 free_netdev(sp->dev); in sixpack_close()
689 struct sixpack *sp = sp_get(tty); in sixpack_ioctl() local
693 if (!sp) in sixpack_ioctl()
695 dev = sp->dev; in sixpack_ioctl()
713 sp->mode = tmp; in sixpack_ioctl()
741 sp_put(sp); in sixpack_ioctl()
823 static void decode_data(struct sixpack *sp, unsigned char inbyte) in decode_data() argument
827 if (sp->rx_count != 3) { in decode_data()
828 sp->raw_buf[sp->rx_count++] = inbyte; in decode_data()
833 if (sp->rx_count_cooked + 2 >= sizeof(sp->cooked_buf)) { in decode_data()
835 sp->rx_count = 0; in decode_data()
839 buf = sp->raw_buf; in decode_data()
840 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
842 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
844 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
846 sp->rx_count = 0; in decode_data()
851 static void decode_prio_command(struct sixpack *sp, unsigned char cmd) in decode_prio_command() argument
864 if (((sp->status & SIXP_DCD_MASK) == 0) && in decode_prio_command()
866 if (sp->status != 1) in decode_prio_command()
869 sp->status = 0; in decode_prio_command()
872 sp->status = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
874 if ((sp->status2 != 0) && (sp->duplex == 1)) { in decode_prio_command()
875 sp->led_state = 0x70; in decode_prio_command()
876 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
877 sp->tx_enable = 1; in decode_prio_command()
878 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in decode_prio_command()
879 sp->xleft -= actual; in decode_prio_command()
880 sp->xhead += actual; in decode_prio_command()
881 sp->led_state = 0x60; in decode_prio_command()
882 sp->status2 = 0; in decode_prio_command()
888 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
893 if (sp->tnc_state == TNC_IN_SYNC) in decode_prio_command()
894 mod_timer(&sp->resync_t, jiffies + SIXP_INIT_RESYNC_TIMEOUT); in decode_prio_command()
896 sp->status1 = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
901 static void decode_std_command(struct sixpack *sp, unsigned char cmd) in decode_std_command() argument
908 if ((sp->rx_count == 0) && (sp->rx_count_cooked == 0)) { in decode_std_command()
909 if ((sp->status & SIXP_RX_DCD_MASK) == in decode_std_command()
911 sp->led_state = 0x68; in decode_std_command()
912 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
915 sp->led_state = 0x60; in decode_std_command()
917 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
918 spin_lock_bh(&sp->rxlock); in decode_std_command()
919 rest = sp->rx_count; in decode_std_command()
922 decode_data(sp, 0); in decode_std_command()
924 sp->rx_count_cooked -= 2; in decode_std_command()
926 sp->rx_count_cooked -= 1; in decode_std_command()
927 for (i = 0; i < sp->rx_count_cooked; i++) in decode_std_command()
928 checksum += sp->cooked_buf[i]; in decode_std_command()
932 sp->rcount = sp->rx_count_cooked-2; in decode_std_command()
933 sp_bump(sp, 0); in decode_std_command()
935 sp->rx_count_cooked = 0; in decode_std_command()
936 spin_unlock_bh(&sp->rxlock); in decode_std_command()
951 sixpack_decode(struct sixpack *sp, const unsigned char *pre_rbuff, int count) in sixpack_decode() argument
959 tnc_set_sync_state(sp, TNC_IN_SYNC); in sixpack_decode()
960 del_timer(&sp->resync_t); in sixpack_decode()
963 decode_prio_command(sp, inbyte); in sixpack_decode()
965 decode_std_command(sp, inbyte); in sixpack_decode()
966 else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK) { in sixpack_decode()
967 spin_lock_bh(&sp->rxlock); in sixpack_decode()
968 decode_data(sp, inbyte); in sixpack_decode()
969 spin_unlock_bh(&sp->rxlock); in sixpack_decode()