From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 1C5D31C17C for ; Fri, 11 May 2018 13:15:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2018 04:15:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,388,1520924400"; d="scan'208";a="40443841" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga008.jf.intel.com with ESMTP; 11 May 2018 04:15:32 -0700 From: Fiona Trahe To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com Date: Fri, 11 May 2018 12:13:47 +0100 Message-Id: <1526037249-25545-10-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 v2 09/31] crypto/qat: make dequeue function generic 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, 11 May 2018 11:15:34 -0000 Queue-handling code in dequeue is made generic, so it can be used by other services in future. This is done by - Removing all sym-specific refs in input params - replace with void ptrs. - Wrapping this generic dequeue with the sym-specific dequeue called through the API. - extracting the sym-specific response processing into a new fn. - Setting a fn ptr for process_response in qp on qp creation - Passing void * params to this, in the service-specific implementation qat_sym_process_response cast back to sym structs. Signed-off-by: Fiona Trahe --- drivers/crypto/qat/qat_qp.c | 1 + drivers/crypto/qat/qat_sym.c | 101 ++++++++++++++++++++++++++----------------- drivers/crypto/qat/qat_sym.h | 10 +++++ 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c index d7d79f1af..bae6cf114 100644 --- a/drivers/crypto/qat/qat_qp.c +++ b/drivers/crypto/qat/qat_qp.c @@ -198,6 +198,7 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id, = dev->data->dev_private; qp->qat_dev_gen = internals->qat_dev_gen; qp->build_request = qat_sym_build_request; + qp->process_response = qat_sym_process_response; dev->data->queue_pairs[queue_pair_id] = qp; return 0; diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index 4e404749a..2bae913a1 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -300,70 +300,91 @@ qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops, return qat_enqueue_op_burst(qp, (void **)ops, nb_ops); } -uint16_t -qat_sym_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops, - uint16_t nb_ops) +int +qat_sym_process_response(void **op, uint8_t *resp, + __rte_unused void *op_cookie, + __rte_unused enum qat_device_gen qat_dev_gen) +{ + + struct icp_qat_fw_comn_resp *resp_msg = + (struct icp_qat_fw_comn_resp *)resp; + struct rte_crypto_op *rx_op = (struct rte_crypto_op *)(uintptr_t) + (resp_msg->opaque_data); + +#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX + rte_hexdump(stdout, "qat_response:", (uint8_t *)resp_msg, + sizeof(struct icp_qat_fw_comn_resp)); +#endif + + if (ICP_QAT_FW_COMN_STATUS_FLAG_OK != + ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET( + resp_msg->comn_hdr.comn_status)) { + + rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; + } else { + struct qat_sym_session *sess = (struct qat_sym_session *) + get_session_private_data( + rx_op->sym->session, + cryptodev_qat_driver_id); + + if (sess->bpi_ctx) + qat_bpicipher_postprocess(sess, rx_op); + rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS; + } + *op = (void *)rx_op; + + return 0; +} + +static uint16_t +qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops) { struct qat_queue *rx_queue, *tx_queue; struct qat_qp *tmp_qp = (struct qat_qp *)qp; - uint32_t msg_counter = 0; - struct rte_crypto_op *rx_op; - struct icp_qat_fw_comn_resp *resp_msg; uint32_t head; + uint32_t resp_counter = 0; + uint8_t *resp_msg; rx_queue = &(tmp_qp->rx_q); tx_queue = &(tmp_qp->tx_q); head = rx_queue->head; - resp_msg = (struct icp_qat_fw_comn_resp *) - ((uint8_t *)rx_queue->base_addr + head); + resp_msg = (uint8_t *)rx_queue->base_addr + rx_queue->head; while (*(uint32_t *)resp_msg != ADF_RING_EMPTY_SIG && - msg_counter != nb_ops) { - rx_op = (struct rte_crypto_op *)(uintptr_t) - (resp_msg->opaque_data); - -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX - rte_hexdump(stdout, "qat_response:", (uint8_t *)resp_msg, - sizeof(struct icp_qat_fw_comn_resp)); -#endif - if (ICP_QAT_FW_COMN_STATUS_FLAG_OK != - ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET( - resp_msg->comn_hdr.comn_status)) { - rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; - } else { - struct qat_sym_session *sess = - (struct qat_sym_session *) - get_session_private_data( - rx_op->sym->session, - cryptodev_qat_driver_id); + resp_counter != nb_ops) { - if (sess->bpi_ctx) - qat_bpicipher_postprocess(sess, rx_op); - rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS; - } + tmp_qp->process_response(ops, resp_msg, + tmp_qp->op_cookies[head / rx_queue->msg_size], + tmp_qp->qat_dev_gen); head = adf_modulo(head + rx_queue->msg_size, rx_queue->modulo); - resp_msg = (struct icp_qat_fw_comn_resp *) - ((uint8_t *)rx_queue->base_addr + head); - *ops = rx_op; + + resp_msg = (uint8_t *)rx_queue->base_addr + head; ops++; - msg_counter++; + resp_counter++; } - if (msg_counter > 0) { + if (resp_counter > 0) { rx_queue->head = head; - tmp_qp->stats.dequeued_count += msg_counter; - rx_queue->nb_processed_responses += msg_counter; - tmp_qp->inflights16 -= msg_counter; + tmp_qp->stats.dequeued_count += resp_counter; + rx_queue->nb_processed_responses += resp_counter; + tmp_qp->inflights16 -= resp_counter; if (rx_queue->nb_processed_responses > QAT_CSR_HEAD_WRITE_THRESH) rxq_free_desc(tmp_qp, rx_queue); } /* also check if tail needs to be advanced */ if (tmp_qp->inflights16 <= QAT_CSR_TAIL_FORCE_WRITE_THRESH && - tx_queue->tail != tx_queue->csr_tail) { + tx_queue->tail != tx_queue->csr_tail) { txq_write_tail(tmp_qp, tx_queue); } - return msg_counter; + return resp_counter; +} + +uint16_t +qat_sym_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops, + uint16_t nb_ops) +{ + return qat_dequeue_op_burst(qp, (void **)ops, nb_ops); } static inline int diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index b1ddb6e93..279d3a3ae 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -32,6 +32,11 @@ typedef int (*build_request_t)(void *op, enum qat_device_gen qat_dev_gen); /**< Build a request from an op. */ +typedef int (*process_response_t)(void **ops, + uint8_t *resp, void *op_cookie, + enum qat_device_gen qat_dev_gen); +/**< Process a response descriptor and return the associated op. */ + struct qat_sym_session; /** @@ -69,6 +74,7 @@ struct qat_qp { uint32_t nb_descriptors; enum qat_device_gen qat_dev_gen; build_request_t build_request; + process_response_t process_response; } __rte_cache_aligned; @@ -76,6 +82,10 @@ int qat_sym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie, enum qat_device_gen qat_dev_gen); +int +qat_sym_process_response(void **op, uint8_t *resp, + __rte_unused void *op_cookie, enum qat_device_gen qat_dev_gen); + void qat_sym_stats_get(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats); void qat_sym_stats_reset(struct rte_cryptodev *dev); -- 2.13.6