1 /* 2 * Copyright (c) 2017-2018 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 * 27 * $FreeBSD: stable/10/sys/dev/qlnx/qlnxe/ecore_hw.h 337519 2018-08-09 01:39:47Z davidcs $ 28 * 29 */ 30 31 #ifndef __ECORE_HW_H__ 32 #define __ECORE_HW_H__ 33 34 #include "ecore.h" 35 #include "ecore_dev_api.h" 36 37 /* Forward decleration */ 38 struct ecore_ptt; 39 40 enum reserved_ptts { 41 RESERVED_PTT_EDIAG, 42 RESERVED_PTT_USER_SPACE, 43 RESERVED_PTT_MAIN, 44 RESERVED_PTT_DPC, 45 RESERVED_PTT_MAX 46 }; 47 48 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1 49 * instead of 0, this should be fixed in later HW versions. 50 */ 51 #ifndef MISC_REG_DRIVER_CONTROL_0 52 #define MISC_REG_DRIVER_CONTROL_0 MISC_REG_DRIVER_CONTROL_1 53 #endif 54 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE 55 #define MISC_REG_DRIVER_CONTROL_0_SIZE MISC_REG_DRIVER_CONTROL_1_SIZE 56 #endif 57 58 enum _dmae_cmd_dst_mask { 59 DMAE_CMD_DST_MASK_NONE = 0, 60 DMAE_CMD_DST_MASK_PCIE = 1, 61 DMAE_CMD_DST_MASK_GRC = 2 62 }; 63 64 enum _dmae_cmd_src_mask { 65 DMAE_CMD_SRC_MASK_PCIE = 0, 66 DMAE_CMD_SRC_MASK_GRC = 1 67 }; 68 69 enum _dmae_cmd_crc_mask { 70 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0, 71 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1 72 }; 73 74 /* definitions for DMA constants */ 75 #define DMAE_GO_VALUE 0x1 76 77 #ifdef __BIG_ENDIAN 78 #define DMAE_COMPLETION_VAL 0xAED10000 79 #define DMAE_CMD_ENDIANITY 0x3 80 #else 81 #define DMAE_COMPLETION_VAL 0xD1AE 82 #define DMAE_CMD_ENDIANITY 0x2 83 #endif 84 85 #define DMAE_CMD_SIZE 14 86 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */ 87 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5) 88 /* Minimum wait for dmae opertaion to complete 2 milliseconds */ 89 #define DMAE_MIN_WAIT_TIME 0x2 90 #define DMAE_MAX_CLIENTS 32 91 92 /** 93 * @brief ecore_gtt_init - Initialize GTT windows 94 * 95 * @param p_hwfn 96 * @param p_ptt 97 */ 98 void ecore_gtt_init(struct ecore_hwfn *p_hwfn, 99 struct ecore_ptt *p_ptt); 100 101 /** 102 * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured 103 * 104 * @param p_hwfn 105 */ 106 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn); 107 108 /** 109 * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool 110 * 111 * @param p_hwfn 112 * 113 * @return _ecore_status_t - success (0), negative - error. 114 */ 115 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn); 116 117 /** 118 * @brief ecore_ptt_pool_free - 119 * 120 * @param p_hwfn 121 */ 122 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn); 123 124 /** 125 * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address 126 * 127 * @param p_hwfn 128 * @param p_ptt 129 * 130 * @return u32 131 */ 132 u32 ecore_ptt_get_bar_addr(struct ecore_ptt *p_ptt); 133 134 /** 135 * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address 136 * 137 * @param p_hwfn 138 * @param new_hw_addr 139 * @param p_ptt 140 */ 141 void ecore_ptt_set_win(struct ecore_hwfn *p_hwfn, 142 struct ecore_ptt *p_ptt, 143 u32 new_hw_addr); 144 145 /** 146 * @brief ecore_get_reserved_ptt - Get a specific reserved PTT 147 * 148 * @param p_hwfn 149 * @param ptt_idx 150 * 151 * @return struct ecore_ptt * 152 */ 153 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn *p_hwfn, 154 enum reserved_ptts ptt_idx); 155 156 /** 157 * @brief ecore_wr - Write value to BAR using the given ptt 158 * 159 * @param p_hwfn 160 * @param p_ptt 161 * @param hw_addr 162 * @param val 163 */ 164 void ecore_wr(struct ecore_hwfn *p_hwfn, 165 struct ecore_ptt *p_ptt, 166 u32 hw_addr, 167 u32 val); 168 169 /** 170 * @brief ecore_rd - Read value from BAR using the given ptt 171 * 172 * @param p_hwfn 173 * @param p_ptt 174 * @param hw_addr 175 */ 176 u32 ecore_rd(struct ecore_hwfn *p_hwfn, 177 struct ecore_ptt *p_ptt, 178 u32 hw_addr); 179 180 /** 181 * @brief ecore_memcpy_from - copy n bytes from BAR using the given 182 * ptt 183 * 184 * @param p_hwfn 185 * @param p_ptt 186 * @param dest 187 * @param hw_addr 188 * @param n 189 */ 190 void ecore_memcpy_from(struct ecore_hwfn *p_hwfn, 191 struct ecore_ptt *p_ptt, 192 void *dest, 193 u32 hw_addr, 194 osal_size_t n); 195 196 /** 197 * @brief ecore_memcpy_to - copy n bytes to BAR using the given 198 * ptt 199 * 200 * @param p_hwfn 201 * @param p_ptt 202 * @param hw_addr 203 * @param src 204 * @param n 205 */ 206 void ecore_memcpy_to(struct ecore_hwfn *p_hwfn, 207 struct ecore_ptt *p_ptt, 208 u32 hw_addr, 209 void *src, 210 osal_size_t n); 211 /** 212 * @brief ecore_fid_pretend - pretend to another function when 213 * accessing the ptt window. There is no way to unpretend 214 * a function. The only way to cancel a pretend is to 215 * pretend back to the original function. 216 * 217 * @param p_hwfn 218 * @param p_ptt 219 * @param fid - fid field of pxp_pretend structure. Can contain 220 * either pf / vf, port/path fields are don't care. 221 */ 222 void ecore_fid_pretend(struct ecore_hwfn *p_hwfn, 223 struct ecore_ptt *p_ptt, 224 u16 fid); 225 226 /** 227 * @brief ecore_port_pretend - pretend to another port when 228 * accessing the ptt window 229 * 230 * @param p_hwfn 231 * @param p_ptt 232 * @param port_id - the port to pretend to 233 */ 234 void ecore_port_pretend(struct ecore_hwfn *p_hwfn, 235 struct ecore_ptt *p_ptt, 236 u8 port_id); 237 238 /** 239 * @brief ecore_port_unpretend - cancel any previously set port 240 * pretend 241 * 242 * @param p_hwfn 243 * @param p_ptt 244 */ 245 void ecore_port_unpretend(struct ecore_hwfn *p_hwfn, 246 struct ecore_ptt *p_ptt); 247 248 /** 249 * @brief ecore_vfid_to_concrete - build a concrete FID for a 250 * given VF ID 251 * 252 * @param p_hwfn 253 * @param p_ptt 254 * @param vfid 255 */ 256 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid); 257 258 /** 259 * @brief ecore_dmae_info_alloc - Init the dmae_info structure 260 * which is part of p_hwfn. 261 * @param p_hwfn 262 */ 263 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn *p_hwfn); 264 265 /** 266 * @brief ecore_dmae_info_free - Free the dmae_info structure 267 * which is part of p_hwfn 268 * 269 * @param p_hwfn 270 */ 271 void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn); 272 273 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev, 274 const u8 *fw_data); 275 276 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn, 277 enum ecore_hw_err_type err_type); 278 279 enum _ecore_status_t ecore_dmae_sanity(struct ecore_hwfn *p_hwfn, 280 struct ecore_ptt *p_ptt, 281 const char *phase); 282 283 /** 284 * @brief ecore_ppfid_wr - Write value to BAR using the given ptt while 285 * pretending to a PF to which the given PPFID pertains. 286 * 287 * @param p_hwfn 288 * @param p_ptt 289 * @param abs_ppfid 290 * @param hw_addr 291 * @param val 292 */ 293 void ecore_ppfid_wr(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, 294 u8 abs_ppfid, u32 hw_addr, u32 val); 295 296 /** 297 * @brief ecore_ppfid_rd - Read value from BAR using the given ptt while 298 * pretending to a PF to which the given PPFID pertains. 299 * 300 * @param p_hwfn 301 * @param p_ptt 302 * @param abs_ppfid 303 * @param hw_addr 304 */ 305 u32 ecore_ppfid_rd(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, 306 u8 abs_ppfid, u32 hw_addr); 307 308 #endif /* __ECORE_HW_H__ */ 309