diff --git a/lib/bdev/compress/vbdev_compress.c b/lib/bdev/compress/vbdev_compress.c index 1d231eac8..db634af6b 100644 --- a/lib/bdev/compress/vbdev_compress.c +++ b/lib/bdev/compress/vbdev_compress.c @@ -152,6 +152,30 @@ struct comp_bdev_io { static struct rte_mempool *g_mbuf_mp = NULL; /* mbuf mempool */ static struct rte_mempool *g_comp_op_mp = NULL; /* comp operations, must be rte* mempool */ static struct rte_mbuf_ext_shared_info g_shinfo = {}; /* used by DPDK mbuf macros */ +/* Create shrared (between all ops per PMD) compress xforms. */ +static struct rte_comp_xform g_comp_xform = (struct rte_comp_xform) +{ + .type = RTE_COMP_COMPRESS, + .compress = { + .algo = RTE_COMP_ALGO_DEFLATE, + .deflate.huffman = RTE_COMP_HUFFMAN_DEFAULT, + .level = RTE_COMP_LEVEL_MAX, + .window_size = DEFAULT_WINDOW_SIZE, + .chksum = RTE_COMP_CHECKSUM_NONE, + .hash_algo = RTE_COMP_HASH_ALGO_NONE + } +}; +/* Create shrared (between all ops per PMD) decompress xforms. */ +static struct rte_comp_xform g_decomp_xform = (struct rte_comp_xform) +{ + .type = RTE_COMP_DECOMPRESS, + .decompress = { + .algo = RTE_COMP_ALGO_DEFLATE, + .chksum = RTE_COMP_CHECKSUM_NONE, + .window_size = DEFAULT_WINDOW_SIZE, + .hash_algo = RTE_COMP_HASH_ALGO_NONE + } +}; static void vbdev_compress_examine(struct spdk_bdev *bdev); static void vbdev_compress_claim(struct vbdev_compress *comp_bdev); @@ -176,8 +200,6 @@ create_compress_dev(uint8_t index, uint16_t num_lcores) struct compress_dev *device; uint16_t q_pairs = num_lcores; uint8_t cdev_id; - struct rte_comp_xform comp_xform = {}; - struct rte_comp_xform decomp_xform = {}; int rc, i; struct comp_device_qp *dev_qp; struct comp_device_qp *tmp_qp; @@ -234,23 +256,7 @@ create_compress_dev(uint8_t index, uint16_t num_lcores) goto err; } - /* TODO: if later on all elements remain static, move these - * xform structs to static globals. - */ - - /* Create shrared (between all ops per PMD) compress xforms. */ - comp_xform = (struct rte_comp_xform) { - .type = RTE_COMP_COMPRESS, - .compress = { - .algo = RTE_COMP_ALGO_DEFLATE, - .deflate.huffman = RTE_COMP_HUFFMAN_DEFAULT, - .level = RTE_COMP_LEVEL_MAX, - .window_size = DEFAULT_WINDOW_SIZE, - .chksum = RTE_COMP_CHECKSUM_NONE, - .hash_algo = RTE_COMP_HASH_ALGO_NONE - } - }; - rc = rte_compressdev_private_xform_create(cdev_id, &comp_xform, + rc = rte_compressdev_private_xform_create(cdev_id, &g_comp_xform, &device->comp_xform); if (rc < 0) { SPDK_ERRLOG("Failed to create private comp xform device %u: error %d\n", @@ -258,19 +264,7 @@ create_compress_dev(uint8_t index, uint16_t num_lcores) goto err; } - /* Create shrared (between all ops per PMD) decompress xforms. * - * also TODO make this global static if everything stays like this - */ - decomp_xform = (struct rte_comp_xform) { - .type = RTE_COMP_DECOMPRESS, - .decompress = { - .algo = RTE_COMP_ALGO_DEFLATE, - .chksum = RTE_COMP_CHECKSUM_NONE, - .window_size = DEFAULT_WINDOW_SIZE, - .hash_algo = RTE_COMP_HASH_ALGO_NONE - } - }; - rc = rte_compressdev_private_xform_create(cdev_id, &decomp_xform, + rc = rte_compressdev_private_xform_create(cdev_id, &g_decomp_xform, &device->decomp_xform); if (rc) { SPDK_ERRLOG("Failed to create private decomp xform device %u: error %d\n", diff --git a/test/unit/lib/bdev/compress.c/compress_ut.c b/test/unit/lib/bdev/compress.c/compress_ut.c index c42fb17eb..34b739f4a 100644 --- a/test/unit/lib/bdev/compress.c/compress_ut.c +++ b/test/unit/lib/bdev/compress.c/compress_ut.c @@ -46,8 +46,6 @@ struct rte_comp_op g_comp_op[2]; struct vbdev_compress g_comp_bdev; struct comp_device_qp g_device_qp; struct compress_dev g_device; -struct rte_comp_xform g_comp_xform; -struct rte_comp_xform g_decomp_xform; static struct rte_mbuf *g_src_mbufs[2]; static struct rte_mbuf *g_dst_mbufs[2]; static struct rte_mbuf g_expected_src_mbufs[2];