New upstream version 17.08
[deb_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 #define DPAA2_EVENT_MIN_DEQUEUE_TIMEOUT         1
60 #define DPAA2_EVENT_MAX_DEQUEUE_TIMEOUT         (UINT32_MAX - 1)
61 #define DPAA2_EVENT_MAX_QUEUE_FLOWS             2048
62 #define DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS   8
63 #define DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS   0
64 #define DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH      8
65 #define DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH      8
66 #define DPAA2_EVENT_MAX_NUM_EVENTS              (INT32_MAX - 1)
67
68 #define DPAA2_EVENT_QUEUE_ATOMIC_FLOWS          2048
69 #define DPAA2_EVENT_QUEUE_ORDER_SEQUENCES       2048
70
71 enum {
72         DPAA2_EVENT_DPCI_PARALLEL_QUEUE,
73         DPAA2_EVENT_DPCI_ATOMIC_QUEUE,
74         DPAA2_EVENT_DPCI_MAX_QUEUES
75 };
76
77 struct dpaa2_dpcon_dev {
78         TAILQ_ENTRY(dpaa2_dpcon_dev) next;
79         struct fsl_mc_io dpcon;
80         uint16_t token;
81         rte_atomic16_t in_use;
82         uint32_t dpcon_id;
83         uint16_t qbman_ch_id;
84         uint8_t num_priorities;
85         uint8_t channel_index;
86 };
87
88 struct evq_info_t {
89         /* DPcon device */
90         struct dpaa2_dpcon_dev *dpcon;
91         /* Attached DPCI device */
92         struct dpaa2_dpci_dev *dpci;
93         /* Configuration provided by the user */
94         uint32_t event_queue_cfg;
95         uint8_t link;
96 };
97
98 struct dpaa2_eventdev {
99         struct evq_info_t evq_info[DPAA2_EVENT_MAX_QUEUES];
100         uint32_t dequeue_timeout_ns;
101         uint8_t max_event_queues;
102         uint8_t nb_event_queues;
103         uint8_t nb_event_ports;
104         uint8_t resvd_1;
105         uint32_t nb_event_queue_flows;
106         uint32_t nb_event_port_dequeue_depth;
107         uint32_t nb_event_port_enqueue_depth;
108         uint32_t event_dev_cfg;
109 };
110
111 struct dpaa2_dpcon_dev *rte_dpaa2_alloc_dpcon_dev(void);
112 void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon);
113
114 #endif /* __DPAA2_EVENTDEV_H__ */