2a3211c319ae98bd9528e70aaae6c17f371daa0d
[dpdk.git] / drivers / event / dpaa2 / dpaa2_eventdev.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright 2017 NXP.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of NXP nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef __DPAA2_EVENTDEV_H__
34 #define __DPAA2_EVENTDEV_H__
35
36 #include <rte_eventdev_pmd.h>
37 #include <rte_eventdev_pmd_vdev.h>
38 #include <rte_atomic.h>
39 #include <mc/fsl_dpcon.h>
40 #include <mc/fsl_mc_sys.h>
41
42 #define EVENTDEV_NAME_DPAA2_PMD         event_dpaa2
43
44 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV_DEBUG
45 #define PMD_DRV_LOG(level, fmt, args...) \
46         RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
47 #define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, ">>")
48 #else
49 #define PMD_DRV_LOG(level, fmt, args...) do { } while (0)
50 #define PMD_DRV_FUNC_TRACE() do { } while (0)
51 #endif
52
53 #define PMD_DRV_ERR(fmt, args...) \
54         RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ## args)
55
56 #define DPAA2_EVENT_DEFAULT_DPCI_PRIO 0
57
58 #define DPAA2_EVENT_MAX_QUEUES                  16
59
60 enum {
61         DPAA2_EVENT_DPCI_PARALLEL_QUEUE,
62         DPAA2_EVENT_DPCI_ATOMIC_QUEUE,
63         DPAA2_EVENT_DPCI_MAX_QUEUES
64 };
65
66 struct dpaa2_dpcon_dev {
67         TAILQ_ENTRY(dpaa2_dpcon_dev) next;
68         struct fsl_mc_io dpcon;
69         uint16_t token;
70         rte_atomic16_t in_use;
71         uint32_t dpcon_id;
72         uint16_t qbman_ch_id;
73         uint8_t num_priorities;
74         uint8_t channel_index;
75 };
76
77 struct evq_info_t {
78         /* DPcon device */
79         struct dpaa2_dpcon_dev *dpcon;
80         /* Attached DPCI device */
81         struct dpaa2_dpci_dev *dpci;
82 };
83
84 struct dpaa2_eventdev {
85         struct evq_info_t evq_info[DPAA2_EVENT_MAX_QUEUES];
86         uint8_t max_event_queues;
87 };
88
89 struct dpaa2_dpcon_dev *rte_dpaa2_alloc_dpcon_dev(void);
90 void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon);
91
92 #endif /* __DPAA2_EVENTDEV_H__ */