18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Broadcom NetXtreme-E RoCE driver. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term 58c2ecf20Sopenharmony_ci * Broadcom refers to Broadcom Limited and/or its subsidiaries. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 88c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 98c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 108c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 118c2ecf20Sopenharmony_ci * BSD license below: 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 148c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 158c2ecf20Sopenharmony_ci * are met: 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 188c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 198c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 208c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 218c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 228c2ecf20Sopenharmony_ci * distribution. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' 258c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 268c2ecf20Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 278c2ecf20Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 288c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 298c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 308c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 318c2ecf20Sopenharmony_ci * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 328c2ecf20Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 338c2ecf20Sopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 348c2ecf20Sopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * Description: Slow Path Operators (header) 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifndef __BNXT_QPLIB_SP_H__ 418c2ecf20Sopenharmony_ci#define __BNXT_QPLIB_SP_H__ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define BNXT_QPLIB_RESERVED_QP_WRS 128 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct bnxt_qplib_dev_attr { 488c2ecf20Sopenharmony_ci#define FW_VER_ARR_LEN 4 498c2ecf20Sopenharmony_ci u8 fw_ver[FW_VER_ARR_LEN]; 508c2ecf20Sopenharmony_ci#define BNXT_QPLIB_NUM_GIDS_SUPPORTED 256 518c2ecf20Sopenharmony_ci u16 max_sgid; 528c2ecf20Sopenharmony_ci u16 max_mrw; 538c2ecf20Sopenharmony_ci u32 max_qp; 548c2ecf20Sopenharmony_ci#define BNXT_QPLIB_MAX_OUT_RD_ATOM 126 558c2ecf20Sopenharmony_ci u32 max_qp_rd_atom; 568c2ecf20Sopenharmony_ci u32 max_qp_init_rd_atom; 578c2ecf20Sopenharmony_ci u32 max_qp_wqes; 588c2ecf20Sopenharmony_ci u32 max_qp_sges; 598c2ecf20Sopenharmony_ci u32 max_cq; 608c2ecf20Sopenharmony_ci u32 max_cq_wqes; 618c2ecf20Sopenharmony_ci u32 max_cq_sges; 628c2ecf20Sopenharmony_ci u32 max_mr; 638c2ecf20Sopenharmony_ci u64 max_mr_size; 648c2ecf20Sopenharmony_ci u32 max_pd; 658c2ecf20Sopenharmony_ci u32 max_mw; 668c2ecf20Sopenharmony_ci u32 max_raw_ethy_qp; 678c2ecf20Sopenharmony_ci u32 max_ah; 688c2ecf20Sopenharmony_ci u32 max_srq; 698c2ecf20Sopenharmony_ci u32 max_srq_wqes; 708c2ecf20Sopenharmony_ci u32 max_srq_sges; 718c2ecf20Sopenharmony_ci u32 max_pkey; 728c2ecf20Sopenharmony_ci u32 max_inline_data; 738c2ecf20Sopenharmony_ci u32 l2_db_size; 748c2ecf20Sopenharmony_ci u8 tqm_alloc_reqs[MAX_TQM_ALLOC_REQ]; 758c2ecf20Sopenharmony_ci bool is_atomic; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct bnxt_qplib_pd { 798c2ecf20Sopenharmony_ci u32 id; 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistruct bnxt_qplib_gid { 838c2ecf20Sopenharmony_ci u8 data[16]; 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistruct bnxt_qplib_gid_info { 878c2ecf20Sopenharmony_ci struct bnxt_qplib_gid gid; 888c2ecf20Sopenharmony_ci u16 vlan_id; 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistruct bnxt_qplib_ah { 928c2ecf20Sopenharmony_ci struct bnxt_qplib_gid dgid; 938c2ecf20Sopenharmony_ci struct bnxt_qplib_pd *pd; 948c2ecf20Sopenharmony_ci u32 id; 958c2ecf20Sopenharmony_ci u8 sgid_index; 968c2ecf20Sopenharmony_ci /* For Query AH if the hw table and SW table are differnt */ 978c2ecf20Sopenharmony_ci u8 host_sgid_index; 988c2ecf20Sopenharmony_ci u8 traffic_class; 998c2ecf20Sopenharmony_ci u32 flow_label; 1008c2ecf20Sopenharmony_ci u8 hop_limit; 1018c2ecf20Sopenharmony_ci u8 sl; 1028c2ecf20Sopenharmony_ci u8 dmac[6]; 1038c2ecf20Sopenharmony_ci u16 vlan_id; 1048c2ecf20Sopenharmony_ci u8 nw_type; 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistruct bnxt_qplib_mrw { 1088c2ecf20Sopenharmony_ci struct bnxt_qplib_pd *pd; 1098c2ecf20Sopenharmony_ci int type; 1108c2ecf20Sopenharmony_ci u32 flags; 1118c2ecf20Sopenharmony_ci#define BNXT_QPLIB_FR_PMR 0x80000000 1128c2ecf20Sopenharmony_ci u32 lkey; 1138c2ecf20Sopenharmony_ci u32 rkey; 1148c2ecf20Sopenharmony_ci#define BNXT_QPLIB_RSVD_LKEY 0xFFFFFFFF 1158c2ecf20Sopenharmony_ci u64 va; 1168c2ecf20Sopenharmony_ci u64 total_size; 1178c2ecf20Sopenharmony_ci u32 npages; 1188c2ecf20Sopenharmony_ci u64 mr_handle; 1198c2ecf20Sopenharmony_ci struct bnxt_qplib_hwq hwq; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct bnxt_qplib_frpl { 1238c2ecf20Sopenharmony_ci int max_pg_ptrs; 1248c2ecf20Sopenharmony_ci struct bnxt_qplib_hwq hwq; 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_LOCAL_WRITE BIT(0) 1288c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_REMOTE_READ BIT(1) 1298c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_REMOTE_WRITE BIT(2) 1308c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_REMOTE_ATOMIC BIT(3) 1318c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_MW_BIND BIT(4) 1328c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_ZERO_BASED BIT(5) 1338c2ecf20Sopenharmony_ci#define BNXT_QPLIB_ACCESS_ON_DEMAND BIT(6) 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistruct bnxt_qplib_roce_stats { 1368c2ecf20Sopenharmony_ci u64 to_retransmits; 1378c2ecf20Sopenharmony_ci u64 seq_err_naks_rcvd; 1388c2ecf20Sopenharmony_ci /* seq_err_naks_rcvd is 64 b */ 1398c2ecf20Sopenharmony_ci u64 max_retry_exceeded; 1408c2ecf20Sopenharmony_ci /* max_retry_exceeded is 64 b */ 1418c2ecf20Sopenharmony_ci u64 rnr_naks_rcvd; 1428c2ecf20Sopenharmony_ci /* rnr_naks_rcvd is 64 b */ 1438c2ecf20Sopenharmony_ci u64 missing_resp; 1448c2ecf20Sopenharmony_ci u64 unrecoverable_err; 1458c2ecf20Sopenharmony_ci /* unrecoverable_err is 64 b */ 1468c2ecf20Sopenharmony_ci u64 bad_resp_err; 1478c2ecf20Sopenharmony_ci /* bad_resp_err is 64 b */ 1488c2ecf20Sopenharmony_ci u64 local_qp_op_err; 1498c2ecf20Sopenharmony_ci /* local_qp_op_err is 64 b */ 1508c2ecf20Sopenharmony_ci u64 local_protection_err; 1518c2ecf20Sopenharmony_ci /* local_protection_err is 64 b */ 1528c2ecf20Sopenharmony_ci u64 mem_mgmt_op_err; 1538c2ecf20Sopenharmony_ci /* mem_mgmt_op_err is 64 b */ 1548c2ecf20Sopenharmony_ci u64 remote_invalid_req_err; 1558c2ecf20Sopenharmony_ci /* remote_invalid_req_err is 64 b */ 1568c2ecf20Sopenharmony_ci u64 remote_access_err; 1578c2ecf20Sopenharmony_ci /* remote_access_err is 64 b */ 1588c2ecf20Sopenharmony_ci u64 remote_op_err; 1598c2ecf20Sopenharmony_ci /* remote_op_err is 64 b */ 1608c2ecf20Sopenharmony_ci u64 dup_req; 1618c2ecf20Sopenharmony_ci /* dup_req is 64 b */ 1628c2ecf20Sopenharmony_ci u64 res_exceed_max; 1638c2ecf20Sopenharmony_ci /* res_exceed_max is 64 b */ 1648c2ecf20Sopenharmony_ci u64 res_length_mismatch; 1658c2ecf20Sopenharmony_ci /* res_length_mismatch is 64 b */ 1668c2ecf20Sopenharmony_ci u64 res_exceeds_wqe; 1678c2ecf20Sopenharmony_ci /* res_exceeds_wqe is 64 b */ 1688c2ecf20Sopenharmony_ci u64 res_opcode_err; 1698c2ecf20Sopenharmony_ci /* res_opcode_err is 64 b */ 1708c2ecf20Sopenharmony_ci u64 res_rx_invalid_rkey; 1718c2ecf20Sopenharmony_ci /* res_rx_invalid_rkey is 64 b */ 1728c2ecf20Sopenharmony_ci u64 res_rx_domain_err; 1738c2ecf20Sopenharmony_ci /* res_rx_domain_err is 64 b */ 1748c2ecf20Sopenharmony_ci u64 res_rx_no_perm; 1758c2ecf20Sopenharmony_ci /* res_rx_no_perm is 64 b */ 1768c2ecf20Sopenharmony_ci u64 res_rx_range_err; 1778c2ecf20Sopenharmony_ci /* res_rx_range_err is 64 b */ 1788c2ecf20Sopenharmony_ci u64 res_tx_invalid_rkey; 1798c2ecf20Sopenharmony_ci /* res_tx_invalid_rkey is 64 b */ 1808c2ecf20Sopenharmony_ci u64 res_tx_domain_err; 1818c2ecf20Sopenharmony_ci /* res_tx_domain_err is 64 b */ 1828c2ecf20Sopenharmony_ci u64 res_tx_no_perm; 1838c2ecf20Sopenharmony_ci /* res_tx_no_perm is 64 b */ 1848c2ecf20Sopenharmony_ci u64 res_tx_range_err; 1858c2ecf20Sopenharmony_ci /* res_tx_range_err is 64 b */ 1868c2ecf20Sopenharmony_ci u64 res_irrq_oflow; 1878c2ecf20Sopenharmony_ci /* res_irrq_oflow is 64 b */ 1888c2ecf20Sopenharmony_ci u64 res_unsup_opcode; 1898c2ecf20Sopenharmony_ci /* res_unsup_opcode is 64 b */ 1908c2ecf20Sopenharmony_ci u64 res_unaligned_atomic; 1918c2ecf20Sopenharmony_ci /* res_unaligned_atomic is 64 b */ 1928c2ecf20Sopenharmony_ci u64 res_rem_inv_err; 1938c2ecf20Sopenharmony_ci /* res_rem_inv_err is 64 b */ 1948c2ecf20Sopenharmony_ci u64 res_mem_error; 1958c2ecf20Sopenharmony_ci /* res_mem_error is 64 b */ 1968c2ecf20Sopenharmony_ci u64 res_srq_err; 1978c2ecf20Sopenharmony_ci /* res_srq_err is 64 b */ 1988c2ecf20Sopenharmony_ci u64 res_cmp_err; 1998c2ecf20Sopenharmony_ci /* res_cmp_err is 64 b */ 2008c2ecf20Sopenharmony_ci u64 res_invalid_dup_rkey; 2018c2ecf20Sopenharmony_ci /* res_invalid_dup_rkey is 64 b */ 2028c2ecf20Sopenharmony_ci u64 res_wqe_format_err; 2038c2ecf20Sopenharmony_ci /* res_wqe_format_err is 64 b */ 2048c2ecf20Sopenharmony_ci u64 res_cq_load_err; 2058c2ecf20Sopenharmony_ci /* res_cq_load_err is 64 b */ 2068c2ecf20Sopenharmony_ci u64 res_srq_load_err; 2078c2ecf20Sopenharmony_ci /* res_srq_load_err is 64 b */ 2088c2ecf20Sopenharmony_ci u64 res_tx_pci_err; 2098c2ecf20Sopenharmony_ci /* res_tx_pci_err is 64 b */ 2108c2ecf20Sopenharmony_ci u64 res_rx_pci_err; 2118c2ecf20Sopenharmony_ci /* res_rx_pci_err is 64 b */ 2128c2ecf20Sopenharmony_ci u64 res_oos_drop_count; 2138c2ecf20Sopenharmony_ci /* res_oos_drop_count */ 2148c2ecf20Sopenharmony_ci u64 active_qp_count_p0; 2158c2ecf20Sopenharmony_ci /* port 0 active qps */ 2168c2ecf20Sopenharmony_ci u64 active_qp_count_p1; 2178c2ecf20Sopenharmony_ci /* port 1 active qps */ 2188c2ecf20Sopenharmony_ci u64 active_qp_count_p2; 2198c2ecf20Sopenharmony_ci /* port 2 active qps */ 2208c2ecf20Sopenharmony_ci u64 active_qp_count_p3; 2218c2ecf20Sopenharmony_ci /* port 3 active qps */ 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ciint bnxt_qplib_get_sgid(struct bnxt_qplib_res *res, 2258c2ecf20Sopenharmony_ci struct bnxt_qplib_sgid_tbl *sgid_tbl, int index, 2268c2ecf20Sopenharmony_ci struct bnxt_qplib_gid *gid); 2278c2ecf20Sopenharmony_ciint bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl, 2288c2ecf20Sopenharmony_ci struct bnxt_qplib_gid *gid, u16 vlan_id, bool update); 2298c2ecf20Sopenharmony_ciint bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl, 2308c2ecf20Sopenharmony_ci struct bnxt_qplib_gid *gid, u8 *mac, u16 vlan_id, 2318c2ecf20Sopenharmony_ci bool update, u32 *index); 2328c2ecf20Sopenharmony_ciint bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl, 2338c2ecf20Sopenharmony_ci struct bnxt_qplib_gid *gid, u16 gid_idx, u8 *smac); 2348c2ecf20Sopenharmony_ciint bnxt_qplib_get_pkey(struct bnxt_qplib_res *res, 2358c2ecf20Sopenharmony_ci struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index, 2368c2ecf20Sopenharmony_ci u16 *pkey); 2378c2ecf20Sopenharmony_ciint bnxt_qplib_del_pkey(struct bnxt_qplib_res *res, 2388c2ecf20Sopenharmony_ci struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey, 2398c2ecf20Sopenharmony_ci bool update); 2408c2ecf20Sopenharmony_ciint bnxt_qplib_add_pkey(struct bnxt_qplib_res *res, 2418c2ecf20Sopenharmony_ci struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey, 2428c2ecf20Sopenharmony_ci bool update); 2438c2ecf20Sopenharmony_ciint bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, 2448c2ecf20Sopenharmony_ci struct bnxt_qplib_dev_attr *attr, bool vf); 2458c2ecf20Sopenharmony_ciint bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res, 2468c2ecf20Sopenharmony_ci struct bnxt_qplib_rcfw *rcfw, 2478c2ecf20Sopenharmony_ci struct bnxt_qplib_ctx *ctx); 2488c2ecf20Sopenharmony_ciint bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah, 2498c2ecf20Sopenharmony_ci bool block); 2508c2ecf20Sopenharmony_civoid bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah, 2518c2ecf20Sopenharmony_ci bool block); 2528c2ecf20Sopenharmony_ciint bnxt_qplib_alloc_mrw(struct bnxt_qplib_res *res, 2538c2ecf20Sopenharmony_ci struct bnxt_qplib_mrw *mrw); 2548c2ecf20Sopenharmony_ciint bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw, 2558c2ecf20Sopenharmony_ci bool block); 2568c2ecf20Sopenharmony_ciint bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr, 2578c2ecf20Sopenharmony_ci struct ib_umem *umem, int num_pbls, u32 buf_pg_size); 2588c2ecf20Sopenharmony_ciint bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr); 2598c2ecf20Sopenharmony_ciint bnxt_qplib_alloc_fast_reg_mr(struct bnxt_qplib_res *res, 2608c2ecf20Sopenharmony_ci struct bnxt_qplib_mrw *mr, int max); 2618c2ecf20Sopenharmony_ciint bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res, 2628c2ecf20Sopenharmony_ci struct bnxt_qplib_frpl *frpl, int max); 2638c2ecf20Sopenharmony_ciint bnxt_qplib_free_fast_reg_page_list(struct bnxt_qplib_res *res, 2648c2ecf20Sopenharmony_ci struct bnxt_qplib_frpl *frpl); 2658c2ecf20Sopenharmony_ciint bnxt_qplib_map_tc2cos(struct bnxt_qplib_res *res, u16 *cids); 2668c2ecf20Sopenharmony_ciint bnxt_qplib_get_roce_stats(struct bnxt_qplib_rcfw *rcfw, 2678c2ecf20Sopenharmony_ci struct bnxt_qplib_roce_stats *stats); 2688c2ecf20Sopenharmony_ci#endif /* __BNXT_QPLIB_SP_H__*/ 269