crypto/qat: optimize ADF modulo function
authorFiona Trahe <fiona.trahe@intel.com>
Wed, 13 Jun 2018 12:14:17 +0000 (14:14 +0200)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 27 Jun 2018 23:25:33 +0000 (01:25 +0200)
Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
drivers/crypto/qat/qat_qp.c
drivers/crypto/qat/qat_qp.h

index 569eace..b84ba64 100644 (file)
@@ -376,7 +376,7 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
 
        queue->max_inflights = ADF_MAX_INFLIGHTS(queue->queue_size,
                                        ADF_BYTES_TO_MSG_SIZE(desc_size));
-       queue->modulo = ADF_RING_SIZE_MODULO(queue->queue_size);
+       queue->modulo_mask = (1 << ADF_RING_SIZE_MODULO(queue->queue_size)) - 1;
 
        if (queue->max_inflights < 2) {
                PMD_DRV_LOG(ERR, "Invalid num inflights");
@@ -401,11 +401,11 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
                        queue->hw_queue_number, queue_base);
 
        PMD_DRV_LOG(DEBUG, "RING: Name:%s, size in CSR: %u, in bytes %u,"
-                       " nb msgs %u, msg_size %u, max_inflights %u modulo %u",
+               " nb msgs %u, msg_size %u, max_inflights %u modulo mask %u",
                        queue->memz_name,
                        queue->queue_size, queue_size_bytes,
                        qp_conf->nb_descriptors, desc_size,
-                       queue->max_inflights, queue->modulo);
+                       queue->max_inflights, queue->modulo_mask);
 
        return 0;
 
@@ -494,13 +494,9 @@ static void adf_configure_queues(struct qat_qp *qp)
                        queue->hw_queue_number, queue_config);
 }
 
-
-static inline uint32_t adf_modulo(uint32_t data, uint32_t shift)
+static inline uint32_t adf_modulo(uint32_t data, uint32_t modulo_mask)
 {
-       uint32_t div = data >> shift;
-       uint32_t mult = div << shift;
-
-       return data - mult;
+       return data & modulo_mask;
 }
 
 static inline void
@@ -584,7 +580,7 @@ qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops)
                        goto kick_tail;
                }
 
-               tail = adf_modulo(tail + queue->msg_size, queue->modulo);
+               tail = adf_modulo(tail + queue->msg_size, queue->modulo_mask);
                ops++;
                nb_ops_sent++;
        }
@@ -620,7 +616,8 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
                        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);
+               head = adf_modulo(head + rx_queue->msg_size,
+                                 rx_queue->modulo_mask);
 
                resp_msg = (uint8_t *)rx_queue->base_addr + head;
                ops++;
index 6f07bd6..764125d 100644 (file)
@@ -59,7 +59,7 @@ struct qat_queue {
        rte_iova_t      base_phys_addr;         /* Queue physical address */
        uint32_t        head;                   /* Shadow copy of the head */
        uint32_t        tail;                   /* Shadow copy of the tail */
-       uint32_t        modulo;
+       uint32_t        modulo_mask;
        uint32_t        msg_size;
        uint16_t        max_inflights;
        uint32_t        queue_size;