• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/net/

Lines Matching refs:sl

13  *					Has a new sl->mtu field.
32 * ifconfig sl? up & down now works correctly.
94 static void slip_unesc(struct slip *sl, unsigned char c);
97 static void slip_unesc6(struct slip *sl, unsigned char c);
121 sl_alloc_bufs(struct slip *sl, int mtu)
162 spin_lock_bh(&sl->lock);
163 if (sl->tty == NULL) {
164 spin_unlock_bh(&sl->lock);
168 sl->mtu = mtu;
169 sl->buffsize = len;
170 sl->rcount = 0;
171 sl->xleft = 0;
172 rbuff = xchg(&sl->rbuff, rbuff);
173 xbuff = xchg(&sl->xbuff, xbuff);
175 cbuff = xchg(&sl->cbuff, cbuff);
176 slcomp = xchg(&sl->slcomp, slcomp);
178 sl->xdata = 0;
179 sl->xbits = 0;
182 spin_unlock_bh(&sl->lock);
199 sl_free_bufs(struct slip *sl)
202 kfree(xchg(&sl->rbuff, NULL));
203 kfree(xchg(&sl->xbuff, NULL));
205 kfree(xchg(&sl->cbuff, NULL));
206 slhc_free(xchg(&sl->slcomp, NULL));
214 static int sl_realloc_bufs(struct slip *sl, int mtu)
217 struct net_device *dev = sl->dev;
244 if (mtu >= sl->mtu) {
252 spin_lock_bh(&sl->lock);
255 if (sl->tty == NULL)
258 xbuff = xchg(&sl->xbuff, xbuff);
259 rbuff = xchg(&sl->rbuff, rbuff);
261 cbuff = xchg(&sl->cbuff, cbuff);
263 if (sl->xleft) {
264 if (sl->xleft <= len) {
265 memcpy(sl->xbuff, sl->xhead, sl->xleft);
267 sl->xleft = 0;
268 sl->tx_dropped++;
271 sl->xhead = sl->xbuff;
273 if (sl->rcount) {
274 if (sl->rcount <= len) {
275 memcpy(sl->rbuff, rbuff, sl->rcount);
277 sl->rcount = 0;
278 sl->rx_over_errors++;
279 set_bit(SLF_ERROR, &sl->flags);
282 sl->mtu = mtu;
284 sl->buffsize = len;
288 spin_unlock_bh(&sl->lock);
302 sl_lock(struct slip *sl)
304 netif_stop_queue(sl->dev);
310 sl_unlock(struct slip *sl)
312 netif_wake_queue(sl->dev);
317 sl_bump(struct slip *sl)
322 count = sl->rcount;
324 if (sl->mode & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
326 if ((c = sl->rbuff[0]) & SL_TYPE_COMPRESSED_TCP) {
328 if (!(sl->mode & SL_MODE_CSLIP)) {
329 printk(KERN_WARNING "%s: compressed packet ignored\n", sl->dev->name);
333 if (count + 80 > sl->buffsize) {
334 sl->rx_over_errors++;
337 count = slhc_uncompress(sl->slcomp, sl->rbuff, count);
342 if (!(sl->mode & SL_MODE_CSLIP)) {
344 sl->mode |= SL_MODE_CSLIP;
345 sl->mode &= ~SL_MODE_ADAPTIVE;
346 printk(KERN_INFO "%s: header compression turned on\n", sl->dev->name);
348 sl->rbuff[0] &= 0x4f;
349 if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0) {
356 sl->rx_bytes+=count;
360 printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", sl->dev->name);
361 sl->rx_dropped++;
364 skb->dev = sl->dev;
365 memcpy(skb_put(skb,count), sl->rbuff, count);
369 sl->dev->last_rx = jiffies;
370 sl->rx_packets++;
375 sl_encaps(struct slip *sl, unsigned char *icp, int len)
380 if (len > sl->mtu) { /* Sigh, shouldn't occur BUT ... */
381 printk(KERN_WARNING "%s: truncating oversized transmit packet!\n", sl->dev->name);
382 sl->tx_dropped++;
383 sl_unlock(sl);
389 if (sl->mode & SL_MODE_CSLIP) {
390 len = slhc_compress(sl->slcomp, p, len, sl->cbuff, &p, 1);
394 if(sl->mode & SL_MODE_SLIP6)
395 count = slip_esc6(p, (unsigned char *) sl->xbuff, len);
398 count = slip_esc(p, (unsigned char *) sl->xbuff, len);
408 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
409 actual = sl->tty->driver->write(sl->tty, sl->xbuff, count);
411 sl->dev->trans_start = jiffies;
413 sl->xleft = count - actual;
414 sl->xhead = sl->xbuff + actual;
417 clear_bit(SLF_OUTWAIT, &sl->flags); /* reset outfill flag */
428 struct slip *sl = (struct slip *) tty->disc_data;
431 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
434 if (sl->xleft <= 0) {
437 sl->tx_packets++;
439 sl_unlock(sl);
443 actual = tty->driver->write(tty, sl->xhead, sl->xleft);
444 sl->xleft -= actual;
445 sl->xhead += actual;
450 struct slip *sl = netdev_priv(dev);
452 spin_lock(&sl->lock);
467 (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
469 sl->xleft = 0;
470 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
471 sl_unlock(sl);
476 spin_unlock(&sl->lock);
484 struct slip *sl = netdev_priv(dev);
486 spin_lock(&sl->lock);
488 spin_unlock(&sl->lock);
493 if (sl->tty == NULL) {
494 spin_unlock(&sl->lock);
499 sl_lock(sl);
500 sl->tx_bytes+=skb->len;
501 sl_encaps(sl, skb->data, skb->len);
502 spin_unlock(&sl->lock);
518 struct slip *sl = netdev_priv(dev);
520 spin_lock_bh(&sl->lock);
521 if (sl->tty) {
523 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
526 sl->rcount = 0;
527 sl->xleft = 0;
528 spin_unlock_bh(&sl->lock);
537 struct slip *sl = netdev_priv(dev);
539 if (sl->tty==NULL)
542 sl->flags &= (1 << SLF_INUSE);
551 struct slip *sl = netdev_priv(dev);
557 return sl_realloc_bufs(sl, new_mtu);
567 struct slip *sl = netdev_priv(dev);
574 stats.rx_packets = sl->rx_packets;
575 stats.tx_packets = sl->tx_packets;
576 stats.rx_bytes = sl->rx_bytes;
577 stats.tx_bytes = sl->tx_bytes;
578 stats.rx_dropped = sl->rx_dropped;
579 stats.tx_dropped = sl->tx_dropped;
580 stats.tx_errors = sl->tx_errors;
581 stats.rx_errors = sl->rx_errors;
582 stats.rx_over_errors = sl->rx_over_errors;
584 stats.rx_fifo_errors = sl->rx_compressed;
585 stats.tx_fifo_errors = sl->tx_compressed;
586 stats.collisions = sl->tx_misses;
587 comp = sl->slcomp;
602 struct slip *sl = netdev_priv(dev);
608 dev->mtu = sl->mtu;
609 dev->type = ARPHRD_SLIP + sl->mode;
620 struct slip *sl = netdev_priv(dev);
622 sl_free_bufs(sl);
664 struct slip *sl = (struct slip *) tty->disc_data;
666 if (!sl || sl->magic != SLIP_MAGIC ||
667 !netif_running(sl->dev))
673 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) {
674 sl->rx_errors++;
680 if (sl->mode & SL_MODE_SLIP6)
681 slip_unesc6(sl, *cp++);
684 slip_unesc(sl, *cp++);
698 struct slip *sl;
704 sl = netdev_priv(dev);
705 if (sl->tty || sl->leased)
721 struct slip *sl;
731 sl = netdev_priv(dev);
732 if (sl->leased) {
733 if (sl->line != line)
735 if (sl->tty)
739 sl->flags &= (1 << SLF_INUSE);
740 return sl;
743 if (sl->tty)
746 if (current->pid == sl->pid) {
747 if (sl->line == line && score < 3) {
758 if (sl->line == line && score < 1) {
773 sl = netdev_priv(dev);
774 sl->flags &= (1 << SLF_INUSE);
775 return sl;
784 sl = netdev_priv(dev);
785 if (test_bit(SLF_INUSE, &sl->flags)) {
794 sprintf(name, "sl%d", i);
796 dev = alloc_netdev(sizeof(*sl), name, sl_setup);
802 sl = netdev_priv(dev);
805 sl->magic = SLIP_MAGIC;
806 sl->dev = dev;
807 spin_lock_init(&sl->lock);
808 sl->mode = SL_MODE_DEFAULT;
810 init_timer(&sl->keepalive_timer); /* initialize timer_list struct */
811 sl->keepalive_timer.data=(unsigned long)sl;
812 sl->keepalive_timer.function=sl_keepalive;
813 init_timer(&sl->outfill_timer);
814 sl->outfill_timer.data=(unsigned long)sl;
815 sl->outfill_timer.function=sl_outfill;
819 return sl;
834 struct slip *sl;
849 sl = (struct slip *) tty->disc_data;
853 if (sl && sl->magic == SLIP_MAGIC)
858 if ((sl = sl_alloc(tty_devnum(tty))) == NULL)
861 sl->tty = tty;
862 tty->disc_data = sl;
863 sl->line = tty_devnum(tty);
864 sl->pid = current->pid;
866 if (!test_bit(SLF_INUSE, &sl->flags)) {
868 if ((err = sl_alloc_bufs(sl, SL_MTU)) != 0)
871 set_bit(SLF_INUSE, &sl->flags);
873 if ((err = register_netdevice(sl->dev)))
878 if (sl->keepalive) {
879 sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
880 add_timer (&sl->keepalive_timer);
882 if (sl->outfill) {
883 sl->outfill_timer.expires=jiffies+sl->outfill*HZ;
884 add_timer (&sl->outfill_timer);
891 return sl->dev->base_addr;
894 sl_free_bufs(sl);
897 sl->tty = NULL;
899 clear_bit(SLF_INUSE, &sl->flags);
917 struct slip *sl = (struct slip *) tty->disc_data;
920 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty)
924 sl->tty = NULL;
925 if (!sl->leased)
926 sl->line = 0;
930 del_timer_sync(&sl->keepalive_timer);
931 del_timer_sync(&sl->outfill_timer);
979 static void slip_unesc(struct slip *sl, unsigned char s)
986 if (test_bit(SLF_KEEPTEST, &sl->flags))
987 clear_bit(SLF_KEEPTEST, &sl->flags);
990 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) {
991 sl_bump(sl);
993 clear_bit(SLF_ESCAPE, &sl->flags);
994 sl->rcount = 0;
998 set_bit(SLF_ESCAPE, &sl->flags);
1001 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) {
1006 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) {
1011 if (!test_bit(SLF_ERROR, &sl->flags)) {
1012 if (sl->rcount < sl->buffsize) {
1013 sl->rbuff[sl->rcount++] = s;
1016 sl->rx_over_errors++;
1017 set_bit(SLF_ERROR, &sl->flags);
1066 slip_unesc6(struct slip *sl, unsigned char s)
1073 if (test_bit(SLF_KEEPTEST, &sl->flags))
1074 clear_bit(SLF_KEEPTEST, &sl->flags);
1077 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) {
1078 sl_bump(sl);
1080 sl->rcount = 0;
1081 sl->xbits = 0;
1082 sl->xdata = 0;
1084 sl->xdata = (sl->xdata << 6) | ((s - 0x30) & 0x3F);
1085 sl->xbits += 6;
1086 if (sl->xbits >= 8) {
1087 sl->xbits -= 8;
1088 c = (unsigned char)(sl->xdata >> sl->xbits);
1089 if (!test_bit(SLF_ERROR, &sl->flags)) {
1090 if (sl->rcount < sl->buffsize) {
1091 sl->rbuff[sl->rcount++] = c;
1094 sl->rx_over_errors++;
1095 set_bit(SLF_ERROR, &sl->flags);
1105 struct slip *sl = (struct slip *) tty->disc_data;
1110 if (!sl || sl->magic != SLIP_MAGIC) {
1116 tmp = strlen(sl->dev->name) + 1;
1117 if (copy_to_user((void __user *)arg, sl->dev->name, tmp))
1122 if (put_user(sl->mode, p))
1145 sl->mode = tmp;
1146 sl->dev->type = ARPHRD_SLIP+sl->mode;
1160 spin_lock_bh(&sl->lock);
1161 if (!sl->tty) {
1162 spin_unlock_bh(&sl->lock);
1165 if ((sl->keepalive = (unchar) tmp) != 0) {
1166 mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
1167 set_bit(SLF_KEEPTEST, &sl->flags);
1169 del_timer (&sl->keepalive_timer);
1171 spin_unlock_bh(&sl->lock);
1175 if (put_user(sl->keepalive, p))
1184 spin_lock_bh(&sl->lock);
1185 if (!sl->tty) {
1186 spin_unlock_bh(&sl->lock);
1189 if ((sl->outfill = (unchar) tmp) != 0){
1190 mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
1191 set_bit(SLF_OUTWAIT, &sl->flags);
1193 del_timer (&sl->outfill_timer);
1195 spin_unlock_bh(&sl->lock);
1199 if (put_user(sl->outfill, p))
1223 struct slip *sl = netdev_priv(dev);
1226 if (sl == NULL) /* Allocation failed ?? */
1229 spin_lock_bh(&sl->lock);
1231 if (!sl->tty) {
1232 spin_unlock_bh(&sl->lock);
1240 spin_unlock_bh(&sl->lock);
1243 sl->keepalive = (unchar) *p;
1244 if (sl->keepalive != 0) {
1245 sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
1246 mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
1247 set_bit(SLF_KEEPTEST, &sl->flags);
1249 del_timer(&sl->keepalive_timer);
1254 *p = sl->keepalive;
1259 spin_unlock_bh(&sl->lock);
1262 if ((sl->outfill = (unchar)*p) != 0){
1263 mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
1264 set_bit(SLF_OUTWAIT, &sl->flags);
1266 del_timer (&sl->outfill_timer);
1271 *p = sl->outfill;
1278 if (sl->tty != current->signal->tty && sl->pid != current->pid) {
1279 spin_unlock_bh(&sl->lock);
1282 sl->leased = 0;
1284 sl->leased = 1;
1288 *p = sl->leased;
1290 spin_unlock_bh(&sl->lock);
1345 struct slip *sl;
1363 sl = netdev_priv(dev);
1364 spin_lock_bh(&sl->lock);
1365 if (sl->tty) {
1367 tty_hangup(sl->tty);
1369 spin_unlock_bh(&sl->lock);
1380 sl = netdev_priv(dev);
1381 if (sl->tty) {
1411 struct slip *sl=(struct slip *)sls;
1413 spin_lock(&sl->lock);
1415 if (sl->tty == NULL)
1418 if(sl->outfill)
1420 if( test_bit(SLF_OUTWAIT, &sl->flags) )
1424 unsigned char s = (sl->mode & SL_MODE_SLIP6)?0x70:END;
1429 if (!netif_queue_stopped(sl->dev))
1432 sl->tty->driver->write(sl->tty, &s, 1);
1436 set_bit(SLF_OUTWAIT, &sl->flags);
1438 mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
1441 spin_unlock(&sl->lock);
1446 struct slip *sl=(struct slip *)sls;
1448 spin_lock(&sl->lock);
1450 if (sl->tty == NULL)
1453 if( sl->keepalive)
1455 if(test_bit(SLF_KEEPTEST, &sl->flags))
1458 if( sl->outfill ) /* outfill timer must be deleted too */
1459 (void)del_timer(&sl->outfill_timer);
1460 printk(KERN_DEBUG "%s: no packets received during keepalive timeout, hangup.\n", sl->dev->name);
1461 tty_hangup(sl->tty); /* this must hangup tty & close slip */
1466 set_bit(SLF_KEEPTEST, &sl->flags);
1468 mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
1472 spin_unlock(&sl->lock);