1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Cavium, Inc
7 #include <rte_byteorder.h>
8 #include <rte_common.h>
9 #include <rte_cpuflags.h>
10 #include <rte_malloc.h>
14 struct rte_compressdev_ops octtx_zip_pmd_ops = {
19 zip_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
20 struct rte_pci_device *pci_dev)
23 char compressdev_name[RTE_COMPRESSDEV_NAME_MAX_LEN];
24 struct rte_compressdev *compressdev;
25 struct rte_compressdev_pmd_init_params init_params = {
30 ZIP_PMD_INFO("vendor_id=0x%x device_id=0x%x",
31 (unsigned int)pci_dev->id.vendor_id,
32 (unsigned int)pci_dev->id.device_id);
34 rte_pci_device_name(&pci_dev->addr, compressdev_name,
35 sizeof(compressdev_name));
37 compressdev = rte_compressdev_pmd_create(compressdev_name,
38 &pci_dev->device, sizeof(struct zip_vf), &init_params);
39 if (compressdev == NULL) {
40 ZIP_PMD_ERR("driver %s: create failed", init_params.name);
45 * create only if proc_type is primary.
47 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
48 /* create vf dev with given pmd dev id */
49 ret = zipvf_create(compressdev);
51 ZIP_PMD_ERR("Device creation failed");
52 rte_compressdev_pmd_destroy(compressdev);
57 compressdev->dev_ops = &octtx_zip_pmd_ops;
58 /* register rx/tx burst functions for data path */
59 compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
64 zip_pci_remove(struct rte_pci_device *pci_dev)
66 struct rte_compressdev *compressdev;
67 char compressdev_name[RTE_COMPRESSDEV_NAME_MAX_LEN];
69 if (pci_dev == NULL) {
70 ZIP_PMD_ERR(" Invalid PCI Device\n");
73 rte_pci_device_name(&pci_dev->addr, compressdev_name,
74 sizeof(compressdev_name));
76 compressdev = rte_compressdev_pmd_get_named_dev(compressdev_name);
77 if (compressdev == NULL)
80 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
81 if (zipvf_destroy(compressdev) < 0)
84 return rte_compressdev_pmd_destroy(compressdev);
87 static struct rte_pci_id pci_id_octtx_zipvf_table[] = {
89 RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
90 PCI_DEVICE_ID_OCTEONTX_ZIPVF),
98 * Structure that represents a PCI driver
100 static struct rte_pci_driver octtx_zip_pmd = {
101 .id_table = pci_id_octtx_zipvf_table,
102 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
103 .probe = zip_pci_probe,
104 .remove = zip_pci_remove,
107 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
108 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
110 RTE_INIT(octtx_zip_init_log);
113 octtx_zip_init_log(void)
115 octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
116 if (octtx_zip_logtype_driver >= 0)
117 rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);