WE310F5  39.00.000
m2mb_netbuf.h File Reference

Network Interface. More...

#include "stdint.h"

Go to the source code of this file.

Data Structures

struct  M2MB_NET_BUF
 Structure to hold network buffer information. More...
 
struct  m2mb_Net_Buf_Queue_s
 Structure that contains information about a free queue. More...
 
struct  m2mb_Net_Buf_Queue_Status_s
 Structure that contains information about all free queues. More...
 
#define M2MB_NETBUF_MAX_QUEUE_NAME   6
 
#define M2MB_NETBUF_MAX_QUEUES   3
 
#define M2MB_NETBUF_UDP_HEADROOM   (52)
 
#define M2MB_NETBUF_TCP_HEADROOM   (64)
 
#define M2MB_NETBUF_UDP6_HEADROOM   (72)
 
#define M2MB_NETBUF_TCP6_HEADROOM   (88)
 
#define M2MB_NET_BUF_UPDATE_START(pkt, p)   (p) = ((M2MB_NET_BUF_T *)(pkt))->nb_Prot
 
#define M2MB_NET_BUF_UPDATE_INT32(p, val)   *(UINT32 *)(p) = (UINT32)(val); (p) += sizeof(UINT32)
 
#define M2MB_NET_BUF_UPDATE_INT16(p, val)   *(uint16_t *)(p) = (uint16_t)(val); (p) += sizeof(uint16_t)
 
#define M2MB_NET_BUF_UPDATE_INT8(p, val)   *(uint8_t *)(p) = (uint8_t)(val); (p) += sizeof(uint8_t)
 
#define M2MB_NET_BUF_UPDATE_DATA(p, data, len)   memcpy((p), (data), (len)); (p) += (len)
 
#define M2MB_NET_BUF_UPDATE_END(pkt, len)
 
#define M2MB_NETBUF_APP   0x0
 
#define M2MB_NETBUF_SYS   0x1
 
#define M2MB_NETBUF_SYS_CONTIG   (0x4 | M2MB_NETBUF_SYS)
 
#define M2MB_NETBUF_SSL   0x2
 
typedef struct M2MB_NET_BUF M2MB_NET_BUF_T
 Structure to hold network buffer information. More...
 
typedef M2MB_NET_BUF_TPACKET
 
typedef struct m2mb_Net_Buf_Queue_s m2mb_Net_Buf_Queue_t
 Structure that contains information about a free queue. More...
 
typedef struct m2mb_Net_Buf_Queue_Status_s m2mb_Net_Buf_Queue_Status_t
 Structure that contains information about all free queues. More...
 
void * m2mb_Net_Buf_Alloc (UINT32 size, UINT32 id)
 Allocates a network buffer. More...
 
INT32 m2mb_Net_Buf_Free (void *buf, UINT32 id)
 Frees a network buffer. More...
 
INT32 m2mb_Net_Buf_Update (void *netbuf, UINT32 offset, void *srcbuf, UINT32 len, UINT32 id)
 Updates data in a network buffer. More...
 
M2MB_STATUS_T m2mb_Net_Buf_Free_Queue_Status (m2mb_Net_Buf_Queue_Status_t *arg)
 

Detailed Description

Network Interface.

we866e4/epl/inc/nwk/m2mb_netbuf.h

This file describes M2MBs for network buffer allocation and deallocation. When an application wants to send data over a communication socket, it first has to allocate a network buffer. There are two types of network buffers:

  • Local (application) buffers – These buffers are allocated from the heap using the M2MB_NETBUF_APP flag. These buffers are owned and maintained by the application, and the stack copies the data from it (on TX) and to it (on RX). The application can reuse the buffer once it was sent or once done processing the incoming data.
  • System buffers – These buffers are allocated from the internal stack memory using the M2MB_NETBUF_SYS flag. Using this option enables the Zero-Copy mechanism, which may improve performance and reduce power due to skipping the memory copy from the application memory to the stack memory. These buffers are shared between the application and the stack and some restrictions apply: The application does not own the buffer once it was sent and it must allocate a new one in order to transmit more data. Upon receiving a system buffer, the application must free it once done processing. Note that a system buffer can be a list of chained buffers.
m2mb_Net_Buf_t *my_buf;
do {
// Allocate a buffer of 1200 bytes
m2mb_Net_Buf_t my_buf = m2mb_Net_Buf_Alloc(1200, M2MB_NETBUF_SYS);
if(!my_buf) {
// No memory, wait and retry
sleep(1);
continue;
}
}
while(0);
Note
Dependencies:
"#include <stdint.h>"
Author
Prasad Reddy
Date
03/10/2017

Definition in file m2mb_netbuf.h.