BLK Memory Management Interfaces
1 2 3 4 5 6 7 | /* Memory pool creating parameters */ struct wd_blkpool_setup { __u32 block_size;/* Block buffer size */ __u32 block_num;/* Block buffer number */ __u32 align_size;/* Block buffer startging address align size */ struct wd_mm_br br;/* memory from user if don't use WD memory */ }; |
Prototype |
void *wd_blkpool_create(struct wd_queue *q, struct wd_blkpool_setup *setup); |
|---|---|
Function |
Create a block memory pool on the WD queue using the WD memory or user memory. |
Input Description |
q: WD algorithm queue setup: specifications and memory information provided by users |
Output Description |
setup->block_num: When you use the WD memory to create a pool, block_num is the number of created block buffers. If the number is less than 90% of the required number, the block pool fails to be created. |
Return Value Description |
A not-NULL value: BLK pool NULL: failure |
Usage Instruction |
|
Precautions |
If no memory is specified, the memory reserved by the WD is used to create a pool by default. In this case, block_num in struct wd_blkpool_setup is an input and output parameter. |
Prototype |
void wd_blkpool_destroy(void *pool); |
|---|---|
Function |
Destroy a BLK pool. |
Input Description |
pool: BLK pool to be destroyed |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
None |
Precautions |
None |
Prototype |
void *wd_alloc_blk(void *pool); |
|---|---|
Function |
Allocate a BLK buffer from the WD SGL memory pool. |
Input Description |
pool: BLK pool |
Output Description |
None |
Return Value Description |
A non-NULL value: start address of a BLK buffer NULL: failure |
Usage Instruction |
Multiple threads are supported. |
Precautions |
None |
Prototype |
void wd_free_blk(void *pool, void *blk); |
|---|---|
Function |
Release the BLK buffer to the WD BLK memory pool. |
Input Description |
pool: BLK pool blk: any address within the BLK buffer |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
Multiple threads are supported. |
Precautions |
The input parameter blk is any address within the block buffer. |
Prototype |
void *wd_blk_iova_map(void *pool, void *blk); |
|---|---|
Function |
Map an IOVA to the block buffer. |
Input Description |
pool: BLK pool blk: any address within the block buffer |
Output Description |
None |
Return Value Description |
A non-NULL value: IOVA address of block mapping NULL: mapping failure |
Usage Instruction |
Multiple threads are supported. |
Precautions |
|
Prototype |
void wd_blk_iova_unmap(void *pool, void *blk_iova, void *blk); |
|---|---|
Function |
Cancel the IOVA of the mapping block buffer by using the physical address. |
Input Description |
pool: BLK pool blk_iova: IOVA address of block mapping blk: any address within the block buffer |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
Multiple threads are supported. |
Precautions |
This interface is used to support the no-IOMMU and IOMMU-passthrough scenarios. No operation is performed in the no-IOMMU mode. |
Prototype |
int wd_get_free_blk_num (void *pool, __u32 *free_num); |
|---|---|
Function |
Obtain the buffer area code of the free block in the pool. |
Input Description |
pool: BLK pool |
Output Description |
*free_num: number of free block buffers |
Return Value Description |
WD_SUCCESS: success -WD_EINVAL: failure |
Usage Instruction |
Multiple threads are supported. |
Precautions |
Maintenance and debugging interface |
Prototype |
unsigned int wd_blk_alloc_failures (void *pool, __u32 *fail_num); |
|---|---|
Function |
Obtain the number of pool allocation failure times. |
Input Description |
pool: BLK pool |
Output Description |
*fail_num: number of allocation failure times |
Return Value Description |
WD_SUCCESS: success -WD_EINVAL: failure |
Usage Instruction |
Multiple threads are supported. |
Precautions |
Maintenance and debugging interface |