9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or http://www.opensolaris.org/os/licensing.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifndef _SYS_IB_ADAPTERS_TAVOR_CQ_H
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define _SYS_IB_ADAPTERS_TAVOR_CQ_H
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_cq.h
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains all of the prototypes, #defines, and structures necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for the Completion Queue Processing routines.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically it contains the various completion types, flags,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structures used for managing Tavor completion queues, and prototypes
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for many of the functions consumed by other parts of the Tavor driver
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (including those routines directly exposed through the IBTF CI
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * interface).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/types.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/conf.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/ddi.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/sunddi.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/ib/adapters/tavor/tavor_misc.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifdef __cplusplus
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorextern "C" {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the default number of Completion Queues (CQ)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * their maximum size. Settings exist for the supported DDR DIMM sizes of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * 128MB and 256MB. If a DIMM greater than 256 is found, then the 256MB
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * profile is used. See tavor_cfg.c for more discussion on config profiles.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * For manual configuration (not using config profiles), these values are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controllable through the "tavor_log_max_cq_sz" and "tavor_log_num_cq"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * configuration variables, respectively. To override config profile settings
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the 'tavor_alt_config_enable' configuration variable must first be set.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: We also have a define for the minimum size of a CQ. CQs allocated
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * with size 0, 1, 2, or 3 will always get back a CQ of size 4. This is the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * smallest size that Tavor hardware and software can correctly handle.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_NUM_CQ_SHIFT_128 0x10
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_NUM_CQ_SHIFT_256 0x11
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_SZ_SHIFT 0x10
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_SZ (1 << TAVOR_CQ_SZ_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_MIN_SIZE 0x3
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Minimal configuration values.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_NUM_CQ_SHIFT_MIN 0xC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_SZ_SHIFT_MIN 0xC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following macro determines whether the contents of CQ memory (CQEs)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * need to be sync'd (with ddi_dma_sync()). This decision is based on whether
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the CQ memory is in DDR memory (no sync) or system memory (sync required).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: It doesn't make much sense to put CQEs in DDR memory (since they are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * primarily written by HW and read by the CPU), but the driver does support
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that possibility. And it also supports the possibility that if a CQ in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * system memory is mapped DDI_DMA_CONSISTENT, it can be configured to not be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * sync'd because of the "sync override" parameter in the config profile.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_IS_SYNC_REQ(state, cqinfo) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((((((state)->ts_cfg_profile->cp_streaming_consistent) && \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((state)->ts_cfg_profile->cp_consistent_syncoverride))) || \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((cqinfo).qa_location == TAVOR_QUEUE_LOCATION_INDDR)) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ? 0 : 1)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the size of the individual Completion Queue
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context (CQC) entries
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQC_SIZE_SHIFT 0x6
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQC_SIZE (1 << TAVOR_CQC_SIZE_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These are the defines for the Tavor CQ completion statuses. They are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specified by the Tavor register specification.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SUCCESS 0x0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOC_LEN_ERR 0x1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOC_OP_ERR 0x2
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOC_EEC_ERR 0x3 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOC_PROT_ERR 0x4
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_WR_FLUSHED_ERR 0x5
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_MW_BIND_ERR 0x6
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_BAD_RESPONSE_ERR 0x10
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOCAL_ACCESS_ERR 0x11
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_REM_INV_REQ_ERR 0x12
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_REM_ACC_ERR 0x13
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_REM_OP_ERR 0x14
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_TRANS_TO_ERR 0x15
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RNRNAK_TO_ERR 0x16
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_LOCAL_RDD_VIO_ERR 0x20 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_REM_INV_RD_REQ_ERR 0x21 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_EEC_REM_ABORTED_ERR 0x22 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_INV_EEC_NUM_ERR 0x23 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_INV_EEC_STATE_ERR 0x24 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These are the defines for the Tavor CQ entry types. They are also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specified by the Tavor register specification. They indicate what type
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of work request is completing (for successful completions). Note: The
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "SND" or "RCV" in each define is used to indicate whether the completion
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * work request was from the Send work queue or the Receive work queue on
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the associated QP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_RDMAWR 0x8
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_RDMAWR_IMM 0x9
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_SEND 0xA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_SEND_IMM 0xB
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_RDMARD 0x10
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_ATOMIC_CS 0x11
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_ATOMIC_FA 0x12
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SND_BIND_MW 0x18
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RECV_IMM 0x3
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RECV_IMM2 0x5
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RECV 0x2
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RECV2 0x4
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RDMAWR_IMM 0x9
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RCV_RDMAWR_IMM2 0xB
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Define for maximum CQ number mask (CQ number is 24 bits) */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_MAXNUMBER_MSK 0xFFFFFF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This define and the following macro are used to find an event queue for a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * new CQ based on its completion queue number. Note: This is a rather
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * simple method that we use today. We simply choose from one of the first
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * 32 EQs based on the 5 least significant bits of the CQ number.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_TO_EQ_MASK 0x1F
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_EQNUM_GET(cqnum) ((cqnum) & TAVOR_CQ_TO_EQ_MASK)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following macro is even simpler than the above one. This is used to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * find an event queue for CQ errors for a new CQ. In theory we could do this
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * based on the CQ's number (as we do above). Today, however, all CQ error
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * events go to one specific EQ (i.e. EQ #32).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_ERREQNUM_GET(cqnum) 0x20
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines are used for Tavor CQ error handling. Note: For
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CQEs which correspond to error events, the Tavor device requires some
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * special handling by software. These defines are used to identify and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * extract the necessary information from each error CQE, including status
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * code (above), doorbell count, and whether a error completion is for a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * send or receive work request.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_ERR_STATUS_SHIFT 24
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_ERR_STATUS_MASK 0xFF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_ERR_DBDCNT_MASK 0xFFFF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_SEND_ERR_OPCODE 0xFF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQE_RECV_ERR_OPCODE 0xFE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_SYNC_AND_DB 0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_RECYCLE_ENTRY 1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Defines for tracking whether a CQ is being used with special QP or not */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_IS_NORMAL 0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQ_IS_SPECIAL 1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_sw_cq_s structure is also referred to using the "tavor_cqhdl_t"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * typedef (see tavor_typedef.h). It encodes all the information necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to track the various resources needed to allocate, initialize, poll, resize,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and (later) free a completion queue (CQ).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically, it has a consumer index and a lock to ensure single threaded
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * access to it. It has pointers to the various resources allocated for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * completion queue, i.e. a CQC resource and the memory for the completion
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * queue itself. It has flags to indicate whether the CQ requires
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ddi_dma_sync() ("cq_sync"). It also has a reference count and the number(s)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of the EQs to which it is associated (for success and for errors).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Additionally, it has a pointer to the associated MR handle (for the mapped
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * queue memory) and a void pointer that holds the argument that should be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * passed back to the IBTF when events are generated on the CQ.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We also have the always necessary backpointer to the resource for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CQ handle structure itself. But we also have pointers to the "Work Request
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ID" processing lists (both the lock and the regular list, as well as the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * head and tail for the "reapable" list). See tavor_wrid.c for more details.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstruct tavor_sw_cq_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor kmutex_t cq_lock;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_consindx;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_cqnum;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_hw_cqe_t *cq_buf;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_mrhdl_t cq_mrhdl;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_bufsz;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t cq_sync;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t cq_refcnt;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_eqnum;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_erreqnum;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t cq_is_special;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t cq_is_umap;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t cq_uarpg;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor devmap_cookie_t cq_umap_dhp;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_t *cq_cqcrsrcp;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_t *cq_rsrcp;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *cq_hdlrarg;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* For Work Request ID processing */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor kmutex_t cq_wrid_wqhdr_lock;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor avl_tree_t cq_wrid_wqhdr_avl_tree;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_wrid_list_hdr_t *cq_wrid_reap_head;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_wrid_list_hdr_t *cq_wrid_reap_tail;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor struct tavor_qalloc_info_s cq_cqinfo;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor};
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(READ_ONLY_DATA(tavor_sw_cq_s::cq_cqnum
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_eqnum
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_erreqnum
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_cqcrsrcp
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_rsrcp
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_hdlrarg
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_is_umap
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_uarpg))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(DATA_READABLE_WITHOUT_LOCK(tavor_sw_cq_s::cq_bufsz
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_cqinfo))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(tavor_sw_cq_s::cq_lock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_consindx
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_buf
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_mrhdl
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_sync
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_refcnt
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_is_special
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_sw_cq_s::cq_umap_dhp))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_alloc(tavor_state_t *state, ibt_cq_hdl_t ibt_cqhdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cq_attr_t *attr_p, uint_t *actual_size, tavor_cqhdl_t *cqhdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t sleepflag);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_free(tavor_state_t *state, tavor_cqhdl_t *cqhdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t sleepflag);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_resize(tavor_state_t *state, tavor_cqhdl_t cqhdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t req_size, uint_t *actual_size, uint_t sleepflag);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_notify(tavor_state_t *state, tavor_cqhdl_t cqhdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cq_notify_flags_t flags);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_poll(tavor_state_t *state, tavor_cqhdl_t cqhdl, ibt_wc_t *wc_p,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t num_wc, uint_t *num_polled);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_handler(tavor_state_t *state, tavor_eqhdl_t eq,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_hw_eqe_t *eqe);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_err_handler(tavor_state_t *state, tavor_eqhdl_t eq,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_hw_eqe_t *eqe);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_cq_refcnt_inc(tavor_cqhdl_t cq, uint_t is_special);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_cq_refcnt_dec(tavor_cqhdl_t cq);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_cqhdl_t tavor_cqhdl_from_cqnum(tavor_state_t *state, uint_t cqnum);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_cq_srq_entries_flush(tavor_state_t *state, tavor_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifdef __cplusplus
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor}
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_TAVOR_CQ_H */