From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 644D4406E8C3; Thu, 5 Apr 2018 08:22:15 +0000 (UTC) Received: from [10.36.112.61] (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5332D1208F7A; Thu, 5 Apr 2018 08:22:14 +0000 (UTC) To: Fan Zhang , dev@dpdk.org Cc: jianjay.zhou@huawei.com, jianfeng.tan@intel.com, pawelx.wodkowski@intel.com 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> From: Maxime Coquelin Message-ID: Date: Thu, 5 Apr 2018 10:22:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180404142504.31836-5-roy.fan.zhang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 08:22:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 08:22:15 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH v6 4/8] lib/librte_vhost: add request handler X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 08:22:16 -0000 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.