hwchannel.c (8bfddfbe2100862fd39b97001d0559ccd4c77f19) | hwchannel.c (7206e659f689558b41aa058c3040b081cb281d03) |
---|---|
1/* 2 * 3 * Author Karsten Keil <kkeil@novell.com> 4 * 5 * Copyright 2008 by Karsten Keil <kkeil@novell.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 187 unchanged lines hidden (view full) --- 196} 197EXPORT_SYMBOL(recv_Echannel); 198 199void 200recv_Bchannel(struct bchannel *bch, unsigned int id) 201{ 202 struct mISDNhead *hh; 203 | 1/* 2 * 3 * Author Karsten Keil <kkeil@novell.com> 4 * 5 * Copyright 2008 by Karsten Keil <kkeil@novell.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 187 unchanged lines hidden (view full) --- 196} 197EXPORT_SYMBOL(recv_Echannel); 198 199void 200recv_Bchannel(struct bchannel *bch, unsigned int id) 201{ 202 struct mISDNhead *hh; 203 |
204 hh = mISDN_HEAD_P(bch->rx_skb); 205 hh->prim = PH_DATA_IND; 206 hh->id = id; 207 if (bch->rcount >= 64) { 208 printk(KERN_WARNING "B-channel %p receive queue overflow, " 209 "flushing!\n", bch); 210 skb_queue_purge(&bch->rqueue); 211 bch->rcount = 0; | 204 /* if allocation did fail upper functions still may call us */ 205 if (unlikely(!bch->rx_skb)) |
212 return; | 206 return; |
207 if (unlikely(!bch->rx_skb->len)) { 208 /* we have no data to send - this may happen after recovery 209 * from overflow or too small allocation. 210 * We need to free the buffer here */ 211 dev_kfree_skb(bch->rx_skb); 212 bch->rx_skb = NULL; 213 } else { 214 hh = mISDN_HEAD_P(bch->rx_skb); 215 hh->prim = PH_DATA_IND; 216 hh->id = id; 217 if (bch->rcount >= 64) { 218 printk(KERN_WARNING 219 "B%d receive queue overflow - flushing!\n", 220 bch->nr); 221 skb_queue_purge(&bch->rqueue); 222 } 223 bch->rcount++; 224 skb_queue_tail(&bch->rqueue, bch->rx_skb); 225 bch->rx_skb = NULL; 226 schedule_event(bch, FLG_RECVQUEUE); |
|
213 } | 227 } |
214 bch->rcount++; 215 skb_queue_tail(&bch->rqueue, bch->rx_skb); 216 bch->rx_skb = NULL; 217 schedule_event(bch, FLG_RECVQUEUE); | |
218} 219EXPORT_SYMBOL(recv_Bchannel); 220 221void 222recv_Dchannel_skb(struct dchannel *dch, struct sk_buff *skb) 223{ 224 skb_queue_tail(&dch->rqueue, skb); 225 schedule_event(dch, FLG_RECVQUEUE); --- 168 unchanged lines hidden (view full) --- 394 /* write to fifo */ 395 ch->tx_skb = skb; 396 ch->tx_idx = 0; 397 confirm_Bsend(ch); 398 return 1; 399 } 400} 401EXPORT_SYMBOL(bchannel_senddata); | 228} 229EXPORT_SYMBOL(recv_Bchannel); 230 231void 232recv_Dchannel_skb(struct dchannel *dch, struct sk_buff *skb) 233{ 234 skb_queue_tail(&dch->rqueue, skb); 235 schedule_event(dch, FLG_RECVQUEUE); --- 168 unchanged lines hidden (view full) --- 404 /* write to fifo */ 405 ch->tx_skb = skb; 406 ch->tx_idx = 0; 407 confirm_Bsend(ch); 408 return 1; 409 } 410} 411EXPORT_SYMBOL(bchannel_senddata); |
412 413/* The function allocates a new receive skb on demand with a size for the 414 * requirements of the current protocol. It returns the tailroom of the 415 * receive skb or an error. 416 */ 417int 418bchannel_get_rxbuf(struct bchannel *bch, int reqlen) 419{ 420 int len; 421 422 if (bch->rx_skb) { 423 len = skb_tailroom(bch->rx_skb); 424 if (len < reqlen) { 425 pr_warning("B%d no space for %d (only %d) bytes\n", 426 bch->nr, reqlen, len); 427 if (test_bit(FLG_TRANSPARENT, &bch->Flags)) { 428 /* send what we have now and try a new buffer */ 429 recv_Bchannel(bch, 0); 430 } else { 431 /* on HDLC we have to drop too big frames */ 432 return -EMSGSIZE; 433 } 434 } else { 435 return len; 436 } 437 } 438 if (unlikely(reqlen > bch->maxlen)) 439 return -EMSGSIZE; 440 if (test_bit(FLG_TRANSPARENT, &bch->Flags)) 441 len = reqlen; 442 else /* with HDLC we do not know the length yet */ 443 len = bch->maxlen; 444 bch->rx_skb = mI_alloc_skb(len, GFP_ATOMIC); 445 if (!bch->rx_skb) { 446 pr_warning("B%d receive no memory for %d bytes\n", 447 bch->nr, len); 448 len = -ENOMEM; 449 } 450 return len; 451} 452EXPORT_SYMBOL(bchannel_get_rxbuf); |
|