9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
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 * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains all of the prototypes, #defines, and structures necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for all of the Queue Pair Processing routines.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically it contains the various flags, structures used for managing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor queue pairs, and prototypes for many of the functions consumed by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * other parts of the Tavor driver (including those routines directly
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * exposed through the IBTF CI interface).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the default number of Queue Pairs (QP) and
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 * For manual configuration (not using config profiles), these values are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controllable through the "tavor_log_max_qp_sz" and "tavor_log_num_qp"
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 * Note: We also have a define for the minimum size of a QP. QPs allocated
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * with size 0, 1, 2, or 3 will always get back a QP of size 4. This is the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * smallest size that Tavor hardware and software can correctly handle.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Minimal configuration values.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following macro determines whether the contents of QP memory (WQEs)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * need to be sync'd (with ddi_dma_sync()). This decision is based on whether
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the QP memory is in DDR memory (no sync) or system memory (sync required).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * And it also supports the possibility that if a CQ in system memory is mapped
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DDI_DMA_CONSISTENT, it can be configured to not be sync'd because of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "sync override" parameter in the config profile.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((((((state)->ts_cfg_profile->cp_streaming_consistent) && \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((state)->ts_cfg_profile->cp_consistent_syncoverride))) || \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((wqinfo).qa_location == TAVOR_QUEUE_LOCATION_INDDR)) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the size of the individual Queue Pair
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context (QPC) entries. Below we also specify the size of the "Extended
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * QPC entries as well.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_QPC_SIZE (1 << TAVOR_QPC_SIZE_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_EQPC_SIZE (1 << TAVOR_EQPC_SIZE_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the default number of Tavor RDMA Backing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * entries (RDB). Settings exist for the supported DDR DIMM sizes of 128MB and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * 256MB. If a DIMM greater than 256 is found, then the 256MB profile is used.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See tavor_cfg.c for more discussion on config profiles.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * For manual configuration (not using config profiles), this value is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controllable through the "tavor_log_num_rdb" configuration variable. To
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * override config profile settings the 'tavor_alt_config_enable' configuration
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * variable must first be set.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Below we also include the defines that are used to specify four (4)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * outstanding RDMA Reads/Atomics per QP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Minimal configuration value.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the size of the individual RDMA Backing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * entries (RDB).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_RDB_SIZE (1 << TAVOR_RDB_SIZE_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This defines the maximum number of SGLs per WQE. This value is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controllable through the "tavor_wqe_max_sgl" configuration variable (but
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * should not be set larger than this value).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Define for maximum QP number mask (QP number is 24 bits) */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This define and the following macro are used to find a schedule queue for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * a new QP based on its queue pair number. Note: This is a rather simple
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * method that we use today. We simply choose from the schedule queue based
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * on the 4 least significant bits of the QP number.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_QP_SCHEDQ_GET(qpnum) ((qpnum) & TAVOR_QP_TO_SCHEDQ_MASK)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This define determines the frequency with which the AckReq bit will be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set in outgoing RC packets. By default it is set to five (5) or 2^5 = 32.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * So AckReq will be set once every 32 packets sent. This value is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controllable through the "tavor_qp_ackreq_freq" configuration variable.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Define the maximum message size (log 2). Note: This value corresponds
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to the maximum allowable message sized as defined by the IBA spec.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This macro is used to determine the appropriate alignment for a Tavor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * work queue (see tavor_qp_alloc() and tavor_special_qp_alloc()). Note:
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor work queues are aligned on their combined size (i.e. combined size
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of send queue and receive queue) because of certain hardware limitations
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (i.e. work queue memory cannot cross a 32-bit boundary).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This macro is used to determine if the tavor known QP type (qp_serv) is the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * same as the caller passed in IBT type (qp_trans). This is used in QP modify
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to ensure the types match.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((qp_trans == IBT_UD_SRV && qp_serv == TAVOR_QP_UD) || \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (qp_trans == IBT_RC_SRV && qp_serv == TAVOR_QP_RC) || \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (qp_trans == IBT_UC_SRV && qp_serv == TAVOR_QP_UC))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type is used to capture all the various types
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of Tavor work queue types. Note: It is specifically used as an argument
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to the tavor_qp_sgl_to_logwqesz() routine.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The defines below are also used by the tavor_qp_sgl_to_logwqesz() routine
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * they indicate the amount of overhead (in WQE header size) consumed by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * each of the following types of WQEs. This information is used to round
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the WQE size to the next largest power-of-2 (and to determine the number
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of SGLs that are supported for the given WQE type). There is also a define
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * below used to specify the minimum size for a WQE. The minimum size is set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to 64 bytes (a single cacheline).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_qp_info_t structure is used internally by the Tavor driver to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * pass information to and from the tavor_qp_alloc() and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_special_qp_alloc() routines. It contains placeholders for all of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * potential inputs and outputs that either routine can take.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The QPN entry which is stored in the AVL tree
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_sw_qp_s structure is also referred to using the "tavor_qphdl_t"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * typedef (see tavor_typedef.h). It encodes all the information necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to track the various resources needed to allocate, query, modify, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (later) free both normal QP and special QP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically, it has a lock to ensure single threaded access to the QP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * It has QP state, type, and number, pointers to the PD, MR, and CQ handles
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * associated with the QP, and pointers to the buffer where the work queues
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * come from.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * It has two pointers (one per work queue) to the workQ headers for the WRID
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * list, as well as pointers to the last WQE on each chain (used when
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * connecting a new chain of WQEs to a previously executing chain - see
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_wr.c). It's also got the real WQE size, real number of SGL per WQE,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and the size of each of the work queues (in number of WQEs).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Additionally, it has pointers to the resources associated with the QP
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (including the obligatory backpointer to the resource for the QP handle
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * itself. But it also has some flags, like "qp_forward_sqd_event" and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_sqd_still_draining" (which are used to indicate whether a Send Queue
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Drained Event should be forwarded to the IBTF) or "qp_is_special",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_portnum", and "qp_pkeyindx" (which are used by special QP to store
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * necessary information about the type of the QP, which port it's connected
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to, and what its current PKey index is set to).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Send Work Queue */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Receive Work Queue */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Shared Receive Queue */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Refcnt of QP belongs to an MCG */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* save the mtu & srate from init2rtr for future use */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(tavor_sw_qp_s::qp_lock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines are used to indicate whether a QP is special or
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not (and what type it is). They are used in the "qp_is_special" field
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_qp_options_t structure is used in the Tavor QP allocation
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * routines to provide additional option functionality. When a NULL pointer
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is passed in place of a pointer to this struct, it is a way of specifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "default" behavior. Using this structure, however, is a way of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * controlling any extended behavior.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Currently, the only defined "extended" behavior is for specifying whether
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * a given QP's work queues should be allocated from kernel system memory
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (TAVOR_QUEUE_LOCATION_NORMAL) or should be allocated from local DDR memory
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (TAVOR_QUEUE_LOCATION_INDDR). This defaults today to always allocating
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * from kernel system memory but can be changed by using the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "tavor_qp_wq_inddr" configuration variable.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Defined in tavor_qp.c */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_qp_alloc(tavor_state_t *state, tavor_qp_info_t *qpinfo,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_special_qp_alloc(tavor_state_t *state, tavor_qp_info_t *qpinfo,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_qp_free(tavor_state_t *state, tavor_qphdl_t *qphdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh, uint_t sleepflag);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_qp_query(tavor_state_t *state, tavor_qphdl_t qphdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qphdl_t tavor_qphdl_from_qpnum(tavor_state_t *state, uint_t qpnum);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_qp_release_qpn(tavor_state_t *state, tavor_qpn_entry_t *entry,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Defined in tavor_qpmod.c */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_qp_modify(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_qp_to_reset(tavor_state_t *state, tavor_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_TAVOR_QP_H */