From: Adam Dybkowski <adamx.dybkowski@intel.com>
To: dev@dpdk.org, fiona.trahe@intel.com, akhil.goyal@nxp.com,
adamx.dybkowski@intel.com
Subject: [dpdk-dev] [PATCH 3/3] common/qat: optimise calculation of cookie index
Date: Wed, 11 Mar 2020 13:26:08 +0100 [thread overview]
Message-ID: <20200311122608.1262-3-adamx.dybkowski@intel.com> (raw)
In-Reply-To: <20200311122608.1262-1-adamx.dybkowski@intel.com>
From: Fiona Trahe <fiona.trahe@intel.com>
Avoid costly division, use shift instead.
Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
---
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
next prev parent reply other threads:[~2020-03-11 12:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 12:26 [dpdk-dev] [PATCH 1/3] crypto/qat: improve out-of-place conditional check Adam Dybkowski
2020-03-11 12:26 ` [dpdk-dev] [PATCH 2/3] crypto/qat: optimise check for chained mbufs Adam Dybkowski
2020-03-11 15:44 ` Kusztal, ArkadiuszX
2020-03-11 12:26 ` Adam Dybkowski [this message]
2020-03-11 15:44 ` [dpdk-dev] [PATCH 3/3] common/qat: optimise calculation of cookie index Kusztal, ArkadiuszX
2020-03-11 15:45 ` [dpdk-dev] [PATCH 1/3] crypto/qat: improve out-of-place conditional check Kusztal, ArkadiuszX
2020-03-25 19:06 ` Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200311122608.1262-3-adamx.dybkowski@intel.com \
--to=adamx.dybkowski@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).