[dpdk-dev] [PATCH v1 1/7] compress/octeontx: add octeontx zip PMD support

Shally Verma shally.verma at caviumnetworks.com
Tue Jun 5 12:35:07 CEST 2018


Add octeontx zip pmd support in compressdev driver.
Add device probe and remove support.
Update makefile to build octeontx zip pmd

Signed-off-by: Ashish Gupta <ashish.gupta at caviumnetworks.com>
Signed-off-by: Shally Verma <shally.verma at caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu at caviumnetworks.com>
---
 config/common_base                                 |   6 +
 drivers/compress/Makefile                          |   2 +-
 drivers/compress/octeontx/Makefile                 |  33 ++++++
 drivers/compress/octeontx/meson.build              |  10 ++
 .../octeontx/rte_pmd_octeontx_compress_version.map |   3 +
 drivers/compress/octeontx/zip_pmd.c                | 129 +++++++++++++++++++++
 drivers/compress/octeontx/zipvf.c                  |  48 ++++++++
 drivers/compress/octeontx/zipvf.h                  |  47 ++++++++
 usertools/dpdk-devbind.py                          |   9 ++
 9 files changed, 286 insertions(+), 1 deletion(-)

diff --git a/config/common_base b/config/common_base
index 6b0d1cbbb..e56d14b7f 100644
--- a/config/common_base
+++ b/config/common_base
@@ -584,6 +584,12 @@ CONFIG_RTE_COMPRESS_MAX_DEVS=64
 #
 CONFIG_RTE_COMPRESSDEV_TEST=n
 
+#
+# Compile PMD for Octeontx ZIPVF compression device
+#
+CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF=n
+CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF_DEBUG=n
+
 #
 # Compile PMD for ISA-L compression device
 #
diff --git a/drivers/compress/Makefile b/drivers/compress/Makefile
index 592497f51..62b4e5abe 100644
--- a/drivers/compress/Makefile
+++ b/drivers/compress/Makefile
@@ -4,5 +4,5 @@
 include $(RTE_SDK)/mk/rte.vars.mk
 
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_ISAL) += isal
-
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF) += octeontx
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/compress/octeontx/Makefile b/drivers/compress/octeontx/Makefile
new file mode 100644
index 000000000..89078f085
--- /dev/null
+++ b/drivers/compress/octeontx/Makefile
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017-2018 Cavium Networks
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_pmd_octeontx_zip.a
+
+# library version
+LIBABIVER := 1
+
+# build flags
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/compress/octeontx/include
+
+# external library include paths
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
+LDLIBS += -lrte_compressdev
+LDLIBS += -lrte_pci -lrte_bus_pci
+
+# library source files
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF) += zip_pmd.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF) += zipvf.c
+
+# export include files
+SYMLINK-y-include +=
+
+# versioning export map
+EXPORT_MAP := rte_pmd_octeontx_compress_version.map
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/compress/octeontx/meson.build b/drivers/compress/octeontx/meson.build
new file mode 100644
index 000000000..cce404337
--- /dev/null
+++ b/drivers/compress/octeontx/meson.build
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cavium Networks
+
+sources = files('zipvf.c', 'zip_pmd.c')
+allow_experimental_apis = true
+includes += include_directories('include')
+deps += ['mempool_octeontx', 'bus_pci']
+ext_deps += dep
+
+
diff --git a/drivers/compress/octeontx/rte_pmd_octeontx_compress_version.map b/drivers/compress/octeontx/rte_pmd_octeontx_compress_version.map
new file mode 100644
index 000000000..33c1b976f
--- /dev/null
+++ b/drivers/compress/octeontx/rte_pmd_octeontx_compress_version.map
@@ -0,0 +1,3 @@
+EXPERIMENTAL {
+	local: *;
+};
diff --git a/drivers/compress/octeontx/zip_pmd.c b/drivers/compress/octeontx/zip_pmd.c
new file mode 100644
index 000000000..1181bed19
--- /dev/null
+++ b/drivers/compress/octeontx/zip_pmd.c
@@ -0,0 +1,129 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+
+#include <string.h>
+#include <rte_common.h>
+#include <rte_malloc.h>
+#include <rte_cpuflags.h>
+#include <rte_byteorder.h>
+#include "zipvf.h"
+
+/* global structure to keep driver info */
+struct zip_pmd_private zip_pmd_priv;
+
+static int
+zip_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	struct rte_pci_device *pci_dev)
+{
+	int ret = 0;
+	char compressdev_name[RTE_COMPRESSDEV_NAME_MAX_LEN];
+	struct rte_compressdev *compressdev;
+	struct rte_compressdev_pmd_init_params init_params = {
+		"",
+		rte_socket_id(),
+	};
+
+	ZIP_PMD_INFO("vendor_id=0x%x device_id=0x%x",
+			(unsigned int)pci_dev->id.vendor_id,
+			(unsigned int)pci_dev->id.device_id);
+
+	rte_pci_device_name(&pci_dev->addr, compressdev_name,
+			    sizeof(compressdev_name));
+
+	compressdev = rte_compressdev_pmd_create(compressdev_name,
+		&pci_dev->device, sizeof(struct zip_vf), &init_params);
+	if (compressdev == NULL) {
+		ZIP_PMD_ERR("driver %s: create failed", init_params.name);
+		return -ENODEV;
+	}
+
+	/*
+	 * create only if proc_type is primary.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		/*  create vf dev with given pmd dev id */
+		ret = zipvf_create(compressdev, zip_pmd_priv.num_zipvfs);
+		if (ret < 0) {
+			ZIP_PMD_ERR("Device creation failed");
+			rte_compressdev_pmd_destroy(compressdev);
+			return ret;
+		}
+	}
+
+	/* TBD: check if driver global structure to be shared
+	 * too among processes. if yes, then zip_pmd_priv
+	 * had to be allocated from shared memzone. Currently
+	 * it is in global data segment
+	 */
+	zip_pmd_priv.zipvf_table[zip_pmd_priv.num_zipvfs] =
+		compressdev->data->dev_private;
+	zip_pmd_priv.num_zipvfs++;
+
+	compressdev->dev_ops = &octtx_zip_pmd_ops;
+	/* register rx/tx burst functions for data path */
+	compressdev->dequeue_burst = zip_pmd_dequeue_burst_sync;
+	compressdev->enqueue_burst = zip_pmd_enqueue_burst_sync;
+	compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
+	return ret;
+}
+
+static int
+zip_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct rte_compressdev *compressdev;
+	char compressdev_name[RTE_COMPRESSDEV_NAME_MAX_LEN];
+
+	if (pci_dev == NULL) {
+		ZIP_PMD_ERR(" Invalid PCI Device\n");
+		return -EINVAL;
+	}
+	rte_pci_device_name(&pci_dev->addr, compressdev_name,
+			sizeof(compressdev_name));
+
+	compressdev = rte_compressdev_pmd_get_named_dev(compressdev_name);
+	if (compressdev == NULL)
+		return -ENODEV;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		if (zipvf_destroy(compressdev) < 0)
+			return -ENODEV;
+	}
+	return rte_compressdev_pmd_destroy(compressdev);
+}
+
+
+
+static struct rte_pci_id pci_id_octtx_zipvf_table[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
+			PCI_DEVICE_ID_OCTEONTX_ZIPVF),
+	},
+	{
+		.device_id = 0
+	},
+};
+
+/**
+ * Structure that represents a PCI driver
+ */
+static struct rte_pci_driver octtx_zip_pmd = {
+	.id_table    = pci_id_octtx_zipvf_table,
+	.drv_flags   = RTE_PCI_DRV_NEED_MAPPING,
+	.probe       = zip_pci_probe,
+	.remove      = zip_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
+
+RTE_INIT(octtx_zip_init_log);
+
+static void
+octtx_zip_init_log(void)
+{
+	octtx_zip_logtype_driver = rte_log_register("comp_octeontx_zip");
+	if (octtx_zip_logtype_driver >= 0)
+		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
+}
+
diff --git a/drivers/compress/octeontx/zipvf.c b/drivers/compress/octeontx/zipvf.c
new file mode 100644
index 000000000..e082c2849
--- /dev/null
+++ b/drivers/compress/octeontx/zipvf.c
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+
+#include "zipvf.h"
+
+int zipvf_create(struct rte_compressdev *compressdev, int vfid)
+{
+	struct   rte_pci_device *pdev = RTE_DEV_TO_PCI(compressdev->device);
+	struct   zip_vf *zipvf = NULL;
+	char     *dev_name = compressdev->data->name;
+	void     *vbar0;
+	uint64_t reg;
+
+	if (pdev->mem_resource[0].phys_addr == 0ULL)
+		return -EIO;
+
+	vbar0 = pdev->mem_resource[0].addr;
+	if (!vbar0) {
+		ZIP_PMD_ERR("Failed to map BAR0 of %s", dev_name);
+		return -ENODEV;
+	}
+
+	zipvf = (struct zip_vf *)(compressdev->data->dev_private);
+
+	if (!zipvf)
+		return -ENOMEM;
+
+	zipvf->vbar0 = vbar0;
+	reg = zip_reg_read64(zipvf->vbar0, ZIP_VF_PF_MBOXX(0));
+	/* Storing domain in local to ZIP VF */
+	zipvf->dom_sdom = reg;
+	zipvf->pdev = pdev;
+	zipvf->max_nb_queue_pairs = ZIP_MAX_VF_QUEUE;
+	zipvf->vfid = vfid;
+	return 0;
+}
+
+int zipvf_destroy(struct rte_compressdev *compressdev)
+{
+	struct zip_vf *vf = (struct zip_vf *)(compressdev->data->dev_private);
+
+	/* Rewriting the domain_id in ZIP_VF_MBOX for app rerun */
+	zip_reg_write64(vf->vbar0, ZIP_VF_PF_MBOXX(0), vf->dom_sdom);
+
+	return 0;
+}
+
diff --git a/drivers/compress/octeontx/zipvf.h b/drivers/compress/octeontx/zipvf.h
new file mode 100644
index 000000000..dcaaf4e46
--- /dev/null
+++ b/drivers/compress/octeontx/zipvf.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+#ifndef _RTE_OCTEONTX_ZIP_VF_H_
+#define _RTE_OCTEONTX_ZIP_VF_H_
+
+#include <rte_comp.h>
+#include <rte_compressdev.h>
+#include <rte_compressdev_pmd.h>
+#include <unistd.h>
+
+int octtx_zip_logtype_driver;
+
+
+#define ZIP_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, \
+	octtx_zip_logtype_driver, "%s(): "fmt "\n", \
+	__func__, ##args)
+
+#define ZIP_PMD_INFO(fmt, args...) \
+	ZIP_PMD_LOG(INFO, fmt, ## args)
+#define ZIP_PMD_ERR(fmt, args...) \
+	ZIP_PMD_LOG(ERR, fmt, ## args)
+#define ZIP_PMD_WARN(fmt, args...) \
+	ZIP_PMD_LOG(WARNING, fmt, ## args)
+
+/**
+ * ZIP VF device structure.
+ */
+struct zip_vf {
+	int vfid;
+	/* vf index */
+	struct rte_pci_device *pdev;
+	/* pci device */
+	void *vbar0;
+	/* CSR base address for underlying BAR0 VF.*/
+	uint64_t dom_sdom;
+	/* Storing mbox domain and subdomain id for app rerun*/
+	uint32_t  max_nb_queue_pairs;
+	/* pointer to device qps */
+	struct rte_mempool *zip_mp;
+	/* pointer to pools */
+} __rte_cache_aligned;
+
+int zipvf_create(struct rte_compressdev *compressdev, int vfid);
+
+#endif /* _RTE_ZIP_VF_H_ */
diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index d0c420906..1d48a6cba 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -24,6 +24,8 @@
               'SVendor': None, 'SDevice': None}
 cavium_tim = {'Class': '08', 'Vendor': '177d', 'Device': 'a051',
               'SVendor': None, 'SDevice': None}
+cavium_zip = {'Class': '12', 'Vendor': '177d', 'Device': 'a037',
+              'SVendor': None, 'SDevice': None}
 avp_vnic = {'Class': '05', 'Vendor': '1af4', 'Device': '1110',
               'SVendor': None, 'SDevice': None}
 
@@ -31,6 +33,7 @@
 crypto_devices = [encryption_class, intel_processor_class]
 eventdev_devices = [cavium_sso, cavium_tim]
 mempool_devices = [cavium_fpa]
+compress_devices = [cavium_zip]
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -569,6 +572,10 @@ def show_status():
     if status_dev == "mempool" or status_dev == "all":
         show_device_status(mempool_devices, "Mempool")
 
+    if status_dev == "compress" or status_dev == "all":
+        show_device_status(compress_devices , "Compress")
+
+
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
     appropriate action for each'''
@@ -642,6 +649,7 @@ def do_arg_actions():
             get_device_details(crypto_devices)
             get_device_details(eventdev_devices)
             get_device_details(mempool_devices)
+            get_device_details(compress_devices)
         show_status()
 
 
@@ -654,6 +662,7 @@ def main():
     get_device_details(crypto_devices)
     get_device_details(eventdev_devices)
     get_device_details(mempool_devices)
+    get_device_details(compress_devices)
     do_arg_actions()
 
 if __name__ == "__main__":
-- 
2.14.3



More information about the dev mailing list