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

Lines Matching refs:sl

46 static void x25_asy_unesc(struct x25_asy *sl, unsigned char c);
53 struct x25_asy *sl;
66 sl = dev->priv;
68 if (!test_and_set_bit(SLF_INUSE, &sl->flags))
69 return sl;
88 sl = dev->priv;
94 set_bit(SLF_INUSE, &sl->flags);
96 return sl;
107 static void x25_asy_free(struct x25_asy *sl)
110 kfree(sl->rbuff);
111 sl->rbuff = NULL;
112 kfree(sl->xbuff);
113 sl->xbuff = NULL;
115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) {
116 printk("%s: x25_asy_free for already free unit.\n", sl->dev->name);
122 struct x25_asy *sl = dev->priv;
138 spin_lock_bh(&sl->lock);
139 xbuff = xchg(&sl->xbuff, xbuff);
140 if (sl->xleft) {
141 if (sl->xleft <= len) {
142 memcpy(sl->xbuff, sl->xhead, sl->xleft);
144 sl->xleft = 0;
145 sl->stats.tx_dropped++;
148 sl->xhead = sl->xbuff;
150 rbuff = xchg(&sl->rbuff, rbuff);
151 if (sl->rcount) {
152 if (sl->rcount <= len) {
153 memcpy(sl->rbuff, rbuff, sl->rcount);
155 sl->rcount = 0;
156 sl->stats.rx_over_errors++;
157 set_bit(SLF_ERROR, &sl->flags);
162 sl->buffsize = len;
164 spin_unlock_bh(&sl->lock);
174 static inline void x25_asy_lock(struct x25_asy *sl)
176 netif_stop_queue(sl->dev);
182 static inline void x25_asy_unlock(struct x25_asy *sl)
184 netif_wake_queue(sl->dev);
189 static void x25_asy_bump(struct x25_asy *sl)
195 count = sl->rcount;
196 sl->stats.rx_bytes+=count;
201 printk("%s: memory squeeze, dropping packet.\n", sl->dev->name);
202 sl->stats.rx_dropped++;
206 memcpy(skb_put(skb,count), sl->rbuff, count);
207 skb->protocol = x25_type_trans(skb, sl->dev);
216 sl->dev->last_rx = jiffies;
217 sl->stats.rx_packets++;
222 static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len)
225 int actual, count, mtu = sl->dev->mtu;
230 printk ("%s: truncating oversized transmit packet!\n", sl->dev->name);
231 sl->stats.tx_dropped++;
232 x25_asy_unlock(sl);
237 count = x25_asy_esc(p, (unsigned char *) sl->xbuff, len);
247 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
248 actual = sl->tty->driver->write(sl->tty, sl->xbuff, count);
249 sl->xleft = count - actual;
250 sl->xhead = sl->xbuff + actual;
252 clear_bit(SLF_OUTWAIT, &sl->flags); /* reset outfill flag */
262 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
265 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))
268 if (sl->xleft <= 0)
272 sl->stats.tx_packets++;
274 x25_asy_unlock(sl);
278 actual = tty->driver->write(tty, sl->xhead, sl->xleft);
279 sl->xleft -= actual;
280 sl->xhead += actual;
285 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
287 spin_lock(&sl->lock);
293 (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
295 sl->xleft = 0;
296 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
297 x25_asy_unlock(sl);
299 spin_unlock(&sl->lock);
306 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
309 if (!netif_running(sl->dev)) {
375 struct x25_asy *sl=dev->priv;
377 spin_lock(&sl->lock);
378 if (netif_queue_stopped(sl->dev) || sl->tty == NULL)
380 spin_unlock(&sl->lock);
388 x25_asy_lock(sl);
389 sl->stats.tx_bytes+=skb->len;
390 x25_asy_encaps(sl, skb->data, skb->len);
393 spin_unlock(&sl->lock);
402 struct x25_asy *sl = dev->priv;
414 skb->protocol = x25_type_trans(skb, sl->dev);
416 sl->dev->last_rx = jiffies;
421 struct x25_asy *sl = dev->priv;
433 skb->protocol = x25_type_trans(skb, sl->dev);
435 sl->dev->last_rx = jiffies;
452 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
456 if (sl->tty == NULL)
468 sl->rbuff = kmalloc(len + 4, GFP_KERNEL);
469 if (sl->rbuff == NULL) {
472 sl->xbuff = kmalloc(len + 4, GFP_KERNEL);
473 if (sl->xbuff == NULL) {
477 sl->buffsize = len;
478 sl->rcount = 0;
479 sl->xleft = 0;
480 sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */
491 kfree(sl->xbuff);
493 kfree(sl->rbuff);
502 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
505 spin_lock(&sl->lock);
506 if (sl->tty)
507 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
510 sl->rcount = 0;
511 sl->xleft = 0;
514 spin_unlock(&sl->lock);
527 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
529 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))
536 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) {
537 sl->stats.rx_errors++;
542 x25_asy_unesc(sl, *cp++);
556 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
560 if (sl && sl->magic == X25_ASY_MAGIC) {
565 if ((sl = x25_asy_alloc()) == NULL) {
569 sl->tty = tty;
570 tty->disc_data = sl;
580 sl->dev->type = ARPHRD_X25;
583 if ((err = x25_asy_open(sl->dev)))
587 return sl->dev->base_addr;
599 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
602 if (!sl || sl->magic != X25_ASY_MAGIC)
605 if (sl->dev->flags & IFF_UP)
607 (void) dev_close(sl->dev);
611 sl->tty = NULL;
612 x25_asy_free(sl);
618 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
620 return &sl->stats;
667 static void x25_asy_unesc(struct x25_asy *sl, unsigned char s)
673 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2))
675 x25_asy_bump(sl);
677 clear_bit(SLF_ESCAPE, &sl->flags);
678 sl->rcount = 0;
682 set_bit(SLF_ESCAPE, &sl->flags);
687 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
691 if (!test_bit(SLF_ERROR, &sl->flags))
693 if (sl->rcount < sl->buffsize)
695 sl->rbuff[sl->rcount++] = s;
698 sl->stats.rx_over_errors++;
699 set_bit(SLF_ERROR, &sl->flags);
708 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
711 if (!sl || sl->magic != X25_ASY_MAGIC)
716 if (copy_to_user((void __user *)arg, sl->dev->name,
717 strlen(sl->dev->name) + 1))
733 struct x25_asy *sl = (struct x25_asy*)(dev->priv);
734 if(sl->tty==NULL)
742 struct x25_asy *sl = dev->priv;
744 sl->magic = X25_ASY_MAGIC;
745 sl->dev = dev;
746 spin_lock_init(&sl->lock);
747 set_bit(SLF_INUSE, &sl->flags);
810 struct x25_asy *sl = dev->priv;
812 spin_lock_bh(&sl->lock);
813 if (sl->tty)
814 tty_hangup(sl->tty);
816 spin_unlock_bh(&sl->lock);