Commit 2828b121 authored by Zhangfei Gao's avatar Zhangfei Gao Committed by Konrad Sztyber
Browse files

accel/dpdk_compressdev: add the missing rte_compressdev_stop/close



Add the missing rte_compressdev_stop and rte_compressdev_close,
which will clean up the accelerator.

Change-Id: I01f71bccbe31dae0a392702b10f66eb43a00e97e
Signed-off-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24875


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 8cd576fe
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ create_compress_dev(uint8_t index)
	rc = rte_compressdev_configure(cdev_id, &config);
	if (rc < 0) {
		SPDK_ERRLOG("Failed to configure compressdev %u\n", cdev_id);
		goto err;
		goto err_close;
	}

	/* Pre-setup all potential qpairs now and assign them in the channel
@@ -176,7 +176,7 @@ create_compress_dev(uint8_t index)
				SPDK_ERRLOG("Failed to setup queue pair on "
					    "compressdev %u with error %u\n", cdev_id, rc);
				rc = -EINVAL;
				goto err;
				goto err_close;
			}
		}
	}
@@ -185,7 +185,7 @@ create_compress_dev(uint8_t index)
	if (rc < 0) {
		SPDK_ERRLOG("Failed to start device %u: error %d\n",
			    cdev_id, rc);
		goto err;
		goto err_close;
	}

	if (device->cdev_info.capabilities->comp_feature_flags & RTE_COMP_FF_SHAREABLE_PRIV_XFORM) {
@@ -194,7 +194,7 @@ create_compress_dev(uint8_t index)
		if (rc < 0) {
			SPDK_ERRLOG("Failed to create private comp xform device %u: error %d\n",
				    cdev_id, rc);
			goto err;
			goto err_stop;
		}

		rc = rte_compressdev_private_xform_create(cdev_id, &g_decomp_xform,
@@ -202,11 +202,11 @@ create_compress_dev(uint8_t index)
		if (rc) {
			SPDK_ERRLOG("Failed to create private decomp xform device %u: error %d\n",
				    cdev_id, rc);
			goto err;
			goto err_stop;
		}
	} else {
		SPDK_ERRLOG("PMD does not support shared transforms\n");
		goto err;
		goto err_stop;
	}

	/* Build up list of device/qp combinations */
@@ -214,7 +214,7 @@ create_compress_dev(uint8_t index)
		dev_qp = calloc(1, sizeof(struct comp_device_qp));
		if (!dev_qp) {
			rc = -ENOMEM;
			goto err;
			goto err_qp;
		}
		dev_qp->device = device;
		dev_qp->qp = i;
@@ -234,11 +234,15 @@ create_compress_dev(uint8_t index)

	return 0;

err:
err_qp:
	TAILQ_FOREACH_SAFE(dev_qp, &g_comp_device_qp, link, tmp_qp) {
		TAILQ_REMOVE(&g_comp_device_qp, dev_qp, link);
		free(dev_qp);
	}
err_stop:
	rte_compressdev_stop(cdev_id);
err_close:
	rte_compressdev_close(cdev_id);
	free(device);
	return rc;
}
@@ -861,6 +865,8 @@ _device_unregister_cb(void *io_device)

	while ((device = TAILQ_FIRST(&g_compress_devs))) {
		TAILQ_REMOVE(&g_compress_devs, device, link);
		rte_compressdev_stop(device->cdev_id);
		rte_compressdev_close(device->cdev_id);
		free(device);
	}

+3 −0
Original line number Diff line number Diff line
@@ -250,6 +250,9 @@ DEFINE_STUB(rte_mbuf_dynfield_register, int, (const struct rte_mbuf_dynfield *pa
	    DPDK_DYNFIELD_OFFSET);
DEFINE_STUB(rte_socket_id, unsigned, (void), 0);
DEFINE_STUB(rte_vdev_init, int, (const char *name, const char *args), 0);
DEFINE_STUB(rte_vdev_uninit, int, (const char *name), 0);
DEFINE_STUB_V(rte_compressdev_stop, (uint8_t dev_id));
DEFINE_STUB(rte_compressdev_close, int, (uint8_t dev_id), 0);
DEFINE_STUB_V(rte_comp_op_free, (struct rte_comp_op *op));
DEFINE_STUB(rte_comp_op_alloc, struct rte_comp_op *, (struct rte_mempool *mempool), NULL);