1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Freescale Layerscape MC I/O wrapper 4 * 5 * Copyright 2013-2016 Freescale Semiconductor, Inc. 6 * Copyright 2017 NXP 7 */ 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 */ 16 #define DPBP_VER_MAJOR 3 17 #define DPBP_VER_MINOR 3 18 19 /* Command IDs */ 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 25 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 31 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 36 /* cmd, param, offset, width, type, arg_name */ 37 #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ 38 do { \ 39 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \ 40 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ 41 } while (0) 42 43 /* Data Path Buffer Pool API 44 * Contains initialization APIs and runtime control APIs for DPBP 45 */ 46 47 struct 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 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 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 */ 66 int dpbp_open(struct fsl_mc_io *mc_io, 67 uint32_t cmd_flags, 68 int dpbp_id, 69 uint16_t *token); 70 71 /** 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 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 */ 82 int dpbp_close(struct fsl_mc_io *mc_io, 83 uint32_t cmd_flags, 84 uint16_t token); 85 86 /** 87 * struct dpbp_cfg - Structure representing DPBP configuration 88 * @options: place holder 89 */ 90 struct 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 */ 115 int dpbp_create(struct fsl_mc_io *mc_io, 116 uint16_t dprc_token, 117 uint32_t cmd_flags, 118 const struct dpbp_cfg *cfg, 119 uint32_t *obj_id); 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 uint16_t dprc_token, 131 uint32_t cmd_flags, 132 uint32_t obj_id); 133 134 /** 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 139 * 140 * Return: '0' on Success; Error code otherwise. 141 */ 142 int dpbp_enable(struct fsl_mc_io *mc_io, 143 uint32_t cmd_flags, 144 uint16_t token); 145 146 /** 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 151 * 152 * Return: '0' on Success; Error code otherwise. 153 */ 154 int dpbp_disable(struct fsl_mc_io *mc_io, 155 uint32_t cmd_flags, 156 uint16_t token); 157 158 /** 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 164 * 165 * Return: '0' on Success; Error code otherwise. 166 */ 167 int dpbp_is_enabled(struct fsl_mc_io *mc_io, 168 uint32_t cmd_flags, 169 uint16_t token, 170 int *en); 171 172 /** 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 177 * 178 * Return: '0' on Success; Error code otherwise. 179 */ 180 int dpbp_reset(struct fsl_mc_io *mc_io, 181 uint32_t cmd_flags, 182 uint16_t token); 183 184 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 */ 192 struct dpbp_attr { 193 uint32_t id; 194 uint16_t bpid; 195 }; 196 197 /** 198 * dpbp_get_attributes - Retrieve DPBP attributes. 199 * 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 204 * 205 * Return: '0' on Success; Error code otherwise. 206 */ 207 int dpbp_get_attributes(struct fsl_mc_io *mc_io, 208 uint32_t cmd_flags, 209 uint16_t token, 210 struct dpbp_attr *attr); 211 212 /** 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 */ 222 int dpbp_get_api_version(struct fsl_mc_io *mc_io, 223 u32 cmd_flags, 224 u16 *major_ver, 225 u16 *minor_ver); 226 227 /** @} */ 228 229 #endif /* __FSL_DPBP_H */ 230