Rate This Document
Findability
Accuracy
Completeness
Readability

Default Scenario

  1. When requesting a queue, you need to declare a structure variable struct wd_queue (the structure is defined in the following table) and initialize the variable to all 0s. Specify the required algorithm string in the member variable alg of the member variable capa. The algorithm string must match the algorithm string supported by the device that is registered with the UACCE, and other structure members do not need to be assigned values. In the shell of the user environment, you can run the cat /sys/class/uacce/*/attrs/algorithms command to list the algorithms supported by the devices that are registered with the UACCE.

    To search for queues that support a specific algorithm from a specified device registered with the UACCE, you need to specify the value of dev_path or node_mask. dev_path must be the path of the device registered with the UACCE, and node_mask must be the mask or combination of the NUMA node.

    Visible to External

    Visible to External

    Invisible to External (for Logical Integrity Only)

    1
    2
    3
    4
    5
    6
    struct wd_queue {
    struct wd_capa capa;
    char dev_path[PATH_STR_SIZE];
    unsigned int node_mask;
    void *qinfo; Specifies the internal private information. Users do not need to process it.
    };
    
    1
    2
    3
    4
    5
    6
    7
    struct wd_capa {
    char *alg;
    int throughput;
    int latency;
    __u32 flags;
    struct wcrypto_paras priv;
    };
    
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    struct q_info {
    const char *hw_type;
    int hw_type_id;
    int ref;
    void *priv; Specifies hardware data.
    const void *dev_info;
    int fd;
    int ctx_num;
    ...
    }
    
  2. When requesting a queue, use the address of the structure variable struct wd_queue in step 1 as the parameter, and invoke int wd_request_queue(struct wd_queue *q) to request a queue of a specified algorithm. If a negative value is returned, the request fails. Otherwise, the operation is successful. The obtained private information about the queue is saved to the member variable qinfo of the structure variable struct wd_queue. Subsequent operations related to the queue access the information saved in qinfo. The memory to which qinfo points is released when wd_release_queue is invoked.
  3. Before sending a message, you need to declare the variables of the message structure of an algorithm (for details, see Algorithm Layer Interfaces). For example, for the RSA algorithm message, you need to fill in the data required by the algorithm and apply for the memory to which in, out, and key points. After the processing is complete, the related memory is released by the user. You can also declare user-defined message structure variables if the message structure can be identified and processed by the user-mode driver of the hardware accelerator.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    struct wcrypto_rsa_msg {
    __u8 alg_type:3;/* Denoted by enum wcrypto_type */
    __u8 op_type:2;/* Denoted by enum wcrypto_rsa_op_type */
    __u8 key_type:2;/* Denoted by enum wcrypto_rsa_key_type */
    __u8 data_fmt:1; /* Data format, denoted by enum wd_buff_type */
    __u8 result;/* Data format, denoted by WD error code */
    __u16 in_bytes;/* Input data bytes */
    __u16 out_bytes;/* Output data bytes */
    __u16 key_bytes;/* Input key bytes */
    __u8 *in;/* Input data VA, buf should be DMA buffer. */
    __u8 *out;/* Output data VA pointer, should be DMA buffer */
    __u8 *key;/* Input key VA pointer, should be DMA buffer */
    __u64 usr_data;/* Input user tag, used for indentify data stream/user: struct wcrypto_cb_tag */
    };
    
  4. When a message is being sent, use the address of the structure variable struct wd_queue in step 1 and the address of the algorithm message structure variable in step 3 as parameters, and invoke int wd_send(struct wd_queue *q, void *req) to send the request to the hardware for processing. If the request is processed successfully, 0 is returned. Do not release the variables and memory applied in step 3. If the operation fails, a negative value is returned. In the internal logic, a proper hardware accelerator user-mode driver is determined according to hw_type in the member variable qinfo of wd_queue, and a method of the driver is invoked to send the request to the hardware.
  5. Before receiving the message, you need to declare a pointer variable of the algorithm message structure that is the same as that in step 3.
  6. When a message is being received, use the address of the structure variable struct wd_queue in step 1 and the address of the algorithm message structure pointer variable in step 5 as parameters, and invoke int wd_recv(struct wd_queue *q, void **resp) to receive a response message from the hardware. If the response message is received successfully, 0 is returned. The processed data is updated to req in step 3 and resp is pointed to req. If the operation fails, a negative value is returned. In the internal logic, a proper hardware accelerator user-mode driver is determined according to hw_type in the member variable qinfo of wd_queue, and a method of the driver is invoked to receive the response message from the hardware.
  7. Before releasing the queue, release the variables and memory requested in step 3 after data is processed.
  8. When a queue is being released, use the address of the structure variable struct wd_queue in step 1 as the parameter, and invoke void wd_release_queue(struct wd_queue *q) to release the queue and related hardware resources.