Rate This Document
Findability
Accuracy
Completeness
Readability

Default Scenario

  1. Before applying for a queue, declare a structure variable struct wd_queue and specify the required algorithm string in the member variable alg of the member variable capa. (The process is the same as that in Default Scenario.)
  2. When applying for 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 apply for a queue of a specified algorithm. (The process is the same as that in Default Scenario.)
  3. When the algorithm context is being created, the address of the structure variable struct wd_queue in step 1 is used as the parameter, and the wcrypto_create_digest_ctx function is invoked to create the context. If the context is created successfully, a void * pointer pointing to the context is returned. If the context fails to be created, a null pointer is returned.
  4. Before invoking an algorithm, declare an operation structure variable struct wcrypto_digest_op_data of the algorithm (for details about the structure definition, see Interfaces Related to Hash). Apply for proper memory for in and out as required and enter the data to be operated to in, or point in and out to the applied memory and specify the sizes of in_bytes and out_bytes. After the processing is complete, the user is responsible for releasing the memory.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    struct wcrypto_digest_op_data{
    void *in;
    void *out;
    __u32 in_bytes;
    __u32 out_bytes;
    void *priv;
    int status;
    bool has_next;
    };
    
  5. When the algorithm operation is invoked to instruct the hardware to execute the algorithm to process data, use the context pointer returned in step 3 and the struct wcrypto_digest_op_data variable address in step 4 as parameters, and invoke the wcrypto_do_digest function to deliver the data to the accelerator hardware for processing through the send/recv interface at the WD basic layer. If the data is successfully processed, 0 is returned. Then fill the data processed by the hardware into the member variable out of the struct wcrypto_digest_op_data variable in step 4. If the operation fails, a negative value is returned.
  6. Before releasing the algorithm context, release the memory of in and out involved in step 4 after processing the data returned by the accelerator.
  7. When releasing the algorithm context, use the context pointer returned in step 3 as the parameter, and invoke the wcrypto_del_digest_ctx function to release the context.
  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.