1fe56b9e6SYuval Mintz /* QLogic qed NIC Driver 2e8f1cb50SMintz, Yuval * Copyright (c) 2015-2017 QLogic Corporation 3fe56b9e6SYuval Mintz * 4e8f1cb50SMintz, Yuval * This software is available to you under a choice of one of two 5e8f1cb50SMintz, Yuval * licenses. You may choose to be licensed under the terms of the GNU 6e8f1cb50SMintz, Yuval * General Public License (GPL) Version 2, available from the file 7e8f1cb50SMintz, Yuval * COPYING in the main directory of this source tree, or the 8e8f1cb50SMintz, Yuval * OpenIB.org BSD license below: 9e8f1cb50SMintz, Yuval * 10e8f1cb50SMintz, Yuval * Redistribution and use in source and binary forms, with or 11e8f1cb50SMintz, Yuval * without modification, are permitted provided that the following 12e8f1cb50SMintz, Yuval * conditions are met: 13e8f1cb50SMintz, Yuval * 14e8f1cb50SMintz, Yuval * - Redistributions of source code must retain the above 15e8f1cb50SMintz, Yuval * copyright notice, this list of conditions and the following 16e8f1cb50SMintz, Yuval * disclaimer. 17e8f1cb50SMintz, Yuval * 18e8f1cb50SMintz, Yuval * - Redistributions in binary form must reproduce the above 19e8f1cb50SMintz, Yuval * copyright notice, this list of conditions and the following 20e8f1cb50SMintz, Yuval * disclaimer in the documentation and /or other materials 21e8f1cb50SMintz, Yuval * provided with the distribution. 22e8f1cb50SMintz, Yuval * 23e8f1cb50SMintz, Yuval * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24e8f1cb50SMintz, Yuval * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25e8f1cb50SMintz, Yuval * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26e8f1cb50SMintz, Yuval * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27e8f1cb50SMintz, Yuval * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28e8f1cb50SMintz, Yuval * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29e8f1cb50SMintz, Yuval * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30e8f1cb50SMintz, Yuval * SOFTWARE. 31fe56b9e6SYuval Mintz */ 32fe56b9e6SYuval Mintz 33fe56b9e6SYuval Mintz #ifndef _QED_HW_H 34fe56b9e6SYuval Mintz #define _QED_HW_H 35fe56b9e6SYuval Mintz 36fe56b9e6SYuval Mintz #include <linux/types.h> 37fe56b9e6SYuval Mintz #include <linux/bitops.h> 38fe56b9e6SYuval Mintz #include <linux/slab.h> 39fe56b9e6SYuval Mintz #include <linux/string.h> 40fe56b9e6SYuval Mintz #include "qed.h" 41fe56b9e6SYuval Mintz #include "qed_dev_api.h" 42fe56b9e6SYuval Mintz 43fe56b9e6SYuval Mintz /* Forward decleration */ 44fe56b9e6SYuval Mintz struct qed_ptt; 45fe56b9e6SYuval Mintz 46fe56b9e6SYuval Mintz enum reserved_ptts { 47fe56b9e6SYuval Mintz RESERVED_PTT_EDIAG, 48fe56b9e6SYuval Mintz RESERVED_PTT_USER_SPACE, 49fe56b9e6SYuval Mintz RESERVED_PTT_MAIN, 50fe56b9e6SYuval Mintz RESERVED_PTT_DPC, 51fe56b9e6SYuval Mintz RESERVED_PTT_MAX 52fe56b9e6SYuval Mintz }; 53fe56b9e6SYuval Mintz 54fe56b9e6SYuval Mintz enum _dmae_cmd_dst_mask { 55fe56b9e6SYuval Mintz DMAE_CMD_DST_MASK_NONE = 0, 56fe56b9e6SYuval Mintz DMAE_CMD_DST_MASK_PCIE = 1, 57fe56b9e6SYuval Mintz DMAE_CMD_DST_MASK_GRC = 2 58fe56b9e6SYuval Mintz }; 59fe56b9e6SYuval Mintz 60fe56b9e6SYuval Mintz enum _dmae_cmd_src_mask { 61fe56b9e6SYuval Mintz DMAE_CMD_SRC_MASK_PCIE = 0, 62fe56b9e6SYuval Mintz DMAE_CMD_SRC_MASK_GRC = 1 63fe56b9e6SYuval Mintz }; 64fe56b9e6SYuval Mintz 65fe56b9e6SYuval Mintz enum _dmae_cmd_crc_mask { 66fe56b9e6SYuval Mintz DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0, 67fe56b9e6SYuval Mintz DMAE_CMD_COMP_CRC_EN_MASK_SET = 1 68fe56b9e6SYuval Mintz }; 69fe56b9e6SYuval Mintz 70fe56b9e6SYuval Mintz /* definitions for DMA constants */ 71fe56b9e6SYuval Mintz #define DMAE_GO_VALUE 0x1 72fe56b9e6SYuval Mintz 73fe56b9e6SYuval Mintz #define DMAE_COMPLETION_VAL 0xD1AE 74fe56b9e6SYuval Mintz #define DMAE_CMD_ENDIANITY 0x2 75fe56b9e6SYuval Mintz 76fe56b9e6SYuval Mintz #define DMAE_CMD_SIZE 14 77fe56b9e6SYuval Mintz #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5) 78fe56b9e6SYuval Mintz #define DMAE_MIN_WAIT_TIME 0x2 79fe56b9e6SYuval Mintz #define DMAE_MAX_CLIENTS 32 80fe56b9e6SYuval Mintz 81fe56b9e6SYuval Mintz /** 82fe56b9e6SYuval Mintz * @brief qed_gtt_init - Initialize GTT windows 83fe56b9e6SYuval Mintz * 84fe56b9e6SYuval Mintz * @param p_hwfn 85fe56b9e6SYuval Mintz */ 86fe56b9e6SYuval Mintz void qed_gtt_init(struct qed_hwfn *p_hwfn); 87fe56b9e6SYuval Mintz 88fe56b9e6SYuval Mintz /** 89fe56b9e6SYuval Mintz * @brief qed_ptt_invalidate - Forces all ptt entries to be re-configured 90fe56b9e6SYuval Mintz * 91fe56b9e6SYuval Mintz * @param p_hwfn 92fe56b9e6SYuval Mintz */ 93fe56b9e6SYuval Mintz void qed_ptt_invalidate(struct qed_hwfn *p_hwfn); 94fe56b9e6SYuval Mintz 95fe56b9e6SYuval Mintz /** 96fe56b9e6SYuval Mintz * @brief qed_ptt_pool_alloc - Allocate and initialize PTT pool 97fe56b9e6SYuval Mintz * 98fe56b9e6SYuval Mintz * @param p_hwfn 99fe56b9e6SYuval Mintz * 100fe56b9e6SYuval Mintz * @return struct _qed_status - success (0), negative - error. 101fe56b9e6SYuval Mintz */ 102fe56b9e6SYuval Mintz int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn); 103fe56b9e6SYuval Mintz 104fe56b9e6SYuval Mintz /** 105fe56b9e6SYuval Mintz * @brief qed_ptt_pool_free - 106fe56b9e6SYuval Mintz * 107fe56b9e6SYuval Mintz * @param p_hwfn 108fe56b9e6SYuval Mintz */ 109fe56b9e6SYuval Mintz void qed_ptt_pool_free(struct qed_hwfn *p_hwfn); 110fe56b9e6SYuval Mintz 111fe56b9e6SYuval Mintz /** 112fe56b9e6SYuval Mintz * @brief qed_ptt_get_hw_addr - Get PTT's GRC/HW address 113fe56b9e6SYuval Mintz * 114fe56b9e6SYuval Mintz * @param p_hwfn 115fe56b9e6SYuval Mintz * @param p_ptt 116fe56b9e6SYuval Mintz * 117fe56b9e6SYuval Mintz * @return u32 118fe56b9e6SYuval Mintz */ 119fe56b9e6SYuval Mintz u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn, 120fe56b9e6SYuval Mintz struct qed_ptt *p_ptt); 121fe56b9e6SYuval Mintz 122fe56b9e6SYuval Mintz /** 123fe56b9e6SYuval Mintz * @brief qed_ptt_get_bar_addr - Get PPT's external BAR address 124fe56b9e6SYuval Mintz * 125fe56b9e6SYuval Mintz * @param p_hwfn 126fe56b9e6SYuval Mintz * @param p_ptt 127fe56b9e6SYuval Mintz * 128fe56b9e6SYuval Mintz * @return u32 129fe56b9e6SYuval Mintz */ 130fe56b9e6SYuval Mintz u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt); 131fe56b9e6SYuval Mintz 132fe56b9e6SYuval Mintz /** 133fe56b9e6SYuval Mintz * @brief qed_ptt_set_win - Set PTT Window's GRC BAR address 134fe56b9e6SYuval Mintz * 135fe56b9e6SYuval Mintz * @param p_hwfn 136fe56b9e6SYuval Mintz * @param new_hw_addr 137fe56b9e6SYuval Mintz * @param p_ptt 138fe56b9e6SYuval Mintz */ 139fe56b9e6SYuval Mintz void qed_ptt_set_win(struct qed_hwfn *p_hwfn, 140fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 141fe56b9e6SYuval Mintz u32 new_hw_addr); 142fe56b9e6SYuval Mintz 143fe56b9e6SYuval Mintz /** 144fe56b9e6SYuval Mintz * @brief qed_get_reserved_ptt - Get a specific reserved PTT 145fe56b9e6SYuval Mintz * 146fe56b9e6SYuval Mintz * @param p_hwfn 147fe56b9e6SYuval Mintz * @param ptt_idx 148fe56b9e6SYuval Mintz * 149fe56b9e6SYuval Mintz * @return struct qed_ptt * 150fe56b9e6SYuval Mintz */ 151fe56b9e6SYuval Mintz struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn, 152fe56b9e6SYuval Mintz enum reserved_ptts ptt_idx); 153fe56b9e6SYuval Mintz 154fe56b9e6SYuval Mintz /** 155fe56b9e6SYuval Mintz * @brief qed_wr - Write value to BAR using the given ptt 156fe56b9e6SYuval Mintz * 157fe56b9e6SYuval Mintz * @param p_hwfn 158fe56b9e6SYuval Mintz * @param p_ptt 159fe56b9e6SYuval Mintz * @param val 160fe56b9e6SYuval Mintz * @param hw_addr 161fe56b9e6SYuval Mintz */ 162fe56b9e6SYuval Mintz void qed_wr(struct qed_hwfn *p_hwfn, 163fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 164fe56b9e6SYuval Mintz u32 hw_addr, 165fe56b9e6SYuval Mintz u32 val); 166fe56b9e6SYuval Mintz 167fe56b9e6SYuval Mintz /** 168fe56b9e6SYuval Mintz * @brief qed_rd - Read value from BAR using the given ptt 169fe56b9e6SYuval Mintz * 170fe56b9e6SYuval Mintz * @param p_hwfn 171fe56b9e6SYuval Mintz * @param p_ptt 172fe56b9e6SYuval Mintz * @param val 173fe56b9e6SYuval Mintz * @param hw_addr 174fe56b9e6SYuval Mintz */ 175fe56b9e6SYuval Mintz u32 qed_rd(struct qed_hwfn *p_hwfn, 176fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 177fe56b9e6SYuval Mintz u32 hw_addr); 178fe56b9e6SYuval Mintz 179fe56b9e6SYuval Mintz /** 180fe56b9e6SYuval Mintz * @brief qed_memcpy_from - copy n bytes from BAR using the given 181fe56b9e6SYuval Mintz * ptt 182fe56b9e6SYuval Mintz * 183fe56b9e6SYuval Mintz * @param p_hwfn 184fe56b9e6SYuval Mintz * @param p_ptt 185fe56b9e6SYuval Mintz * @param dest 186fe56b9e6SYuval Mintz * @param hw_addr 187fe56b9e6SYuval Mintz * @param n 188fe56b9e6SYuval Mintz */ 189fe56b9e6SYuval Mintz void qed_memcpy_from(struct qed_hwfn *p_hwfn, 190fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 191fe56b9e6SYuval Mintz void *dest, 192fe56b9e6SYuval Mintz u32 hw_addr, 193fe56b9e6SYuval Mintz size_t n); 194fe56b9e6SYuval Mintz 195fe56b9e6SYuval Mintz /** 196fe56b9e6SYuval Mintz * @brief qed_memcpy_to - copy n bytes to BAR using the given 197fe56b9e6SYuval Mintz * ptt 198fe56b9e6SYuval Mintz * 199fe56b9e6SYuval Mintz * @param p_hwfn 200fe56b9e6SYuval Mintz * @param p_ptt 201fe56b9e6SYuval Mintz * @param hw_addr 202fe56b9e6SYuval Mintz * @param src 203fe56b9e6SYuval Mintz * @param n 204fe56b9e6SYuval Mintz */ 205fe56b9e6SYuval Mintz void qed_memcpy_to(struct qed_hwfn *p_hwfn, 206fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 207fe56b9e6SYuval Mintz u32 hw_addr, 208fe56b9e6SYuval Mintz void *src, 209fe56b9e6SYuval Mintz size_t n); 210fe56b9e6SYuval Mintz /** 211fe56b9e6SYuval Mintz * @brief qed_fid_pretend - pretend to another function when 212fe56b9e6SYuval Mintz * accessing the ptt window. There is no way to unpretend 213fe56b9e6SYuval Mintz * a function. The only way to cancel a pretend is to 214fe56b9e6SYuval Mintz * pretend back to the original function. 215fe56b9e6SYuval Mintz * 216fe56b9e6SYuval Mintz * @param p_hwfn 217fe56b9e6SYuval Mintz * @param p_ptt 218fe56b9e6SYuval Mintz * @param fid - fid field of pxp_pretend structure. Can contain 219fe56b9e6SYuval Mintz * either pf / vf, port/path fields are don't care. 220fe56b9e6SYuval Mintz */ 221fe56b9e6SYuval Mintz void qed_fid_pretend(struct qed_hwfn *p_hwfn, 222fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 223fe56b9e6SYuval Mintz u16 fid); 224fe56b9e6SYuval Mintz 225fe56b9e6SYuval Mintz /** 226fe56b9e6SYuval Mintz * @brief qed_port_pretend - pretend to another port when 227fe56b9e6SYuval Mintz * accessing the ptt window 228fe56b9e6SYuval Mintz * 229fe56b9e6SYuval Mintz * @param p_hwfn 230fe56b9e6SYuval Mintz * @param p_ptt 231fe56b9e6SYuval Mintz * @param port_id - the port to pretend to 232fe56b9e6SYuval Mintz */ 233fe56b9e6SYuval Mintz void qed_port_pretend(struct qed_hwfn *p_hwfn, 234fe56b9e6SYuval Mintz struct qed_ptt *p_ptt, 235fe56b9e6SYuval Mintz u8 port_id); 236fe56b9e6SYuval Mintz 237fe56b9e6SYuval Mintz /** 238fe56b9e6SYuval Mintz * @brief qed_port_unpretend - cancel any previously set port 239fe56b9e6SYuval Mintz * pretend 240fe56b9e6SYuval Mintz * 241fe56b9e6SYuval Mintz * @param p_hwfn 242fe56b9e6SYuval Mintz * @param p_ptt 243fe56b9e6SYuval Mintz */ 244fe56b9e6SYuval Mintz void qed_port_unpretend(struct qed_hwfn *p_hwfn, 245fe56b9e6SYuval Mintz struct qed_ptt *p_ptt); 246fe56b9e6SYuval Mintz 247fe56b9e6SYuval Mintz /** 248d52c89f1SMichal Kalderon * @brief qed_port_fid_pretend - pretend to another port and another function 249d52c89f1SMichal Kalderon * when accessing the ptt window 250d52c89f1SMichal Kalderon * 251d52c89f1SMichal Kalderon * @param p_hwfn 252d52c89f1SMichal Kalderon * @param p_ptt 253d52c89f1SMichal Kalderon * @param port_id - the port to pretend to 254d52c89f1SMichal Kalderon * @param fid - fid field of pxp_pretend structure. Can contain either pf / vf. 255d52c89f1SMichal Kalderon */ 256d52c89f1SMichal Kalderon void qed_port_fid_pretend(struct qed_hwfn *p_hwfn, 257d52c89f1SMichal Kalderon struct qed_ptt *p_ptt, u8 port_id, u16 fid); 258d52c89f1SMichal Kalderon 259d52c89f1SMichal Kalderon /** 26032a47e72SYuval Mintz * @brief qed_vfid_to_concrete - build a concrete FID for a 26132a47e72SYuval Mintz * given VF ID 26232a47e72SYuval Mintz * 26332a47e72SYuval Mintz * @param p_hwfn 26432a47e72SYuval Mintz * @param p_ptt 26532a47e72SYuval Mintz * @param vfid 26632a47e72SYuval Mintz */ 26732a47e72SYuval Mintz u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid); 26832a47e72SYuval Mintz 26932a47e72SYuval Mintz /** 270fe56b9e6SYuval Mintz * @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd 271fe56b9e6SYuval Mintz * this is declared here since other files will require it. 272fe56b9e6SYuval Mintz * @param idx 273fe56b9e6SYuval Mintz */ 274fe56b9e6SYuval Mintz u32 qed_dmae_idx_to_go_cmd(u8 idx); 275fe56b9e6SYuval Mintz 276fe56b9e6SYuval Mintz /** 277fe56b9e6SYuval Mintz * @brief qed_dmae_info_alloc - Init the dmae_info structure 278fe56b9e6SYuval Mintz * which is part of p_hwfn. 279fe56b9e6SYuval Mintz * @param p_hwfn 280fe56b9e6SYuval Mintz */ 281fe56b9e6SYuval Mintz int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn); 282fe56b9e6SYuval Mintz 283fe56b9e6SYuval Mintz /** 284fe56b9e6SYuval Mintz * @brief qed_dmae_info_free - Free the dmae_info structure 285fe56b9e6SYuval Mintz * which is part of p_hwfn 286fe56b9e6SYuval Mintz * 287fe56b9e6SYuval Mintz * @param p_hwfn 288fe56b9e6SYuval Mintz */ 289fe56b9e6SYuval Mintz void qed_dmae_info_free(struct qed_hwfn *p_hwfn); 290fe56b9e6SYuval Mintz 291fe56b9e6SYuval Mintz union qed_qm_pq_params { 292fe56b9e6SYuval Mintz struct { 293dbb799c3SYuval Mintz u8 q_idx; 294dbb799c3SYuval Mintz } iscsi; 295dbb799c3SYuval Mintz 296dbb799c3SYuval Mintz struct { 297fe56b9e6SYuval Mintz u8 tc; 298fe56b9e6SYuval Mintz } core; 299fe56b9e6SYuval Mintz 300fe56b9e6SYuval Mintz struct { 301fe56b9e6SYuval Mintz u8 is_vf; 302fe56b9e6SYuval Mintz u8 vf_id; 303fe56b9e6SYuval Mintz u8 tc; 304fe56b9e6SYuval Mintz } eth; 305dbb799c3SYuval Mintz 306dbb799c3SYuval Mintz struct { 307dbb799c3SYuval Mintz u8 dcqcn; 308dbb799c3SYuval Mintz u8 qpid; /* roce relative */ 309dbb799c3SYuval Mintz } roce; 310fe56b9e6SYuval Mintz }; 311fe56b9e6SYuval Mintz 312fe56b9e6SYuval Mintz int qed_init_fw_data(struct qed_dev *cdev, 313fe56b9e6SYuval Mintz const u8 *fw_data); 314da090917STomer Tayar 315da090917STomer Tayar int qed_dmae_sanity(struct qed_hwfn *p_hwfn, 316da090917STomer Tayar struct qed_ptt *p_ptt, const char *phase); 317da090917STomer Tayar 318*d639836aSIgor Russkikh #define QED_HW_ERR_MAX_STR_SIZE 256 319*d639836aSIgor Russkikh 320*d639836aSIgor Russkikh /** 321*d639836aSIgor Russkikh * @brief qed_hw_err_notify - Notify upper layer driver and management FW 322*d639836aSIgor Russkikh * about a HW error. 323*d639836aSIgor Russkikh * 324*d639836aSIgor Russkikh * @param p_hwfn 325*d639836aSIgor Russkikh * @param p_ptt 326*d639836aSIgor Russkikh * @param err_type 327*d639836aSIgor Russkikh * @param fmt - debug data buffer to send to the MFW 328*d639836aSIgor Russkikh * @param ... - buffer format args 329*d639836aSIgor Russkikh */ 330*d639836aSIgor Russkikh void qed_hw_err_notify(struct qed_hwfn *p_hwfn, 331*d639836aSIgor Russkikh struct qed_ptt *p_ptt, 332*d639836aSIgor Russkikh enum qed_hw_err_type err_type, char *fmt, ...); 333fe56b9e6SYuval Mintz #endif 334