1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #include "otx2_evdev.h"
6 #include "otx2_tim_evdev.h"
9 otx2_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
11 const struct rte_event_timer_adapter_ops **ops)
13 struct otx2_tim_evdev *dev = tim_priv_get();
20 /* Store evdev pointer for later use. */
21 dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev;
22 *caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
28 otx2_tim_init(struct rte_pci_device *pci_dev, struct otx2_dev *cmn_dev)
30 struct rsrc_attach_req *atch_req;
31 struct free_rsrcs_rsp *rsrc_cnt;
32 const struct rte_memzone *mz;
33 struct otx2_tim_evdev *dev;
36 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
39 mz = rte_memzone_reserve(RTE_STR(OTX2_TIM_EVDEV_NAME),
40 sizeof(struct otx2_tim_evdev),
43 otx2_tim_dbg("Unable to allocate memory for TIM Event device");
48 dev->pci_dev = pci_dev;
49 dev->mbox = cmn_dev->mbox;
50 dev->bar2 = cmn_dev->bar2;
52 otx2_mbox_alloc_msg_free_rsrc_cnt(dev->mbox);
53 rc = otx2_mbox_process_msg(dev->mbox, (void *)&rsrc_cnt);
55 otx2_err("Unable to get free rsrc count.");
59 dev->nb_rings = rsrc_cnt->tim;
62 otx2_tim_dbg("No TIM Logical functions provisioned.");
66 atch_req = otx2_mbox_alloc_msg_attach_resources(dev->mbox);
67 atch_req->modify = true;
68 atch_req->timlfs = dev->nb_rings;
70 rc = otx2_mbox_process(dev->mbox);
72 otx2_err("Unable to attach TIM rings.");
85 struct otx2_tim_evdev *dev = tim_priv_get();
86 struct rsrc_detach_req *dtch_req;
88 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
91 dtch_req = otx2_mbox_alloc_msg_detach_resources(dev->mbox);
92 dtch_req->partial = true;
93 dtch_req->timlfs = true;
95 otx2_mbox_process(dev->mbox);
96 rte_memzone_free(rte_memzone_lookup(RTE_STR(OTX2_TIM_EVDEV_NAME)));