1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 Intel Corporation
5 #include <rte_malloc.h>
8 #include "qat_comp_pmd.h"
10 #define QAT_PMD_COMP_SGL_DEF_SEGMENTS 16
12 struct stream_create_info {
13 struct qat_comp_dev_private *comp_dev;
18 static const struct rte_compressdev_capabilities qat_comp_gen_capabilities[] = {
19 {/* COMPRESSION - deflate */
20 .algo = RTE_COMP_ALGO_DEFLATE,
21 .comp_feature_flags = RTE_COMP_FF_MULTI_PKT_CHECKSUM |
22 RTE_COMP_FF_CRC32_CHECKSUM |
23 RTE_COMP_FF_ADLER32_CHECKSUM |
24 RTE_COMP_FF_CRC32_ADLER32_CHECKSUM |
25 RTE_COMP_FF_SHAREABLE_PRIV_XFORM |
26 RTE_COMP_FF_HUFFMAN_FIXED |
27 RTE_COMP_FF_HUFFMAN_DYNAMIC |
28 RTE_COMP_FF_OOP_SGL_IN_SGL_OUT |
29 RTE_COMP_FF_OOP_SGL_IN_LB_OUT |
30 RTE_COMP_FF_OOP_LB_IN_SGL_OUT |
31 RTE_COMP_FF_STATEFUL_DECOMPRESSION,
32 .window_size = {.min = 15, .max = 15, .increment = 0} },
33 {RTE_COMP_ALGO_LIST_END, 0, {0, 0, 0} } };
36 qat_comp_stats_get(struct rte_compressdev *dev,
37 struct rte_compressdev_stats *stats)
39 struct qat_common_stats qat_stats = {0};
40 struct qat_comp_dev_private *qat_priv;
42 if (stats == NULL || dev == NULL) {
43 QAT_LOG(ERR, "invalid ptr: stats %p, dev %p", stats, dev);
46 qat_priv = dev->data->dev_private;
48 qat_stats_get(qat_priv->qat_dev, &qat_stats, QAT_SERVICE_COMPRESSION);
49 stats->enqueued_count = qat_stats.enqueued_count;
50 stats->dequeued_count = qat_stats.dequeued_count;
51 stats->enqueue_err_count = qat_stats.enqueue_err_count;
52 stats->dequeue_err_count = qat_stats.dequeue_err_count;
56 qat_comp_stats_reset(struct rte_compressdev *dev)
58 struct qat_comp_dev_private *qat_priv;
61 QAT_LOG(ERR, "invalid compressdev ptr %p", dev);
64 qat_priv = dev->data->dev_private;
66 qat_stats_reset(qat_priv->qat_dev, QAT_SERVICE_COMPRESSION);
71 qat_comp_qp_release(struct rte_compressdev *dev, uint16_t queue_pair_id)
73 struct qat_comp_dev_private *qat_private = dev->data->dev_private;
74 struct qat_qp **qp_addr =
75 (struct qat_qp **)&(dev->data->queue_pairs[queue_pair_id]);
76 struct qat_qp *qp = (struct qat_qp *)*qp_addr;
79 QAT_LOG(DEBUG, "Release comp qp %u on device %d",
80 queue_pair_id, dev->data->dev_id);
82 qat_private->qat_dev->qps_in_use[QAT_SERVICE_COMPRESSION][queue_pair_id]
85 for (i = 0; i < qp->nb_descriptors; i++) {
87 struct qat_comp_op_cookie *cookie = qp->op_cookies[i];
89 rte_free(cookie->qat_sgl_src_d);
90 rte_free(cookie->qat_sgl_dst_d);
93 return qat_qp_release((struct qat_qp **)
94 &(dev->data->queue_pairs[queue_pair_id]));
98 qat_comp_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
99 uint32_t max_inflight_ops, int socket_id)
104 struct qat_qp_config qat_qp_conf;
106 struct qat_qp **qp_addr =
107 (struct qat_qp **)&(dev->data->queue_pairs[qp_id]);
108 struct qat_comp_dev_private *qat_private = dev->data->dev_private;
109 const struct qat_qp_hw_data *comp_hw_qps =
110 qat_gen_config[qat_private->qat_dev->qat_dev_gen]
111 .qp_hw_data[QAT_SERVICE_COMPRESSION];
112 const struct qat_qp_hw_data *qp_hw_data = comp_hw_qps + qp_id;
114 /* If qp is already in use free ring memory and qp metadata. */
115 if (*qp_addr != NULL) {
116 ret = qat_comp_qp_release(dev, qp_id);
120 if (qp_id >= qat_qps_per_service(comp_hw_qps,
121 QAT_SERVICE_COMPRESSION)) {
122 QAT_LOG(ERR, "qp_id %u invalid for this device", qp_id);
126 qat_qp_conf.hw = qp_hw_data;
127 qat_qp_conf.build_request = qat_comp_build_request;
128 qat_qp_conf.cookie_size = sizeof(struct qat_comp_op_cookie);
129 qat_qp_conf.nb_descriptors = max_inflight_ops;
130 qat_qp_conf.socket_id = socket_id;
131 qat_qp_conf.service_str = "comp";
133 ret = qat_qp_setup(qat_private->qat_dev, qp_addr, qp_id, &qat_qp_conf);
137 /* store a link to the qp in the qat_pci_device */
138 qat_private->qat_dev->qps_in_use[QAT_SERVICE_COMPRESSION][qp_id]
141 qp = (struct qat_qp *)*qp_addr;
142 qp->min_enq_burst_threshold = qat_private->min_enq_burst_threshold;
144 for (i = 0; i < qp->nb_descriptors; i++) {
146 struct qat_comp_op_cookie *cookie =
150 cookie->cookie_index = i;
152 cookie->qat_sgl_src_d = rte_zmalloc_socket(NULL,
153 sizeof(struct qat_sgl) +
154 sizeof(struct qat_flat_buf) *
155 QAT_PMD_COMP_SGL_DEF_SEGMENTS,
156 64, dev->data->socket_id);
158 cookie->qat_sgl_dst_d = rte_zmalloc_socket(NULL,
159 sizeof(struct qat_sgl) +
160 sizeof(struct qat_flat_buf) *
161 QAT_PMD_COMP_SGL_DEF_SEGMENTS,
162 64, dev->data->socket_id);
164 if (cookie->qat_sgl_src_d == NULL ||
165 cookie->qat_sgl_dst_d == NULL) {
166 QAT_LOG(ERR, "Can't allocate SGL"
168 qat_private->qat_dev->name);
172 cookie->qat_sgl_src_phys_addr =
173 rte_malloc_virt2iova(cookie->qat_sgl_src_d);
175 cookie->qat_sgl_dst_phys_addr =
176 rte_malloc_virt2iova(cookie->qat_sgl_dst_d);
178 cookie->dst_nb_elems = cookie->src_nb_elems =
179 QAT_PMD_COMP_SGL_DEF_SEGMENTS;
181 cookie->socket_id = dev->data->socket_id;
190 #define QAT_IM_BUFFER_DEBUG 0
191 static const struct rte_memzone *
192 qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev,
195 char inter_buff_mz_name[RTE_MEMZONE_NAMESIZE];
196 const struct rte_memzone *memzone;
197 uint8_t *mz_start = NULL;
198 rte_iova_t mz_start_phys = 0;
199 struct array_of_ptrs *array_of_pointers;
200 int size_of_ptr_array;
202 uint32_t offset_of_sgls, offset_of_flat_buffs = 0;
204 int num_im_sgls = qat_gen_config[
205 comp_dev->qat_dev->qat_dev_gen].comp_num_im_bufs_required;
207 QAT_LOG(DEBUG, "QAT COMP device %s needs %d sgls",
208 comp_dev->qat_dev->name, num_im_sgls);
209 snprintf(inter_buff_mz_name, RTE_MEMZONE_NAMESIZE,
210 "%s_inter_buff", comp_dev->qat_dev->name);
211 memzone = rte_memzone_lookup(inter_buff_mz_name);
212 if (memzone != NULL) {
213 QAT_LOG(DEBUG, "QAT COMP im buffer memzone created already");
217 /* Create a memzone to hold intermediate buffers and associated
218 * meta-data needed by the firmware. The memzone contains 3 parts:
219 * - a list of num_im_sgls physical pointers to sgls
220 * - the num_im_sgl sgl structures, each pointing to
221 * QAT_NUM_BUFS_IN_IM_SGL flat buffers
222 * - the flat buffers: num_im_sgl * QAT_NUM_BUFS_IN_IM_SGL
223 * buffers, each of buff_size
224 * num_im_sgls depends on the hardware generation of the device
225 * buff_size comes from the user via the config file
228 size_of_ptr_array = num_im_sgls * sizeof(phys_addr_t);
229 offset_of_sgls = (size_of_ptr_array + (~QAT_64_BYTE_ALIGN_MASK))
230 & QAT_64_BYTE_ALIGN_MASK;
231 offset_of_flat_buffs =
232 offset_of_sgls + num_im_sgls * sizeof(struct qat_inter_sgl);
233 full_size = offset_of_flat_buffs +
234 num_im_sgls * buff_size * QAT_NUM_BUFS_IN_IM_SGL;
236 memzone = rte_memzone_reserve_aligned(inter_buff_mz_name, full_size,
237 comp_dev->compressdev->data->socket_id,
238 RTE_MEMZONE_IOVA_CONTIG, QAT_64_BYTE_ALIGN);
239 if (memzone == NULL) {
240 QAT_LOG(ERR, "Can't allocate intermediate buffers"
241 " for device %s", comp_dev->qat_dev->name);
245 mz_start = (uint8_t *)memzone->addr;
246 mz_start_phys = memzone->phys_addr;
247 QAT_LOG(DEBUG, "Memzone %s: addr = %p, phys = 0x%"PRIx64
248 ", size required %d, size created %zu",
249 inter_buff_mz_name, mz_start, mz_start_phys,
250 full_size, memzone->len);
252 array_of_pointers = (struct array_of_ptrs *)mz_start;
253 for (i = 0; i < num_im_sgls; i++) {
254 uint32_t curr_sgl_offset =
255 offset_of_sgls + i * sizeof(struct qat_inter_sgl);
256 struct qat_inter_sgl *sgl =
257 (struct qat_inter_sgl *)(mz_start + curr_sgl_offset);
259 array_of_pointers->pointer[i] = mz_start_phys + curr_sgl_offset;
261 sgl->num_bufs = QAT_NUM_BUFS_IN_IM_SGL;
262 sgl->num_mapped_bufs = 0;
265 #if QAT_IM_BUFFER_DEBUG
266 QAT_LOG(DEBUG, " : phys addr of sgl[%i] in array_of_pointers"
267 " = 0x%"PRIx64, i, array_of_pointers->pointer[i]);
268 QAT_LOG(DEBUG, " : virt address of sgl[%i] = %p", i, sgl);
270 for (lb = 0; lb < QAT_NUM_BUFS_IN_IM_SGL; lb++) {
271 sgl->buffers[lb].addr =
272 mz_start_phys + offset_of_flat_buffs +
273 (((i * QAT_NUM_BUFS_IN_IM_SGL) + lb) * buff_size);
274 sgl->buffers[lb].len = buff_size;
275 sgl->buffers[lb].resrvd = 0;
276 #if QAT_IM_BUFFER_DEBUG
278 " : sgl->buffers[%d].addr = 0x%"PRIx64", len=%d",
279 lb, sgl->buffers[lb].addr, sgl->buffers[lb].len);
283 #if QAT_IM_BUFFER_DEBUG
284 QAT_DP_HEXDUMP_LOG(DEBUG, "IM buffer memzone start:",
285 mz_start, offset_of_flat_buffs + 32);
290 static struct rte_mempool *
291 qat_comp_create_xform_pool(struct qat_comp_dev_private *comp_dev,
292 struct rte_compressdev_config *config,
293 uint32_t num_elements)
295 char xform_pool_name[RTE_MEMPOOL_NAMESIZE];
296 struct rte_mempool *mp;
298 snprintf(xform_pool_name, RTE_MEMPOOL_NAMESIZE,
299 "%s_xforms", comp_dev->qat_dev->name);
301 QAT_LOG(DEBUG, "xformpool: %s", xform_pool_name);
302 mp = rte_mempool_lookup(xform_pool_name);
305 QAT_LOG(DEBUG, "xformpool already created");
306 if (mp->size != num_elements) {
307 QAT_LOG(DEBUG, "xformpool wrong size - delete it");
308 rte_mempool_free(mp);
310 comp_dev->xformpool = NULL;
315 mp = rte_mempool_create(xform_pool_name,
317 qat_comp_xform_size(), 0, 0,
318 NULL, NULL, NULL, NULL, config->socket_id,
321 QAT_LOG(ERR, "Err creating mempool %s w %d elements of size %d",
322 xform_pool_name, num_elements, qat_comp_xform_size());
330 qat_comp_stream_init(struct rte_mempool *mp __rte_unused, void *opaque,
331 void *obj, unsigned int obj_idx)
333 struct stream_create_info *info = opaque;
334 struct qat_comp_stream *stream = obj;
335 char mz_name[RTE_MEMZONE_NAMESIZE];
336 const struct rte_memzone *memzone;
337 struct qat_inter_sgl *ram_banks_desc;
339 /* find a memzone for RAM banks */
340 snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "%s_%u_rambanks",
341 info->comp_dev->qat_dev->name, obj_idx);
342 memzone = rte_memzone_lookup(mz_name);
343 if (memzone == NULL) {
344 /* allocate a memzone for compression state and RAM banks */
345 memzone = rte_memzone_reserve_aligned(mz_name,
346 QAT_STATE_REGISTERS_MAX_SIZE
347 + sizeof(struct qat_inter_sgl)
348 + QAT_INFLATE_CONTEXT_SIZE,
350 RTE_MEMZONE_IOVA_CONTIG, QAT_64_BYTE_ALIGN);
351 if (memzone == NULL) {
353 "Can't allocate RAM banks for device %s, object %u",
354 info->comp_dev->qat_dev->name, obj_idx);
355 info->error = -ENOMEM;
360 /* prepare the buffer list descriptor for RAM banks */
361 ram_banks_desc = (struct qat_inter_sgl *)
362 (((uint8_t *) memzone->addr) + QAT_STATE_REGISTERS_MAX_SIZE);
363 ram_banks_desc->num_bufs = 1;
364 ram_banks_desc->buffers[0].len = QAT_INFLATE_CONTEXT_SIZE;
365 ram_banks_desc->buffers[0].addr = memzone->iova
366 + QAT_STATE_REGISTERS_MAX_SIZE
367 + sizeof(struct qat_inter_sgl);
369 memset(stream, 0, qat_comp_stream_size());
370 stream->memzone = memzone;
371 stream->state_registers_decomp = memzone->addr;
372 stream->state_registers_decomp_phys = memzone->iova;
373 stream->inflate_context = ((uint8_t *) memzone->addr)
374 + QAT_STATE_REGISTERS_MAX_SIZE;
375 stream->inflate_context_phys = memzone->iova
376 + QAT_STATE_REGISTERS_MAX_SIZE;
380 qat_comp_stream_destroy(struct rte_mempool *mp __rte_unused,
381 void *opaque __rte_unused, void *obj,
382 unsigned obj_idx __rte_unused)
384 struct qat_comp_stream *stream = obj;
386 rte_memzone_free(stream->memzone);
389 static struct rte_mempool *
390 qat_comp_create_stream_pool(struct qat_comp_dev_private *comp_dev,
392 uint32_t num_elements)
394 char stream_pool_name[RTE_MEMPOOL_NAMESIZE];
395 struct rte_mempool *mp;
397 snprintf(stream_pool_name, RTE_MEMPOOL_NAMESIZE,
398 "%s_streams", comp_dev->qat_dev->name);
400 QAT_LOG(DEBUG, "streampool: %s", stream_pool_name);
401 mp = rte_mempool_lookup(stream_pool_name);
404 QAT_LOG(DEBUG, "streampool already created");
405 if (mp->size != num_elements) {
406 QAT_LOG(DEBUG, "streampool wrong size - delete it");
407 rte_mempool_obj_iter(mp, qat_comp_stream_destroy, NULL);
408 rte_mempool_free(mp);
410 comp_dev->streampool = NULL;
415 struct stream_create_info info = {
416 .comp_dev = comp_dev,
417 .socket_id = socket_id,
420 mp = rte_mempool_create(stream_pool_name,
422 qat_comp_stream_size(), 0, 0,
423 NULL, NULL, qat_comp_stream_init, &info,
427 "Err creating mempool %s w %d elements of size %d",
428 stream_pool_name, num_elements,
429 qat_comp_stream_size());
430 } else if (info.error) {
431 rte_mempool_obj_iter(mp, qat_comp_stream_destroy, NULL);
433 "Destoying mempool %s as at least one element failed initialisation",
435 rte_mempool_free(mp);
444 _qat_comp_dev_config_clear(struct qat_comp_dev_private *comp_dev)
446 /* Free intermediate buffers */
447 if (comp_dev->interm_buff_mz) {
448 rte_memzone_free(comp_dev->interm_buff_mz);
449 comp_dev->interm_buff_mz = NULL;
452 /* Free private_xform pool */
453 if (comp_dev->xformpool) {
454 /* Free internal mempool for private xforms */
455 rte_mempool_free(comp_dev->xformpool);
456 comp_dev->xformpool = NULL;
459 /* Free stream pool */
460 if (comp_dev->streampool) {
461 rte_mempool_obj_iter(comp_dev->streampool,
462 qat_comp_stream_destroy, NULL);
463 rte_mempool_free(comp_dev->streampool);
464 comp_dev->streampool = NULL;
469 qat_comp_dev_config(struct rte_compressdev *dev,
470 struct rte_compressdev_config *config)
472 struct qat_comp_dev_private *comp_dev = dev->data->dev_private;
475 if (RTE_PMD_QAT_COMP_IM_BUFFER_SIZE == 0) {
477 "RTE_PMD_QAT_COMP_IM_BUFFER_SIZE = 0 in config file, so"
478 " QAT device can't be used for Dynamic Deflate. "
479 "Did you really intend to do this?");
481 comp_dev->interm_buff_mz =
482 qat_comp_setup_inter_buffers(comp_dev,
483 RTE_PMD_QAT_COMP_IM_BUFFER_SIZE);
484 if (comp_dev->interm_buff_mz == NULL) {
490 if (config->max_nb_priv_xforms) {
491 comp_dev->xformpool = qat_comp_create_xform_pool(comp_dev,
492 config, config->max_nb_priv_xforms);
493 if (comp_dev->xformpool == NULL) {
498 comp_dev->xformpool = NULL;
500 if (config->max_nb_streams) {
501 comp_dev->streampool = qat_comp_create_stream_pool(comp_dev,
502 config->socket_id, config->max_nb_streams);
503 if (comp_dev->streampool == NULL) {
508 comp_dev->streampool = NULL;
513 _qat_comp_dev_config_clear(comp_dev);
518 qat_comp_dev_start(struct rte_compressdev *dev __rte_unused)
524 qat_comp_dev_stop(struct rte_compressdev *dev __rte_unused)
530 qat_comp_dev_close(struct rte_compressdev *dev)
534 struct qat_comp_dev_private *comp_dev = dev->data->dev_private;
536 for (i = 0; i < dev->data->nb_queue_pairs; i++) {
537 ret = qat_comp_qp_release(dev, i);
542 _qat_comp_dev_config_clear(comp_dev);
549 qat_comp_dev_info_get(struct rte_compressdev *dev,
550 struct rte_compressdev_info *info)
552 struct qat_comp_dev_private *comp_dev = dev->data->dev_private;
553 const struct qat_qp_hw_data *comp_hw_qps =
554 qat_gen_config[comp_dev->qat_dev->qat_dev_gen]
555 .qp_hw_data[QAT_SERVICE_COMPRESSION];
558 info->max_nb_queue_pairs =
559 qat_qps_per_service(comp_hw_qps,
560 QAT_SERVICE_COMPRESSION);
561 info->feature_flags = dev->feature_flags;
562 info->capabilities = comp_dev->qat_dev_capabilities;
567 qat_comp_pmd_enq_deq_dummy_op_burst(void *qp __rte_unused,
568 struct rte_comp_op **ops __rte_unused,
569 uint16_t nb_ops __rte_unused)
571 QAT_DP_LOG(ERR, "QAT PMD detected wrong FW version !");
575 static struct rte_compressdev_ops compress_qat_dummy_ops = {
577 /* Device related operations */
578 .dev_configure = NULL,
580 .dev_stop = qat_comp_dev_stop,
581 .dev_close = qat_comp_dev_close,
582 .dev_infos_get = NULL,
585 .stats_reset = qat_comp_stats_reset,
586 .queue_pair_setup = NULL,
587 .queue_pair_release = qat_comp_qp_release,
589 /* Compression related operations */
590 .private_xform_create = NULL,
591 .private_xform_free = qat_comp_private_xform_free
595 qat_comp_pmd_dequeue_first_op_burst(void *qp, struct rte_comp_op **ops,
598 uint16_t ret = qat_dequeue_op_burst(qp, (void **)ops, nb_ops);
599 struct qat_qp *tmp_qp = (struct qat_qp *)qp;
602 if ((*ops)->debug_status ==
603 (uint64_t)ERR_CODE_QAT_COMP_WRONG_FW) {
604 tmp_qp->qat_dev->comp_dev->compressdev->enqueue_burst =
605 qat_comp_pmd_enq_deq_dummy_op_burst;
606 tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst =
607 qat_comp_pmd_enq_deq_dummy_op_burst;
609 tmp_qp->qat_dev->comp_dev->compressdev->dev_ops =
610 &compress_qat_dummy_ops;
611 QAT_LOG(ERR, "QAT PMD detected wrong FW version !");
614 tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst =
615 (compressdev_dequeue_pkt_burst_t)
616 qat_dequeue_op_burst;
622 static struct rte_compressdev_ops compress_qat_ops = {
624 /* Device related operations */
625 .dev_configure = qat_comp_dev_config,
626 .dev_start = qat_comp_dev_start,
627 .dev_stop = qat_comp_dev_stop,
628 .dev_close = qat_comp_dev_close,
629 .dev_infos_get = qat_comp_dev_info_get,
631 .stats_get = qat_comp_stats_get,
632 .stats_reset = qat_comp_stats_reset,
633 .queue_pair_setup = qat_comp_qp_setup,
634 .queue_pair_release = qat_comp_qp_release,
636 /* Compression related operations */
637 .private_xform_create = qat_comp_private_xform_create,
638 .private_xform_free = qat_comp_private_xform_free,
639 .stream_create = qat_comp_stream_create,
640 .stream_free = qat_comp_stream_free
643 /* An rte_driver is needed in the registration of the device with compressdev.
644 * The actual qat pci's rte_driver can't be used as its name represents
645 * the whole pci device with all services. Think of this as a holder for a name
646 * for the compression part of the pci device.
648 static const char qat_comp_drv_name[] = RTE_STR(COMPRESSDEV_NAME_QAT_PMD);
649 static const struct rte_driver compdev_qat_driver = {
650 .name = qat_comp_drv_name,
651 .alias = qat_comp_drv_name
654 qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
655 struct qat_dev_cmd_param *qat_dev_cmd_param)
658 if (qat_pci_dev->qat_dev_gen == QAT_GEN3) {
659 QAT_LOG(ERR, "Compression PMD not supported on QAT P5xxx");
663 struct rte_compressdev_pmd_init_params init_params = {
665 .socket_id = qat_pci_dev->pci_dev->device.numa_node,
667 char name[RTE_COMPRESSDEV_NAME_MAX_LEN];
668 struct rte_compressdev *compressdev;
669 struct qat_comp_dev_private *comp_dev;
671 snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, "%s_%s",
672 qat_pci_dev->name, "comp");
673 QAT_LOG(DEBUG, "Creating QAT COMP device %s", name);
675 /* Populate subset device to use in compressdev device creation */
676 qat_pci_dev->comp_rte_dev.driver = &compdev_qat_driver;
677 qat_pci_dev->comp_rte_dev.numa_node =
678 qat_pci_dev->pci_dev->device.numa_node;
679 qat_pci_dev->comp_rte_dev.devargs = NULL;
681 compressdev = rte_compressdev_pmd_create(name,
682 &(qat_pci_dev->comp_rte_dev),
683 sizeof(struct qat_comp_dev_private),
686 if (compressdev == NULL)
689 compressdev->dev_ops = &compress_qat_ops;
691 compressdev->enqueue_burst = (compressdev_enqueue_pkt_burst_t)
692 qat_enqueue_comp_op_burst;
693 compressdev->dequeue_burst = qat_comp_pmd_dequeue_first_op_burst;
695 compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
697 comp_dev = compressdev->data->dev_private;
698 comp_dev->qat_dev = qat_pci_dev;
699 comp_dev->compressdev = compressdev;
700 qat_pci_dev->comp_dev = comp_dev;
702 switch (qat_pci_dev->qat_dev_gen) {
706 comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities;
709 comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities;
711 "QAT gen %d capabilities unknown, default to GEN1",
712 qat_pci_dev->qat_dev_gen);
717 if (qat_dev_cmd_param[i].name == NULL)
719 if (!strcmp(qat_dev_cmd_param[i].name, COMP_ENQ_THRESHOLD_NAME))
720 comp_dev->min_enq_burst_threshold =
721 qat_dev_cmd_param[i].val;
726 "Created QAT COMP device %s as compressdev instance %d",
727 name, compressdev->data->dev_id);
732 qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev)
734 struct qat_comp_dev_private *comp_dev;
736 if (qat_pci_dev == NULL)
739 comp_dev = qat_pci_dev->comp_dev;
740 if (comp_dev == NULL)
743 /* clean up any resources used by the device */
744 qat_comp_dev_close(comp_dev->compressdev);
746 rte_compressdev_pmd_destroy(comp_dev->compressdev);
747 qat_pci_dev->comp_dev = NULL;