Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Freescale Layerscape MC I/O wrapper |
| 3 | * |
| 4 | * Copyright (C) 2013-2015 Freescale Semiconductor, Inc. |
| 5 | * Author: German Rivera <German.Rivera@freescale.com> |
| 6 | * |
| 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 */ |
| 17 | #define DPBP_VER_MAJOR 2 |
Prabhakar Kushwaha | c3d06e3 | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 18 | #define DPBP_VER_MINOR 2 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 19 | |
| 20 | /* Command IDs */ |
| 21 | #define DPBP_CMDID_CLOSE 0x800 |
| 22 | #define DPBP_CMDID_OPEN 0x804 |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 23 | #define DPBP_CMDID_CREATE 0x904 |
| 24 | #define DPBP_CMDID_DESTROY 0x900 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 25 | |
| 26 | #define DPBP_CMDID_ENABLE 0x002 |
| 27 | #define DPBP_CMDID_DISABLE 0x003 |
| 28 | #define DPBP_CMDID_GET_ATTR 0x004 |
| 29 | #define DPBP_CMDID_RESET 0x005 |
| 30 | |
| 31 | /* cmd, param, offset, width, type, arg_name */ |
| 32 | #define DPBP_CMD_OPEN(cmd, dpbp_id) \ |
| 33 | MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id) |
| 34 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 35 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 36 | #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ |
| 37 | do { \ |
| 38 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \ |
| 39 | MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ |
| 40 | MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\ |
| 41 | MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\ |
| 42 | } while (0) |
| 43 | |
| 44 | /* Data Path Buffer Pool API |
| 45 | * Contains initialization APIs and runtime control APIs for DPBP |
| 46 | */ |
| 47 | |
| 48 | struct 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 Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 53 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 54 | * @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 Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 67 | int dpbp_open(struct fsl_mc_io *mc_io, |
| 68 | uint32_t cmd_flags, |
| 69 | int dpbp_id, |
| 70 | uint16_t *token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * dpbp_close() - Close the control session of the object |
| 74 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 75 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 76 | * @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 Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 83 | int dpbp_close(struct fsl_mc_io *mc_io, |
| 84 | uint32_t cmd_flags, |
| 85 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 86 | |
| 87 | /** |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 88 | * struct dpbp_cfg - Structure representing DPBP configuration |
| 89 | * @options: place holder |
| 90 | */ |
| 91 | struct 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 | */ |
| 116 | int dpbp_create(struct fsl_mc_io *mc_io, |
| 117 | uint32_t cmd_flags, |
| 118 | const struct dpbp_cfg *cfg, |
| 119 | uint16_t *token); |
| 120 | |
| 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 | */ |
| 129 | int dpbp_destroy(struct fsl_mc_io *mc_io, |
| 130 | uint32_t cmd_flags, |
| 131 | uint16_t token); |
| 132 | |
| 133 | /** |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 134 | * dpbp_enable() - Enable the DPBP. |
| 135 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 136 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 137 | * @token: Token of DPBP object |
| 138 | * |
| 139 | * Return: '0' on Success; Error code otherwise. |
| 140 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 141 | int dpbp_enable(struct fsl_mc_io *mc_io, |
| 142 | uint32_t cmd_flags, |
| 143 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * dpbp_disable() - Disable the DPBP. |
| 147 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 148 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 149 | * @token: Token of DPBP object |
| 150 | * |
| 151 | * Return: '0' on Success; Error code otherwise. |
| 152 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 153 | int dpbp_disable(struct fsl_mc_io *mc_io, |
| 154 | uint32_t cmd_flags, |
| 155 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 158 | * dpbp_is_enabled() - Check if the DPBP is enabled. |
| 159 | * @mc_io: Pointer to MC portal's I/O object |
| 160 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 161 | * @token: Token of DPBP object |
| 162 | * @en: Returns '1' if object is enabled; '0' otherwise |
| 163 | * |
| 164 | * Return: '0' on Success; Error code otherwise. |
| 165 | */ |
| 166 | int dpbp_is_enabled(struct fsl_mc_io *mc_io, |
| 167 | uint32_t cmd_flags, |
| 168 | uint16_t token, |
| 169 | int *en); |
| 170 | |
| 171 | /** |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 172 | * dpbp_reset() - Reset the DPBP, returns the object to initial state. |
| 173 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 174 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 175 | * @token: Token of DPBP object |
| 176 | * |
| 177 | * Return: '0' on Success; Error code otherwise. |
| 178 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 179 | int dpbp_reset(struct fsl_mc_io *mc_io, |
| 180 | uint32_t cmd_flags, |
| 181 | uint16_t token); |
| 182 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 183 | |
| 184 | /** |
| 185 | * struct dpbp_attr - Structure representing DPBP attributes |
| 186 | * @id: DPBP object ID |
| 187 | * @version: DPBP version |
| 188 | * @bpid: Hardware buffer pool ID; should be used as an argument in |
| 189 | * acquire/release operations on buffers |
| 190 | */ |
| 191 | struct dpbp_attr { |
| 192 | int id; |
| 193 | /** |
| 194 | * struct version - Structure representing DPBP version |
| 195 | * @major: DPBP major version |
| 196 | * @minor: DPBP minor version |
| 197 | */ |
| 198 | struct { |
| 199 | uint16_t major; |
| 200 | uint16_t minor; |
| 201 | } version; |
| 202 | uint16_t bpid; |
| 203 | }; |
| 204 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 205 | /** |
| 206 | * dpbp_get_attributes - Retrieve DPBP attributes. |
| 207 | * |
| 208 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 209 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 210 | * @token: Token of DPBP object |
| 211 | * @attr: Returned object's attributes |
| 212 | * |
| 213 | * Return: '0' on Success; Error code otherwise. |
| 214 | */ |
| 215 | int dpbp_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 216 | uint32_t cmd_flags, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 217 | uint16_t token, |
| 218 | struct dpbp_attr *attr); |
| 219 | |
| 220 | /** @} */ |
| 221 | |
| 222 | #endif /* __FSL_DPBP_H */ |