General Memory Interfaces
Defined by enum wd_buff_type:
Buffer Type |
Description |
Type Value |
|---|---|---|
WD_FLAT_BUF |
General buffer type |
0 |
WD_SGL_BUF |
Parent and child hash linked list buffer |
1 |
Prototype |
typedef void *(*wd_alloc)(void *usr, size_t size); |
|---|---|
Function |
Apply for memory of a specified size based on the user memory mechanism usr. |
Input Description |
usr: user memory mechanism handle size: memory size |
Output Description |
None |
Return Value Description |
A non-NULL value: success, the start address of the memory NULL: failure |
Usage Instruction |
Currently, this interface is used to support the no-IOMMU and IOMMU-passthrough scenarios. This interface is not required in the SVA scenario. |
Precautions |
Multiple threads need to be supported. |
Prototype |
typedef void (*wd_free)(void *usr, void *va); |
|---|---|
Function |
Release the memory of the start address va based on the user memory mechanism usr. |
Input Description |
usr: user memory mechanism va: start address of the memory to be released |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
Currently, this interface is used to support the no-IOMMU and IOMMU-passthrough scenarios. This interface is not required in the SVA scenario. |
Precautions |
Multiple threads need to be supported. |
Prototype |
typedef void *(* wd_map)(void *usr, void *va, size_t sz); |
|---|---|
Function |
Perform iova map on the memory of the start address va and size sz based on the user memory mechanism usr. |
Input Description |
usr: user memory mechanism va: start address of the memory on which iova map is performed sz: memory size |
Output Description |
None |
Return Value Description |
IOVA of corresponding VA is returned. |
Usage Instruction |
|
Precautions |
Multiple threads need to be supported. |
Prototype |
typedef void (*wd_unmap)(void *usr, void *va, void *iova, size_t sz); |
|---|---|
Function |
Perform iova unmap on the memory of the start address va or iova and size sz based on the user memory mechanism usr. |
Input Description |
usr: user memory mechanism va: start address of the memory on which iova unmap is performed iova: start IOVA address sz: memory size |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
|
Precautions |
Multiple threads need to be supported. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* Memory brigde from user, it is given at ctx. While SVA, this interface is in no need */ struct wd_mm_br { wd_alloc alloc;/* Memory allocation */ wd_free free;/* Memory free */ wd_map iova_map; /* get iova from user space VA */ wd_unmap iova_unmap; /* destroy the mapping between the PA of VA and iova */ void *usr; /* data for the above operations */ }; /* Warpdrive data buffer */ struct wd_dtb { char *data;/* data/buffer start address */ __u32 dsize;/* data size */ __u32 bsize;/* buffer size */ }; |
Prototype |
void *wd_iova_map(struct wd_queue *q, void *va, size_t sz); |
|---|---|
Function |
Perform iova map on the user-mode memory of the start address va and size sz based on the WD queue. |
Input Description |
q: source queue va: user-mode virtual address sz: memory size starting from va |
Output Description |
None |
Return Value Description |
A non-NULL value: IOVA address NULL: failure |
Usage Instruction |
Southbound API |
Precautions |
This interface is used to support the no-IOMMU and IOMMU-passthrough scenarios. Only virtual and physical address conversion is performed in the no-IOMMU mode. |
Prototype |
void wd_iova_unmap(struct wd_queue *q, void *va, void *iova, size_t sz); |
|---|---|
Function |
Perform iova unmap on the user-mode memory of the start address va or iova and size sz based on the WD queue. |
Input Description |
q: source queue va: user-mode virtual address iova: user-mode IOVA address sz: memory size |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
Southbound API |
Precautions |
This interface is used to support the no-IOMMU and IOMMU-passthrough scenarios. No operation is performed in the no-IOMMU mode. |
