From: Fiona Trahe Date: Wed, 11 Mar 2020 12:26:08 +0000 (+0100) Subject: common/qat: optimise calculation of cookie index X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dda27cb3c1b7de2062c273ad46e0dfefc9e6a80c;p=dpdk.git common/qat: optimise calculation of cookie index Avoid costly division, use shift instead. Signed-off-by: Fiona Trahe Acked-by: Arek Kusztal --- diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c index 9958789f08..b0a2064344 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 0b95ea3c93..0d6896d7bd 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 */