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_init(struct rte_pci_device *pci_dev, struct otx2_dev *cmn_dev)
11 struct rsrc_attach_req *atch_req;
12 struct free_rsrcs_rsp *rsrc_cnt;
13 const struct rte_memzone *mz;
14 struct otx2_tim_evdev *dev;
17 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
20 mz = rte_memzone_reserve(RTE_STR(OTX2_TIM_EVDEV_NAME),
21 sizeof(struct otx2_tim_evdev),
24 otx2_tim_dbg("Unable to allocate memory for TIM Event device");
29 dev->pci_dev = pci_dev;
30 dev->mbox = cmn_dev->mbox;
31 dev->bar2 = cmn_dev->bar2;
33 otx2_mbox_alloc_msg_free_rsrc_cnt(dev->mbox);
34 rc = otx2_mbox_process_msg(dev->mbox, (void *)&rsrc_cnt);
36 otx2_err("Unable to get free rsrc count.");
40 dev->nb_rings = rsrc_cnt->tim;
43 otx2_tim_dbg("No TIM Logical functions provisioned.");
47 atch_req = otx2_mbox_alloc_msg_attach_resources(dev->mbox);
48 atch_req->modify = true;
49 atch_req->timlfs = dev->nb_rings;
51 rc = otx2_mbox_process(dev->mbox);
53 otx2_err("Unable to attach TIM rings.");
66 struct otx2_tim_evdev *dev = tim_priv_get();
67 struct rsrc_detach_req *dtch_req;
69 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
72 dtch_req = otx2_mbox_alloc_msg_detach_resources(dev->mbox);
73 dtch_req->partial = true;
74 dtch_req->timlfs = true;
76 otx2_mbox_process(dev->mbox);
77 rte_memzone_free(rte_memzone_lookup(RTE_STR(OTX2_TIM_EVDEV_NAME)));