blob: 5401e861f0f049404d37aaecb5e11b79c59566fb [file] [log] [blame]
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07001/*
2 * Freescale Layerscape MC I/O wrapper
3 *
Yogesh Gaur318c32f2017-11-15 11:59:31 +05304 * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
5 * Copyright 2017 NXP
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07006 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9/*!
10 * @file fsl_dpbp.h
11 * @brief Data Path Buffer Pool API
12 */
13#ifndef __FSL_DPBP_H
14#define __FSL_DPBP_H
15
16/* DPBP Version */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053017#define DPBP_VER_MAJOR 3
18#define DPBP_VER_MINOR 3
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070019
20/* Command IDs */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053021#define DPBP_CMDID_CLOSE 0x8001
22#define DPBP_CMDID_OPEN 0x8041
23#define DPBP_CMDID_CREATE 0x9041
24#define DPBP_CMDID_DESTROY 0x9841
25#define DPBP_CMDID_GET_API_VERSION 0xa041
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070026
Yogesh Gaur318c32f2017-11-15 11:59:31 +053027#define DPBP_CMDID_ENABLE 0x0021
28#define DPBP_CMDID_DISABLE 0x0031
29#define DPBP_CMDID_GET_ATTR 0x0041
30#define DPBP_CMDID_RESET 0x0051
31#define DPBP_CMDID_IS_ENABLED 0x0061
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070032
33/* cmd, param, offset, width, type, arg_name */
34#define DPBP_CMD_OPEN(cmd, dpbp_id) \
35 MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
36
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053037/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070038#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
39do { \
40 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
41 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070042} while (0)
43
44/* Data Path Buffer Pool API
45 * Contains initialization APIs and runtime control APIs for DPBP
46 */
47
48struct fsl_mc_io;
49
50/**
51 * dpbp_open() - Open a control session for the specified object.
52 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053053 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070054 * @dpbp_id: DPBP unique ID
55 * @token: Returned token; use in subsequent API calls
56 *
57 * This function can be used to open a control session for an
58 * already created object; an object may have been declared in
59 * the DPL or by calling the dpbp_create function.
60 * This function returns a unique authentication token,
61 * associated with the specific object ID and the specific MC
62 * portal; this token must be used in all subsequent commands for
63 * this specific object
64 *
65 * Return: '0' on Success; Error code otherwise.
66 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053067int dpbp_open(struct fsl_mc_io *mc_io,
68 uint32_t cmd_flags,
69 int dpbp_id,
70 uint16_t *token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070071
72/**
73 * dpbp_close() - Close the control session of the object
74 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053075 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070076 * @token: Token of DPBP object
77 *
78 * After this function is called, no further operations are
79 * allowed on the object without opening a new control session.
80 *
81 * Return: '0' on Success; Error code otherwise.
82 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053083int dpbp_close(struct fsl_mc_io *mc_io,
84 uint32_t cmd_flags,
85 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070086
87/**
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053088 * struct dpbp_cfg - Structure representing DPBP configuration
89 * @options: place holder
90 */
91struct dpbp_cfg {
92 uint32_t options;
93};
94
95/**
96 * dpbp_create() - Create the DPBP object.
97 * @mc_io: Pointer to MC portal's I/O object
98 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
99 * @cfg: Configuration structure
100 * @token: Returned token; use in subsequent API calls
101 *
102 * Create the DPBP object, allocate required resources and
103 * perform required initialization.
104 *
105 * The object can be created either by declaring it in the
106 * DPL file, or by calling this function.
107 * This function returns a unique authentication token,
108 * associated with the specific object ID and the specific MC
109 * portal; this token must be used in all subsequent calls to
110 * this specific object. For objects that are created using the
111 * DPL file, call dpbp_open function to get an authentication
112 * token first.
113 *
114 * Return: '0' on Success; Error code otherwise.
115 */
116int dpbp_create(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530117 uint16_t dprc_token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530118 uint32_t cmd_flags,
119 const struct dpbp_cfg *cfg,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530120 uint32_t *obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530121
122/**
123 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
124 * @mc_io: Pointer to MC portal's I/O object
125 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
126 * @token: Token of DPBP object
127 *
128 * Return: '0' on Success; error code otherwise.
129 */
130int dpbp_destroy(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530131 uint16_t dprc_token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530132 uint32_t cmd_flags,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530133 uint32_t obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530134
135/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700136 * dpbp_enable() - Enable the DPBP.
137 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530138 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700139 * @token: Token of DPBP object
140 *
141 * Return: '0' on Success; Error code otherwise.
142 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530143int dpbp_enable(struct fsl_mc_io *mc_io,
144 uint32_t cmd_flags,
145 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700146
147/**
148 * dpbp_disable() - Disable the DPBP.
149 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530150 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700151 * @token: Token of DPBP object
152 *
153 * Return: '0' on Success; Error code otherwise.
154 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530155int dpbp_disable(struct fsl_mc_io *mc_io,
156 uint32_t cmd_flags,
157 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700158
159/**
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530160 * dpbp_is_enabled() - Check if the DPBP is enabled.
161 * @mc_io: Pointer to MC portal's I/O object
162 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
163 * @token: Token of DPBP object
164 * @en: Returns '1' if object is enabled; '0' otherwise
165 *
166 * Return: '0' on Success; Error code otherwise.
167 */
168int dpbp_is_enabled(struct fsl_mc_io *mc_io,
169 uint32_t cmd_flags,
170 uint16_t token,
171 int *en);
172
173/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700174 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
175 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530176 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700177 * @token: Token of DPBP object
178 *
179 * Return: '0' on Success; Error code otherwise.
180 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530181int dpbp_reset(struct fsl_mc_io *mc_io,
182 uint32_t cmd_flags,
183 uint16_t token);
184
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700185
186/**
187 * struct dpbp_attr - Structure representing DPBP attributes
188 * @id: DPBP object ID
189 * @version: DPBP version
190 * @bpid: Hardware buffer pool ID; should be used as an argument in
191 * acquire/release operations on buffers
192 */
193struct dpbp_attr {
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530194 uint32_t id;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700195 uint16_t bpid;
196};
197
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700198/**
199 * dpbp_get_attributes - Retrieve DPBP attributes.
200 *
201 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530202 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700203 * @token: Token of DPBP object
204 * @attr: Returned object's attributes
205 *
206 * Return: '0' on Success; Error code otherwise.
207 */
208int dpbp_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530209 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700210 uint16_t token,
211 struct dpbp_attr *attr);
212
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530213/**
214 * dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
215 *
216 * @mc_io: Pointer to MC portal's I/O object
217 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
218 * @major_ver: DPBP major version
219 * @minor_ver: DPBP minor version
220 *
221 * Return: '0' on Success; Error code otherwise.
222 */
223int dpbp_get_api_version(struct fsl_mc_io *mc_io,
224 u32 cmd_flags,
225 u16 *major_ver,
226 u16 *minor_ver);
227
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700228/** @} */
229
230#endif /* __FSL_DPBP_H */