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 |
| 18 | #define DPBP_VER_MINOR 0 |
| 19 | |
| 20 | /* Command IDs */ |
| 21 | #define DPBP_CMDID_CLOSE 0x800 |
| 22 | #define DPBP_CMDID_OPEN 0x804 |
| 23 | |
| 24 | #define DPBP_CMDID_ENABLE 0x002 |
| 25 | #define DPBP_CMDID_DISABLE 0x003 |
| 26 | #define DPBP_CMDID_GET_ATTR 0x004 |
| 27 | #define DPBP_CMDID_RESET 0x005 |
| 28 | |
| 29 | /* cmd, param, offset, width, type, arg_name */ |
| 30 | #define DPBP_CMD_OPEN(cmd, dpbp_id) \ |
| 31 | MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id) |
| 32 | |
| 33 | /* cmd, param, offset, width, type, arg_name */ |
| 34 | #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ |
| 35 | do { \ |
| 36 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \ |
| 37 | MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ |
| 38 | MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\ |
| 39 | MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\ |
| 40 | } while (0) |
| 41 | |
| 42 | /* Data Path Buffer Pool API |
| 43 | * Contains initialization APIs and runtime control APIs for DPBP |
| 44 | */ |
| 45 | |
| 46 | struct fsl_mc_io; |
| 47 | |
| 48 | /** |
| 49 | * dpbp_open() - Open a control session for the specified object. |
| 50 | * @mc_io: Pointer to MC portal's I/O object |
| 51 | * @dpbp_id: DPBP unique ID |
| 52 | * @token: Returned token; use in subsequent API calls |
| 53 | * |
| 54 | * This function can be used to open a control session for an |
| 55 | * already created object; an object may have been declared in |
| 56 | * the DPL or by calling the dpbp_create function. |
| 57 | * This function returns a unique authentication token, |
| 58 | * associated with the specific object ID and the specific MC |
| 59 | * portal; this token must be used in all subsequent commands for |
| 60 | * this specific object |
| 61 | * |
| 62 | * Return: '0' on Success; Error code otherwise. |
| 63 | */ |
| 64 | int dpbp_open(struct fsl_mc_io *mc_io, int dpbp_id, uint16_t *token); |
| 65 | |
| 66 | /** |
| 67 | * dpbp_close() - Close the control session of the object |
| 68 | * @mc_io: Pointer to MC portal's I/O object |
| 69 | * @token: Token of DPBP object |
| 70 | * |
| 71 | * After this function is called, no further operations are |
| 72 | * allowed on the object without opening a new control session. |
| 73 | * |
| 74 | * Return: '0' on Success; Error code otherwise. |
| 75 | */ |
| 76 | int dpbp_close(struct fsl_mc_io *mc_io, uint16_t token); |
| 77 | |
| 78 | /** |
| 79 | * dpbp_enable() - Enable the DPBP. |
| 80 | * @mc_io: Pointer to MC portal's I/O object |
| 81 | * @token: Token of DPBP object |
| 82 | * |
| 83 | * Return: '0' on Success; Error code otherwise. |
| 84 | */ |
| 85 | |
| 86 | int dpbp_enable(struct fsl_mc_io *mc_io, uint16_t token); |
| 87 | |
| 88 | /** |
| 89 | * dpbp_disable() - Disable the DPBP. |
| 90 | * @mc_io: Pointer to MC portal's I/O object |
| 91 | * @token: Token of DPBP object |
| 92 | * |
| 93 | * Return: '0' on Success; Error code otherwise. |
| 94 | */ |
| 95 | int dpbp_disable(struct fsl_mc_io *mc_io, uint16_t token); |
| 96 | |
| 97 | /** |
| 98 | * dpbp_reset() - Reset the DPBP, returns the object to initial state. |
| 99 | * @mc_io: Pointer to MC portal's I/O object |
| 100 | * @token: Token of DPBP object |
| 101 | * |
| 102 | * Return: '0' on Success; Error code otherwise. |
| 103 | */ |
| 104 | int dpbp_reset(struct fsl_mc_io *mc_io, uint16_t token); |
| 105 | |
| 106 | /** |
| 107 | * struct dpbp_attr - Structure representing DPBP attributes |
| 108 | * @id: DPBP object ID |
| 109 | * @version: DPBP version |
| 110 | * @bpid: Hardware buffer pool ID; should be used as an argument in |
| 111 | * acquire/release operations on buffers |
| 112 | */ |
| 113 | struct dpbp_attr { |
| 114 | int id; |
| 115 | /** |
| 116 | * struct version - Structure representing DPBP version |
| 117 | * @major: DPBP major version |
| 118 | * @minor: DPBP minor version |
| 119 | */ |
| 120 | struct { |
| 121 | uint16_t major; |
| 122 | uint16_t minor; |
| 123 | } version; |
| 124 | uint16_t bpid; |
| 125 | }; |
| 126 | |
| 127 | |
| 128 | /** |
| 129 | * dpbp_get_attributes - Retrieve DPBP attributes. |
| 130 | * |
| 131 | * @mc_io: Pointer to MC portal's I/O object |
| 132 | * @token: Token of DPBP object |
| 133 | * @attr: Returned object's attributes |
| 134 | * |
| 135 | * Return: '0' on Success; Error code otherwise. |
| 136 | */ |
| 137 | int dpbp_get_attributes(struct fsl_mc_io *mc_io, |
| 138 | uint16_t token, |
| 139 | struct dpbp_attr *attr); |
| 140 | |
| 141 | /** @} */ |
| 142 | |
| 143 | #endif /* __FSL_DPBP_H */ |