From patchwork Wed Apr 4 17:03:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhoujian (jay)" X-Patchwork-Id: 37186 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A35D61C819; Wed, 4 Apr 2018 19:04:26 +0200 (CEST) Received: from huawei.com (unknown [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 3BD531C80F for ; Wed, 4 Apr 2018 19:04:23 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 70B798D261638; Thu, 5 Apr 2018 01:04:20 +0800 (CST) Received: from localhost (10.177.19.14) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.361.1; Thu, 5 Apr 2018 01:04:12 +0800 From: Jay Zhou To: CC: , , , , , , , , Date: Thu, 5 Apr 2018 01:03:38 +0800 Message-ID: X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.177.19.14] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v7 07/10] crypto/virtio: support AES-CBC 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The AES-CBC cipher only algorithm has been supported now. Signed-off-by: Jay Zhou Reviewed-by: Fan Zhang Acked-by: Fan Zhang --- drivers/crypto/virtio/virtio_crypto_capabilities.h | 30 ++++++++++++++++++++++ drivers/crypto/virtio/virtio_cryptodev.c | 11 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 drivers/crypto/virtio/virtio_crypto_capabilities.h diff --git a/drivers/crypto/virtio/virtio_crypto_capabilities.h b/drivers/crypto/virtio/virtio_crypto_capabilities.h new file mode 100644 index 0000000..db6932f --- /dev/null +++ b/drivers/crypto/virtio/virtio_crypto_capabilities.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD. + */ + +#ifndef _VIRTIO_CRYPTO_CAPABILITIES_H_ +#define _VIRTIO_CRYPTO_CAPABILITIES_H_ + +#define VIRTIO_SYM_CAPABILITIES \ + { /* AES CBC */ \ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, \ + {.sym = { \ + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, \ + {.cipher = { \ + .algo = RTE_CRYPTO_CIPHER_AES_CBC, \ + .block_size = 16, \ + .key_size = { \ + .min = 16, \ + .max = 32, \ + .increment = 8 \ + }, \ + .iv_size = { \ + .min = 16, \ + .max = 16, \ + .increment = 0 \ + } \ + }, } \ + }, } \ + } + +#endif /* _VIRTIO_CRYPTO_CAPABILITIES_H_ */ diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index 0ab0d38..209f639 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.c +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -15,6 +15,7 @@ #include "virtio_cryptodev.h" #include "virtqueue.h" #include "virtio_crypto_algs.h" +#include "virtio_crypto_capabilities.h" int virtio_crypto_logtype_init; int virtio_crypto_logtype_session; @@ -58,6 +59,11 @@ static int virtio_crypto_sym_configure_session(struct rte_cryptodev *dev, { .vendor_id = 0, /* sentinel */ }, }; +static const struct rte_cryptodev_capabilities virtio_capabilities[] = { + VIRTIO_SYM_CAPABILITIES, + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + uint8_t cryptodev_virtio_driver_id; #define NUM_ENTRY_SYM_CREATE_SESSION 4 @@ -744,6 +750,7 @@ int virtio_crypto_queue_setup(struct rte_cryptodev *dev, hw = cryptodev->data->dev_private; hw->dev_id = cryptodev->data->dev_id; + hw->virtio_dev_capabilities = virtio_capabilities; VIRTIO_CRYPTO_INIT_LOG_DBG("dev %d vendorID=0x%x deviceID=0x%x", cryptodev->data->dev_id, pci_dev->id.vendor_id, @@ -1131,6 +1138,9 @@ static int virtio_crypto_sym_pad_cipher_param( struct rte_crypto_cipher_xform *cipher_xform) { switch (cipher_xform->algo) { + case RTE_CRYPTO_CIPHER_AES_CBC: + para->algo = VIRTIO_CRYPTO_CIPHER_AES_CBC; + break; default: VIRTIO_CRYPTO_SESSION_LOG_ERR("Crypto: Unsupported " "Cipher alg %u", cipher_xform->algo); @@ -1390,6 +1400,7 @@ static int virtio_crypto_sym_configure_session( info->max_nb_queue_pairs = hw->max_dataqueues; info->sym.max_nb_sessions = RTE_VIRTIO_CRYPTO_PMD_MAX_NB_SESSIONS; + info->capabilities = hw->virtio_dev_capabilities; } }