blob: d8c458fb4fc270d6ed83afa442df0454eb536d64 [file] [log] [blame]
Prabhakar Kushwahacfd9fbf2015-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 Kushwahafd5d1272015-07-02 11:28:59 +053011#define DPIO_VER_MAJOR 3
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +053012#define DPIO_VER_MINOR 2
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070013
14/* Command IDs */
15#define DPIO_CMDID_CLOSE 0x800
16#define DPIO_CMDID_OPEN 0x803
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053017#define DPIO_CMDID_CREATE 0x903
18#define DPIO_CMDID_DESTROY 0x900
Prabhakar Kushwahacfd9fbf2015-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 Kushwahacf0c8cf2015-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 Kushwahacfd9fbf2015-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 Kushwahafd5d1272015-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 Kushwahacfd9fbf2015-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);\
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +053048 MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070049} while (0)
50
51/* Data Path I/O Portal API
52 * Contains initialization APIs and runtime control APIs for DPIO
53 */
54
55struct fsl_mc_io;
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053056
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070057/**
58 * dpio_open() - Open a control session for the specified object
59 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053060 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070061 * @dpio_id: DPIO unique ID
62 * @token: Returned token; use in subsequent API calls
63 *
64 * This function can be used to open a control session for an
65 * already created object; an object may have been declared in
66 * the DPL or by calling the dpio_create() function.
67 * This function returns a unique authentication token,
68 * associated with the specific object ID and the specific MC
69 * portal; this token must be used in all subsequent commands for
70 * this specific object.
71 *
72 * Return: '0' on Success; Error code otherwise.
73 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053074int dpio_open(struct fsl_mc_io *mc_io,
75 uint32_t cmd_flags,
76 int dpio_id,
77 uint16_t *token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070078
79/**
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053080 * dpio_close() - Close the control session of the object
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070081 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053082 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053083 * @token: Token of DPIO object
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070084 *
85 * Return: '0' on Success; Error code otherwise.
86 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053087int dpio_close(struct fsl_mc_io *mc_io,
88 uint32_t cmd_flags,
89 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070090
91/**
92 * enum dpio_channel_mode - DPIO notification channel mode
93 * @DPIO_NO_CHANNEL: No support for notification channel
94 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
95 * dedicated channel in the DPIO; user should point the queue's
96 * destination in the relevant interface to this DPIO
97 */
98enum dpio_channel_mode {
99 DPIO_NO_CHANNEL = 0,
100 DPIO_LOCAL_CHANNEL = 1,
101};
102
103/**
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530104 * struct dpio_cfg - Structure representing DPIO configuration
105 * @channel_mode: Notification channel mode
106 * @num_priorities: Number of priorities for the notification channel (1-8);
107 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
108 */
109struct dpio_cfg {
110 enum dpio_channel_mode channel_mode;
111 uint8_t num_priorities;
112};
113
114/**
115 * dpio_create() - Create the DPIO object.
116 * @mc_io: Pointer to MC portal's I/O object
117 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
118 * @cfg: Configuration structure
119 * @token: Returned token; use in subsequent API calls
120 *
121 * Create the DPIO object, allocate required resources and
122 * perform required initialization.
123 *
124 * The object can be created either by declaring it in the
125 * DPL file, or by calling this function.
126 *
127 * This function returns a unique authentication token,
128 * associated with the specific object ID and the specific MC
129 * portal; this token must be used in all subsequent calls to
130 * this specific object. For objects that are created using the
131 * DPL file, call dpio_open() function to get an authentication
132 * token first.
133 *
134 * Return: '0' on Success; Error code otherwise.
135 */
136int dpio_create(struct fsl_mc_io *mc_io,
137 uint32_t cmd_flags,
138 const struct dpio_cfg *cfg,
139 uint16_t *token);
140
141/**
142 * dpio_destroy() - Destroy the DPIO object and release all its resources.
143 * @mc_io: Pointer to MC portal's I/O object
144 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
145 * @token: Token of DPIO object
146 *
147 * Return: '0' on Success; Error code otherwise
148 */
149int dpio_destroy(struct fsl_mc_io *mc_io,
150 uint32_t cmd_flags,
151 uint16_t token);
152
153/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700154 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
155 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530156 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700157 * @token: Token of DPIO object
158 *
159 * Return: '0' on Success; Error code otherwise
160 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530161int dpio_enable(struct fsl_mc_io *mc_io,
162 uint32_t cmd_flags,
163 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700164
165/**
166 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
167 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530168 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700169 * @token: Token of DPIO object
170 *
171 * Return: '0' on Success; Error code otherwise
172 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530173int dpio_disable(struct fsl_mc_io *mc_io,
174 uint32_t cmd_flags,
175 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700176
177/**
178 * dpio_reset() - Reset the DPIO, returns the object to initial state.
179 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530180 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700181 * @token: Token of DPIO object
182 *
183 * Return: '0' on Success; Error code otherwise.
184 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530185int dpio_reset(struct fsl_mc_io *mc_io,
186 uint32_t cmd_flags,
187 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700188
189/**
190 * struct dpio_attr - Structure representing DPIO attributes
191 * @id: DPIO object ID
192 * @version: DPIO version
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +0530193 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
194 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700195 * @qbman_portal_id: Software portal ID
196 * @channel_mode: Notification channel mode
197 * @num_priorities: Number of priorities for the notification channel (1-8);
198 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +0530199 * @qbman_version: QBMAN version
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700200 */
201struct dpio_attr {
202 int id;
203 /**
204 * struct version - DPIO version
205 * @major: DPIO major version
206 * @minor: DPIO minor version
207 */
208 struct {
209 uint16_t major;
210 uint16_t minor;
211 } version;
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +0530212 uint64_t qbman_portal_ce_offset;
213 uint64_t qbman_portal_ci_offset;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700214 uint16_t qbman_portal_id;
215 enum dpio_channel_mode channel_mode;
216 uint8_t num_priorities;
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +0530217 uint32_t qbman_version;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700218};
219
220/**
221 * dpio_get_attributes() - Retrieve DPIO attributes
222 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530223 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700224 * @token: Token of DPIO object
225 * @attr: Returned object's attributes
226 *
227 * Return: '0' on Success; Error code otherwise
228 */
229int dpio_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530230 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700231 uint16_t token,
232 struct dpio_attr *attr);
233
234#endif /* _FSL_DPIO_H */