2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
43 /* Data Path Buffer Pool API
44 * Contains initialization APIs and runtime control APIs for DPBP
50 * dpbp_open() - Open a control session for the specified object.
51 * @mc_io: Pointer to MC portal's I/O object
52 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
53 * @dpbp_id: DPBP unique ID
54 * @token: Returned token; use in subsequent API calls
56 * This function can be used to open a control session for an
57 * already created object; an object may have been declared in
58 * the DPL or by calling the dpbp_create function.
59 * This function returns a unique authentication token,
60 * associated with the specific object ID and the specific MC
61 * portal; this token must be used in all subsequent commands for
62 * this specific object
64 * Return: '0' on Success; Error code otherwise.
66 int dpbp_open(struct fsl_mc_io *mc_io,
72 * dpbp_close() - Close the control session of the object
73 * @mc_io: Pointer to MC portal's I/O object
74 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
75 * @token: Token of DPBP object
77 * After this function is called, no further operations are
78 * allowed on the object without opening a new control session.
80 * Return: '0' on Success; Error code otherwise.
82 int dpbp_close(struct fsl_mc_io *mc_io,
87 * struct dpbp_cfg - Structure representing DPBP configuration
88 * @options: place holder
95 * dpbp_create() - Create the DPBP object.
96 * @mc_io: Pointer to MC portal's I/O object
97 * @dprc_token: Parent container token; '0' for default container
98 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
99 * @cfg: Configuration structure
100 * @obj_id: returned object id
102 * Create the DPBP object, allocate required resources and
103 * perform required initialization.
105 * The object can be created either by declaring it in the
106 * DPL file, or by calling this function.
108 * The function accepts an authentication token of a parent
109 * container that this object should be assigned to. The token
110 * can be '0' so the object will be assigned to the default container.
111 * The newly created object can be opened with the returned
112 * object id and using the container's associated tokens and MC portals.
114 * Return: '0' on Success; Error code otherwise.
116 int dpbp_create(struct fsl_mc_io *mc_io,
119 const struct dpbp_cfg *cfg,
123 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
124 * @dprc_token: Parent container token; '0' for default container
125 * @mc_io: Pointer to MC portal's I/O object
126 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
127 * @object_id: The object id; it must be a valid id within the container that
128 * created this object;
130 * Return: '0' on Success; error code otherwise.
132 int dpbp_destroy(struct fsl_mc_io *mc_io,
138 * dpbp_enable() - Enable the DPBP.
139 * @mc_io: Pointer to MC portal's I/O object
140 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
141 * @token: Token of DPBP object
143 * Return: '0' on Success; Error code otherwise.
145 int dpbp_enable(struct fsl_mc_io *mc_io,
150 * dpbp_disable() - Disable the DPBP.
151 * @mc_io: Pointer to MC portal's I/O object
152 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
153 * @token: Token of DPBP object
155 * Return: '0' on Success; Error code otherwise.
157 int dpbp_disable(struct fsl_mc_io *mc_io,
162 * dpbp_is_enabled() - Check if the DPBP is enabled.
163 * @mc_io: Pointer to MC portal's I/O object
164 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
165 * @token: Token of DPBP object
166 * @en: Returns '1' if object is enabled; '0' otherwise
168 * Return: '0' on Success; Error code otherwise.
170 int dpbp_is_enabled(struct fsl_mc_io *mc_io,
176 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
177 * @mc_io: Pointer to MC portal's I/O object
178 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
179 * @token: Token of DPBP object
181 * Return: '0' on Success; Error code otherwise.
183 int dpbp_reset(struct fsl_mc_io *mc_io,
188 * struct dpbp_attr - Structure representing DPBP attributes
189 * @id: DPBP object ID
190 * @bpid: Hardware buffer pool ID; should be used as an argument in
191 * acquire/release operations on buffers
199 * dpbp_get_attributes - Retrieve DPBP attributes.
201 * @mc_io: Pointer to MC portal's I/O object
202 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
203 * @token: Token of DPBP object
204 * @attr: Returned object's attributes
206 * Return: '0' on Success; Error code otherwise.
208 int dpbp_get_attributes(struct fsl_mc_io *mc_io,
211 struct dpbp_attr *attr);
214 * dpbp_get_api_version() - Get buffer pool API version
215 * @mc_io: Pointer to MC portal's I/O object
216 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
217 * @major_ver: Major version of data path buffer pool API
218 * @minor_ver: Minor version of data path buffer pool API
220 * Return: '0' on Success; Error code otherwise.
222 int dpbp_get_api_version(struct fsl_mc_io *mc_io,
225 uint16_t *minor_ver);
228 * dpbp_get_num_free_bufs() - Get number of free buffers in the buffer pool
229 * @mc_io: Pointer to MC portal's I/O object
230 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
231 * @token: Token of DPBP object
232 * @num_free_bufs: Number of free buffers
234 * Return: '0' on Success; Error code otherwise.
236 int dpbp_get_num_free_bufs(struct fsl_mc_io *mc_io,
239 uint32_t *num_free_bufs);
241 #endif /* __FSL_DPBP_H */