MCPcopy Create free account
hub / github.com/F-Stack/f-stack / virtio_crypto_send_command

Function virtio_crypto_send_command

dpdk/drivers/crypto/virtio/virtio_cryptodev.c:63–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61#define NUM_ENTRY_SYM_CREATE_SESSION 4
62
63static int
64virtio_crypto_send_command(struct virtqueue *vq,
65 struct virtio_crypto_op_ctrl_req *ctrl, uint8_t *cipher_key,
66 uint8_t *auth_key, struct virtio_crypto_session *session)
67{
68 uint8_t idx = 0;
69 uint8_t needed = 1;
70 uint32_t head = 0;
71 uint32_t len_cipher_key = 0;
72 uint32_t len_auth_key = 0;
73 uint32_t len_ctrl_req = sizeof(struct virtio_crypto_op_ctrl_req);
74 uint32_t len_session_input = sizeof(struct virtio_crypto_session_input);
75 uint32_t len_total = 0;
76 uint32_t input_offset = 0;
77 void *virt_addr_started = NULL;
78 phys_addr_t phys_addr_started;
79 struct vring_desc *desc;
80 uint32_t desc_offset;
81 struct virtio_crypto_session_input *input;
82 int ret;
83
84 PMD_INIT_FUNC_TRACE();
85
86 if (session == NULL) {
87 VIRTIO_CRYPTO_SESSION_LOG_ERR("session is NULL.");
88 return -EINVAL;
89 }
90 /* cipher only is supported, it is available if auth_key is NULL */
91 if (!cipher_key) {
92 VIRTIO_CRYPTO_SESSION_LOG_ERR("cipher key is NULL.");
93 return -EINVAL;
94 }
95
96 head = vq->vq_desc_head_idx;
97 VIRTIO_CRYPTO_INIT_LOG_DBG("vq->vq_desc_head_idx = %d, vq = %p",
98 head, vq);
99
100 if (vq->vq_free_cnt < needed) {
101 VIRTIO_CRYPTO_SESSION_LOG_ERR("Not enough entry");
102 return -ENOSPC;
103 }
104
105 /* calculate the length of cipher key */
106 if (cipher_key) {
107 switch (ctrl->u.sym_create_session.op_type) {
108 case VIRTIO_CRYPTO_SYM_OP_CIPHER:
109 len_cipher_key
110 = ctrl->u.sym_create_session.u.cipher
111 .para.keylen;
112 break;
113 case VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING:
114 len_cipher_key
115 = ctrl->u.sym_create_session.u.chain
116 .para.cipher_param.keylen;
117 break;
118 default:
119 VIRTIO_CRYPTO_SESSION_LOG_ERR("invalid op type");
120 return -EINVAL;

Callers 1

Calls 7

rte_mallocFunction · 0.85
rte_malloc_virt2iovaFunction · 0.85
rte_freeFunction · 0.85
vq_update_avail_ringFunction · 0.70
vq_update_avail_idxFunction · 0.70
virtqueue_notifyFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected