From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7677DA056E; Wed, 11 Mar 2020 13:28:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5BE0B1C020; Wed, 11 Mar 2020 13:28:19 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id C45FD1BFA5 for ; Wed, 11 Mar 2020 13:28:15 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 05:28:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,540,1574150400"; d="scan'208";a="277356877" Received: from adamdybx-mobl.ger.corp.intel.com (HELO addy-VirtualBox.ger.corp.intel.com) ([10.104.121.4]) by fmsmga002.fm.intel.com with ESMTP; 11 Mar 2020 05:28:12 -0700 From: Adam Dybkowski To: dev@dpdk.org, fiona.trahe@intel.com, akhil.goyal@nxp.com, adamx.dybkowski@intel.com Date: Wed, 11 Mar 2020 13:26:08 +0100 Message-Id: <20200311122608.1262-3-adamx.dybkowski@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311122608.1262-1-adamx.dybkowski@intel.com> References: <20200311122608.1262-1-adamx.dybkowski@intel.com> Subject: [dpdk-dev] [PATCH 3/3] common/qat: optimise calculation of cookie index 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" From: Fiona Trahe Avoid costly division, use shift instead. Signed-off-by: Fiona Trahe --- drivers/common/qat/qat_qp.c | 9 ++++++--- drivers/common/qat/qat_qp.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c index 9958789f0..b0a206434 100644 --- a/drivers/common/qat/qat_qp.c +++ b/drivers/common/qat/qat_qp.c @@ -430,6 +430,9 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue, queue->tail = 0; queue->msg_size = desc_size; + /* For fast calculation of cookie index, relies on msg_size being 2^n */ + queue->trailz = __builtin_ctz(desc_size); + /* * Write an unused pattern to the queue memory. */ @@ -623,7 +626,7 @@ qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops) while (nb_ops_sent != nb_ops_possible) { ret = tmp_qp->build_request(*ops, base_addr + tail, - tmp_qp->op_cookies[tail / queue->msg_size], + tmp_qp->op_cookies[tail >> queue->trailz], tmp_qp->qat_dev_gen); if (ret != 0) { tmp_qp->stats.enqueue_err_count++; @@ -665,12 +668,12 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops) qat_sym_process_response(ops, resp_msg); else if (tmp_qp->service_type == QAT_SERVICE_COMPRESSION) qat_comp_process_response(ops, resp_msg, - tmp_qp->op_cookies[head / rx_queue->msg_size], + tmp_qp->op_cookies[head >> rx_queue->trailz], &tmp_qp->stats.dequeue_err_count); else if (tmp_qp->service_type == QAT_SERVICE_ASYMMETRIC) { #ifdef BUILD_QAT_ASYM qat_asym_process_response(ops, resp_msg, - tmp_qp->op_cookies[head / rx_queue->msg_size]); + tmp_qp->op_cookies[head >> rx_queue->trailz]); #endif } diff --git a/drivers/common/qat/qat_qp.h b/drivers/common/qat/qat_qp.h index 0b95ea3c9..0d6896d7b 100644 --- a/drivers/common/qat/qat_qp.h +++ b/drivers/common/qat/qat_qp.h @@ -54,6 +54,7 @@ struct qat_queue { uint32_t modulo_mask; uint32_t msg_size; uint32_t queue_size; + uint8_t trailz; uint8_t hw_bundle_number; uint8_t hw_queue_number; /* HW queue aka ring offset on bundle */ -- 2.17.1