• Home
  • Raw
  • Download

Lines Matching refs:sl

104 static void slip_unesc(struct slip *sl, unsigned char c);
107 static void slip_unesc6(struct slip *sl, unsigned char c);
130 static int sl_alloc_bufs(struct slip *sl, int mtu) in sl_alloc_bufs() argument
171 spin_lock_bh(&sl->lock); in sl_alloc_bufs()
172 if (sl->tty == NULL) { in sl_alloc_bufs()
173 spin_unlock_bh(&sl->lock); in sl_alloc_bufs()
177 sl->mtu = mtu; in sl_alloc_bufs()
178 sl->buffsize = len; in sl_alloc_bufs()
179 sl->rcount = 0; in sl_alloc_bufs()
180 sl->xleft = 0; in sl_alloc_bufs()
181 rbuff = xchg(&sl->rbuff, rbuff); in sl_alloc_bufs()
182 xbuff = xchg(&sl->xbuff, xbuff); in sl_alloc_bufs()
184 cbuff = xchg(&sl->cbuff, cbuff); in sl_alloc_bufs()
185 slcomp = xchg(&sl->slcomp, slcomp); in sl_alloc_bufs()
188 sl->xdata = 0; in sl_alloc_bufs()
189 sl->xbits = 0; in sl_alloc_bufs()
191 spin_unlock_bh(&sl->lock); in sl_alloc_bufs()
206 static void sl_free_bufs(struct slip *sl) in sl_free_bufs() argument
209 kfree(xchg(&sl->rbuff, NULL)); in sl_free_bufs()
210 kfree(xchg(&sl->xbuff, NULL)); in sl_free_bufs()
212 kfree(xchg(&sl->cbuff, NULL)); in sl_free_bufs()
213 slhc_free(xchg(&sl->slcomp, NULL)); in sl_free_bufs()
221 static int sl_realloc_bufs(struct slip *sl, int mtu) argument
224 struct net_device *dev = sl->dev;
251 if (mtu > sl->mtu) {
258 spin_lock_bh(&sl->lock);
261 if (sl->tty == NULL)
264 xbuff = xchg(&sl->xbuff, xbuff);
265 rbuff = xchg(&sl->rbuff, rbuff);
267 cbuff = xchg(&sl->cbuff, cbuff);
269 if (sl->xleft) {
270 if (sl->xleft <= len) {
271 memcpy(sl->xbuff, sl->xhead, sl->xleft);
273 sl->xleft = 0;
277 sl->xhead = sl->xbuff;
279 if (sl->rcount) {
280 if (sl->rcount <= len) {
281 memcpy(sl->rbuff, rbuff, sl->rcount);
283 sl->rcount = 0;
285 set_bit(SLF_ERROR, &sl->flags);
288 sl->mtu = mtu;
290 sl->buffsize = len;
294 spin_unlock_bh(&sl->lock);
307 static inline void sl_lock(struct slip *sl) argument
309 netif_stop_queue(sl->dev);
314 static inline void sl_unlock(struct slip *sl) argument
316 netif_wake_queue(sl->dev);
320 static void sl_bump(struct slip *sl) argument
322 struct net_device *dev = sl->dev;
326 count = sl->rcount;
328 if (sl->mode & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
329 unsigned char c = sl->rbuff[0];
332 if (!(sl->mode & SL_MODE_CSLIP)) {
338 if (count + 80 > sl->buffsize) {
342 count = slhc_uncompress(sl->slcomp, sl->rbuff, count);
346 if (!(sl->mode & SL_MODE_CSLIP)) {
348 sl->mode |= SL_MODE_CSLIP;
349 sl->mode &= ~SL_MODE_ADAPTIVE;
352 sl->rbuff[0] &= 0x4f;
353 if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0)
368 skb_put_data(skb, sl->rbuff, count);
376 static void sl_encaps(struct slip *sl, unsigned char *icp, int len) argument
381 if (len > sl->mtu) { /* Sigh, shouldn't occur BUT ... */
382 printk(KERN_WARNING "%s: truncating oversized transmit packet!\n", sl->dev->name);
383 sl->dev->stats.tx_dropped++;
384 sl_unlock(sl);
390 if (sl->mode & SL_MODE_CSLIP)
391 len = slhc_compress(sl->slcomp, p, len, sl->cbuff, &p, 1);
394 if (sl->mode & SL_MODE_SLIP6)
395 count = slip_esc6(p, sl->xbuff, len);
398 count = slip_esc(p, sl->xbuff, len);
408 set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
409 actual = sl->tty->ops->write(sl->tty, sl->xbuff, count);
411 netif_trans_update(sl->dev);
413 sl->xleft = count - actual;
414 sl->xhead = sl->xbuff + actual;
417 clear_bit(SLF_OUTWAIT, &sl->flags); /* reset outfill flag */
424 struct slip *sl = container_of(work, struct slip, tx_work); local
427 spin_lock_bh(&sl->lock);
429 if (!sl->tty || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
430 spin_unlock_bh(&sl->lock);
434 if (sl->xleft <= 0) {
437 sl->dev->stats.tx_packets++;
438 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
439 spin_unlock_bh(&sl->lock);
440 sl_unlock(sl);
444 actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft);
445 sl->xleft -= actual;
446 sl->xhead += actual;
447 spin_unlock_bh(&sl->lock);
456 struct slip *sl; local
459 sl = rcu_dereference(tty->disc_data);
460 if (sl)
461 schedule_work(&sl->tx_work);
467 struct slip *sl = netdev_priv(dev); local
469 spin_lock(&sl->lock);
472 if (!netif_running(dev) || !sl->tty)
485 (tty_chars_in_buffer(sl->tty) || sl->xleft) ?
487 sl->xleft = 0;
488 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
489 sl_unlock(sl);
493 spin_unlock(&sl->lock);
501 struct slip *sl = netdev_priv(dev); local
503 spin_lock(&sl->lock);
505 spin_unlock(&sl->lock);
510 if (sl->tty == NULL) {
511 spin_unlock(&sl->lock);
516 sl_lock(sl);
518 sl_encaps(sl, skb->data, skb->len);
519 spin_unlock(&sl->lock);
535 struct slip *sl = netdev_priv(dev); local
537 spin_lock_bh(&sl->lock);
538 if (sl->tty)
540 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
542 sl->rcount = 0;
543 sl->xleft = 0;
544 spin_unlock_bh(&sl->lock);
553 struct slip *sl = netdev_priv(dev); local
555 if (sl->tty == NULL)
558 sl->flags &= (1 << SLF_INUSE);
567 struct slip *sl = netdev_priv(dev); local
569 return sl_realloc_bufs(sl, new_mtu);
579 struct slip *sl = netdev_priv(dev); local
580 struct slcompress *comp = sl->slcomp;
611 struct slip *sl = netdev_priv(dev); local
617 dev->mtu = sl->mtu;
618 dev->type = ARPHRD_SLIP + sl->mode;
628 struct slip *sl = netdev_priv(dev); local
630 sl_free_bufs(sl);
691 struct slip *sl = tty->disc_data; local
693 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
699 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
700 sl->dev->stats.rx_errors++;
705 if (sl->mode & SL_MODE_SLIP6)
706 slip_unesc6(sl, *cp++);
709 slip_unesc(sl, *cp++);
722 struct slip *sl; local
729 sl = netdev_priv(dev);
730 if (sl->tty || sl->leased)
744 struct slip *sl; local
756 dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, sl_setup);
761 sl = netdev_priv(dev);
764 sl->magic = SLIP_MAGIC;
765 sl->dev = dev;
766 spin_lock_init(&sl->lock);
767 INIT_WORK(&sl->tx_work, slip_transmit);
768 sl->mode = SL_MODE_DEFAULT;
771 timer_setup(&sl->keepalive_timer, sl_keepalive, 0);
772 timer_setup(&sl->outfill_timer, sl_outfill, 0);
775 return sl;
790 struct slip *sl; local
808 sl = tty->disc_data;
812 if (sl && sl->magic == SLIP_MAGIC)
817 sl = sl_alloc();
818 if (sl == NULL)
821 sl->tty = tty;
822 tty->disc_data = sl;
823 sl->pid = current->pid;
825 if (!test_bit(SLF_INUSE, &sl->flags)) {
827 err = sl_alloc_bufs(sl, SL_MTU);
831 set_bit(SLF_INUSE, &sl->flags);
833 err = register_netdevice(sl->dev);
839 if (sl->keepalive) {
840 sl->keepalive_timer.expires = jiffies + sl->keepalive * HZ;
841 add_timer(&sl->keepalive_timer);
843 if (sl->outfill) {
844 sl->outfill_timer.expires = jiffies + sl->outfill * HZ;
845 add_timer(&sl->outfill_timer);
857 sl_free_bufs(sl);
860 sl->tty = NULL;
862 clear_bit(SLF_INUSE, &sl->flags);
863 sl_free_netdev(sl->dev);
866 free_netdev(sl->dev);
886 struct slip *sl = tty->disc_data; local
889 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty)
892 spin_lock_bh(&sl->lock);
894 sl->tty = NULL;
895 spin_unlock_bh(&sl->lock);
898 flush_work(&sl->tx_work);
902 del_timer_sync(&sl->keepalive_timer);
903 del_timer_sync(&sl->outfill_timer);
906 unregister_netdev(sl->dev);
956 static void slip_unesc(struct slip *sl, unsigned char s) argument
963 if (test_bit(SLF_KEEPTEST, &sl->flags))
964 clear_bit(SLF_KEEPTEST, &sl->flags);
967 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) &&
968 (sl->rcount > 2))
969 sl_bump(sl);
970 clear_bit(SLF_ESCAPE, &sl->flags);
971 sl->rcount = 0;
975 set_bit(SLF_ESCAPE, &sl->flags);
978 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
982 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
986 if (!test_bit(SLF_ERROR, &sl->flags)) {
987 if (sl->rcount < sl->buffsize) {
988 sl->rbuff[sl->rcount++] = s;
991 sl->dev->stats.rx_over_errors++;
992 set_bit(SLF_ERROR, &sl->flags);
1039 static void slip_unesc6(struct slip *sl, unsigned char s) argument
1046 if (test_bit(SLF_KEEPTEST, &sl->flags))
1047 clear_bit(SLF_KEEPTEST, &sl->flags);
1050 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) &&
1051 (sl->rcount > 2))
1052 sl_bump(sl);
1053 sl->rcount = 0;
1054 sl->xbits = 0;
1055 sl->xdata = 0;
1057 sl->xdata = (sl->xdata << 6) | ((s - 0x30) & 0x3F);
1058 sl->xbits += 6;
1059 if (sl->xbits >= 8) {
1060 sl->xbits -= 8;
1061 c = (unsigned char)(sl->xdata >> sl->xbits);
1062 if (!test_bit(SLF_ERROR, &sl->flags)) {
1063 if (sl->rcount < sl->buffsize) {
1064 sl->rbuff[sl->rcount++] = c;
1067 sl->dev->stats.rx_over_errors++;
1068 set_bit(SLF_ERROR, &sl->flags);
1079 struct slip *sl = tty->disc_data; local
1084 if (!sl || sl->magic != SLIP_MAGIC)
1089 tmp = strlen(sl->dev->name) + 1;
1090 if (copy_to_user((void __user *)arg, sl->dev->name, tmp))
1095 if (put_user(sl->mode, p))
1115 sl->mode = tmp;
1116 sl->dev->type = ARPHRD_SLIP + sl->mode;
1130 spin_lock_bh(&sl->lock);
1131 if (!sl->tty) {
1132 spin_unlock_bh(&sl->lock);
1135 sl->keepalive = (u8)tmp;
1136 if (sl->keepalive != 0) {
1137 mod_timer(&sl->keepalive_timer,
1138 jiffies + sl->keepalive * HZ);
1139 set_bit(SLF_KEEPTEST, &sl->flags);
1141 del_timer(&sl->keepalive_timer);
1142 spin_unlock_bh(&sl->lock);
1146 if (put_user(sl->keepalive, p))
1155 spin_lock_bh(&sl->lock);
1156 if (!sl->tty) {
1157 spin_unlock_bh(&sl->lock);
1160 sl->outfill = (u8)tmp;
1161 if (sl->outfill != 0) {
1162 mod_timer(&sl->outfill_timer,
1163 jiffies + sl->outfill * HZ);
1164 set_bit(SLF_OUTWAIT, &sl->flags);
1166 del_timer(&sl->outfill_timer);
1167 spin_unlock_bh(&sl->lock);
1171 if (put_user(sl->outfill, p))
1190 struct slip *sl = netdev_priv(dev); local
1193 if (sl == NULL) /* Allocation failed ?? */
1199 spin_lock_bh(&sl->lock);
1201 if (!sl->tty) {
1202 spin_unlock_bh(&sl->lock);
1210 spin_unlock_bh(&sl->lock);
1213 sl->keepalive = (u8)*p;
1214 if (sl->keepalive != 0) {
1215 sl->keepalive_timer.expires =
1216 jiffies + sl->keepalive * HZ;
1217 mod_timer(&sl->keepalive_timer,
1218 jiffies + sl->keepalive * HZ);
1219 set_bit(SLF_KEEPTEST, &sl->flags);
1221 del_timer(&sl->keepalive_timer);
1225 *p = sl->keepalive;
1230 spin_unlock_bh(&sl->lock);
1233 sl->outfill = (u8)*p;
1234 if (sl->outfill != 0) {
1235 mod_timer(&sl->outfill_timer,
1236 jiffies + sl->outfill * HZ);
1237 set_bit(SLF_OUTWAIT, &sl->flags);
1239 del_timer(&sl->outfill_timer);
1243 *p = sl->outfill;
1250 if (sl->tty != current->signal->tty &&
1251 sl->pid != current->pid) {
1252 spin_unlock_bh(&sl->lock);
1255 sl->leased = 0;
1257 sl->leased = 1;
1261 *p = sl->leased;
1263 spin_unlock_bh(&sl->lock);
1319 struct slip *sl; local
1337 sl = netdev_priv(dev);
1338 spin_lock_bh(&sl->lock);
1339 if (sl->tty) {
1341 tty_hangup(sl->tty);
1343 spin_unlock_bh(&sl->lock);
1356 sl = netdev_priv(dev);
1357 if (sl->tty) {
1382 struct slip *sl = from_timer(sl, t, outfill_timer); local
1384 spin_lock(&sl->lock);
1386 if (sl->tty == NULL)
1389 if (sl->outfill) {
1390 if (test_bit(SLF_OUTWAIT, &sl->flags)) {
1393 unsigned char s = (sl->mode & SL_MODE_SLIP6)?0x70:END;
1398 if (!netif_queue_stopped(sl->dev)) {
1400 sl->tty->ops->write(sl->tty, &s, 1);
1403 set_bit(SLF_OUTWAIT, &sl->flags);
1405 mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
1408 spin_unlock(&sl->lock);
1413 struct slip *sl = from_timer(sl, t, keepalive_timer); local
1415 spin_lock(&sl->lock);
1417 if (sl->tty == NULL)
1420 if (sl->keepalive) {
1421 if (test_bit(SLF_KEEPTEST, &sl->flags)) {
1423 if (sl->outfill)
1425 (void)del_timer(&sl->outfill_timer);
1426 printk(KERN_DEBUG "%s: no packets received during keepalive timeout, hangup.\n", sl->dev->name);
1428 tty_hangup(sl->tty);
1432 set_bit(SLF_KEEPTEST, &sl->flags);
1434 mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
1437 spin_unlock(&sl->lock);