Atmel Software Framework

lwip-port-1.3.2/hd/if/netif/wlif.c File Reference
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/sys.h"
#include "netif/etharp.h"
#include "netif/wlif.h"
#include <wl_api.h>

Data Structures

struct  wlif_t
 

Macros

#define IFNAME0   'w'
 
#define IFNAME1   'l'
 
#define PQUEUE_DEQUEUE(q)
 
#define PQUEUE_EMPTY(q)   (q.last == q.first)
 
#define PQUEUE_ENQUEUE(q, p)
 
#define PQUEUE_FIRST(q)   (q.buf[q.first])
 
#define PQUEUE_FULL(q)   ((q.last + 1) % PQUEUE_SIZE == q.first)
 
#define PQUEUE_SIZE   8
 

Functions

static err_t low_level_init (struct netif *netif)
 In this function, the hardware should be initialized. More...
 
static struct pbuflow_level_input (struct netif *netif)
 Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf. More...
 
static err_t low_level_output (struct netif *netif, struct pbuf *p)
 This function should do the actual transmission of the packet. More...
 
static err_t process_pqueue (struct netif *netif)
 
static void rx_isr (void *ctx)
 Called in interrupt context when we can read more data from the mac. More...
 
err_t wlif_init (struct netif *netif)
 Should be called at the beginning of the program to set up the network interface. More...
 
static void wlif_input (struct netif *netif)
 This function will be called by wlif_poll() when a packet has been received from the mac. More...
 
void wlif_poll (struct netif *netif)
 

#define IFNAME0   'w'

Referenced by wlif_init().

#define IFNAME1   'l'

Referenced by wlif_init().

#define PQUEUE_DEQUEUE (   q)
Value:
({ \
struct pbuf* __p = PQUEUE_FIRST(q); \
q.first = (q.first + 1) % PQUEUE_SIZE; \
__p; \
})
#define PQUEUE_SIZE
Definition: lwip-port-1.3.2/hd/if/netif/wlif.c:24
Definition: lwip-1.4.0/src/include/lwip/pbuf.h:73
#define PQUEUE_FIRST(q)
Definition: lwip-port-1.3.2/hd/if/netif/wlif.c:38

Referenced by process_pqueue().

#define PQUEUE_EMPTY (   q)    (q.last == q.first)

Referenced by process_pqueue().

#define PQUEUE_ENQUEUE (   q,
 
)
Value:
({ \
q.buf[q.last] = p; \
q.last = (q.last + 1) % PQUEUE_SIZE; \
})
#define PQUEUE_SIZE
Definition: lwip-port-1.3.2/hd/if/netif/wlif.c:24

Referenced by low_level_output().

#define PQUEUE_FIRST (   q)    (q.buf[q.first])

Referenced by process_pqueue().

#define PQUEUE_FULL (   q)    ((q.last + 1) % PQUEUE_SIZE == q.first)

Referenced by low_level_output().

#define PQUEUE_SIZE   8

static err_t low_level_init ( struct netif netif)
static

In this function, the hardware should be initialized.

Called from wlif_init().

Parameters
netifthe already initialized lwip network interface structure for this ethernetif

References ERR_IF, ERR_OK, netif::flags, netif::hwaddr, netif::hwaddr_len, netif::mtu, NETIF_FLAG_BROADCAST, NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, and NETIF_FLAG_LINK_UP.

Referenced by wlif_init().

static struct pbuf* low_level_input ( struct netif netif)
static

Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf.

Parameters
netifthe lwip network interface structure for this ethernetif
Returns
a pbuf filled with the received packet (including MAC header) NULL on memory error

References LINK_STATS_INC, NULL, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_RAM, PBUF_RAW, pbuf_realloc(), wlif_t::rx_pending, netif::state, and status.

Referenced by wlif_input().

static err_t low_level_output ( struct netif netif,
struct pbuf p 
)
static

This function should do the actual transmission of the packet.

The packet is contained in the pbuf that is passed to the function. This pbuf might be chained.

Parameters
netifthe lwip network interface structure for this ethernetif
pthe MAC packet to send (e.g. IP packet including MAC addresses and type)
Returns
ERR_OK if the packet could be sent an err_t value if the packet couldn't be sent
Note
Returning ERR_MEM here if a DMA queue of your MAC is full can lead to strange results. You might consider waiting for space in the DMA queue to become availale since the stack doesn't retry to send a packet dropped because of memory failure (except for the TCP timers).

References ERR_IF, ERR_INPROGRESS, ERR_OK, if(), pbuf::len, pbuf_ref(), wlif_t::pqueue, PQUEUE_ENQUEUE, PQUEUE_FULL, process_pqueue(), and netif::state.

Referenced by wlif_init().

static void rx_isr ( void *  ctx)
static

Called in interrupt context when we can read more data from the mac.

References ctx, wlif_t::rx_pending, and netif::state.

Referenced by wlif_init().

err_t wlif_init ( struct netif netif)

Should be called at the beginning of the program to set up the network interface.

It calls the function low_level_init() to do the actual setup of the hardware.

This function should be passed as a parameter to netif_add().

Parameters
netifthe lwip network interface structure for this ethernetif
Returns
ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error

References IFNAME0, IFNAME1, netif::linkoutput, low_level_init(), low_level_output(), LWIP_ASSERT, netif::name, NULL, netif::output, rx_isr(), and netif::state.

static void wlif_input ( struct netif netif)
static

This function will be called by wlif_poll() when a packet has been received from the mac.

Then the type of the received packet is determined and the appropriate input function is called.

Parameters
netifthe lwip network interface structure for this ethernetif

References ERR_OK, htons, netif::input, low_level_input(), LWIP_DEBUGF, NETIF_DEBUG, NULL, pbuf::payload, and pbuf_free().

Referenced by wlif_poll().

void wlif_poll ( struct netif netif)