DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@nvidia.com>
To: dev@dpdk.org
Cc: Thomas Monjalon <thomas@monjalon.net>,
	Ashish Gupta <ashish.gupta@marvell.com>,
	Fiona Trahe <fiona.trahe@intel.com>,
	akhil.goyal@nxp.com
Subject: [dpdk-dev] [PATCH v2 06/10] compress/mlx5: add transformation operations
Date: Wed, 13 Jan 2021 16:18:06 +0000
Message-ID: <1610554690-411627-7-git-send-email-matan@nvidia.com> (raw)
In-Reply-To: <1610554690-411627-1-git-send-email-matan@nvidia.com>

Add support for the next operations:
	private_xform_create
	private_xform_free

The driver transformation structure includes preparations for the next
GGA WQE fields used by the enqueue function: opcode. compress specific
fields checksum type and compress type.

Signed-off-by: Matan Azrad <matan@nvidia.com>
---
 drivers/compress/mlx5/mlx5_compress.c | 122 +++++++++++++++++++++++++++++++++-
 1 file changed, 120 insertions(+), 2 deletions(-)

diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index ffd866a..132837e 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -6,6 +6,7 @@
 #include <rte_log.h>
 #include <rte_errno.h>
 #include <rte_pci.h>
+#include <rte_spinlock.h>
 #include <rte_comp.h>
 #include <rte_compressdev.h>
 #include <rte_compressdev_pmd.h>
@@ -24,6 +25,14 @@
 #define MLX5_COMPRESS_DRIVER_NAME mlx5_compress
 #define MLX5_COMPRESS_LOG_NAME    pmd.compress.mlx5
 
+struct mlx5_compress_xform {
+	SLIST_ENTRY(mlx5_compress_xform) next;
+	enum rte_comp_xform_type type;
+	enum rte_comp_checksum_type csum_type;
+	uint32_t opcode;
+	uint32_t gga_ctrl1; /* BE. */
+};
+
 struct mlx5_compress_priv {
 	TAILQ_ENTRY(mlx5_compress_priv) next;
 	struct ibv_context *ctx; /* Device context. */
@@ -35,6 +44,8 @@ struct mlx5_compress_priv {
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
+	SLIST_HEAD(xform_list, mlx5_compress_xform) xform_list;
+	rte_spinlock_t xform_sl;
 };
 
 struct mlx5_compress_qp {
@@ -215,6 +226,113 @@ struct mlx5_compress_qp {
 	return -1;
 }
 
+static int
+mlx5_compress_xform_free(struct rte_compressdev *dev, void *xform)
+{
+	struct mlx5_compress_priv *priv = dev->data->dev_private;
+
+	rte_spinlock_lock(&priv->xform_sl);
+	SLIST_REMOVE(&priv->xform_list, xform, mlx5_compress_xform, next);
+	rte_spinlock_unlock(&priv->xform_sl);
+	rte_free(xform);
+	return 0;
+}
+
+#define MLX5_COMP_MAX_WIN_SIZE_CONF 6u
+
+static int
+mlx5_compress_xform_create(struct rte_compressdev *dev,
+			    const struct rte_comp_xform *xform,
+			    void **private_xform)
+{
+	struct mlx5_compress_priv *priv = dev->data->dev_private;
+	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.");
+		return -ENOTSUP;
+	}
+	xfrm = rte_zmalloc_socket(__func__, sizeof(*xfrm), 0,
+						    priv->dev_config.socket_id);
+	if (xfrm == NULL)
+		return -ENOMEM;
+	xfrm->opcode = MLX5_OPCODE_MMO;
+	xfrm->type = xform->type;
+	switch (xform->type) {
+	case RTE_COMP_COMPRESS:
+		switch (xform->compress.algo) {
+		case RTE_COMP_ALGO_NULL:
+			xfrm->opcode += MLX5_OPC_MOD_MMO_DMA <<
+							WQE_CSEG_OPC_MOD_OFFSET;
+			break;
+		case RTE_COMP_ALGO_DEFLATE:
+			size = 1 << xform->compress.window_size;
+			size /= MLX5_GGA_COMP_WIN_SIZE_UNITS;
+			xfrm->gga_ctrl1 += RTE_MIN(rte_log2_u32(size),
+					 MLX5_COMP_MAX_WIN_SIZE_CONF) <<
+					   WQE_GGA_COMP_WIN_SIZE_OFFSET;
+			if (xform->compress.level == RTE_COMP_LEVEL_PMD_DEFAULT)
+				size = MLX5_GGA_COMP_LOG_BLOCK_SIZE_MAX;
+			else
+				size = priv->min_block_size - 1 +
+							  xform->compress.level;
+			xfrm->gga_ctrl1 += RTE_MIN(size,
+					    MLX5_GGA_COMP_LOG_BLOCK_SIZE_MAX) <<
+						 WQE_GGA_COMP_BLOCK_SIZE_OFFSET;
+			xfrm->opcode += MLX5_OPC_MOD_MMO_COMP <<
+							WQE_CSEG_OPC_MOD_OFFSET;
+			size = xform->compress.deflate.huffman ==
+						      RTE_COMP_HUFFMAN_DYNAMIC ?
+					    MLX5_GGA_COMP_LOG_DYNAMIC_SIZE_MAX :
+					     MLX5_GGA_COMP_LOG_DYNAMIC_SIZE_MIN;
+			xfrm->gga_ctrl1 += size <<
+					       WQE_GGA_COMP_DYNAMIC_SIZE_OFFSET;
+			break;
+		default:
+			goto err;
+		}
+		xfrm->csum_type = xform->compress.chksum;
+		break;
+	case RTE_COMP_DECOMPRESS:
+		switch (xform->decompress.algo) {
+		case RTE_COMP_ALGO_NULL:
+			xfrm->opcode += MLX5_OPC_MOD_MMO_DMA <<
+							WQE_CSEG_OPC_MOD_OFFSET;
+			break;
+		case RTE_COMP_ALGO_DEFLATE:
+			xfrm->opcode += MLX5_OPC_MOD_MMO_DECOMP <<
+							WQE_CSEG_OPC_MOD_OFFSET;
+			break;
+		default:
+			goto err;
+		}
+		xfrm->csum_type = xform->decompress.chksum;
+		break;
+	default:
+		DRV_LOG(ERR, "Algorithm %u is not supported.", xform->type);
+		goto err;
+	}
+	DRV_LOG(DEBUG, "New xform: gga ctrl1 = 0x%08X opcode = 0x%08X csum "
+		"type = %d.", xfrm->gga_ctrl1, xfrm->opcode, xfrm->csum_type);
+	xfrm->gga_ctrl1 = rte_cpu_to_be_32(xfrm->gga_ctrl1);
+	rte_spinlock_lock(&priv->xform_sl);
+	SLIST_INSERT_HEAD(&priv->xform_list, xfrm, next);
+	rte_spinlock_unlock(&priv->xform_sl);
+	*private_xform = xfrm;
+	return 0;
+err:
+	rte_free(xfrm);
+	return -ENOTSUP;
+}
+
 static struct rte_compressdev_ops mlx5_compress_ops = {
 	.dev_configure		= mlx5_compress_dev_configure,
 	.dev_start		= NULL,
@@ -225,8 +343,8 @@ struct mlx5_compress_qp {
 	.stats_reset		= NULL,
 	.queue_pair_setup	= mlx5_compress_qp_setup,
 	.queue_pair_release	= mlx5_compress_qp_release,
-	.private_xform_create	= NULL,
-	.private_xform_free	= NULL,
+	.private_xform_create	= mlx5_compress_xform_create,
+	.private_xform_free	= mlx5_compress_xform_free,
 	.stream_create		= NULL,
 	.stream_free		= NULL,
 };
-- 
1.8.3.1


  parent reply	other threads:[~2021-01-13 16:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 13:59 [dpdk-dev] [PATCH 00/10] add mlx5 compress PMD Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 01/10] common/mlx5: add DevX attributes for compress Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 02/10] drivers: introduce mlx5 compress PMD Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 03/10] compress/mlx5: support basic control operations Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 04/10] common/mlx5: add compress primitives Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 05/10] compress/mlx5: support queue pair operations Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 06/10] compress/mlx5: add transformation operations Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 07/10] compress/mlx5: add memory region management Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 08/10] compress/mlx5: add data-path functions Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 09/10] compress/mlx5: add statistics operations Matan Azrad
2021-01-11 13:59 ` [dpdk-dev] [PATCH 10/10] compress/mlx5: add the supported capabilities Matan Azrad
2021-01-12 13:08 ` [dpdk-dev] [PATCH 00/10] add mlx5 compress PMD Asaf Penso
2021-01-13 16:18 ` [dpdk-dev] [PATCH v2 " Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 01/10] common/mlx5: add DevX attributes for compress Matan Azrad
2021-01-18 15:08     ` Slava Ovsiienko
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 02/10] drivers: introduce mlx5 compress PMD Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 03/10] compress/mlx5: support basic control operations Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 04/10] common/mlx5: add compress primitives Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 05/10] compress/mlx5: support queue pair operations Matan Azrad
2021-01-13 16:18   ` Matan Azrad [this message]
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 07/10] compress/mlx5: add memory region management Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 08/10] compress/mlx5: add data-path functions Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 09/10] compress/mlx5: add statistics operations Matan Azrad
2021-01-13 16:18   ` [dpdk-dev] [PATCH v2 10/10] compress/mlx5: add the supported capabilities Matan Azrad
2021-01-19 17:54     ` Akhil Goyal
2021-01-20  7:19       ` Matan Azrad
2021-01-20 11:29   ` [dpdk-dev] [PATCH v3 00/11] add mlx5 compress PMD Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 01/11] common/mlx5: add DevX attributes for compress Matan Azrad
2021-01-21 16:52       ` Tal Shnaiderman
2021-01-21 17:10         ` Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 02/11] drivers: introduce mlx5 compress PMD Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 03/11] compress/mlx5: support basic control operations Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 04/11] common/mlx5: add compress primitives Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 05/11] compress/mlx5: support queue pair operations Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 06/11] compress/mlx5: add transformation operations Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 07/11] compress/mlx5: add memory region management Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 08/11] compress/mlx5: add data-path functions Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 09/11] compress/mlx5: add statistics operations Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 10/11] compress/mlx5: support 32-bit systems Matan Azrad
2021-01-20 11:29     ` [dpdk-dev] [PATCH v3 11/11] compress/mlx5: add the supported capabilities Matan Azrad
2021-01-27 19:38     ` [dpdk-dev] [PATCH v3 00/11] add mlx5 compress PMD Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1610554690-411627-7-git-send-email-matan@nvidia.com \
    --to=matan@nvidia.com \
    --cc=akhil.goyal@nxp.com \
    --cc=ashish.gupta@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git