net/bnx2x: fix invalid free on unplug
[dpdk.git] / drivers / common / qat / qat_qp.c
index 32c1759..1312152 100644 (file)
@@ -15,6 +15,8 @@
 #include "qat_device.h"
 #include "qat_qp.h"
 #include "qat_sym.h"
+#include "qat_asym.h"
+#include "qat_comp.h"
 #include "adf_transport_access_macros.h"
 
 
@@ -89,6 +91,44 @@ const struct qat_qp_hw_data qat_gen1_qps[QAT_MAX_SERVICES]
        }
 };
 
+__extension__
+const struct qat_qp_hw_data qat_gen3_qps[QAT_MAX_SERVICES]
+                                        [ADF_MAX_QPS_ON_ANY_SERVICE] = {
+       /* queue pairs which provide an asymmetric crypto service */
+       [QAT_SERVICE_ASYMMETRIC] = {
+               {
+                       .service_type = QAT_SERVICE_ASYMMETRIC,
+                       .hw_bundle_num = 0,
+                       .tx_ring_num = 0,
+                       .rx_ring_num = 4,
+                       .tx_msg_size = 64,
+                       .rx_msg_size = 32,
+               }
+       },
+       /* queue pairs which provide a symmetric crypto service */
+       [QAT_SERVICE_SYMMETRIC] = {
+               {
+                       .service_type = QAT_SERVICE_SYMMETRIC,
+                       .hw_bundle_num = 0,
+                       .tx_ring_num = 1,
+                       .rx_ring_num = 5,
+                       .tx_msg_size = 128,
+                       .rx_msg_size = 32,
+               }
+       },
+       /* queue pairs which provide a compression service */
+       [QAT_SERVICE_COMPRESSION] = {
+               {
+                       .service_type = QAT_SERVICE_COMPRESSION,
+                       .hw_bundle_num = 0,
+                       .tx_ring_num = 3,
+                       .rx_ring_num = 7,
+                       .tx_msg_size = 128,
+                       .rx_msg_size = 32,
+               }
+       }
+};
+
 static int qat_qp_check_queue_alignment(uint64_t phys_addr,
        uint32_t queue_size_bytes);
 static void qat_queue_delete(struct qat_queue *queue);
@@ -172,16 +212,17 @@ int qat_qp_setup(struct qat_pci_device *qat_dev,
        }
 
        /* Allocate the queue pair data structure. */
-       qp = rte_zmalloc("qat PMD qp metadata",
-                       sizeof(*qp), RTE_CACHE_LINE_SIZE);
+       qp = rte_zmalloc_socket("qat PMD qp metadata",
+                               sizeof(*qp), RTE_CACHE_LINE_SIZE,
+                               qat_qp_conf->socket_id);
        if (qp == NULL) {
                QAT_LOG(ERR, "Failed to alloc mem for qp struct");
                return -ENOMEM;
        }
        qp->nb_descriptors = qat_qp_conf->nb_descriptors;
-       qp->op_cookies = rte_zmalloc("qat PMD op cookie pointer",
+       qp->op_cookies = rte_zmalloc_socket("qat PMD op cookie pointer",
                        qat_qp_conf->nb_descriptors * sizeof(*qp->op_cookies),
-                       RTE_CACHE_LINE_SIZE);
+                       RTE_CACHE_LINE_SIZE, qat_qp_conf->socket_id);
        if (qp->op_cookies == NULL) {
                QAT_LOG(ERR, "Failed to alloc mem for cookie");
                rte_free(qp);
@@ -221,7 +262,8 @@ int qat_qp_setup(struct qat_pci_device *qat_dev,
                qp->op_cookie_pool = rte_mempool_create(op_cookie_pool_name,
                                qp->nb_descriptors,
                                qat_qp_conf->cookie_size, 64, 0,
-                               NULL, NULL, NULL, NULL, qat_qp_conf->socket_id,
+                               NULL, NULL, NULL, NULL,
+                               qat_dev->pci_dev->device.numa_node,
                                0);
        if (!qp->op_cookie_pool) {
                QAT_LOG(ERR, "QAT PMD Cannot create"
@@ -234,6 +276,7 @@ int qat_qp_setup(struct qat_pci_device *qat_dev,
                        QAT_LOG(ERR, "QAT PMD Cannot get op_cookie");
                        goto create_err;
                }
+               memset(qp->op_cookies[i], 0, qat_qp_conf->cookie_size);
        }
 
        qp->qat_dev_gen = qat_dev->qat_dev_gen;
@@ -349,7 +392,7 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
                qp_conf->service_str, "qp_mem",
                queue->hw_bundle_number, queue->hw_queue_number);
        qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,
-                       qp_conf->socket_id);
+                       qat_dev->pci_dev->device.numa_node);
        if (qp_mz == NULL) {
                QAT_LOG(ERR, "Failed to allocate ring memzone");
                return -ENOMEM;
@@ -606,8 +649,15 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
                if (tmp_qp->service_type == QAT_SERVICE_SYMMETRIC)
                        qat_sym_process_response(ops, resp_msg);
-               /* add qat_asym_process_response here */
-               /* add qat_comp_process_response here */
+               else if (tmp_qp->service_type == QAT_SERVICE_COMPRESSION)
+                       qat_comp_process_response(ops, resp_msg,
+                                       &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]);
+#endif
+               }
 
                head = adf_modulo(head + rx_queue->msg_size,
                                  rx_queue->modulo_mask);
@@ -633,3 +683,10 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
        }
        return resp_counter;
 }
+
+__rte_weak int
+qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused,
+                         uint64_t *dequeue_err_count __rte_unused)
+{
+       return  0;
+}