Receive packets in a dummy_rx when the maca packet pool is

empty. These packets get dropped.
This commit is contained in:
Mariano Alvira 2013-01-06 15:12:07 -05:00
parent 56ce9247c3
commit a53e653bbf

View file

@ -96,6 +96,7 @@ volatile packet_t *rx_head, *tx_head;
/* used for ack recpetion if the packet_pool goes empty */
/* doesn't go back into the pool when freed */
static volatile packet_t dummy_ack;
static volatile packet_t dummy_rx;
/* incremented on every maca entry */
/* you can use this to detect that the receive loop is still running */
@ -359,6 +360,7 @@ void post_receive(void) {
dma_rx = get_free_packet();
if (dma_rx == 0) {
PRINTF("trying to fill MACA_DMARX in post_receieve but out of packet buffers\n\r");
dma_rx = &dummy_rx;
/* set the sftclock so that we return to the maca_isr */
*MACA_SFTCLK = *MACA_CLK + RECV_SOFTIMEOUT; /* soft timeout */
*MACA_TMREN = (1 << maca_tmren_sft);
@ -652,12 +654,15 @@ void maca_isr(void) {
if (data_indication_irq()) {
*MACA_CLRIRQ = (1 << maca_irq_di);
if (dma_rx != &dummy_ack && dma_rx != &dummy_rx)
{
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
dma_rx->lqi = get_lqi();
dma_rx->rx_time = *MACA_TIMESTAMP;
/* check if received packet needs an ack */
if(prm_mode == AUTOACK && (dma_rx->data[1] & MAC_ACK_REQUEST_FLAG)) {
if(prm_mode == AUTOACK && (dma_rx->data[1] & 0x20)) {
/* this wait is necessary to auto-ack */
volatile uint32_t wait_clk;
wait_clk = *MACA_CLK + 200;
@ -667,6 +672,7 @@ void maca_isr(void) {
if(maca_rx_callback != 0) { maca_rx_callback(dma_rx); }
add_to_rx(dma_rx);
}
dma_rx = 0;
}
if (filter_failed_irq()) {