EVE 1.0
Networking common routines
Collaboration diagram for Networking common routines:

Data Structures

struct  urb_t
 
struct  ep_c_t
 
struct  ep_t
 
struct  ep_init_t
 
struct  usbnet_rx_buf_t
 
struct  usbnet_tx_buf_t
 
struct  usbnet_tx_tiny_buf_t
 
struct  net_buffers_t
 
struct  usbnet_stat_h
 
union  netspace_t
 

Macros

#define USBNET_ETH_FRAME_LEN   (UIP_BUFSIZE + 58 - UIP_LLH_LEN)
 
#define USBNET_RX_BUF_SIZE   USBNET_ETH_FRAME_LEN
 
#define USBNET_TX_BUF_SIZE   USBNET_ETH_FRAME_LEN
 
#define USBNET_TX_TINY_BUF_SIZE   (248)
 
#define USBNET_RX_POOL_SIZE   (1)
 
#define USBNET_TX_POOL_SIZE   (1)
 
#define USBNET_TX_TINY_POOL_SIZE   (2)
 
#define USBNET_MANAGED_TX_POOL_SIZE   (2)
 

Typedefs

typedef ep_xfer_status_t(* ep_if_xfer_cb_t) (ep_xfer_status_t status, uint32_t xferred, uint32_t remaining)
 
typedef void(* ep_xfer_cb_t) (struct ep_t *ep, struct urb_t *urb)
 
typedef void(* ep_complete_cb_t) (struct ep_t *ep, struct urb_t *urb, ep_xfer_status_t status)
 
typedef ep_if_xfer_cb_t ep_done_trap_t
 

Enumerations

Functions

void ep_init (const struct ep_init_t *ep)
 
int ep_xfer_done (ep_xfer_status_t status, uint32_t xferred, uint32_t remaining, struct ep_t *ep)
 
void ep_xfer_in (struct ep_t *ep, struct urb_t *urb)
 
void ep_xfer_out (struct ep_t *ep, struct urb_t *urb)
 
void ep_kill_all_urbs (struct ep_t *ep, void *device)
 
static struct urb_tep_alloc_urb (struct ep_t *ep)
 
static void ep_free_urb (struct ep_t *ep, struct urb_t *urb)
 
static bool ep_is_empty (struct ep_t *ep)
 
static void ep_schedule_urb (struct ep_t *ep, struct urb_t *urb)
 
void usbnet_init ()
 
void usbnet_start (struct process *module, uint8_t rx_backlog_len)
 
void usbnet_stop (struct process *module)
 
struct urb_tusbnet_alloc_urb (struct process *module, uint32_t size, struct dlist_t *backlog)
 
void usbnet_schedule_tx (struct urb_t *urb)
 
void usbnet_schedule_rx (struct urb_t *urb)
 
bool usbnet_quote (void)
 
static struct usbnet_tx_buf_tusbnet_tx_buf (struct urb_t *urb)
 
static struct usbnet_rx_buf_tusbnet_rx_buf (struct urb_t *urb)
 

Variables

struct usbnet_stat_h usbnetStat
 
union netspace_t netspace
 

Detailed Description

Macro Definition Documentation

#define USBNET_ETH_FRAME_LEN   (UIP_BUFSIZE + 58 - UIP_LLH_LEN)

Size of ethernet frame buffer

Definition at line 50 of file usbnet.h.

#define USBNET_RX_BUF_SIZE   USBNET_ETH_FRAME_LEN

Packet size when receiving on USB

Definition at line 51 of file usbnet.h.

#define USBNET_TX_BUF_SIZE   USBNET_ETH_FRAME_LEN

Packet size when transmitting on USB

Definition at line 52 of file usbnet.h.

#define USBNET_TX_TINY_BUF_SIZE   (248)

Ethernet frames with size <= USBNET_TX_TINY_BUF_SIZE bytes are sent over a dedicated tiny pool

Definition at line 55 of file usbnet.h.

#define USBNET_RX_POOL_SIZE   (1)

Number of frames in the RX pool

Definition at line 56 of file usbnet.h.

#define USBNET_TX_POOL_SIZE   (1)

Number of frames on full-size TX pool

Definition at line 57 of file usbnet.h.

#define USBNET_TX_TINY_POOL_SIZE   (2)

Number of frames in the tiny TX pool

Definition at line 58 of file usbnet.h.

#define USBNET_MANAGED_TX_POOL_SIZE   (2)

Number of frames in the managed (TCP data) TX pool

Definition at line 59 of file usbnet.h.

Typedef Documentation

typedef ep_xfer_status_t(* ep_if_xfer_cb_t) (ep_xfer_status_t status, uint32_t xferred, uint32_t remaining)

EFM32-compatible callback type.

Parameters
statusThe transfer status.
xferredNumber of bytes actually transferred.
remainingNumber of bytes remaining.

Definition at line 66 of file ep.h.

typedef void(* ep_xfer_cb_t) (struct ep_t *ep, struct urb_t *urb)

Common prototype for generic URB send and URB receive functions

Parameters
epThe endpoint
urbThe URB to be send or received

Definition at line 73 of file ep.h.

typedef void(* ep_complete_cb_t) (struct ep_t *ep, struct urb_t *urb, ep_xfer_status_t status)

Common prototype for generic URB complete calback

Parameters
epThe endpoint
urbThe URB that was just sent or received
statusStatus code for the transfer

Definition at line 81 of file ep.h.

USB complete callback for the EFM32 USB framework. The callback must call ep_xfer_done for the endpoint like below:

1 static int rx_done_trap(ep_xfer_status_t status,
2  uint32_t xferred,
3  uint32_t remaining)
4 {
5  return ep_xfer_done(status, xferred, remaining, &theEndpoint);
6 }

Definition at line 96 of file ep.h.

Enumeration Type Documentation

Endpoint transfer status

Enumerator
EP_XFER_STATUS_OK 

No errors detected.

EP_XFER_STATUS_ABORTED 

Transfer was aborted.

EP_XFER_STATUS_ERROR 

Transfer error.

Definition at line 53 of file ep.h.

anonymous enum
Enumerator
USBNET_PROCESS_EVENT_RXED 

The event is sent to usbnet process when a new frame is received. Event data points to an URB structure, containing the data received.

USBNET_PROCESS_EVENT__LAST 

The constant is used to count number of common events related to usbnet.

Definition at line 61 of file usbnet.h.

Function Documentation

void ep_init ( const struct ep_init_t ep)

Initialize an endpoint, allocate URBs and buffers

Parameters
epThe endpoint initialization description structure
int ep_xfer_done ( ep_xfer_status_t  status,
uint32_t  xferred,
uint32_t  remaining,
struct ep_t ep 
)

Entry point for transfer done notifications See ep_done_trap_t for details how the function should be called.

Parameters
statusTransfer status
xferredNumber of bytes transferred
remainingNumber of bytes remaining
epThe endpoint the function is called for
void ep_xfer_in ( struct ep_t ep,
struct urb_t urb 
)

Instantiation of ef ep_xfer_cb_t for receive endpoints

Parameters
epThe endpoint
urbThe URB to be received
void ep_xfer_out ( struct ep_t ep,
struct urb_t urb 
)

Instantiation of ef ep_xfer_cb_t for transmit endpoints

Parameters
epThe endpoint
urbThe URB to be send
void ep_kill_all_urbs ( struct ep_t ep,
void *  device 
)

Cancel any ongoing transfer. The function internally called complete callback for the cancelled URBs.

Parameters
epThe endpoint
deviceDevice instance
static struct urb_t* ep_alloc_urb ( struct ep_t ep)
static

Allocate a URB from the endpoint

Parameters
epThe endpoint

Definition at line 189 of file ep.h.

References ep_t::c, dlist_del(), dlist_is_empty(), urb_t::link, dlist_t::next, ep_t::pool, and ep_c_t::size.

static void ep_free_urb ( struct ep_t ep,
struct urb_t urb 
)
inlinestatic

Free a URB

Parameters
epThe endpoint
urbThe URB

Definition at line 206 of file ep.h.

References dlist_append(), urb_t::link, and ep_t::pool.

static bool ep_is_empty ( struct ep_t ep)
inlinestatic

Check if no more URBs can be allocated from the endpoint

Parameters
epThe endpoint
Returns
false if the endpoint is not empty
true if the endpoint is empty

Definition at line 217 of file ep.h.

References dlist_is_empty(), and ep_t::pool.

static void ep_schedule_urb ( struct ep_t ep,
struct urb_t urb 
)
inlinestatic

Schedule the URB for receiving or transmitting

Parameters
epThe endpoint
urbThe URB

Definition at line 227 of file ep.h.

References ep_t::c, dlist_append(), ep_t::head, urb_t::link, dlist_t::next, dlist_t::prev, and ep_c_t::xfer.

void usbnet_init ( )

Initialize the usbnet core.

void usbnet_start ( struct process *  module,
uint8_t  rx_backlog_len 
)

Start the interface; begin listening.

Parameters
moduleUsbnet client module
rx_backlog_lenAmount of buffers in the RX backlog
void usbnet_stop ( struct process *  module)

Stop the interface; kill all URBs

Parameters
moduleUsbnet client module
struct urb_t* usbnet_alloc_urb ( struct process *  module,
uint32_t  size,
struct dlist_t backlog 
)

Allocate an URB for transmitting.

The URB is allocated from the appropriate pool, depending on requested size and backlog.

Parameters
moduleUsbnet client module
sizeActual size of data to send
backlogThe backlog the URB will belong to, or NULL for unmanaged allocation
void usbnet_schedule_tx ( struct urb_t urb)

Schedule the URB for transmission

Parameters
urbThe URB to be sent over the interface
void usbnet_schedule_rx ( struct urb_t urb)

Schedule the URB for reception

Parameters
urbThe URB to be received
bool usbnet_quote ( void  )

Check if there is at least one URB available in the managed pool

Note that it the function returns false, the usbnet core will send USBNET_PROCESS_EVENT_TX_FLOW_ON signal to the usbnet_process when a new fresh URB appears in the managed pool.

Returns
true if at least one URB is available
false if no URB is available
static struct usbnet_tx_buf_t* usbnet_tx_buf ( struct urb_t urb)
static

Convert an URB structure to the usbnet_tx_buf_t it actually points to

Parameters
urbThe urb
Returns
Pointer to usbnet_tx_buf_t structure

Definition at line 210 of file usbnet.h.

References urb_t::buf, and usbnet_rx_buf_t::data.

static struct usbnet_rx_buf_t* usbnet_rx_buf ( struct urb_t urb)
static

Convert an URB structure to the usbnet_rx_buf_t it actually points to

Parameters
urbThe urb
Returns
Pointer to usbnet_rx_buf_t structure

Definition at line 221 of file usbnet.h.

References urb_t::buf, and usbnet_rx_buf_t::data.

Variable Documentation

struct usbnet_stat_h usbnetStat

Usbnet statistics

union netspace_t netspace

The physical USB buffers memory block.