1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2020 Intel Corporation
15 #include <rte_debug.h>
18 #include <rte_devargs.h>
21 #include <rte_errno.h>
22 #include <rte_kvargs.h>
23 #include <rte_malloc.h>
24 #include <rte_cycles.h>
27 #include <rte_bus_pci.h>
28 #include <rte_eventdev.h>
29 #include <rte_eventdev_pmd.h>
30 #include <rte_eventdev_pmd_pci.h>
31 #include <rte_memory.h>
32 #include <rte_string_fns.h>
34 #include "../dlb2_priv.h"
35 #include "../dlb2_inline_fns.h"
36 #include "dlb2_main.h"
37 #include "base/dlb2_hw_types.h"
38 #include "base/dlb2_osdep.h"
39 #include "base/dlb2_resource.h"
41 static const char *event_dlb2_pf_name = RTE_STR(EVDEV_DLB2_NAME_PMD);
43 /* Stubs: Allow building partial probe patch */
44 int dlb2_hw_get_num_resources(struct dlb2_hw *hw,
45 struct dlb2_get_num_resources_args *arg,
51 RTE_SET_USED(vdev_req);
52 RTE_SET_USED(vdev_id);
57 void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw)
62 void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw)
69 dlb2_pf_iface_fn_ptrs_init(void)
71 /* flexible iface fn ptr assignments will go here */
76 dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
79 struct rte_pci_device *pci_dev;
80 struct dlb2_devargs dlb2_args = {
81 .socket_id = rte_socket_id(),
82 .max_num_events = DLB2_MAX_NUM_LDB_CREDITS,
83 .num_dir_credits_override = -1,
84 .qid_depth_thresholds = { {0} },
85 .cos_id = DLB2_COS_DEFAULT
87 struct dlb2_eventdev *dlb2;
89 DLB2_LOG_DBG("Enter with dev_id=%d socket_id=%d",
90 eventdev->data->dev_id, eventdev->data->socket_id);
92 dlb2_pf_iface_fn_ptrs_init();
94 pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
96 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
97 dlb2 = dlb2_pmd_priv(eventdev); /* rte_zmalloc_socket mem */
99 /* Probe the DLB2 PF layer */
100 dlb2->qm_instance.pf_dev = dlb2_probe(pci_dev);
102 if (dlb2->qm_instance.pf_dev == NULL) {
103 DLB2_LOG_ERR("DLB2 PF Probe failed with error %d\n",
106 goto dlb2_probe_failed;
109 /* Were we invoked with runtime parameters? */
110 if (pci_dev->device.devargs) {
111 ret = dlb2_parse_params(pci_dev->device.devargs->args,
112 pci_dev->device.devargs->name,
115 DLB2_LOG_ERR("PFPMD failed to parse args ret=%d, errno=%d\n",
117 goto dlb2_probe_failed;
121 ret = dlb2_primary_eventdev_probe(eventdev,
125 ret = dlb2_secondary_eventdev_probe(eventdev,
129 goto dlb2_probe_failed;
131 DLB2_LOG_INFO("DLB2 PF Probe success\n");
137 DLB2_LOG_INFO("DLB2 PF Probe failed, ret=%d\n", ret);
142 #define EVENTDEV_INTEL_VENDOR_ID 0x8086
144 static const struct rte_pci_id pci_id_dlb2_map[] = {
146 RTE_PCI_DEVICE(EVENTDEV_INTEL_VENDOR_ID,
147 PCI_DEVICE_ID_INTEL_DLB2_PF)
155 event_dlb2_pci_probe(struct rte_pci_driver *pci_drv,
156 struct rte_pci_device *pci_dev)
160 ret = rte_event_pmd_pci_probe_named(pci_drv, pci_dev,
161 sizeof(struct dlb2_eventdev),
162 dlb2_eventdev_pci_init,
165 DLB2_LOG_INFO("rte_event_pmd_pci_probe_named() failed, "
173 event_dlb2_pci_remove(struct rte_pci_device *pci_dev)
177 ret = rte_event_pmd_pci_remove(pci_dev, NULL);
180 DLB2_LOG_INFO("rte_event_pmd_pci_remove() failed, "
188 static struct rte_pci_driver pci_eventdev_dlb2_pmd = {
189 .id_table = pci_id_dlb2_map,
190 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
191 .probe = event_dlb2_pci_probe,
192 .remove = event_dlb2_pci_remove,
195 RTE_PMD_REGISTER_PCI(event_dlb2_pf, pci_eventdev_dlb2_pmd);
196 RTE_PMD_REGISTER_PCI_TABLE(event_dlb2_pf, pci_id_dlb2_map);