[dpdk-dev,v1,1/6] compress/zlib: add ZLIB PMD support

Message ID 1526380346-7386-2-git-send-email-shally.verma@caviumnetworks.com (mailing list archive)
State Changes Requested, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Shally Verma May 15, 2018, 10:32 a.m. UTC
  Add sw zlib pmd support in compressdev driver.
Add device probe and remove support.
Update makefile to build zlib.

Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
 config/common_base                             |   6 ++
 drivers/compress/Makefile                      |   1 +
 drivers/compress/zlib/Makefile                 |  32 ++++++++
 drivers/compress/zlib/rte_pmd_zlib_version.map |   3 +
 drivers/compress/zlib/zlib_pmd.c               | 106 +++++++++++++++++++++++++
 5 files changed, 148 insertions(+)
  

Comments

Daly, Lee June 15, 2018, 11:08 a.m. UTC | #1
Hi,
 thanks for the work, reviewed the PMD see comments below.

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shally Verma
> Sent: Tuesday, May 15, 2018 11:32 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; dev@dpdk.org;
> pathreay@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v1 1/6] compress/zlib: add ZLIB PMD support

<...>

> diff --git a/config/common_base b/config/common_base index
> 28557ed..537e9e4 100644
> --- a/config/common_base
> +++ b/config/common_base
> @@ -586,6 +586,12 @@ CONFIG_RTE_COMPRESSDEV_TEST=n
> CONFIG_RTE_LIBRTE_PMD_ISAL=n
> 
>  #
> +# Compile PMD for ZLIB compression device #
> +CONFIG_RTE_LIBRTE_PMD_ZLIB=n
> CONFIG_RTE_LIBRTE_PMD_ZLIB_DEBUG=n
[Lee] DPDK is moving from the static debugging, I see you have implemented dynamic logging but have not yet used it in the PMD.
i.e using ZLIB_LOG_ERR/INFO() rather than ZLIB_PMD_LOG(INFO, "").
When you have removed the static debugging use, could you remove this flag to enable it please.

> +
> +#
>  # Compile generic event device library
>  #
>  CONFIG_RTE_LIBRTE_EVENTDEV=y
> diff --git a/drivers/compress/Makefile b/drivers/compress/Makefile index
> 592497f..1f159a5 100644
> --- a/drivers/compress/Makefile
> +++ b/drivers/compress/Makefile
> @@ -4,5 +4,6 @@
>  include $(RTE_SDK)/mk/rte.vars.mk
> 
>  DIRS-$(CONFIG_RTE_LIBRTE_PMD_ISAL) += isal
> +DIRS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib
> 
>  include $(RTE_SDK)/mk/rte.subdir.mk
> diff --git a/drivers/compress/zlib/Makefile b/drivers/compress/zlib/Makefile
> new file mode 100644 index 0000000..e613960
> --- /dev/null
> +++ b/drivers/compress/zlib/Makefile
> @@ -0,0 +1,32 @@
> +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Cavium
> +Networks
> +
> +include $(RTE_SDK)/mk/rte.vars.mk
> +
> +# library name
> +LIB = librte_pmd_zlib.a
> +
> +# build flags
> +CFLAGS += -O3
> +CFLAGS += $(WERROR_FLAGS)
> +CFLAGS += -DALLOW_EXPERIMENTAL_API
> +
> +# library version
> +LIBABIVER := 1
> +
> +# versioning export map
> +EXPORT_MAP := rte_pmd_zlib_version.map
> +
> +# external library dependencies
> +LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lz LDLIBS +=
> +-lrte_compressdev LDLIBS += -lrte_bus_vdev
> +
> +# library source files
> +SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd.c
> +SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd_ops.c
> +
> +# export include files
> +SYMLINK-y-include +=
> +
[Lee] Do you have a need for this in the future, not being used now.

> +include $(RTE_SDK)/mk/rte.lib.mk
> diff --git a/drivers/compress/zlib/rte_pmd_zlib_version.map
> b/drivers/compress/zlib/rte_pmd_zlib_version.map
> new file mode 100644
> index 0000000..33c1b97
> --- /dev/null
> +++ b/drivers/compress/zlib/rte_pmd_zlib_version.map
> @@ -0,0 +1,3 @@
> +EXPERIMENTAL {
[Lee] Would be better to replace EXPERMENTAL with 18.08 in this case.

> +	local: *;
> +};
> diff --git a/drivers/compress/zlib/zlib_pmd.c
> b/drivers/compress/zlib/zlib_pmd.c
> new file mode 100644
> index 0000000..bbf49f1
> --- /dev/null
> +++ b/drivers/compress/zlib/zlib_pmd.c
> @@ -0,0 +1,106 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2017-2018 Cavium Networks  */
> +
> +#include <rte_common.h>
> +#include <rte_hexdump.h>
> +#include <rte_comp.h>
> +#include <rte_compressdev.h>
> +#include <rte_compressdev_pmd.h>
> +#include <rte_bus_vdev.h>
> +#include <rte_malloc.h>
> +#include <rte_cpuflags.h>
> +#include <rte_byteorder.h>
> +
> +#include <math.h>
> +#include <assert.h>
> +#include "zlib_pmd_private.h"
> +
> +static uint8_t compressdev_driver_id;
[Lee] The current API no longer has rte_compressdev->driver_id anymore therefor this variable will be unused.

> +int zlib_logtype_driver;
> +
> +static int zlib_remove(struct rte_vdev_device *vdev);
> +
> +static int
> +zlib_create(const char *name,
> +		struct rte_vdev_device *vdev,
> +		struct rte_compressdev_pmd_init_params *init_params) {
> +	struct rte_compressdev *dev;
> +	struct zlib_private *internals;
> +
> +	dev = rte_compressdev_pmd_create(name, &vdev->device,
> +			sizeof(struct zlib_private), init_params);
> +	if (dev == NULL) {
> +		ZLIB_LOG_ERR("driver %s: create failed", init_params-
> >name);
> +		return -ENODEV;
> +	}
> +
> +	dev->driver_id = compressdev_driver_id;
[Lee] See above comment.

> +	dev->dev_ops = rte_zlib_pmd_ops;
> +
> +	dev->feature_flags = 0;
> +	dev->feature_flags |= RTE_COMP_FF_SHAREABLE_PRIV_XFORM |
> +				RTE_COMP_FF_NONCOMPRESSED_BLOCKS |
> +				RTE_COMP_FF_ADLER32_CHECKSUM;

Thanks,
Lee.
  

Patch

diff --git a/config/common_base b/config/common_base
index 28557ed..537e9e4 100644
--- a/config/common_base
+++ b/config/common_base
@@ -586,6 +586,12 @@  CONFIG_RTE_COMPRESSDEV_TEST=n
 CONFIG_RTE_LIBRTE_PMD_ISAL=n
 
 #
+# Compile PMD for ZLIB compression device
+#
+CONFIG_RTE_LIBRTE_PMD_ZLIB=n
+CONFIG_RTE_LIBRTE_PMD_ZLIB_DEBUG=n
+
+#
 # Compile generic event device library
 #
 CONFIG_RTE_LIBRTE_EVENTDEV=y
diff --git a/drivers/compress/Makefile b/drivers/compress/Makefile
index 592497f..1f159a5 100644
--- a/drivers/compress/Makefile
+++ b/drivers/compress/Makefile
@@ -4,5 +4,6 @@ 
 include $(RTE_SDK)/mk/rte.vars.mk
 
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_ISAL) += isal
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib
 
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/compress/zlib/Makefile b/drivers/compress/zlib/Makefile
new file mode 100644
index 0000000..e613960
--- /dev/null
+++ b/drivers/compress/zlib/Makefile
@@ -0,0 +1,32 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cavium Networks
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_pmd_zlib.a
+
+# build flags
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+# library version
+LIBABIVER := 1
+
+# versioning export map
+EXPORT_MAP := rte_pmd_zlib_version.map
+
+# external library dependencies
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lz
+LDLIBS += -lrte_compressdev
+LDLIBS += -lrte_bus_vdev
+
+# library source files
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd_ops.c
+
+# export include files
+SYMLINK-y-include +=
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/compress/zlib/rte_pmd_zlib_version.map b/drivers/compress/zlib/rte_pmd_zlib_version.map
new file mode 100644
index 0000000..33c1b97
--- /dev/null
+++ b/drivers/compress/zlib/rte_pmd_zlib_version.map
@@ -0,0 +1,3 @@ 
+EXPERIMENTAL {
+	local: *;
+};
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
new file mode 100644
index 0000000..bbf49f1
--- /dev/null
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -0,0 +1,106 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+
+#include <rte_common.h>
+#include <rte_hexdump.h>
+#include <rte_comp.h>
+#include <rte_compressdev.h>
+#include <rte_compressdev_pmd.h>
+#include <rte_bus_vdev.h>
+#include <rte_malloc.h>
+#include <rte_cpuflags.h>
+#include <rte_byteorder.h>
+
+#include <math.h>
+#include <assert.h>
+#include "zlib_pmd_private.h"
+
+static uint8_t compressdev_driver_id;
+int zlib_logtype_driver;
+
+static int zlib_remove(struct rte_vdev_device *vdev);
+
+static int
+zlib_create(const char *name,
+		struct rte_vdev_device *vdev,
+		struct rte_compressdev_pmd_init_params *init_params)
+{
+	struct rte_compressdev *dev;
+	struct zlib_private *internals;
+
+	dev = rte_compressdev_pmd_create(name, &vdev->device,
+			sizeof(struct zlib_private), init_params);
+	if (dev == NULL) {
+		ZLIB_LOG_ERR("driver %s: create failed", init_params->name);
+		return -ENODEV;
+	}
+
+	dev->driver_id = compressdev_driver_id;
+	dev->dev_ops = rte_zlib_pmd_ops;
+
+	dev->feature_flags = 0;
+	dev->feature_flags |= RTE_COMP_FF_SHAREABLE_PRIV_XFORM |
+				RTE_COMP_FF_NONCOMPRESSED_BLOCKS |
+				RTE_COMP_FF_ADLER32_CHECKSUM;
+
+	internals = dev->data->dev_private;
+	internals->max_nb_queue_pairs = ZLIB_PMD_MAX_NB_QUEUE_PAIRS;
+
+	return 0;
+}
+
+static int
+zlib_probe(struct rte_vdev_device *vdev)
+{
+	struct rte_compressdev_pmd_init_params init_params = {
+		"",
+		rte_socket_id()
+	};
+	const char *name;
+	const char *input_args;
+
+	name = rte_vdev_device_name(vdev);
+
+	if (name == NULL)
+		return -EINVAL;
+	input_args = rte_vdev_device_args(vdev);
+	rte_compressdev_pmd_parse_input_args(&init_params, input_args);
+
+	return zlib_create(name, vdev, &init_params);
+}
+
+static int
+zlib_remove(struct rte_vdev_device *vdev)
+{
+	struct rte_compressdev *compressdev;
+	const char *name;
+
+	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
+
+	compressdev = rte_compressdev_pmd_get_named_dev(name);
+	if (compressdev == NULL)
+		return -ENODEV;
+
+	return rte_compressdev_pmd_destroy(compressdev);
+}
+
+static struct rte_vdev_driver zlib_pmd_drv = {
+	.probe = zlib_probe,
+	.remove = zlib_remove
+};
+
+RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(COMPRESSDEV_NAME_ZLIB_PMD, compressdev_zlib_pmd);
+
+RTE_INIT(zlib_init_log);
+
+static void
+zlib_init_log(void)
+{
+	zlib_logtype_driver = rte_log_register("compress_zlib");
+	if (zlib_logtype_driver >= 0)
+		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
+}