blob: 0bc0b449c2b8d8b7ccb6da9af20932520c93b262 [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07001/*
2 * Copyright (C) 2013-2015 Freescale Semiconductor
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef _FSL_DPIO_H
8#define _FSL_DPIO_H
9
10/* DPIO Version */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053011#define DPIO_VER_MAJOR 3
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053012#define DPIO_VER_MINOR 1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070013
14/* Command IDs */
15#define DPIO_CMDID_CLOSE 0x800
16#define DPIO_CMDID_OPEN 0x803
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053017#define DPIO_CMDID_CREATE 0x903
18#define DPIO_CMDID_DESTROY 0x900
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070019
20#define DPIO_CMDID_ENABLE 0x002
21#define DPIO_CMDID_DISABLE 0x003
22#define DPIO_CMDID_GET_ATTR 0x004
23#define DPIO_CMDID_RESET 0x005
24
25/* cmd, param, offset, width, type, arg_name */
26#define DPIO_CMD_OPEN(cmd, dpio_id) \
27 MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
28
29/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053030#define DPIO_CMD_CREATE(cmd, cfg) \
31do { \
32 MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
33 cfg->channel_mode);\
34 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
35} while (0)
36
37/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070038#define DPIO_RSP_GET_ATTR(cmd, attr) \
39do { \
40 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
41 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
42 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
43 MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053044 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
45 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070046 MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
47 MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
48} while (0)
49
50/* Data Path I/O Portal API
51 * Contains initialization APIs and runtime control APIs for DPIO
52 */
53
54struct fsl_mc_io;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053055
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070056/**
57 * dpio_open() - Open a control session for the specified object
58 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053059 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070060 * @dpio_id: DPIO unique ID
61 * @token: Returned token; use in subsequent API calls
62 *
63 * This function can be used to open a control session for an
64 * already created object; an object may have been declared in
65 * the DPL or by calling the dpio_create() function.
66 * This function returns a unique authentication token,
67 * associated with the specific object ID and the specific MC
68 * portal; this token must be used in all subsequent commands for
69 * this specific object.
70 *
71 * Return: '0' on Success; Error code otherwise.
72 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053073int dpio_open(struct fsl_mc_io *mc_io,
74 uint32_t cmd_flags,
75 int dpio_id,
76 uint16_t *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070077
78/**
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053079 * dpio_close() - Close the control session of the object
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070080 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053081 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053082 * @token: Token of DPIO object
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070083 *
84 * Return: '0' on Success; Error code otherwise.
85 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053086int dpio_close(struct fsl_mc_io *mc_io,
87 uint32_t cmd_flags,
88 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070089
90/**
91 * enum dpio_channel_mode - DPIO notification channel mode
92 * @DPIO_NO_CHANNEL: No support for notification channel
93 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
94 * dedicated channel in the DPIO; user should point the queue's
95 * destination in the relevant interface to this DPIO
96 */
97enum dpio_channel_mode {
98 DPIO_NO_CHANNEL = 0,
99 DPIO_LOCAL_CHANNEL = 1,
100};
101
102/**
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530103 * struct dpio_cfg - Structure representing DPIO configuration
104 * @channel_mode: Notification channel mode
105 * @num_priorities: Number of priorities for the notification channel (1-8);
106 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
107 */
108struct dpio_cfg {
109 enum dpio_channel_mode channel_mode;
110 uint8_t num_priorities;
111};
112
113/**
114 * dpio_create() - Create the DPIO object.
115 * @mc_io: Pointer to MC portal's I/O object
116 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
117 * @cfg: Configuration structure
118 * @token: Returned token; use in subsequent API calls
119 *
120 * Create the DPIO object, allocate required resources and
121 * perform required initialization.
122 *
123 * The object can be created either by declaring it in the
124 * DPL file, or by calling this function.
125 *
126 * This function returns a unique authentication token,
127 * associated with the specific object ID and the specific MC
128 * portal; this token must be used in all subsequent calls to
129 * this specific object. For objects that are created using the
130 * DPL file, call dpio_open() function to get an authentication
131 * token first.
132 *
133 * Return: '0' on Success; Error code otherwise.
134 */
135int dpio_create(struct fsl_mc_io *mc_io,
136 uint32_t cmd_flags,
137 const struct dpio_cfg *cfg,
138 uint16_t *token);
139
140/**
141 * dpio_destroy() - Destroy the DPIO object and release all its resources.
142 * @mc_io: Pointer to MC portal's I/O object
143 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
144 * @token: Token of DPIO object
145 *
146 * Return: '0' on Success; Error code otherwise
147 */
148int dpio_destroy(struct fsl_mc_io *mc_io,
149 uint32_t cmd_flags,
150 uint16_t token);
151
152/**
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700153 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
154 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530155 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700156 * @token: Token of DPIO object
157 *
158 * Return: '0' on Success; Error code otherwise
159 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530160int dpio_enable(struct fsl_mc_io *mc_io,
161 uint32_t cmd_flags,
162 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700163
164/**
165 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
166 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530167 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700168 * @token: Token of DPIO object
169 *
170 * Return: '0' on Success; Error code otherwise
171 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530172int dpio_disable(struct fsl_mc_io *mc_io,
173 uint32_t cmd_flags,
174 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700175
176/**
177 * dpio_reset() - Reset the DPIO, returns the object to initial state.
178 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530179 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700180 * @token: Token of DPIO object
181 *
182 * Return: '0' on Success; Error code otherwise.
183 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530184int dpio_reset(struct fsl_mc_io *mc_io,
185 uint32_t cmd_flags,
186 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700187
188/**
189 * struct dpio_attr - Structure representing DPIO attributes
190 * @id: DPIO object ID
191 * @version: DPIO version
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530192 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
193 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700194 * @qbman_portal_id: Software portal ID
195 * @channel_mode: Notification channel mode
196 * @num_priorities: Number of priorities for the notification channel (1-8);
197 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
198 */
199struct dpio_attr {
200 int id;
201 /**
202 * struct version - DPIO version
203 * @major: DPIO major version
204 * @minor: DPIO minor version
205 */
206 struct {
207 uint16_t major;
208 uint16_t minor;
209 } version;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530210 uint64_t qbman_portal_ce_offset;
211 uint64_t qbman_portal_ci_offset;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700212 uint16_t qbman_portal_id;
213 enum dpio_channel_mode channel_mode;
214 uint8_t num_priorities;
215};
216
217/**
218 * dpio_get_attributes() - Retrieve DPIO attributes
219 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530220 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700221 * @token: Token of DPIO object
222 * @attr: Returned object's attributes
223 *
224 * Return: '0' on Success; Error code otherwise
225 */
226int dpio_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530227 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700228 uint16_t token,
229 struct dpio_attr *attr);
230
231#endif /* _FSL_DPIO_H */