SGL内存格式接口
(SGL相关接口暂时pending,等确定实现后再进行评审)
1 2 3 4 5 6 7 8 9 10 11 | /* SGL buffers, inner details are not cared about by users */ struct wd_sgl; /* SGL Memory pool creating parameters */ struct wd_sglpool_setup { __u32 slice_num;/* Total number of SGEs with buffer slices */ __u16 sgl_num;/* Total number of sgl with entries and buffers */ __u16 align_size;/* SGE data buffer startging address align size */ __u32 buf_size;/* memory size of entry buffer */ struct wd_mm_br br;/* memory from user if don't use WD memory */ }; |
函数原型 |
void *wd_sglpool_create(struct wd_queue *q, struct wd_sglpool_setup *setup); |
---|---|
函数功能 |
基于用户给的规格与内存创建SGL池 |
输入说明 |
q:Warpdrive算法队列 setup:用户给出的规格与内存 |
输出说明 |
setup->slice_num:仅当使用WD默认内存时为输出,即实际创建的slice数目,当数目小于用户要求数量的90%时,创建sglpool将失败。 |
返回值说明 |
非NULL:SGL池 NULL:失败 |
使用说明 |
|
注意事项 |
如果用户没有指定内存,那么默认使用wd预留内存进行池的创建。在使用WD默认内存创建池时,struct wd_sglpool_setup中slice_num为输入输出参数。 |
函数原型 |
void wd_sglpool_destroy(void *pool); |
---|---|
函数功能 |
销毁SGL池 |
输入说明 |
pool:需要销毁的SGL池。 |
输出说明 |
无。 |
返回值说明 |
无 |
使用说明 |
|
注意事项 |
函数原型 |
struct wd_sgl *wd_alloc_sgl(void *pool, __u32 size); |
---|---|
函数功能 |
Allocate a SGL buffers from Warpdrive SGL memory pool |
输入说明 |
pool:SGL池 size:SGL buffers的整体size大小 |
输出说明 |
无。 |
返回值说明 |
非NULL:一个SGL链buffer的首个SGL地址 NULL:申请失败 |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
void wd_free_sgl(void *pool, struct wd_sgl *sgl); |
---|---|
函数功能 |
Free a SGL buffers to Warpdrive SGL memory pool |
输入说明 |
pool:SGL池 sgl:一个SGL链buffer的首个SGL地址 |
输出说明 |
无 |
返回值说明 |
无 |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
void *wd_sgl_last_entry(struct wd_sgl *sgl); |
---|---|
函数功能 |
Get the start address of the last entry of SGL |
输入说明 |
sgl:一个SGL链 |
输出说明 |
无 |
返回值说明 |
非NULL:Start address of last entry in the SGL NULL:无entry在SGL中 |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
void *wd_sgl_entry(struct wd_sgl *sgl, int num); |
---|---|
函数功能 |
Get the start address of the num-th entry of SGL |
输入说明 |
sgl:一个SGL链 Num:the num-th of entry, 0 ---the first one |
输出说明 |
无 |
返回值说明 |
非NULL:Start address of num-th entry in the SGL NULL:num超过SGL的范围 |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
void *wd_sgl_iova_map(struct wd_sgl *sgl); |
---|---|
函数功能 |
Get the iova of a SGL buffers |
输入说明 |
sgl:一个sgl的地址 |
输出说明 |
无 |
返回值说明 |
非NULL:返回sgl的iova地址 NULL:map失败 |
使用说明 |
支持多线程 |
注意事项 |
目前为了支持no-iommu与iommu-passthrough场景的接口 |
函数原型 |
int wd_sgl_entry_bsize(struct wd_sgl *sgl, size_t *size); |
---|---|
函数功能 |
Get the buffer size of SGL |
输入说明 |
sgl:一个sgl的地址 |
输出说明 |
size:entry buffer size |
返回值说明 |
0: success Other: fail |
使用说明 |
支持多线程 |
注意事项 |
维测接口 |
函数原型 |
int wd_sgl_bsize(struct wd_sgl *sgl, size_t *size); |
---|---|
函数功能 |
Get the total buffer size of SGL |
输入说明 |
sgl:一个sgl的地址 |
输出说明 |
size:total buffer size of the SGL |
返回值说明 |
0: success Other: fail |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
void wd_sgl_iova_unmap(void *pool, void *sgl_iova, struct wd_sgl *sgl); |
---|---|
函数功能 |
do unmap the iova of a SGL with it’s physical address |
输入说明 |
pool:SGL池 sgl_iova:一个sgl的iova地址 sgl:一个sgl的地址 |
输出说明 |
无 |
返回值说明 |
无 |
使用说明 |
支持多线程 |
注意事项 |
目前为了支持no-iommu与iommu-passthrough场景的接口,no-iommu模式下无任何操作 |
函数原型 |
int wd_get_free_sgl_num(void *pool); |
---|---|
函数功能 |
Get the free sgl buffer number of the pool |
输入说明 |
pool: SGL池 |
输出说明 |
无 |
返回值说明 |
Number of free sgl buffer |
使用说明 |
支持多线程 |
注意事项 |
维测接口 |
函数原型 |
int wd_alloc_sgl_failures(void *pool); |
---|---|
函数功能 |
Get the failing allocation times of the pool |
输入说明 |
pool:SGL池 |
输出说明 |
无 |
返回值说明 |
Number of allocation failing times |
使用说明 |
支持多线程 |
注意事项 |
维测接口 |