Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

FIFO_policy.h File Reference

#include "netif/net_policy/net_policy.h"

Include dependency graph for FIFO_policy.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fifo_rx_buffer_t
struct  fifo_rx_slot_t

Defines

#define MAX_FIFO_RX_BUFFER_ENTRIES   50
#define PKT_BUF_SZ   1536

Functions

void FIFO_initialize_rx_buffer (void *fifo_rx_buffer)
void FIFO_dealloc_rx_buffer (void *fifo_rx_buffer)
int FIFO_add_frame_to_buffer (void *rx_buffer, unsigned char *data, int len)
int FIFO_extract_frame_of_buffer (void *fifo_rx_buffer, void *data)


Define Documentation

#define MAX_FIFO_RX_BUFFER_ENTRIES   50
 

Definition at line 52 of file FIFO_policy.h.

Referenced by FIFO_dealloc_rx_buffer(), and FIFO_initialize_rx_buffer().

#define PKT_BUF_SZ   1536
 

Definition at line 53 of file FIFO_policy.h.

Referenced by FIFO_initialize_rx_buffer(), vortex_open(), and vortex_up().


Function Documentation

int FIFO_add_frame_to_buffer void *  rx_buffer,
unsigned char *  data,
int  len
 

Definition at line 96 of file FIFO_policy.c.

References rx_buffer_t::add, data, len, rx_slot_t::length, and rx_buffer.

00096                                                                            {
00097   struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer;
00098   
00099   /* If the packet in the position that we're writting hasn't still been read is */
00100   /* because we're receiving too much packets, so we need to drop it.            */ 
00101 
00102 
00103   if(fifo_rx_buffer->add->read !=  0x00){
00104     fifo_rx_buffer->add->length = len;
00105     
00106     memcpy(fifo_rx_buffer->add->data,data, len);
00107     
00108     fifo_rx_buffer->add->read = 0x00;
00109     fifo_rx_buffer->add = fifo_rx_buffer->add->next;
00110     
00111     return 0;
00112   }else
00113     // The packet is dropped  
00114     return -1;
00115 }

void FIFO_dealloc_rx_buffer void *  fifo_rx_buffer  ) 
 

Definition at line 76 of file FIFO_policy.c.

References rx_buffer_t::first, MAX_FIFO_RX_BUFFER_ENTRIES, rx_slot_t::next, NULL, rtl_free, and rx_buffer.

00076                                             {
00077   struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer;
00078   struct fifo_rx_slot_t *tmp = fifo_rx_buffer->first->next, *actual;
00079   int i;
00080 
00081   for(i=0;i<(MAX_FIFO_RX_BUFFER_ENTRIES-1); i++){
00082     actual = tmp->next;
00083     if(tmp->data != NULL)
00084       rtl_free(tmp->data);
00085     rtl_free(tmp);
00086     tmp = actual;
00087   }  
00088   if(fifo_rx_buffer->first->data != NULL)
00089     rtl_free(fifo_rx_buffer->first->data);
00090   rtl_free(fifo_rx_buffer->first);
00091 
00092   return;
00093 }

int FIFO_extract_frame_of_buffer void *  fifo_rx_buffer,
void *  data
 

Definition at line 118 of file FIFO_policy.c.

References data, rx_slot_t::data, rx_buffer_t::extract, and rx_buffer.

00118                                                              {
00119   struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer;
00120   struct fifo_rx_slot_t *tmp = fifo_rx_buffer->extract;
00121 
00122   ((struct memory *)data)->mem = tmp->data;
00123   tmp->read = 0x01;
00124   fifo_rx_buffer->extract = fifo_rx_buffer->extract->next;
00125   
00126   return tmp->length;
00127 }

void FIFO_initialize_rx_buffer void *  fifo_rx_buffer  ) 
 

Definition at line 55 of file FIFO_policy.c.

References rx_buffer_t::first, MAX_FIFO_RX_BUFFER_ENTRIES, PKT_BUF_SZ, rtl_malloc, and rx_buffer.

00055                                                {
00056   struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer;
00057   struct fifo_rx_slot_t *tmp;
00058   int i;
00059   tmp = fifo_rx_buffer->first = fifo_rx_buffer->add = fifo_rx_buffer->extract = rtl_malloc(sizeof(struct fifo_rx_slot_t));
00060 
00061   for(i=0;i<(MAX_FIFO_RX_BUFFER_ENTRIES-1); i++){ 
00062     tmp->next = rtl_malloc(sizeof(struct fifo_rx_slot_t));
00063     tmp->read = 0x01;
00064     tmp->length = 0;
00065     tmp->data =  rtl_malloc(PKT_BUF_SZ);
00066     tmp = tmp->next;
00067   }
00068   tmp->next = fifo_rx_buffer->first;
00069   tmp->read = 0x01;
00070   tmp->data = rtl_malloc(PKT_BUF_SZ);
00071 
00072   return;
00073 }


Generated on Wed Jan 14 12:59:04 2004 for RTL-lwIP-0.4 by doxygen 1.3.4