1cdcd52d4SBartosz Sobczak /*- 2cdcd52d4SBartosz Sobczak * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 3cdcd52d4SBartosz Sobczak * 4*5b5f7d0eSBartosz Sobczak * Copyright (c) 2017 - 2022 Intel Corporation 5cdcd52d4SBartosz Sobczak * 6cdcd52d4SBartosz Sobczak * This software is available to you under a choice of one of two 7cdcd52d4SBartosz Sobczak * licenses. You may choose to be licensed under the terms of the GNU 8cdcd52d4SBartosz Sobczak * General Public License (GPL) Version 2, available from the file 9cdcd52d4SBartosz Sobczak * COPYING in the main directory of this source tree, or the 10cdcd52d4SBartosz Sobczak * OpenFabrics.org BSD license below: 11cdcd52d4SBartosz Sobczak * 12cdcd52d4SBartosz Sobczak * Redistribution and use in source and binary forms, with or 13cdcd52d4SBartosz Sobczak * without modification, are permitted provided that the following 14cdcd52d4SBartosz Sobczak * conditions are met: 15cdcd52d4SBartosz Sobczak * 16cdcd52d4SBartosz Sobczak * - Redistributions of source code must retain the above 17cdcd52d4SBartosz Sobczak * copyright notice, this list of conditions and the following 18cdcd52d4SBartosz Sobczak * disclaimer. 19cdcd52d4SBartosz Sobczak * 20cdcd52d4SBartosz Sobczak * - Redistributions in binary form must reproduce the above 21cdcd52d4SBartosz Sobczak * copyright notice, this list of conditions and the following 22cdcd52d4SBartosz Sobczak * disclaimer in the documentation and/or other materials 23cdcd52d4SBartosz Sobczak * provided with the distribution. 24cdcd52d4SBartosz Sobczak * 25cdcd52d4SBartosz Sobczak * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26cdcd52d4SBartosz Sobczak * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27cdcd52d4SBartosz Sobczak * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28cdcd52d4SBartosz Sobczak * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29cdcd52d4SBartosz Sobczak * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30cdcd52d4SBartosz Sobczak * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31cdcd52d4SBartosz Sobczak * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32cdcd52d4SBartosz Sobczak * SOFTWARE. 33cdcd52d4SBartosz Sobczak */ 34cdcd52d4SBartosz Sobczak 35cdcd52d4SBartosz Sobczak #ifndef IRDMA_H 36cdcd52d4SBartosz Sobczak #define IRDMA_H 37cdcd52d4SBartosz Sobczak 38cdcd52d4SBartosz Sobczak #define RDMA_BIT2(type, a) ((u##type) 1UL << a) 39cdcd52d4SBartosz Sobczak #define RDMA_MASK3(type, mask, shift) ((u##type) mask << shift) 40cdcd52d4SBartosz Sobczak #define MAKEMASK(m, s) ((m) << (s)) 41777e472cSBartosz Sobczak 42cdcd52d4SBartosz Sobczak #define IRDMA_WQEALLOC_WQE_DESC_INDEX_S 20 43777e472cSBartosz Sobczak #define IRDMA_WQEALLOC_WQE_DESC_INDEX GENMASK(31, 20) 44cdcd52d4SBartosz Sobczak 45cdcd52d4SBartosz Sobczak #define IRDMA_CQPTAIL_WQTAIL_S 0 46777e472cSBartosz Sobczak #define IRDMA_CQPTAIL_WQTAIL GENMASK(10, 0) 47cdcd52d4SBartosz Sobczak #define IRDMA_CQPTAIL_CQP_OP_ERR_S 31 48777e472cSBartosz Sobczak #define IRDMA_CQPTAIL_CQP_OP_ERR BIT(31) 49cdcd52d4SBartosz Sobczak 50cdcd52d4SBartosz Sobczak #define IRDMA_CQPERRCODES_CQP_MINOR_CODE_S 0 51777e472cSBartosz Sobczak #define IRDMA_CQPERRCODES_CQP_MINOR_CODE GENMASK(15, 0) 52cdcd52d4SBartosz Sobczak #define IRDMA_CQPERRCODES_CQP_MAJOR_CODE_S 16 53777e472cSBartosz Sobczak #define IRDMA_CQPERRCODES_CQP_MAJOR_CODE GENMASK(31, 16) 54cdcd52d4SBartosz Sobczak #define IRDMA_GLPCI_LBARCTRL_PE_DB_SIZE_S 4 55777e472cSBartosz Sobczak #define IRDMA_GLPCI_LBARCTRL_PE_DB_SIZE GENMASK(5, 4) 56cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_RATE_INTERVAL_S 0 57777e472cSBartosz Sobczak #define IRDMA_GLINT_RATE_INTERVAL GENMASK(4, 0) 58cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_RATE_INTRL_ENA_S 6 59cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_RATE_INTRL_ENA_M BIT(6) 60777e472cSBartosz Sobczak #define IRDMA_GLINT_RATE_INTRL_ENA BIT(6) 61cdcd52d4SBartosz Sobczak 62cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_INTENA_S 0 63777e472cSBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_INTENA BIT(0) 64cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_CLEARPBA_S 1 65777e472cSBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_CLEARPBA BIT(1) 66cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_ITR_INDX_S 3 67777e472cSBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_ITR_INDX GENMASK(4, 3) 68cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_INTERVAL_S 5 69777e472cSBartosz Sobczak #define IRDMA_GLINT_DYN_CTL_INTERVAL GENMASK(16, 5) 70cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_CEQCTL_ITR_INDX_S 11 71777e472cSBartosz Sobczak #define IRDMA_GLINT_CEQCTL_ITR_INDX GENMASK(12, 11) 72cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_CEQCTL_CAUSE_ENA_S 30 73777e472cSBartosz Sobczak #define IRDMA_GLINT_CEQCTL_CAUSE_ENA BIT(30) 74cdcd52d4SBartosz Sobczak #define IRDMA_GLINT_CEQCTL_MSIX_INDX_S 0 75777e472cSBartosz Sobczak #define IRDMA_GLINT_CEQCTL_MSIX_INDX GENMASK(10, 0) 76cdcd52d4SBartosz Sobczak #define IRDMA_PFINT_AEQCTL_MSIX_INDX_S 0 77777e472cSBartosz Sobczak #define IRDMA_PFINT_AEQCTL_MSIX_INDX GENMASK(10, 0) 78cdcd52d4SBartosz Sobczak #define IRDMA_PFINT_AEQCTL_ITR_INDX_S 11 79777e472cSBartosz Sobczak #define IRDMA_PFINT_AEQCTL_ITR_INDX GENMASK(12, 11) 80cdcd52d4SBartosz Sobczak #define IRDMA_PFINT_AEQCTL_CAUSE_ENA_S 30 81777e472cSBartosz Sobczak #define IRDMA_PFINT_AEQCTL_CAUSE_ENA BIT(30) 82cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMSDIDX_S 0 83777e472cSBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMSDIDX GENMASK(11, 0) 84cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMSDPARTSEL_S 15 85777e472cSBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMSDPARTSEL BIT(15) 86cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMPDIDX_S 16 87777e472cSBartosz Sobczak #define IRDMA_PFHMC_PDINV_PMPDIDX GENMASK(24, 16) 88cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDVALID_S 0 89777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDVALID BIT(0) 90cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDTYPE_S 1 91777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDTYPE BIT(1) 92cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDBPCOUNT_S 2 93777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDBPCOUNT GENMASK(11, 2) 94cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDDATALOW_S 12 95777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDDATALOW_PMSDDATALOW GENMASK(31, 12) 96cdcd52d4SBartosz Sobczak #define IRDMA_PFHMC_SDCMD_PMSDWR_S 31 97777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDCMD_PMSDWR BIT(31) 98777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDCMD_PMSDPARTSEL_S 15 99777e472cSBartosz Sobczak #define IRDMA_PFHMC_SDCMD_PMSDPARTSEL BIT(15) 100cdcd52d4SBartosz Sobczak 101cdcd52d4SBartosz Sobczak #define IRDMA_INVALID_CQ_IDX 0xffffffff 102cdcd52d4SBartosz Sobczak 103777e472cSBartosz Sobczak enum irdma_dyn_idx_t { 104777e472cSBartosz Sobczak IRDMA_IDX_ITR0 = 0, 105777e472cSBartosz Sobczak IRDMA_IDX_ITR1 = 1, 106777e472cSBartosz Sobczak IRDMA_IDX_ITR2 = 2, 107777e472cSBartosz Sobczak IRDMA_IDX_NOITR = 3, 108777e472cSBartosz Sobczak }; 109777e472cSBartosz Sobczak 110cdcd52d4SBartosz Sobczak enum irdma_registers { 111cdcd52d4SBartosz Sobczak IRDMA_CQPTAIL, 112cdcd52d4SBartosz Sobczak IRDMA_CQPDB, 113cdcd52d4SBartosz Sobczak IRDMA_CCQPSTATUS, 114cdcd52d4SBartosz Sobczak IRDMA_CCQPHIGH, 115cdcd52d4SBartosz Sobczak IRDMA_CCQPLOW, 116cdcd52d4SBartosz Sobczak IRDMA_CQARM, 117cdcd52d4SBartosz Sobczak IRDMA_CQACK, 118cdcd52d4SBartosz Sobczak IRDMA_AEQALLOC, 119cdcd52d4SBartosz Sobczak IRDMA_CQPERRCODES, 120cdcd52d4SBartosz Sobczak IRDMA_WQEALLOC, 121cdcd52d4SBartosz Sobczak IRDMA_GLINT_DYN_CTL, 122cdcd52d4SBartosz Sobczak IRDMA_DB_ADDR_OFFSET, 123cdcd52d4SBartosz Sobczak IRDMA_GLPCI_LBARCTRL, 124cdcd52d4SBartosz Sobczak IRDMA_GLPE_CPUSTATUS0, 125cdcd52d4SBartosz Sobczak IRDMA_GLPE_CPUSTATUS1, 126cdcd52d4SBartosz Sobczak IRDMA_GLPE_CPUSTATUS2, 127cdcd52d4SBartosz Sobczak IRDMA_PFINT_AEQCTL, 128cdcd52d4SBartosz Sobczak IRDMA_GLINT_CEQCTL, 129cdcd52d4SBartosz Sobczak IRDMA_VSIQF_PE_CTL1, 130cdcd52d4SBartosz Sobczak IRDMA_PFHMC_PDINV, 131cdcd52d4SBartosz Sobczak IRDMA_GLHMC_VFPDINV, 132cdcd52d4SBartosz Sobczak IRDMA_GLPE_CRITERR, 133cdcd52d4SBartosz Sobczak IRDMA_GLINT_RATE, 134cdcd52d4SBartosz Sobczak IRDMA_MAX_REGS, /* Must be last entry */ 135cdcd52d4SBartosz Sobczak }; 136cdcd52d4SBartosz Sobczak 137cdcd52d4SBartosz Sobczak enum irdma_shifts { 138cdcd52d4SBartosz Sobczak IRDMA_CCQPSTATUS_CCQP_DONE_S, 139cdcd52d4SBartosz Sobczak IRDMA_CCQPSTATUS_CCQP_ERR_S, 140cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_STAG_PDID_S, 141cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_CQ_CEQID_S, 142cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_CQ_CQID_S, 143cdcd52d4SBartosz Sobczak IRDMA_COMMIT_FPM_CQCNT_S, 144777e472cSBartosz Sobczak IRDMA_CQPSQ_UPESD_HMCFNID_S, 145cdcd52d4SBartosz Sobczak IRDMA_MAX_SHIFTS, 146cdcd52d4SBartosz Sobczak }; 147cdcd52d4SBartosz Sobczak 148cdcd52d4SBartosz Sobczak enum irdma_masks { 149cdcd52d4SBartosz Sobczak IRDMA_CCQPSTATUS_CCQP_DONE_M, 150cdcd52d4SBartosz Sobczak IRDMA_CCQPSTATUS_CCQP_ERR_M, 151cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_STAG_PDID_M, 152cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_CQ_CEQID_M, 153cdcd52d4SBartosz Sobczak IRDMA_CQPSQ_CQ_CQID_M, 154cdcd52d4SBartosz Sobczak IRDMA_COMMIT_FPM_CQCNT_M, 155777e472cSBartosz Sobczak IRDMA_CQPSQ_UPESD_HMCFNID_M, 156cdcd52d4SBartosz Sobczak IRDMA_MAX_MASKS, /* Must be last entry */ 157cdcd52d4SBartosz Sobczak }; 158cdcd52d4SBartosz Sobczak 159cdcd52d4SBartosz Sobczak #define IRDMA_MAX_MGS_PER_CTX 8 160cdcd52d4SBartosz Sobczak 161cdcd52d4SBartosz Sobczak struct irdma_mcast_grp_ctx_entry_info { 162cdcd52d4SBartosz Sobczak u32 qp_id; 163cdcd52d4SBartosz Sobczak bool valid_entry; 164cdcd52d4SBartosz Sobczak u16 dest_port; 165cdcd52d4SBartosz Sobczak u32 use_cnt; 166cdcd52d4SBartosz Sobczak }; 167cdcd52d4SBartosz Sobczak 168cdcd52d4SBartosz Sobczak struct irdma_mcast_grp_info { 16901fbb869SBartosz Sobczak u8 dest_mac_addr[ETHER_ADDR_LEN]; 170cdcd52d4SBartosz Sobczak u16 vlan_id; 171777e472cSBartosz Sobczak u16 hmc_fcn_id; 172cdcd52d4SBartosz Sobczak bool ipv4_valid:1; 173cdcd52d4SBartosz Sobczak bool vlan_valid:1; 174cdcd52d4SBartosz Sobczak u16 mg_id; 175cdcd52d4SBartosz Sobczak u32 no_of_mgs; 176cdcd52d4SBartosz Sobczak u32 dest_ip_addr[4]; 177cdcd52d4SBartosz Sobczak u16 qs_handle; 178cdcd52d4SBartosz Sobczak struct irdma_dma_mem dma_mem_mc; 179cdcd52d4SBartosz Sobczak struct irdma_mcast_grp_ctx_entry_info mg_ctx_info[IRDMA_MAX_MGS_PER_CTX]; 180cdcd52d4SBartosz Sobczak }; 181cdcd52d4SBartosz Sobczak 182cdcd52d4SBartosz Sobczak enum irdma_vers { 183777e472cSBartosz Sobczak IRDMA_GEN_RSVD = 0, 184777e472cSBartosz Sobczak IRDMA_GEN_1 = 1, 185777e472cSBartosz Sobczak IRDMA_GEN_2 = 2, 186*5b5f7d0eSBartosz Sobczak IRDMA_GEN_MAX = IRDMA_GEN_2, 187cdcd52d4SBartosz Sobczak }; 188cdcd52d4SBartosz Sobczak 189cdcd52d4SBartosz Sobczak struct irdma_uk_attrs { 190cdcd52d4SBartosz Sobczak u64 feature_flags; 191cdcd52d4SBartosz Sobczak u32 max_hw_wq_frags; 192cdcd52d4SBartosz Sobczak u32 max_hw_read_sges; 193cdcd52d4SBartosz Sobczak u32 max_hw_inline; 194cdcd52d4SBartosz Sobczak u32 max_hw_rq_quanta; 195cdcd52d4SBartosz Sobczak u32 max_hw_wq_quanta; 196cdcd52d4SBartosz Sobczak u32 min_hw_cq_size; 197cdcd52d4SBartosz Sobczak u32 max_hw_cq_size; 198cdcd52d4SBartosz Sobczak u16 max_hw_sq_chunk; 199777e472cSBartosz Sobczak u16 min_hw_wq_size; 200cdcd52d4SBartosz Sobczak u8 hw_rev; 201cdcd52d4SBartosz Sobczak }; 202cdcd52d4SBartosz Sobczak 203cdcd52d4SBartosz Sobczak struct irdma_hw_attrs { 204cdcd52d4SBartosz Sobczak struct irdma_uk_attrs uk_attrs; 205cdcd52d4SBartosz Sobczak u64 max_hw_outbound_msg_size; 206cdcd52d4SBartosz Sobczak u64 max_hw_inbound_msg_size; 207cdcd52d4SBartosz Sobczak u64 max_mr_size; 208777e472cSBartosz Sobczak u64 page_size_cap; 209cdcd52d4SBartosz Sobczak u32 min_hw_qp_id; 210cdcd52d4SBartosz Sobczak u32 min_hw_aeq_size; 211cdcd52d4SBartosz Sobczak u32 max_hw_aeq_size; 212cdcd52d4SBartosz Sobczak u32 min_hw_ceq_size; 213cdcd52d4SBartosz Sobczak u32 max_hw_ceq_size; 214cdcd52d4SBartosz Sobczak u32 max_hw_device_pages; 215cdcd52d4SBartosz Sobczak u32 max_hw_vf_fpm_id; 216cdcd52d4SBartosz Sobczak u32 first_hw_vf_fpm_id; 217cdcd52d4SBartosz Sobczak u32 max_hw_ird; 218cdcd52d4SBartosz Sobczak u32 max_hw_ord; 219cdcd52d4SBartosz Sobczak u32 max_hw_wqes; 220cdcd52d4SBartosz Sobczak u32 max_hw_pds; 221cdcd52d4SBartosz Sobczak u32 max_hw_ena_vf_count; 222cdcd52d4SBartosz Sobczak u32 max_qp_wr; 223cdcd52d4SBartosz Sobczak u32 max_pe_ready_count; 224cdcd52d4SBartosz Sobczak u32 max_done_count; 225cdcd52d4SBartosz Sobczak u32 max_sleep_count; 226cdcd52d4SBartosz Sobczak u32 max_cqp_compl_wait_time_ms; 227cdcd52d4SBartosz Sobczak u16 max_stat_inst; 228cdcd52d4SBartosz Sobczak u16 max_stat_idx; 229cdcd52d4SBartosz Sobczak }; 230cdcd52d4SBartosz Sobczak 231cdcd52d4SBartosz Sobczak void icrdma_init_hw(struct irdma_sc_dev *dev); 232cdcd52d4SBartosz Sobczak void irdma_check_fc_for_qp(struct irdma_sc_vsi *vsi, struct irdma_sc_qp *sc_qp); 233cdcd52d4SBartosz Sobczak #endif /* IRDMA_H*/ 234