blob: 2278ac952ea94d50962e72f3f59cb903badb6e62 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07002/*
3 * Freescale Layerscape MC I/O wrapper
4 *
Yogesh Gaur1a0c4ae2018-05-09 10:52:17 +05305 * Copyright 2013-2016 Freescale Semiconductor, Inc.
Yogesh Gaur318c32f2017-11-15 11:59:31 +05306 * Copyright 2017 NXP
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07007 */
8/*!
9 * @file fsl_dpbp.h
10 * @brief Data Path Buffer Pool API
11 */
12#ifndef __FSL_DPBP_H
13#define __FSL_DPBP_H
14
15/* DPBP Version */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053016#define DPBP_VER_MAJOR 3
17#define DPBP_VER_MINOR 3
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070018
19/* Command IDs */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053020#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
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070025
Yogesh Gaur318c32f2017-11-15 11:59:31 +053026#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
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070031
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)
35
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053036/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070037#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
38do { \
39 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
40 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070041} while (0)
42
43/* Data Path Buffer Pool API
44 * Contains initialization APIs and runtime control APIs for DPBP
45 */
46
47struct fsl_mc_io;
48
49/**
50 * dpbp_open() - Open a control session for the specified object.
51 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053052 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070053 * @dpbp_id: DPBP unique ID
54 * @token: Returned token; use in subsequent API calls
55 *
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
63 *
64 * Return: '0' on Success; Error code otherwise.
65 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053066int dpbp_open(struct fsl_mc_io *mc_io,
67 uint32_t cmd_flags,
68 int dpbp_id,
69 uint16_t *token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070070
71/**
72 * dpbp_close() - Close the control session of the object
73 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053074 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070075 * @token: Token of DPBP object
76 *
77 * After this function is called, no further operations are
78 * allowed on the object without opening a new control session.
79 *
80 * Return: '0' on Success; Error code otherwise.
81 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053082int dpbp_close(struct fsl_mc_io *mc_io,
83 uint32_t cmd_flags,
84 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070085
86/**
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053087 * struct dpbp_cfg - Structure representing DPBP configuration
88 * @options: place holder
89 */
90struct dpbp_cfg {
91 uint32_t options;
92};
93
94/**
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
100 *
101 * Create the DPBP object, allocate required resources and
102 * perform required initialization.
103 *
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
111 * token first.
112 *
113 * Return: '0' on Success; Error code otherwise.
114 */
115int dpbp_create(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530116 uint16_t dprc_token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530117 uint32_t cmd_flags,
118 const struct dpbp_cfg *cfg,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530119 uint32_t *obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530120
121/**
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
126 *
127 * Return: '0' on Success; error code otherwise.
128 */
129int dpbp_destroy(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530130 uint16_t dprc_token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530131 uint32_t cmd_flags,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530132 uint32_t obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530133
134/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700135 * dpbp_enable() - Enable the DPBP.
136 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530137 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700138 * @token: Token of DPBP object
139 *
140 * Return: '0' on Success; Error code otherwise.
141 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530142int dpbp_enable(struct fsl_mc_io *mc_io,
143 uint32_t cmd_flags,
144 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700145
146/**
147 * dpbp_disable() - Disable the DPBP.
148 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530149 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700150 * @token: Token of DPBP object
151 *
152 * Return: '0' on Success; Error code otherwise.
153 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530154int dpbp_disable(struct fsl_mc_io *mc_io,
155 uint32_t cmd_flags,
156 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700157
158/**
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530159 * 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
164 *
165 * Return: '0' on Success; Error code otherwise.
166 */
167int dpbp_is_enabled(struct fsl_mc_io *mc_io,
168 uint32_t cmd_flags,
169 uint16_t token,
170 int *en);
171
172/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700173 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
174 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530175 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700176 * @token: Token of DPBP object
177 *
178 * Return: '0' on Success; Error code otherwise.
179 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530180int dpbp_reset(struct fsl_mc_io *mc_io,
181 uint32_t cmd_flags,
182 uint16_t token);
183
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700184
185/**
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
191 */
192struct dpbp_attr {
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530193 uint32_t id;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700194 uint16_t bpid;
195};
196
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700197/**
198 * dpbp_get_attributes - Retrieve DPBP attributes.
199 *
200 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530201 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700202 * @token: Token of DPBP object
203 * @attr: Returned object's attributes
204 *
205 * Return: '0' on Success; Error code otherwise.
206 */
207int dpbp_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530208 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700209 uint16_t token,
210 struct dpbp_attr *attr);
211
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530212/**
213 * dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
214 *
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
219 *
220 * Return: '0' on Success; Error code otherwise.
221 */
222int dpbp_get_api_version(struct fsl_mc_io *mc_io,
223 u32 cmd_flags,
224 u16 *major_ver,
225 u16 *minor_ver);
226
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700227/** @} */
228
229#endif /* __FSL_DPBP_H */