From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9D8851CEE6 for ; Fri, 6 Apr 2018 20:52:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2018 11:52:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,416,1517904000"; d="scan'208";a="189275705" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga004.jf.intel.com with ESMTP; 06 Apr 2018 11:52:34 -0700 From: Fiona Trahe To: dev@dpdk.org, pablo.de.lara.guarch@intel.com Cc: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com Date: Fri, 6 Apr 2018 19:51:55 +0100 Message-Id: <1523040732-3290-14-git-send-email-fiona.trahe@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> References: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> Subject: [dpdk-dev] [PATCH 13/30] crypto/qat: move sym-specific qp code to sym file 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: Fri, 06 Apr 2018 18:52:37 -0000 Move sym qp setup code from qat_qp.c to qat_sym.c Signed-off-by: Fiona Trahe --- drivers/crypto/qat/qat_qp.c | 78 ++------------------------------------------ drivers/crypto/qat/qat_qp.h | 6 ++++ drivers/crypto/qat/qat_sym.c | 75 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 75 deletions(-) diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c index caec4ea4c..947090580 100644 --- a/drivers/crypto/qat/qat_qp.c +++ b/drivers/crypto/qat/qat_qp.c @@ -20,11 +20,7 @@ #define ADF_MAX_DESC 4096 #define ADF_MIN_DESC 128 -#define ADF_SYM_TX_RING_DESC_SIZE 128 -#define ADF_SYM_RX_RING_DESC_SIZE 32 -#define ADF_SYM_TX_QUEUE_STARTOFF 2 -/* Offset from bundle start to 1st Sym Tx queue */ -#define ADF_SYM_RX_QUEUE_STARTOFF 10 + #define ADF_ARB_REG_SLOT 0x1000 #define ADF_ARB_RINGSRVARBEN_OFFSET 0x19C @@ -93,7 +89,7 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size, memzone_flags, queue_size); } -static int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id, +int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id, struct qat_qp_config *qat_qp_conf) { struct qat_qp *qp; @@ -192,71 +188,7 @@ static int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id, return -EFAULT; } - - -int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, - const struct rte_cryptodev_qp_conf *qp_conf, - int socket_id, struct rte_mempool *session_pool __rte_unused) -{ - struct qat_qp *qp; - int ret = 0; - uint32_t i; - struct qat_qp_config qat_qp_conf; - - /* If qp is already in use free ring memory and qp metadata. */ - if (dev->data->queue_pairs[qp_id] != NULL) { - ret = qat_sym_qp_release(dev, qp_id); - if (ret < 0) - return ret; - } - if (qp_id >= (ADF_NUM_SYM_QPS_PER_BUNDLE * - ADF_NUM_BUNDLES_PER_DEV)) { - PMD_DRV_LOG(ERR, "qp_id %u invalid for this device", qp_id); - return -EINVAL; - } - - - qat_qp_conf.hw_bundle_num = (qp_id/ADF_NUM_SYM_QPS_PER_BUNDLE); - qat_qp_conf.tx_ring_num = (qp_id%ADF_NUM_SYM_QPS_PER_BUNDLE) + - ADF_SYM_TX_QUEUE_STARTOFF; - qat_qp_conf.rx_ring_num = (qp_id%ADF_NUM_SYM_QPS_PER_BUNDLE) + - ADF_SYM_RX_QUEUE_STARTOFF; - qat_qp_conf.tx_msg_size = ADF_SYM_TX_RING_DESC_SIZE; - qat_qp_conf.rx_msg_size = ADF_SYM_RX_RING_DESC_SIZE; - qat_qp_conf.build_request = qat_sym_build_request; - qat_qp_conf.process_response = qat_sym_process_response; - qat_qp_conf.cookie_size = sizeof(struct qat_sym_op_cookie); - qat_qp_conf.nb_descriptors = qp_conf->nb_descriptors; - qat_qp_conf.socket_id = socket_id; - qat_qp_conf.service_str = "sym"; - - ret = qat_qp_setup(dev, qp_id, &qat_qp_conf); - if (ret != 0) - return ret; - - qp = (struct qat_qp *)dev->data->queue_pairs[qp_id]; - - for (i = 0; i < qp->nb_descriptors; i++) { - - struct qat_sym_op_cookie *sql_cookie = - qp->op_cookies[i]; - - sql_cookie->qat_sgl_src_phys_addr = - rte_mempool_virt2iova(sql_cookie) + - offsetof(struct qat_sym_op_cookie, - qat_sgl_list_src); - - sql_cookie->qat_sgl_dst_phys_addr = - rte_mempool_virt2iova(sql_cookie) + - offsetof(struct qat_sym_op_cookie, - qat_sgl_list_dst); - } - - return ret; - -} - -static int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) +int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) { struct qat_qp *qp = (struct qat_qp *)dev->data->queue_pairs[queue_pair_id]; @@ -291,10 +223,6 @@ static int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) } -int qat_sym_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) -{ - return qat_qp_release(dev, queue_pair_id); -} static void qat_queue_delete(struct qat_queue *queue) diff --git a/drivers/crypto/qat/qat_qp.h b/drivers/crypto/qat/qat_qp.h index edebb8773..0cdf37f61 100644 --- a/drivers/crypto/qat/qat_qp.h +++ b/drivers/crypto/qat/qat_qp.h @@ -77,4 +77,10 @@ qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops); uint16_t qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops); +int +qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id); + +int +qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id, + struct qat_qp_config *qat_qp_conf); #endif /* _QAT_QP_H_ */ diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index ab8ce2c96..4f86f2258 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -23,6 +23,12 @@ */ #define BPI_MAX_ENCR_IV_LEN ICP_QAT_HW_AES_BLK_SZ +#define ADF_SYM_TX_RING_DESC_SIZE 128 +#define ADF_SYM_RX_RING_DESC_SIZE 32 +#define ADF_SYM_TX_QUEUE_STARTOFF 2 +/* Offset from bundle start to 1st Sym Tx queue */ +#define ADF_SYM_RX_QUEUE_STARTOFF 10 + /** Encrypt a single partial block * Depends on openssl libcrypto * Uses ECB+XOR to do CFB encryption, same result, more performant @@ -798,3 +804,72 @@ void qat_sym_stats_reset(struct rte_cryptodev *dev) memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats)); PMD_DRV_LOG(DEBUG, "QAT crypto: stats cleared"); } + + + +int qat_sym_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) +{ + return qat_qp_release(dev, queue_pair_id); +} + +int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, + const struct rte_cryptodev_qp_conf *qp_conf, + int socket_id, struct rte_mempool *session_pool __rte_unused) +{ + struct qat_qp *qp; + int ret = 0; + uint32_t i; + struct qat_qp_config qat_qp_conf; + + /* If qp is already in use free ring memory and qp metadata. */ + if (dev->data->queue_pairs[qp_id] != NULL) { + ret = qat_sym_qp_release(dev, qp_id); + if (ret < 0) + return ret; + } + if (qp_id >= (ADF_NUM_SYM_QPS_PER_BUNDLE * + ADF_NUM_BUNDLES_PER_DEV)) { + PMD_DRV_LOG(ERR, "qp_id %u invalid for this device", qp_id); + return -EINVAL; + } + + + qat_qp_conf.hw_bundle_num = (qp_id/ADF_NUM_SYM_QPS_PER_BUNDLE); + qat_qp_conf.tx_ring_num = (qp_id%ADF_NUM_SYM_QPS_PER_BUNDLE) + + ADF_SYM_TX_QUEUE_STARTOFF; + qat_qp_conf.rx_ring_num = (qp_id%ADF_NUM_SYM_QPS_PER_BUNDLE) + + ADF_SYM_RX_QUEUE_STARTOFF; + qat_qp_conf.tx_msg_size = ADF_SYM_TX_RING_DESC_SIZE; + qat_qp_conf.rx_msg_size = ADF_SYM_RX_RING_DESC_SIZE; + qat_qp_conf.build_request = qat_sym_build_request; + qat_qp_conf.process_response = qat_sym_process_response; + qat_qp_conf.cookie_size = sizeof(struct qat_sym_op_cookie); + qat_qp_conf.nb_descriptors = qp_conf->nb_descriptors; + qat_qp_conf.socket_id = socket_id; + qat_qp_conf.service_str = "sym"; + + ret = qat_qp_setup(dev, qp_id, &qat_qp_conf); + if (ret != 0) + return ret; + + qp = (struct qat_qp *)dev->data->queue_pairs[qp_id]; + + for (i = 0; i < qp->nb_descriptors; i++) { + + struct qat_sym_op_cookie *sql_cookie = + qp->op_cookies[i]; + + sql_cookie->qat_sgl_src_phys_addr = + rte_mempool_virt2iova(sql_cookie) + + offsetof(struct qat_sym_op_cookie, + qat_sgl_list_src); + + sql_cookie->qat_sgl_dst_phys_addr = + rte_mempool_virt2iova(sql_cookie) + + offsetof(struct qat_sym_op_cookie, + qat_sgl_list_dst); + } + + return ret; + +} -- 2.13.6