PDK API Guide for J721E
bufpool.h File Reference

Introduction

Implements a simple buffer pool.

Go to the source code of this file.

Data Structures

struct  BufPool_Buf
 Fixed size data buffer. More...
 
struct  BufPool_Pool
 Fixed size buffer pool. More...
 

Macros

#define BUFPOOL_MEM_LEN   (BUFPOOL_MAX_POOLS * sizeof(BufPool_Pool))
 
#define ETH_MAX_PAYLOAD   (1514)
 
#define VLAN_TAG_SIZE   (4U)
 
#define ETH_FRAME_SIZE   (ETH_MAX_PAYLOAD + VLAN_TAG_SIZE)
 
#define BUFPOOL_MCU2_0_R5   (0)
 
#define BUFPOOL_MCU2_1   (1)
 
#define BUFPOOL_A72   (2)
 
#define BUFPOOL_MCU2_0_A72   (3)
 
#define BUFPOOL_MAX_POOLS   (4)
 
#define BUFPOOL_BUF_MAX   (1280U)
 
#define BUFPOOL_OK   (0)
 
#define BUFPOOL_ERROR   (-1)
 
#define BUF_OBJ_SIZE_IN_BYTES   (sizeof(BufPool_Buf))
 

Typedefs

typedef struct BufPool_Pool_s * BufPool_Handle
 BufPool handle. More...
 

Functions

int32_t BufPool_init (BufPool_Handle hBufPool, uint32_t poolId, uint32_t maxSize)
 Initializes a buffer pool. More...
 
BufPool_BufBufPool_getBuf (BufPool_Handle hBufPool)
 Returns a pointer to a free buffer. More...
 
int32_t BufPool_freeBuf (BufPool_Buf *hBuf)
 Decrements the ref count of a buffer object. More...
 

Variables

BufPool_Handle BufPoolTable_Handle
 

Macro Definition Documentation

◆ BUFPOOL_MEM_LEN

#define BUFPOOL_MEM_LEN   (BUFPOOL_MAX_POOLS * sizeof(BufPool_Pool))

Total memory used by all shared buffer pools combined

◆ ETH_MAX_PAYLOAD

#define ETH_MAX_PAYLOAD   (1514)

Maximum Ethernet Payload Size.

◆ VLAN_TAG_SIZE

#define VLAN_TAG_SIZE   (4U)

Size of the VLAN tag in bytes

◆ ETH_FRAME_SIZE

#define ETH_FRAME_SIZE   (ETH_MAX_PAYLOAD + VLAN_TAG_SIZE)

Total size of the Ethernet frame in bytes

◆ BUFPOOL_MCU2_0_R5

#define BUFPOOL_MCU2_0_R5   (0)

MCU2_0 buffer pool for MCU2_0->MCU2_1 interface

◆ BUFPOOL_MCU2_1

#define BUFPOOL_MCU2_1   (1)

MCU2_1 buffer pool

◆ BUFPOOL_A72

#define BUFPOOL_A72   (2)

A72 buffer pool

◆ BUFPOOL_MCU2_0_A72

#define BUFPOOL_MCU2_0_A72   (3)

MCU2_0 buffer pool for MCU2_0->A72 interface

◆ BUFPOOL_MAX_POOLS

#define BUFPOOL_MAX_POOLS   (4)

Total number of buffer pools

◆ BUFPOOL_BUF_MAX

#define BUFPOOL_BUF_MAX   (1280U)

Maximum no. of buffers in each buffer pool

◆ BUFPOOL_OK

#define BUFPOOL_OK   (0)

Buffer pool API return code: Success

◆ BUFPOOL_ERROR

#define BUFPOOL_ERROR   (-1)

Buffer pool API return code: Failure

◆ BUF_OBJ_SIZE_IN_BYTES

#define BUF_OBJ_SIZE_IN_BYTES   (sizeof(BufPool_Buf))

Size of buffer object

Typedef Documentation

◆ BufPool_Handle

typedef struct BufPool_Pool_s* BufPool_Handle

BufPool handle.

BufPool handle provided to the user

Function Documentation

◆ BufPool_init()

int32_t BufPool_init ( BufPool_Handle  hBufPool,
uint32_t  poolId,
uint32_t  maxSize 
)

Initializes a buffer pool.

This function creates a buffer pool in the memory region pointed to by the BufPool_Handle

Parameters
hBufPoolPointer to pre-allocated memory for this buffer pool
poolIdBuffer Pool ID
maxSizeTotal no. of buffers in this buffer pool
Return values
BUFPOOL_OK

◆ BufPool_getBuf()

BufPool_Buf* BufPool_getBuf ( BufPool_Handle  hBufPool)

Returns a pointer to a free buffer.

This function alloctes a free buffer from the given buffer pool and returns a pointer to it.

Parameters
hBufPoolHandle to the buffer pool from which to allocate a buffer
Return values
Pointerto a BufPool_Buf object if the get operation was successfull
NULLin case of failure

◆ BufPool_freeBuf()

int32_t BufPool_freeBuf ( BufPool_Buf hBuf)

Decrements the ref count of a buffer object.

This function decrements the ref count of an allocated buffer object. If the ref count reaches zero, the buffer is released to the buffer pool.

Parameters
hBufHandle to a buffer object
Return values
BUFPOOL_OK

Variable Documentation

◆ BufPoolTable_Handle

BufPool_Handle BufPoolTable_Handle