Rate This Document
Findability
Accuracy
Completeness
Readability

Special Scenario 1: SVA Is Not Supported But IOMMU Is Enabled. All Devices Registered with the UACCE Support PASID and IOMMU

To solve the problem that the hardware cannot access the user-mode VA, memory-related interfaces are added to the WD basic layer interfaces, including the wd_reserve_memory, wd_blkpool_create, wd_blkpool_destroy, wd_alloc_blk, and wd_free_blk functions and the struct wd_blkpool_setup structure. Wherein:

  • Memory reservation interface: The wd_reserve_memory function is used to apply for a piece of memory so that both the hardware and user mode can use the VA to access the memory.
  • Block mode-memory pool reservation and release interface: The wd_blkpool_create function is used to apply for a piece of memory based on the user-defined block size and number of blocks so that both the hardware and user mode can use the VA to access the memory. The wd_blkpool_destroy function is used to destroy the memory pool created by the wd_blkpool_create function.
  • Block mode-memory allocation and release interface: The wd_alloc_blk and wd_free_blk functions are used to apply for or release a block of memory from the memory applied by the wd_blkpool_create function.

For details about each function, see WD Data Storage Formats and Memory Interfaces.

In special scenario 1, when a WD basic layer interface is used, memory operations must be adjusted. Pay attention to the following when using a new interface:

  1. If the pointer needs to be transferred to the hardware before the message is sent, declare a struct wd_blkpool_setup variable before step 3 in Default Scenario to determine the size of the memory pool, the number of blocks in the memory pool, and the size of each memory block.
    1
    2
    3
    4
    5
    6
    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 */
    };
    
  2. If the pointer needs to be transferred to the hardware before the message is sent, use the address of the struct wd_blkpool_setup variable as the parameter to invoke the void *wd_blkpool_create(struct wd_queue *q, struct wd_blkpool_setup *setup) interface to reserve the memory of the corresponding size. If the memory is reserved successfully, the start address of the memory pool is returned. If the memory fails to be reserved, a null pointer is returned. The function internally invokes wd_reserve_memory to reserve memory.
  3. If the pointer needs to be transferred to the hardware before the message is sent, the address to be transferred to the hardware is allocated from the reserved memory pool by using wd_alloc_blk in step 3 in Default Scenario.
  4. After the message is received and processed, release the memory applied through wd_alloc_blk by using wd_free_blk in step 7 in Default Scenario.
  5. After the message is received and processed, use the start address of the reserved memory pool as the parameter, and invoke wd_blkpool_destroy to release the reserved memory after step 7 in Default Scenario.