compress/mlx5: support partial transformation

Currently compress, decompress and dma are allowed
only when all 3 capabilities are on.
A case where the user wants decompress offload, if
decompress capability is on but one of compress,
dma is off, is not allowed.
Split compress/decompress/dma support check to allow
partial transformations.

Signed-off-by: Raja Zidane <rzidane@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
This commit is contained in:
Raja Zidane 2021-09-15 00:12:23 +00:00 committed by Akhil Goyal
parent fd390896f4
commit 2efd265445

View File

@ -286,17 +286,44 @@ mlx5_compress_xform_create(struct rte_compressdev *dev,
struct mlx5_compress_xform *xfrm;
uint32_t size;
if (xform->type == RTE_COMP_COMPRESS && xform->compress.level ==
RTE_COMP_LEVEL_NONE) {
DRV_LOG(ERR, "Non-compressed block is not supported.");
return -ENOTSUP;
}
if ((xform->type == RTE_COMP_COMPRESS && xform->compress.hash_algo !=
RTE_COMP_HASH_ALGO_NONE) || (xform->type == RTE_COMP_DECOMPRESS &&
xform->decompress.hash_algo != RTE_COMP_HASH_ALGO_NONE)) {
DRV_LOG(ERR, "SHA is not supported.");
switch (xform->type) {
case RTE_COMP_COMPRESS:
if (xform->compress.algo == RTE_COMP_ALGO_NULL &&
!priv->mmo_dma_qp && !priv->mmo_dma_sq) {
DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?");
return -ENOTSUP;
} else if (!priv->mmo_comp_qp && !priv->mmo_comp_sq) {
DRV_LOG(ERR, "Not enough capabilities to support compress operation, maybe old FW/OFED version?");
return -ENOTSUP;
}
if (xform->compress.level == RTE_COMP_LEVEL_NONE) {
DRV_LOG(ERR, "Non-compressed block is not supported.");
return -ENOTSUP;
}
if (xform->compress.hash_algo != RTE_COMP_HASH_ALGO_NONE) {
DRV_LOG(ERR, "SHA is not supported.");
return -ENOTSUP;
}
break;
case RTE_COMP_DECOMPRESS:
if (xform->decompress.algo == RTE_COMP_ALGO_NULL &&
!priv->mmo_dma_qp && !priv->mmo_dma_sq) {
DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?");
return -ENOTSUP;
} else if (!priv->mmo_decomp_qp && !priv->mmo_decomp_sq) {
DRV_LOG(ERR, "Not enough capabilities to support decompress operation, maybe old FW/OFED version?");
return -ENOTSUP;
}
if (xform->compress.hash_algo != RTE_COMP_HASH_ALGO_NONE) {
DRV_LOG(ERR, "SHA is not supported.");
return -ENOTSUP;
}
break;
default:
DRV_LOG(ERR, "Xform type should be compress/decompress");
return -ENOTSUP;
}
xfrm = rte_zmalloc_socket(__func__, sizeof(*xfrm), 0,
priv->dev_config.socket_id);
if (xfrm == NULL)
@ -695,11 +722,11 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev)
rte_errno = ENOTSUP;
return -rte_errno;
}
if ((attr->mmo_compress_sq_en == 0 || attr->mmo_decompress_sq_en == 0 ||
attr->mmo_dma_sq_en == 0) && (attr->mmo_compress_qp_en == 0 ||
attr->mmo_decompress_qp_en == 0 || attr->mmo_dma_qp_en == 0)) {
DRV_LOG(ERR, "Not enough capabilities to support compress "
"operations, maybe old FW/OFED version?");
if (!attr->mmo_decompress_qp_en && !attr->mmo_decompress_sq_en
&& !attr->mmo_compress_qp_en && !attr->mmo_compress_sq_en
&& !attr->mmo_dma_qp_en && !attr->mmo_dma_sq_en) {
DRV_LOG(ERR, "Not enough capabilities to support compress operations, maybe old FW/OFED version?");
claim_zero(mlx5_glue->close_device(cdev->ctx));
rte_errno = ENOTSUP;
return -ENOTSUP;
}