Lines Matching +full:frame +full:- +full:buffer
14 * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
16 * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com>
25 * provided "AS-IS" and at no charge.
41 /************************** FRAME WRAPPING **************************/
52 * Byte stuff one single byte and put the result in buffer pointed to by
53 * buf. The buffer must at all times be able to have two bytes inserted.
56 * (2000 bytes on P6 200MHz, non-inlined ~370us, inline ~170us) - Jean II
70 /* Non-special value, no transparency required */ in stuff_byte()
80 * Makes a new buffer with wrapping and stuffing, should check that
81 * we don't get tx buffer overflow.
85 struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb; in async_wrap_skb()
103 if (cb->magic != LAP_MAGIC) { in async_wrap_skb()
105 * This will happen for all frames sent from user-space. in async_wrap_skb()
112 xbofs = cb->xbofs + cb->xbofs_delay; in async_wrap_skb()
129 /* Insert frame and calc CRC */ in async_wrap_skb()
130 for (i=0; i < skb->len; i++) { in async_wrap_skb()
132 * Check for the possibility of tx buffer overflow. We use in async_wrap_skb()
133 * bufsize-5 since the maximum number of bytes that can be in async_wrap_skb()
136 if(n >= (buffsize-5)) { in async_wrap_skb()
137 IRDA_ERROR("%s(), tx buffer overflow (n=%d)\n", in async_wrap_skb()
142 n += stuff_byte(skb->data[i], tx_buff+n); in async_wrap_skb()
143 fcs.value = irda_fcs(fcs.value, skb->data[i]); in async_wrap_skb()
161 /************************* FRAME UNWRAPPING *************************/
170 * And reduce wrapper.o by ~900B in the process ;-)
174 * (2005 B frame + EOF on P6 200MHz, without 30 to 50 us, with 10 to 25 us)
183 * receiving the End-Of-Frame.
187 * (2005 B frame on P6 200MHz, inlined 10 to 25 us, postponed 140 to 180 us)
189 * (2005 B frame on P6 200MHz, inlined 30 to 50 us, postponed 150 to 180 us)
204 * Got a frame, make a copy of it, and pass it up the stack! We can try
219 * skb. But, if the frame is small, it is more efficient to in async_bump()
220 * copy it to save memory (copy will be fast anyway - that's in async_bump()
221 * called Rx-copy-break). Jean II */ in async_bump()
222 docopy = ((rx_buff->skb == NULL) || in async_bump()
223 (rx_buff->len < IRDA_RX_COPY_THRESHOLD)); in async_bump()
226 newskb = dev_alloc_skb(docopy ? rx_buff->len + 1 : rx_buff->truesize); in async_bump()
228 stats->rx_dropped++; in async_bump()
235 /* Align IP header to 20 bytes (i.e. increase skb->data) in async_bump()
237 * header size (2 or 1 bytes) - Jean II */ in async_bump()
242 skb_copy_to_linear_data(newskb, rx_buff->data, in async_bump()
243 rx_buff->len - 2); in async_bump()
248 dataskb = rx_buff->skb; in async_bump()
250 rx_buff->skb = newskb; in async_bump()
251 rx_buff->head = newskb->data; /* NOT newskb->head */ in async_bump()
252 …//printk(KERN_DEBUG "ZeroCopy : len = %d, dataskb = %p, newskb = %p\n", rx_buff->len, dataskb, new… in async_bump()
256 skb_put(dataskb, rx_buff->len - 2); in async_bump()
259 dataskb->dev = dev; in async_bump()
261 dataskb->protocol = htons(ETH_P_IRDA); in async_bump()
265 stats->rx_packets++; in async_bump()
266 stats->rx_bytes += rx_buff->len; in async_bump()
269 rx_buff->data = rx_buff->head; in async_bump()
270 rx_buff->len = 0; in async_bump()
276 * Handle Beginning Of Frame character received within a frame
284 switch(rx_buff->state) { in async_unwrap_bof()
287 /* Not supposed to happen, the previous frame is not in async_unwrap_bof()
288 * finished - Jean II */ in async_unwrap_bof()
289 IRDA_DEBUG(1, "%s(), Discarding incomplete frame\n", in async_unwrap_bof()
291 stats->rx_errors++; in async_unwrap_bof()
292 stats->rx_missed_errors++; in async_unwrap_bof()
299 /* We may receive multiple BOF at the start of frame */ in async_unwrap_bof()
303 /* Now receiving frame */ in async_unwrap_bof()
304 rx_buff->state = BEGIN_FRAME; in async_unwrap_bof()
305 rx_buff->in_frame = TRUE; in async_unwrap_bof()
307 /* Time to initialize receive buffer */ in async_unwrap_bof()
308 rx_buff->data = rx_buff->head; in async_unwrap_bof()
309 rx_buff->len = 0; in async_unwrap_bof()
310 rx_buff->fcs = INIT_FCS; in async_unwrap_bof()
316 * Handle End Of Frame character received within a frame
328 switch(rx_buff->state) { in async_unwrap_eof()
331 stats->rx_errors++; in async_unwrap_eof()
332 stats->rx_missed_errors++; in async_unwrap_eof()
342 * error, as expected - Jean II */ in async_unwrap_eof()
343 rx_buff->state = OUTSIDE_FRAME; in async_unwrap_eof()
344 rx_buff->in_frame = FALSE; in async_unwrap_eof()
349 for(i = 0; i < rx_buff->len; i++) in async_unwrap_eof()
350 rx_buff->fcs = irda_fcs(rx_buff->fcs, in async_unwrap_eof()
351 rx_buff->data[i]); in async_unwrap_eof()
354 /* Test FCS and signal success if the frame is good */ in async_unwrap_eof()
355 if (rx_buff->fcs == GOOD_FCS) { in async_unwrap_eof()
356 /* Deliver frame */ in async_unwrap_eof()
360 /* Wrong CRC, discard frame! */ in async_unwrap_eof()
364 stats->rx_errors++; in async_unwrap_eof()
365 stats->rx_crc_errors++; in async_unwrap_eof()
374 * Handle Character Escape character received within a frame
382 switch(rx_buff->state) { in async_unwrap_ce()
396 rx_buff->state = LINK_ESCAPE; in async_unwrap_ce()
404 * Handle other characters received within a frame
412 switch(rx_buff->state) { in async_unwrap_other()
414 * probability (most frequent first) - Jean II */ in async_unwrap_other()
416 /* Must be the next byte of the frame */ in async_unwrap_other()
417 if (rx_buff->len < rx_buff->truesize) { in async_unwrap_other()
418 rx_buff->data[rx_buff->len++] = byte; in async_unwrap_other()
420 rx_buff->fcs = irda_fcs(rx_buff->fcs, byte); in async_unwrap_other()
423 IRDA_DEBUG(1, "%s(), Rx buffer overflow, aborting\n", in async_unwrap_other()
425 rx_buff->state = OUTSIDE_FRAME; in async_unwrap_other()
435 if (rx_buff->len < rx_buff->truesize) { in async_unwrap_other()
436 rx_buff->data[rx_buff->len++] = byte; in async_unwrap_other()
438 rx_buff->fcs = irda_fcs(rx_buff->fcs, byte); in async_unwrap_other()
440 rx_buff->state = INSIDE_FRAME; in async_unwrap_other()
442 IRDA_DEBUG(1, "%s(), Rx buffer overflow, aborting\n", in async_unwrap_other()
444 rx_buff->state = OUTSIDE_FRAME; in async_unwrap_other()
456 rx_buff->data[rx_buff->len++] = byte; in async_unwrap_other()
458 rx_buff->fcs = irda_fcs(rx_buff->fcs, byte); in async_unwrap_other()
460 rx_buff->state = INSIDE_FRAME; in async_unwrap_other()
468 * Parse and de-stuff frame received from the IrDA-port