1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Freescale Layerscape MC I/O wrapper
5 * Copyright 2013-2016 Freescale Semiconductor, Inc.
10 * @brief Data Path Buffer Pool API
16 #define DPBP_VER_MAJOR 3
17 #define DPBP_VER_MINOR 3
20 #define DPBP_CMDID_CLOSE 0x8001
21 #define DPBP_CMDID_OPEN 0x8041
22 #define DPBP_CMDID_CREATE 0x9041
23 #define DPBP_CMDID_DESTROY 0x9841
24 #define DPBP_CMDID_GET_API_VERSION 0xa041
26 #define DPBP_CMDID_ENABLE 0x0021
27 #define DPBP_CMDID_DISABLE 0x0031
28 #define DPBP_CMDID_GET_ATTR 0x0041
29 #define DPBP_CMDID_RESET 0x0051
30 #define DPBP_CMDID_IS_ENABLED 0x0061
32 /* cmd, param, offset, width, type, arg_name */
33 #define DPBP_CMD_OPEN(cmd, dpbp_id) \
34 MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
36 /* cmd, param, offset, width, type, arg_name */
37 #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
39 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
40 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
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 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
98 * @cfg: Configuration structure
99 * @token: Returned token; use in subsequent API calls
101 * Create the DPBP object, allocate required resources and
102 * perform required initialization.
104 * The object can be created either by declaring it in the
105 * DPL file, or by calling this function.
106 * This function returns a unique authentication token,
107 * associated with the specific object ID and the specific MC
108 * portal; this token must be used in all subsequent calls to
109 * this specific object. For objects that are created using the
110 * DPL file, call dpbp_open function to get an authentication
113 * Return: '0' on Success; Error code otherwise.
115 int dpbp_create(struct fsl_mc_io *mc_io,
118 const struct dpbp_cfg *cfg,
122 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
123 * @mc_io: Pointer to MC portal's I/O object
124 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
125 * @token: Token of DPBP object
127 * Return: '0' on Success; error code otherwise.
129 int dpbp_destroy(struct fsl_mc_io *mc_io,
135 * dpbp_enable() - Enable the DPBP.
136 * @mc_io: Pointer to MC portal's I/O object
137 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
138 * @token: Token of DPBP object
140 * Return: '0' on Success; Error code otherwise.
142 int dpbp_enable(struct fsl_mc_io *mc_io,
147 * dpbp_disable() - Disable the DPBP.
148 * @mc_io: Pointer to MC portal's I/O object
149 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
150 * @token: Token of DPBP object
152 * Return: '0' on Success; Error code otherwise.
154 int dpbp_disable(struct fsl_mc_io *mc_io,
159 * dpbp_is_enabled() - Check if the DPBP is enabled.
160 * @mc_io: Pointer to MC portal's I/O object
161 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
162 * @token: Token of DPBP object
163 * @en: Returns '1' if object is enabled; '0' otherwise
165 * Return: '0' on Success; Error code otherwise.
167 int dpbp_is_enabled(struct fsl_mc_io *mc_io,
173 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
174 * @mc_io: Pointer to MC portal's I/O object
175 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
176 * @token: Token of DPBP object
178 * Return: '0' on Success; Error code otherwise.
180 int dpbp_reset(struct fsl_mc_io *mc_io,
186 * struct dpbp_attr - Structure representing DPBP attributes
187 * @id: DPBP object ID
188 * @version: DPBP version
189 * @bpid: Hardware buffer pool ID; should be used as an argument in
190 * acquire/release operations on buffers
198 * dpbp_get_attributes - Retrieve DPBP attributes.
200 * @mc_io: Pointer to MC portal's I/O object
201 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
202 * @token: Token of DPBP object
203 * @attr: Returned object's attributes
205 * Return: '0' on Success; Error code otherwise.
207 int dpbp_get_attributes(struct fsl_mc_io *mc_io,
210 struct dpbp_attr *attr);
213 * dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
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: DPBP major version
218 * @minor_ver: DPBP minor version
220 * Return: '0' on Success; Error code otherwise.
222 int dpbp_get_api_version(struct fsl_mc_io *mc_io,
229 #endif /* __FSL_DPBP_H */