From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Coquelin Subject: Re: [PATCH v6 4/8] lib/librte_vhost: add request handler Date: Thu, 5 Apr 2018 10:22:12 +0200 Message-ID: References: <20180404100902.27637-1-roy.fan.zhang@intel.com> <20180404142504.31836-1-roy.fan.zhang@intel.com> <20180404142504.31836-5-roy.fan.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: jianjay.zhou@huawei.com, jianfeng.tan@intel.com, pawelx.wodkowski@intel.com To: Fan Zhang , dev@dpdk.org Return-path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 040341C9C1 for ; Thu, 5 Apr 2018 10:22:16 +0200 (CEST) In-Reply-To: <20180404142504.31836-5-roy.fan.zhang@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 04/04/2018 04:25 PM, Fan Zhang wrote: > This patch adds the implementation that parses virtio crypto request > to dpdk crypto operation. > > Signed-off-by: Fan Zhang > --- > lib/librte_vhost/rte_vhost_crypto.h | 14 + > lib/librte_vhost/vhost_crypto.c | 622 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 636 insertions(+) > create mode 100644 lib/librte_vhost/rte_vhost_crypto.h > ... > diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c > index 34587c27e..5608e94ad 100644 > --- a/lib/librte_vhost/vhost_crypto.c > +++ b/lib/librte_vhost/vhost_crypto.c > @@ -8,9 +8,11 @@ ... > +static uint8_t > +prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, > + struct vhost_crypto_data_req *vc_req, > + struct virtio_crypto_cipher_data_req *cipher, > + struct vring_desc *cur_desc) > +{ > + struct vring_desc *head = vc_req->head; > + struct vring_desc *desc = cur_desc; > + struct rte_vhost_memory *mem = vc_req->mem; > + struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst; > + uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET); > + uint8_t ret = 0; > + > + /* prepare */ > + /* iv */ > + if (unlikely(copy_data(iv_data, head, mem, &desc, > + cipher->para.iv_len) < 0)) { > + ret = VIRTIO_CRYPTO_BADMSG; > + goto error_exit; > + } > + > +#ifdef RTE_LIBRTE_VHOST_DEBUG > + rte_hexdump(stdout, "IV:", iv_data, cipher->para.iv_len); > +#endif > + > + m_src->data_len = cipher->para.src_data_len; > + > + switch (vcrypto->option) { > + case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE: > + m_src->buf_iova = gpa_to_hpa(vcrypto->dev, desc->addr, > + cipher->para.src_data_len); > + m_src->buf_addr = get_data_ptr(head, mem, &desc, > + cipher->para.src_data_len); > + if (unlikely(m_src->buf_iova == 0 || > + m_src->buf_addr == NULL)) { > + VC_LOG_ERR("zero_copy may fail due to cross page data"); > + ret = VIRTIO_CRYPTO_ERR; > + goto error_exit; > + } > + break; > + case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE: > + if (unlikely(cipher->para.src_data_len > > + RTE_MBUF_DEFAULT_BUF_SIZE)) { > + VC_LOG_ERR("Not enough space to do data copy"); > + ret = VIRTIO_CRYPTO_ERR; > + goto error_exit; > + } > + if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), head, > + mem, &desc, cipher->para.src_data_len)) > + < 0) { > + ret = VIRTIO_CRYPTO_BADMSG; > + goto error_exit; > + } > + break; > + default: > + ret = VIRTIO_CRYPTO_BADMSG; > + goto error_exit; > + break; Note: I removed the break to make checkpatch happy.