Lines Matching refs:sp
134 struct sixpack *sp = timer_container_of(sp, t, tx_t); in sp_xmit_on_air() local
135 int actual, when = sp->slottime; in sp_xmit_on_air()
140 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { in sp_xmit_on_air()
141 sp->led_state = 0x70; in sp_xmit_on_air()
142 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
143 sp->tx_enable = 1; in sp_xmit_on_air()
144 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in sp_xmit_on_air()
145 sp->xleft -= actual; in sp_xmit_on_air()
146 sp->xhead += actual; in sp_xmit_on_air()
147 sp->led_state = 0x60; in sp_xmit_on_air()
148 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_xmit_on_air()
149 sp->status2 = 0; in sp_xmit_on_air()
151 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); in sp_xmit_on_air()
157 static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len) in sp_encaps() argument
182 count = encode_sixpack(p, sp->xbuff, len, sp->tx_delay); in sp_encaps()
183 set_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_encaps()
186 case 1: sp->tx_delay = p[1]; in sp_encaps()
188 case 2: sp->persistence = p[1]; in sp_encaps()
190 case 3: sp->slottime = p[1]; in sp_encaps()
194 case 5: sp->duplex = p[1]; in sp_encaps()
207 if (sp->duplex == 1) { in sp_encaps()
208 sp->led_state = 0x70; in sp_encaps()
209 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
210 sp->tx_enable = 1; in sp_encaps()
211 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count); in sp_encaps()
212 sp->xleft = count - actual; in sp_encaps()
213 sp->xhead = sp->xbuff + actual; in sp_encaps()
214 sp->led_state = 0x60; in sp_encaps()
215 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in sp_encaps()
217 sp->xleft = count; in sp_encaps()
218 sp->xhead = sp->xbuff; in sp_encaps()
219 sp->status2 = count; in sp_encaps()
220 sp_xmit_on_air(&sp->tx_t); in sp_encaps()
226 sp->dev->stats.tx_dropped++; in sp_encaps()
227 netif_start_queue(sp->dev); in sp_encaps()
229 printk(KERN_DEBUG "%s: %s - dropped.\n", sp->dev->name, msg); in sp_encaps()
236 struct sixpack *sp = netdev_priv(dev); in sp_xmit() local
241 spin_lock_bh(&sp->lock); in sp_xmit()
245 sp_encaps(sp, skb->data, skb->len); in sp_xmit()
246 spin_unlock_bh(&sp->lock); in sp_xmit()
255 struct sixpack *sp = netdev_priv(dev); in sp_open_dev() local
257 if (sp->tty == NULL) in sp_open_dev()
265 struct sixpack *sp = netdev_priv(dev); in sp_close() local
267 spin_lock_bh(&sp->lock); in sp_close()
268 if (sp->tty) { in sp_close()
270 clear_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); in sp_close()
273 spin_unlock_bh(&sp->lock); in sp_close()
324 static void sp_bump(struct sixpack *sp, char cmd) in sp_bump() argument
330 count = sp->rcount + 1; in sp_bump()
332 sp->dev->stats.rx_bytes += count; in sp_bump()
340 memcpy(ptr, sp->cooked_buf + 1, count); in sp_bump()
341 skb->protocol = ax25_type_trans(skb, sp->dev); in sp_bump()
343 sp->dev->stats.rx_packets++; in sp_bump()
348 sp->dev->stats.rx_dropped++; in sp_bump()
360 struct sixpack *sp = tty->disc_data; in sixpack_write_wakeup() local
363 if (!sp) in sixpack_write_wakeup()
365 if (sp->xleft <= 0) { in sixpack_write_wakeup()
368 sp->dev->stats.tx_packets++; in sixpack_write_wakeup()
370 sp->tx_enable = 0; in sixpack_write_wakeup()
371 netif_wake_queue(sp->dev); in sixpack_write_wakeup()
375 if (sp->tx_enable) { in sixpack_write_wakeup()
376 actual = tty->ops->write(tty, sp->xhead, sp->xleft); in sixpack_write_wakeup()
377 sp->xleft -= actual; in sixpack_write_wakeup()
378 sp->xhead += actual; in sixpack_write_wakeup()
393 struct sixpack *sp; in sixpack_receive_buf() local
399 sp = tty->disc_data; in sixpack_receive_buf()
400 if (!sp) in sixpack_receive_buf()
408 if (!test_and_set_bit(SIXPF_ERROR, &sp->flags)) in sixpack_receive_buf()
409 sp->dev->stats.rx_errors++; in sixpack_receive_buf()
413 sixpack_decode(sp, cp, count1); in sixpack_receive_buf()
428 static void __tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in __tnc_set_sync_state() argument
445 sp->tnc_state = new_tnc_state; in __tnc_set_sync_state()
446 printk(KERN_INFO "%s: %s\n", sp->dev->name, msg); in __tnc_set_sync_state()
449 static inline void tnc_set_sync_state(struct sixpack *sp, int new_tnc_state) in tnc_set_sync_state() argument
451 int old_tnc_state = sp->tnc_state; in tnc_set_sync_state()
454 __tnc_set_sync_state(sp, new_tnc_state); in tnc_set_sync_state()
459 struct sixpack *sp = timer_container_of(sp, t, resync_t); in resync_tnc() local
464 sp->rx_count = 0; in resync_tnc()
465 sp->rx_count_cooked = 0; in resync_tnc()
469 sp->status = 1; in resync_tnc()
470 sp->status1 = 1; in resync_tnc()
471 sp->status2 = 0; in resync_tnc()
475 sp->led_state = 0x60; in resync_tnc()
476 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in resync_tnc()
477 sp->tty->ops->write(sp->tty, &resync_cmd, 1); in resync_tnc()
481 mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT); in resync_tnc()
484 static inline int tnc_init(struct sixpack *sp) in tnc_init() argument
488 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); in tnc_init()
490 sp->tty->ops->write(sp->tty, &inbyte, 1); in tnc_init()
492 mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT); in tnc_init()
508 struct sixpack *sp; in sixpack_open() local
524 sp = netdev_priv(dev); in sixpack_open()
525 sp->dev = dev; in sixpack_open()
527 spin_lock_init(&sp->lock); in sixpack_open()
528 spin_lock_init(&sp->rxlock); in sixpack_open()
540 spin_lock_bh(&sp->lock); in sixpack_open()
542 sp->tty = tty; in sixpack_open()
544 sp->xbuff = xbuff; in sixpack_open()
546 sp->rcount = 0; in sixpack_open()
547 sp->rx_count = 0; in sixpack_open()
548 sp->rx_count_cooked = 0; in sixpack_open()
549 sp->xleft = 0; in sixpack_open()
551 sp->flags = 0; /* Clear ESCAPE & ERROR flags */ in sixpack_open()
553 sp->duplex = 0; in sixpack_open()
554 sp->tx_delay = SIXP_TXDELAY; in sixpack_open()
555 sp->persistence = SIXP_PERSIST; in sixpack_open()
556 sp->slottime = SIXP_SLOTTIME; in sixpack_open()
557 sp->led_state = 0x60; in sixpack_open()
558 sp->status = 1; in sixpack_open()
559 sp->status1 = 1; in sixpack_open()
560 sp->status2 = 0; in sixpack_open()
561 sp->tx_enable = 0; in sixpack_open()
565 timer_setup(&sp->tx_t, sp_xmit_on_air, 0); in sixpack_open()
567 timer_setup(&sp->resync_t, resync_tnc, 0); in sixpack_open()
569 spin_unlock_bh(&sp->lock); in sixpack_open()
572 tty->disc_data = sp; in sixpack_open()
580 tnc_init(sp); in sixpack_open()
602 struct sixpack *sp; in sixpack_close() local
604 sp = tty->disc_data; in sixpack_close()
605 if (!sp) in sixpack_close()
614 netif_stop_queue(sp->dev); in sixpack_close()
616 unregister_netdev(sp->dev); in sixpack_close()
618 timer_delete_sync(&sp->tx_t); in sixpack_close()
619 timer_delete_sync(&sp->resync_t); in sixpack_close()
622 kfree(sp->xbuff); in sixpack_close()
624 free_netdev(sp->dev); in sixpack_close()
631 struct sixpack *sp = tty->disc_data; in sixpack_ioctl() local
635 if (!sp) in sixpack_ioctl()
637 dev = sp->dev; in sixpack_ioctl()
655 sp->mode = tmp; in sixpack_ioctl()
756 static void decode_data(struct sixpack *sp, u8 inbyte) in decode_data() argument
760 if (sp->rx_count != 3) { in decode_data()
761 sp->raw_buf[sp->rx_count++] = inbyte; in decode_data()
766 if (sp->rx_count_cooked + 2 >= sizeof(sp->cooked_buf)) { in decode_data()
768 sp->rx_count = 0; in decode_data()
772 buf = sp->raw_buf; in decode_data()
773 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
775 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
777 sp->cooked_buf[sp->rx_count_cooked++] = in decode_data()
779 sp->rx_count = 0; in decode_data()
784 static void decode_prio_command(struct sixpack *sp, u8 cmd) in decode_prio_command() argument
797 if (((sp->status & SIXP_DCD_MASK) == 0) && in decode_prio_command()
799 if (sp->status != 1) in decode_prio_command()
802 sp->status = 0; in decode_prio_command()
805 sp->status = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
807 if ((sp->status2 != 0) && (sp->duplex == 1)) { in decode_prio_command()
808 sp->led_state = 0x70; in decode_prio_command()
809 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
810 sp->tx_enable = 1; in decode_prio_command()
811 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); in decode_prio_command()
812 sp->xleft -= actual; in decode_prio_command()
813 sp->xhead += actual; in decode_prio_command()
814 sp->led_state = 0x60; in decode_prio_command()
815 sp->status2 = 0; in decode_prio_command()
821 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_prio_command()
826 if (sp->tnc_state == TNC_IN_SYNC) in decode_prio_command()
827 mod_timer(&sp->resync_t, jiffies + SIXP_INIT_RESYNC_TIMEOUT); in decode_prio_command()
829 sp->status1 = cmd & SIXP_PRIO_DATA_MASK; in decode_prio_command()
834 static void decode_std_command(struct sixpack *sp, u8 cmd) in decode_std_command() argument
841 if ((sp->rx_count == 0) && (sp->rx_count_cooked == 0)) { in decode_std_command()
842 if ((sp->status & SIXP_RX_DCD_MASK) == in decode_std_command()
844 sp->led_state = 0x68; in decode_std_command()
845 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
848 sp->led_state = 0x60; in decode_std_command()
850 sp->tty->ops->write(sp->tty, &sp->led_state, 1); in decode_std_command()
851 spin_lock_bh(&sp->rxlock); in decode_std_command()
852 rest = sp->rx_count; in decode_std_command()
855 decode_data(sp, 0); in decode_std_command()
857 sp->rx_count_cooked -= 2; in decode_std_command()
859 sp->rx_count_cooked -= 1; in decode_std_command()
860 for (i = 0; i < sp->rx_count_cooked; i++) in decode_std_command()
861 checksum += sp->cooked_buf[i]; in decode_std_command()
865 sp->rcount = sp->rx_count_cooked-2; in decode_std_command()
866 sp_bump(sp, 0); in decode_std_command()
868 sp->rx_count_cooked = 0; in decode_std_command()
869 spin_unlock_bh(&sp->rxlock); in decode_std_command()
884 sixpack_decode(struct sixpack *sp, const u8 *pre_rbuff, size_t count) in sixpack_decode() argument
892 tnc_set_sync_state(sp, TNC_IN_SYNC); in sixpack_decode()
893 timer_delete(&sp->resync_t); in sixpack_decode()
896 decode_prio_command(sp, inbyte); in sixpack_decode()
898 decode_std_command(sp, inbyte); in sixpack_decode()
899 else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK) { in sixpack_decode()
900 spin_lock_bh(&sp->rxlock); in sixpack_decode()
901 decode_data(sp, inbyte); in sixpack_decode()
902 spin_unlock_bh(&sp->rxlock); in sixpack_decode()