New upstream version 18.02
[deb_dpdk.git] / drivers / bus / fslmc / mc / fsl_dpio.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016-2017 NXP
5  *
6  */
7 #ifndef __FSL_DPIO_H
8 #define __FSL_DPIO_H
9
10 /* Data Path I/O Portal API
11  * Contains initialization APIs and runtime control APIs for DPIO
12  */
13
14 struct fsl_mc_io;
15
16 int dpio_open(struct fsl_mc_io *mc_io,
17               uint32_t cmd_flags,
18               int dpio_id,
19               uint16_t *token);
20
21 int dpio_close(struct fsl_mc_io *mc_io,
22                uint32_t cmd_flags,
23                uint16_t token);
24
25 /**
26  * enum dpio_channel_mode - DPIO notification channel mode
27  * @DPIO_NO_CHANNEL:    No support for notification channel
28  * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
29  *      dedicated channel in the DPIO; user should point the queue's
30  *      destination in the relevant interface to this DPIO
31  */
32 enum dpio_channel_mode {
33         DPIO_NO_CHANNEL = 0,
34         DPIO_LOCAL_CHANNEL = 1,
35 };
36
37 /**
38  * struct dpio_cfg - Structure representing DPIO configuration
39  * @channel_mode:       Notification channel mode
40  * @num_priorities:     Number of priorities for the notification channel (1-8);
41  *                      relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
42  */
43 struct dpio_cfg {
44         enum dpio_channel_mode channel_mode;
45         uint8_t num_priorities;
46 };
47
48
49 int dpio_create(struct fsl_mc_io *mc_io,
50                 uint16_t dprc_token,
51                 uint32_t cmd_flags,
52                 const struct dpio_cfg *cfg,
53                 uint32_t *obj_id);
54
55 int dpio_destroy(struct fsl_mc_io *mc_io,
56                  uint16_t dprc_token,
57                  uint32_t cmd_flags,
58                  uint32_t object_id);
59
60 int dpio_enable(struct fsl_mc_io *mc_io,
61                 uint32_t cmd_flags,
62                 uint16_t token);
63
64 int dpio_disable(struct fsl_mc_io *mc_io,
65                  uint32_t cmd_flags,
66                  uint16_t token);
67
68 int dpio_is_enabled(struct fsl_mc_io *mc_io,
69                     uint32_t cmd_flags,
70                     uint16_t token,
71                     int *en);
72
73 int dpio_reset(struct fsl_mc_io *mc_io,
74                uint32_t cmd_flags,
75                uint16_t token);
76
77 int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
78                                   uint32_t cmd_flags,
79                                   uint16_t token,
80                                   uint8_t sdest);
81
82 int dpio_get_stashing_destination(struct fsl_mc_io *mc_io,
83                                   uint32_t cmd_flags,
84                                   uint16_t token,
85                                   uint8_t *sdest);
86
87 int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io,
88                                     uint32_t cmd_flags,
89                                     uint16_t token,
90                                     int dpcon_id,
91                                     uint8_t *channel_index);
92
93 int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io,
94                                        uint32_t cmd_flags,
95                                        uint16_t token,
96                                        int dpcon_id);
97
98 /**
99  * struct dpio_attr - Structure representing DPIO attributes
100  * @id:                         DPIO object ID
101  * @qbman_portal_ce_offset:     Offset of the software portal cache-enabled area
102  * @qbman_portal_ci_offset:     Offset of the software portal
103  *                              cache-inhibited area
104  * @qbman_portal_id:            Software portal ID
105  * @channel_mode:               Notification channel mode
106  * @num_priorities:             Number of priorities for the notification
107  *                              channel (1-8); relevant only if
108  *                              'channel_mode = DPIO_LOCAL_CHANNEL'
109  * @qbman_version:              QBMAN version
110  */
111 struct dpio_attr {
112         int id;
113         uint64_t qbman_portal_ce_offset;
114         uint64_t qbman_portal_ci_offset;
115         uint16_t qbman_portal_id;
116         enum dpio_channel_mode channel_mode;
117         uint8_t num_priorities;
118         uint32_t qbman_version;
119         uint32_t clk;
120 };
121
122 int dpio_get_attributes(struct fsl_mc_io *mc_io,
123                         uint32_t cmd_flags,
124                         uint16_t token,
125                         struct dpio_attr *attr);
126
127 int dpio_get_api_version(struct fsl_mc_io *mc_io,
128                          uint32_t cmd_flags,
129                          uint16_t *major_ver,
130                          uint16_t *minor_ver);
131
132 #endif /* __FSL_DPIO_H */