Lines Matching refs:sp

141 	struct sixpack *sp = (struct sixpack *) channel;
142 int actual, when = sp->slottime;
147 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) {
148 sp->led_state = 0x70;
149 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
150 sp->tx_enable = 1;
151 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2);
152 sp->xleft -= actual;
153 sp->xhead += actual;
154 sp->led_state = 0x60;
155 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
156 sp->status2 = 0;
158 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100);
164 static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
169 if (len > sp->mtu) { /* sp->mtu = AX25_MTU = max. PACLEN = 256 */
174 if (len > sp->mtu) { /* sp->mtu = AX25_MTU = max. PACLEN = 256 */
194 count = encode_sixpack(p, sp->xbuff, len, sp->tx_delay);
195 set_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags);
198 case 1: sp->tx_delay = p[1];
200 case 2: sp->persistence = p[1];
202 case 3: sp->slottime = p[1];
206 case 5: sp->duplex = p[1];
219 if (sp->duplex == 1) {
220 sp->led_state = 0x70;
221 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
222 sp->tx_enable = 1;
223 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count);
224 sp->xleft = count - actual;
225 sp->xhead = sp->xbuff + actual;
226 sp->led_state = 0x60;
227 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
229 sp->xleft = count;
230 sp->xhead = sp->xbuff;
231 sp->status2 = count;
232 sp_xmit_on_air((unsigned long)sp);
238 sp->dev->stats.tx_dropped++;
239 netif_start_queue(sp->dev);
241 printk(KERN_DEBUG "%s: %s - dropped.\n", sp->dev->name, msg);
248 struct sixpack *sp = netdev_priv(dev);
250 spin_lock_bh(&sp->lock);
254 sp_encaps(sp, skb->data, skb->len);
255 spin_unlock_bh(&sp->lock);
264 struct sixpack *sp = netdev_priv(dev);
266 if (sp->tty == NULL)
274 struct sixpack *sp = netdev_priv(dev);
276 spin_lock_bh(&sp->lock);
277 if (sp->tty) {
279 clear_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags);
282 spin_unlock_bh(&sp->lock);
360 static void sp_bump(struct sixpack *sp, char cmd)
366 count = sp->rcount + 1;
368 sp->dev->stats.rx_bytes += count;
376 memcpy(ptr, sp->cooked_buf + 1, count);
377 skb->protocol = ax25_type_trans(skb, sp->dev);
379 sp->dev->stats.rx_packets++;
384 sp->dev->stats.rx_dropped++;
402 struct sixpack *sp;
405 sp = tty->disc_data;
406 if (sp)
407 atomic_inc(&sp->refcnt);
410 return sp;
413 static void sp_put(struct sixpack *sp)
415 if (atomic_dec_and_test(&sp->refcnt))
416 up(&sp->dead_sem);
425 struct sixpack *sp = sp_get(tty);
428 if (!sp)
430 if (sp->xleft <= 0) {
433 sp->dev->stats.tx_packets++;
435 sp->tx_enable = 0;
436 netif_wake_queue(sp->dev);
440 if (sp->tx_enable) {
441 actual = tty->ops->write(tty, sp->xhead, sp->xleft);
442 sp->xleft -= actual;
443 sp->xhead += actual;
447 sp_put(sp);
461 struct sixpack *sp;
468 sp = sp_get(tty);
469 if (!sp)
480 if (!test_and_set_bit(SIXPF_ERROR, &sp->flags))
481 sp->dev->stats.rx_errors++;
485 sixpack_decode(sp, buf, count1);
487 sp_put(sp);
501 static void __tnc_set_sync_state(struct sixpack *sp, int new_tnc_state)
518 sp->tnc_state = new_tnc_state;
519 printk(KERN_INFO "%s: %s\n", sp->dev->name, msg);
522 static inline void tnc_set_sync_state(struct sixpack *sp, int new_tnc_state)
524 int old_tnc_state = sp->tnc_state;
527 __tnc_set_sync_state(sp, new_tnc_state);
532 struct sixpack *sp = (struct sixpack *) channel;
537 sp->rx_count = 0;
538 sp->rx_count_cooked = 0;
542 sp->status = 1;
543 sp->status1 = 1;
544 sp->status2 = 0;
548 sp->led_state = 0x60;
549 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
550 sp->tty->ops->write(sp->tty, &resync_cmd, 1);
555 del_timer(&sp->resync_t);
556 sp->resync_t.data = (unsigned long) sp;
557 sp->resync_t.function = resync_tnc;
558 sp->resync_t.expires = jiffies + SIXP_RESYNC_TIMEOUT;
559 add_timer(&sp->resync_t);
562 static inline int tnc_init(struct sixpack *sp)
566 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP);
568 sp->tty->ops->write(sp->tty, &inbyte, 1);
570 del_timer(&sp->resync_t);
571 sp->resync_t.data = (unsigned long) sp;
572 sp->resync_t.function = resync_tnc;
573 sp->resync_t.expires = jiffies + SIXP_RESYNC_TIMEOUT;
574 add_timer(&sp->resync_t);
590 struct sixpack *sp;
599 dev = alloc_netdev(sizeof(struct sixpack), "sp%d", NET_NAME_UNKNOWN,
606 sp = netdev_priv(dev);
607 sp->dev = dev;
609 spin_lock_init(&sp->lock);
610 atomic_set(&sp->refcnt, 1);
611 sema_init(&sp->dead_sem, 0);
625 spin_lock_bh(&sp->lock);
627 sp->tty = tty;
629 sp->rbuff = rbuff;
630 sp->xbuff = xbuff;
632 sp->mtu = AX25_MTU + 73;
633 sp->buffsize = len;
634 sp->rcount = 0;
635 sp->rx_count = 0;
636 sp->rx_count_cooked = 0;
637 sp->xleft = 0;
639 sp->flags = 0; /* Clear ESCAPE & ERROR flags */
641 sp->duplex = 0;
642 sp->tx_delay = SIXP_TXDELAY;
643 sp->persistence = SIXP_PERSIST;
644 sp->slottime = SIXP_SLOTTIME;
645 sp->led_state = 0x60;
646 sp->status = 1;
647 sp->status1 = 1;
648 sp->status2 = 0;
649 sp->tx_enable = 0;
653 init_timer(&sp->tx_t);
654 sp->tx_t.function = sp_xmit_on_air;
655 sp->tx_t.data = (unsigned long) sp;
657 init_timer(&sp->resync_t);
659 spin_unlock_bh(&sp->lock);
662 tty->disc_data = sp;
670 tnc_init(sp);
694 struct sixpack *sp;
697 sp = tty->disc_data;
700 if (!sp)
707 if (!atomic_dec_and_test(&sp->refcnt))
708 down(&sp->dead_sem);
710 unregister_netdev(sp->dev);
712 del_timer(&sp->tx_t);
713 del_timer(&sp->resync_t);
716 kfree(sp->rbuff);
717 kfree(sp->xbuff);
724 struct sixpack *sp = sp_get(tty);
728 if (!sp)
730 dev = sp->dev;
748 sp->mode = tmp;
778 sp_put(sp);
885 static void decode_data(struct sixpack *sp, unsigned char inbyte)
889 if (sp->rx_count != 3) {
890 sp->raw_buf[sp->rx_count++] = inbyte;
895 buf = sp->raw_buf;
896 sp->cooked_buf[sp->rx_count_cooked++] =
898 sp->cooked_buf[sp->rx_count_cooked++] =
900 sp->cooked_buf[sp->rx_count_cooked++] =
902 sp->rx_count = 0;
907 static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
922 if (((sp->status & SIXP_DCD_MASK) == 0) &&
924 if (sp->status != 1)
927 sp->status = 0;
930 sp->status = cmd & SIXP_PRIO_DATA_MASK;
932 if ((sp->status2 != 0) && (sp->duplex == 1)) {
933 sp->led_state = 0x70;
934 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
935 sp->tx_enable = 1;
936 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2);
937 sp->xleft -= actual;
938 sp->xhead += actual;
939 sp->led_state = 0x60;
940 sp->status2 = 0;
946 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
951 if (sp->tnc_state == TNC_IN_SYNC) {
952 del_timer(&sp->resync_t);
953 sp->resync_t.data = (unsigned long) sp;
954 sp->resync_t.function = resync_tnc;
955 sp->resync_t.expires = jiffies + SIXP_INIT_RESYNC_TIMEOUT;
956 add_timer(&sp->resync_t);
959 sp->status1 = cmd & SIXP_PRIO_DATA_MASK;
964 static void decode_std_command(struct sixpack *sp, unsigned char cmd)
972 if ((sp->rx_count == 0) && (sp->rx_count_cooked == 0)) {
973 if ((sp->status & SIXP_RX_DCD_MASK) ==
975 sp->led_state = 0x68;
976 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
979 sp->led_state = 0x60;
981 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
982 rest = sp->rx_count;
985 decode_data(sp, 0);
987 sp->rx_count_cooked -= 2;
989 sp->rx_count_cooked -= 1;
990 for (i = 0; i < sp->rx_count_cooked; i++)
991 checksum += sp->cooked_buf[i];
995 sp->rcount = sp->rx_count_cooked-2;
996 sp_bump(sp, 0);
998 sp->rx_count_cooked = 0;
1013 sixpack_decode(struct sixpack *sp, unsigned char *pre_rbuff, int count)
1021 tnc_set_sync_state(sp, TNC_IN_SYNC);
1022 del_timer(&sp->resync_t);
1025 decode_prio_command(sp, inbyte);
1027 decode_std_command(sp, inbyte);
1028 else if ((sp->status & SIXP_RX_DCD_MASK) == SIXP_RX_DCD_MASK)
1029 decode_data(sp, inbyte);