2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _DAPL_TAVOR_HW_H
2N/A#define _DAPL_TAVOR_HW_H
2N/A
2N/A/*
2N/A * dapl_tavor_hw.h
2N/A * Contains all the structure definitions and #defines for all Tavor
2N/A * hardware resources and registers.
2N/A * Most of these definitions have been replicated from the tavor_hw.h
2N/A * header file used by the tavor device driver.
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include "dapl.h"
2N/A#include "dapl_tavor_ibtf.h"
2N/A
2N/A
2N/A/*
2N/A * Ownership flags used to define hardware or software ownership for
2N/A * various Tavor resources
2N/A */
2N/A#define TAVOR_HW_OWNER 0x1U
2N/A#define TAVOR_SW_OWNER 0x0
2N/A
2N/A/*
2N/A * Tavor Completion Queue Entries (CQE)
2N/A * Each CQE contains enough information for the software to associate the
2N/A * completion with the Work Queue Element (WQE) to which it corresponds.
2N/A *
2N/A * Note: The following structure is not #define'd with both little-endian
2N/A * and big-endian definitions. This is because each CQE's individual
2N/A * fields are not directly accessed except through the macros defined below.
2N/A */
2N/A
2N/A/*
2N/A * The following defines are used for Tavor CQ error handling. Note: For
2N/A * CQEs which correspond to error events, the Tavor device requires some
2N/A * special handling by software. These defines are used to identify and
2N/A * extract the necessary information from each error CQE, including status
2N/A * code (above), doorbell count, and whether a error completion is for a
2N/A * send or receive work request.
2N/A */
2N/A#define TAVOR_CQE_ERR_STATUS_SHIFT 24
2N/A#define TAVOR_CQE_ERR_STATUS_MASK 0xFF
2N/A#define TAVOR_CQE_ERR_DBDCNT_MASK 0xFFFF
2N/A#define TAVOR_CQE_SEND_ERR_OPCODE 0xFF
2N/A#define TAVOR_CQE_RECV_ERR_OPCODE 0xFE
2N/A#define TAVOR_CQ_SYNC_AND_DB 0
2N/A#define TAVOR_CQ_RECYCLE_ENTRY 1
2N/A
2N/A/*
2N/A * These are the defines for the Tavor CQ entry types. They are also
2N/A * specified by the Tavor register specification. They indicate what type
2N/A * of work request is completing (for successful completions). Note: The
2N/A * "SND" or "RCV" in each define is used to indicate whether the completion
2N/A * work request was from the Send work queue or the Receive work queue on
2N/A * the associated QP.
2N/A */
2N/A#define TAVOR_CQE_SND_RDMAWR 0x8
2N/A#define TAVOR_CQE_SND_RDMAWR_IMM 0x9
2N/A#define TAVOR_CQE_SND_SEND 0xA
2N/A#define TAVOR_CQE_SND_SEND_IMM 0xB
2N/A#define TAVOR_CQE_SND_RDMARD 0x10
2N/A#define TAVOR_CQE_SND_ATOMIC_CS 0x11
2N/A#define TAVOR_CQE_SND_ATOMIC_FA 0x12
2N/A#define TAVOR_CQE_SND_BIND_MW 0x18
2N/A#define TAVOR_CQE_RCV_RECV_IMM 0x3
2N/A#define TAVOR_CQE_RCV_RECV_IMM2 0x5
2N/A#define TAVOR_CQE_RCV_RECV 0x2
2N/A#define TAVOR_CQE_RCV_RECV2 0x4
2N/A#define TAVOR_CQE_RCV_RDMAWR_IMM 0x9
2N/A#define TAVOR_CQE_RCV_RDMAWR_IMM2 0xB
2N/A
2N/A/*
2N/A * These are the defines for the Tavor CQ completion statuses. They are
2N/A * specified by the Tavor register specification.
2N/A */
2N/A#define TAVOR_CQE_SUCCESS 0x0
2N/A#define TAVOR_CQE_LOC_LEN_ERR 0x1
2N/A#define TAVOR_CQE_LOC_OP_ERR 0x2
2N/A#define TAVOR_CQE_LOC_EEC_ERR 0x3 /* unsupported: RD */
2N/A#define TAVOR_CQE_LOC_PROT_ERR 0x4
2N/A#define TAVOR_CQE_WR_FLUSHED_ERR 0x5
2N/A#define TAVOR_CQE_MW_BIND_ERR 0x6
2N/A#define TAVOR_CQE_BAD_RESPONSE_ERR 0x10
2N/A#define TAVOR_CQE_LOCAL_ACCESS_ERR 0x11
2N/A#define TAVOR_CQE_REM_INV_REQ_ERR 0x12
2N/A#define TAVOR_CQE_REM_ACC_ERR 0x13
2N/A#define TAVOR_CQE_REM_OP_ERR 0x14
2N/A#define TAVOR_CQE_TRANS_TO_ERR 0x15
2N/A#define TAVOR_CQE_RNRNAK_TO_ERR 0x16
2N/A#define TAVOR_CQE_LOCAL_RDD_VIO_ERR 0x20 /* unsupported: RD */
2N/A#define TAVOR_CQE_REM_INV_RD_REQ_ERR 0x21 /* unsupported: RD */
2N/A#define TAVOR_CQE_EEC_REM_ABORTED_ERR 0x22 /* unsupported: RD */
2N/A#define TAVOR_CQE_INV_EEC_NUM_ERR 0x23 /* unsupported: RD */
2N/A#define TAVOR_CQE_INV_EEC_STATE_ERR 0x24 /* unsupported: RD */
2N/A
2N/Atypedef struct tavor_hw_cqe_s {
2N/A uint32_t ver :4;
2N/A uint32_t :4;
2N/A uint32_t my_qpn :24;
2N/A uint32_t :8;
2N/A uint32_t my_ee :24;
2N/A uint32_t :8;
2N/A uint32_t rqpn :24;
2N/A uint32_t sl :4;
2N/A uint32_t :4;
2N/A uint32_t grh :1;
2N/A uint32_t ml_path :7;
2N/A uint32_t rlid :16;
2N/A uint32_t imm_eth_pkey_cred;
2N/A uint32_t byte_cnt;
2N/A uint32_t wqe_addr :26;
2N/A uint32_t wqe_sz :6;
2N/A uint32_t opcode :8;
2N/A uint32_t send_or_recv :1;
2N/A uint32_t :15;
2N/A uint32_t owner :1;
2N/A uint32_t status :7;
2N/A} tavor_hw_cqe_t;
2N/A#define TAVOR_COMPLETION_RECV 0x0
2N/A#define TAVOR_COMPLETION_SEND 0x1
2N/A
2N/A#define TAVOR_CQE_DEFAULT_VERSION 0x0
2N/A
2N/A/*
2N/A * The following macros are used for extracting (and in some cases filling in)
2N/A * information from CQEs
2N/A */
2N/A#define TAVOR_CQE_QPNUM_MASK 0x00FFFFFF
2N/A#define TAVOR_CQE_QPNUM_SHIFT 0
2N/A#define TAVOR_CQE_DQPN_MASK 0x00FFFFFF
2N/A#define TAVOR_CQE_DQPN_SHIFT 0
2N/A#define TAVOR_CQE_SL_MASK 0xF0000000
2N/A#define TAVOR_CQE_SL_SHIFT 28
2N/A#define TAVOR_CQE_GRH_MASK 0x00800000
2N/A#define TAVOR_CQE_GRH_SHIFT 23
2N/A#define TAVOR_CQE_PATHBITS_MASK 0x007F0000
2N/A#define TAVOR_CQE_PATHBITS_SHIFT 16
2N/A#define TAVOR_CQE_DLID_MASK 0x0000FFFF
2N/A#define TAVOR_CQE_DLID_SHIFT 0
2N/A#define TAVOR_CQE_OPCODE_MASK 0xFF000000
2N/A#define TAVOR_CQE_OPCODE_SHIFT 24
2N/A#define TAVOR_CQE_SENDRECV_MASK 0x00800000
2N/A#define TAVOR_CQE_SENDRECV_SHIFT 23
2N/A#define TAVOR_CQE_OWNER_MASK 0x00000080
2N/A#define TAVOR_CQE_OWNER_SHIFT 7
2N/A
2N/A#define TAVOR_CQE_QPNUM_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[0]) & TAVOR_CQE_QPNUM_MASK) >> \
2N/A TAVOR_CQE_QPNUM_SHIFT)
2N/A#define TAVOR_CQE_DQPN_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[2]) & TAVOR_CQE_DQPN_MASK) >> \
2N/A TAVOR_CQE_DQPN_SHIFT)
2N/A#define TAVOR_CQE_SL_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[3]) & TAVOR_CQE_SL_MASK) >> \
2N/A TAVOR_CQE_SL_SHIFT)
2N/A#define TAVOR_CQE_GRH_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[3]) & TAVOR_CQE_GRH_MASK) >> \
2N/A TAVOR_CQE_GRH_SHIFT)
2N/A#define TAVOR_CQE_PATHBITS_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[3]) & TAVOR_CQE_PATHBITS_MASK) >>\
2N/A TAVOR_CQE_PATHBITS_SHIFT)
2N/A#define TAVOR_CQE_DLID_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[3]) & TAVOR_CQE_DLID_MASK) >> \
2N/A TAVOR_CQE_DLID_SHIFT)
2N/A#define TAVOR_CQE_IMM_ETH_PKEY_CRED_GET(cqe) \
2N/A (BETOH_32(((uint32_t *)(cqe))[4]))
2N/A#define TAVOR_CQE_IMM_ETH_PKEY_CRED_SET(cqe, arg) \
2N/A (((uint32_t *)(cqe))[4] = HTOBE_32((arg)))
2N/A#define TAVOR_CQE_BYTECNT_GET(cqe) \
2N/A (BETOH_32(((uint32_t *)(cqe))[5]))
2N/A#define TAVOR_CQE_WQEADDRSZ_GET(cqe) \
2N/A (BETOH_32(((uint32_t *)(cqe))[6]))
2N/A#define TAVOR_CQE_WQEADDRSZ_SET(cqe, arg) \
2N/A (((uint32_t *)(cqe))[6] = HTOBE_32((arg)))
2N/A#define TAVOR_CQE_OPCODE_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[7]) & TAVOR_CQE_OPCODE_MASK) >> \
2N/A TAVOR_CQE_OPCODE_SHIFT)
2N/A#define TAVOR_CQE_SENDRECV_GET(cqe) \
2N/A ((BETOH_32(((uint32_t *)(cqe))[7]) & TAVOR_CQE_SENDRECV_MASK) >>\
2N/A TAVOR_CQE_SENDRECV_SHIFT)
2N/A#define TAVOR_CQE_OWNER_IS_SW(cqe) \
2N/A (((BETOH_32(((uint32_t *)(cqe))[7]) & TAVOR_CQE_OWNER_MASK) >> \
2N/A TAVOR_CQE_OWNER_SHIFT) == TAVOR_SW_OWNER)
2N/A#define TAVOR_CQE_OWNER_SET_HW(cqe) \
2N/A (((uint32_t *)(cqe))[7] = \
2N/A BETOH_32((TAVOR_HW_OWNER << TAVOR_CQE_OWNER_SHIFT) & \
2N/A TAVOR_CQE_OWNER_MASK))
2N/A
2N/A/*
2N/A * Tavor User Access Region (UAR)
2N/A * Tavor doorbells are each rung by writing to the doorbell registers that
2N/A * form a User Access Region (UAR). A doorbell is a write-only hardware
2N/A * register which enables passing information from software to hardware
2N/A * with minimum software latency. A write operation from the host software
2N/A * to these doorbell registers passes information about the HCA resources
2N/A * and initiates processing of the doorbell data. There are 6 types of
2N/A * doorbells in Tavor.
2N/A *
2N/A * "Send Doorbell" for synchronizing the attachment of a WQE (or a chain
2N/A * of WQEs) to the send queue.
2N/A * "RD Send Doorbell" (Same as above, except for RD QPs) is not supported.
2N/A * "Receive Doorbell" for synchronizing the attachment of a WQE (or a chain
2N/A * of WQEs) to the receive queue.
2N/A * "CQ Doorbell" for updating the CQ consumer index and requesting
2N/A * completion notifications.
2N/A * "EQ Doorbell" for updating the EQ consumer index, arming interrupt
2N/A * triggering, and disarming CQ notification requests.
2N/A * "InfiniBlast" (which would have enabled access to the "InfiniBlast
2N/A * buffer") is not supported.
2N/A *
2N/A * Note: The tavor_hw_uar_t below is the container for all of the various
2N/A * doorbell types. Below we first define several structures which make up
2N/A * the contents of those doorbell types.
2N/A *
2N/A * Note also: The following structures are not #define'd with both little-
2N/A * endian and big-endian definitions. This is because each doorbell type
2N/A * is not directly accessed except through a single ddi_put64() operation
2N/A * (see tavor_qp_send_doorbell, tavor_qp_recv_doorbell, tavor_cq_doorbell,
2N/A * or tavor_eq_doorbell)
2N/A */
2N/Atypedef struct tavor_hw_uar_send_s {
2N/A uint32_t nda :26;
2N/A uint32_t fence :1;
2N/A uint32_t nopcode :5;
2N/A uint32_t qpn :24;
2N/A uint32_t :2;
2N/A uint32_t nds :6;
2N/A} tavor_hw_uar_send_t;
2N/A#define TAVOR_QPSNDDB_NDA_MASK 0xFFFFFFC0
2N/A#define TAVOR_QPSNDDB_NDA_SHIFT 0x20
2N/A#define TAVOR_QPSNDDB_F_SHIFT 0x25
2N/A#define TAVOR_QPSNDDB_NOPCODE_SHIFT 0x20
2N/A#define TAVOR_QPSNDDB_QPN_SHIFT 0x8
2N/A
2N/Atypedef struct tavor_hw_uar_recv_s {
2N/A uint32_t nda :26;
2N/A uint32_t nds :6;
2N/A uint32_t qpn :24;
2N/A uint32_t credits :8;
2N/A} tavor_hw_uar_recv_t;
2N/A#define TAVOR_QPRCVDB_NDA_MASK 0xFFFFFFC0
2N/A#define TAVOR_QPRCVDB_NDA_SHIFT 0x20
2N/A#define TAVOR_QPRCVDB_NDS_SHIFT 0x20
2N/A#define TAVOR_QPRCVDB_QPN_SHIFT 0x8
2N/A/* Max descriptors per Tavor doorbell */
2N/A#define TAVOR_QP_MAXDESC_PER_DB 256
2N/A
2N/Atypedef struct tavor_hw_uar_cq_s {
2N/A uint32_t cmd :8;
2N/A uint32_t cqn :24;
2N/A uint32_t param;
2N/A} tavor_hw_uar_cq_t;
2N/A#define TAVOR_CQDB_CMD_SHIFT 0x38
2N/A#define TAVOR_CQDB_CQN_SHIFT 0x20
2N/A
2N/A#define TAVOR_CQDB_INCR_CONSINDX 0x01
2N/A#define TAVOR_CQDB_NOTIFY_CQ 0x02
2N/A#define TAVOR_CQDB_NOTIFY_CQ_SOLICIT 0x03
2N/A#define TAVOR_CQDB_SET_CONSINDX 0x04
2N/A#define TAVOR_CQDB_NOTIFY_NCQ 0x05
2N/A/* Default value for use in NOTIFY_CQ doorbell */
2N/A#define TAVOR_CQDB_DEFAULT_PARAM 0xFFFFFFFF
2N/A
2N/Atypedef struct tavor_hw_uar_eq_s {
2N/A uint32_t cmd :8;
2N/A uint32_t :18;
2N/A uint32_t eqn :6;
2N/A uint32_t param;
2N/A} tavor_hw_uar_eq_t;
2N/A
2N/Atypedef struct tavor_hw_uar_s {
2N/A uint32_t rsrv0[4]; /* "RD Send" unsupported */
2N/A uint64_t send; /* tavor_hw_uar_send_t */
2N/A uint64_t recv; /* tavor_hw_uar_recv_t */
2N/A uint64_t cq; /* tavor_hw_uar_cq_t */
2N/A uint64_t eq; /* tavor_hw_uar_eq_t */
2N/A uint32_t rsrv1[244];
2N/A uint32_t iblast[256]; /* "InfiniBlast" unsupported */
2N/A} tavor_hw_uar_t;
2N/A
2N/Atypedef struct tavor_hw_uar32_s {
2N/A uint32_t rsrv0[4]; /* "RD Send" unsupported */
2N/A uint32_t send[2]; /* tavor_hw_uar_send_t */
2N/A uint32_t recv[2]; /* tavor_hw_uar_recv_t */
2N/A uint32_t cq[2]; /* tavor_hw_uar_cq_t */
2N/A uint32_t eq[2]; /* tavor_hw_uar_eq_t */
2N/A uint32_t rsrv1[244];
2N/A uint32_t iblast[256]; /* "InfiniBlast" unsupported */
2N/A} tavor_hw_uar32_t;
2N/A
2N/A
2N/A/*
2N/A * Tavor Send Work Queue Element (WQE)
2N/A * A Tavor Send WQE is built of the following segments, each of which is a
2N/A * multiple of 16 bytes. Note: Each individual WQE may contain only a
2N/A * subset of these segments described below (according to the operation type
2N/A * and transport type of the QP).
2N/A *
2N/A * The first 16 bytes of ever WQE are formed from the "Next/Ctrl" segment.
2N/A * This segment contains the address of the next WQE to be executed and the
2N/A * information required in order to allocate the resources to execute the
2N/A * next WQE. The "Ctrl" part of this segment contains the control
2N/A * information required to execute the WQE, including the opcode and other
2N/A * control information.
2N/A * The "Datagram" segment contains address information required in order to
2N/A * form a UD message.
2N/A * The "Bind" segment contains the parameters required for a Bind Memory
2N/A * Window operation.
2N/A * The "Remote Address" segment is present only in RDMA or Atomic WQEs and
2N/A * specifies remote virtual addresses and RKey, respectively. Length of
2N/A * the remote access is calculated from the scatter/gather list (for
2N/A * RDMA-write/RDMA-read) or set to eight (for Atomic).
2N/A * The "Atomic" segment is present only in Atomic WQEs and specifies
2N/A * Swap/Add and Compare data.
2N/A *
2N/A * Note: The following structures are not #define'd with both little-endian
2N/A * and big-endian definitions. This is because their individual fields are
2N/A * not directly accessed except through macros defined below.
2N/A */
2N/Atypedef struct tavor_hw_snd_wqe_nextctrl_s {
2N/A uint32_t next_wqe_addr :26;
2N/A uint32_t :1;
2N/A uint32_t nopcode :5;
2N/A uint32_t next_eec :24;
2N/A uint32_t dbd :1;
2N/A uint32_t fence :1;
2N/A uint32_t nds :6;
2N/A
2N/A uint32_t :28;
2N/A uint32_t c :1;
2N/A uint32_t e :1;
2N/A uint32_t s :1;
2N/A uint32_t i :1;
2N/A uint32_t immediate :32;
2N/A} tavor_hw_snd_wqe_nextctrl_t;
2N/A
2N/A#define TAVOR_WQE_NDA_MASK 0x00000000FFFFFFC0
2N/A#define TAVOR_WQE_NDS_MASK 0x3F
2N/A#define TAVOR_WQE_DBD_MASK 0x80
2N/A
2N/A#define TAVOR_WQE_SEND_FENCE_MASK 0x40
2N/A#define TAVOR_WQE_SEND_NOPCODE_RDMAW 0x8
2N/A#define TAVOR_WQE_SEND_NOPCODE_RDMAWI 0x9
2N/A#define TAVOR_WQE_SEND_NOPCODE_SEND 0xA
2N/A#define TAVOR_WQE_SEND_NOPCODE_SENDI 0xB
2N/A#define TAVOR_WQE_SEND_NOPCODE_RDMAR 0x10
2N/A#define TAVOR_WQE_SEND_NOPCODE_ATMCS 0x11
2N/A#define TAVOR_WQE_SEND_NOPCODE_ATMFA 0x12
2N/A#define TAVOR_WQE_SEND_NOPCODE_BIND 0x18
2N/A
2N/A#define TAVOR_WQE_SEND_SIGNALED_MASK 0x800000000ULL
2N/A#define TAVOR_WQE_SEND_EVENT_MASK 0x400000000ULL
2N/A#define TAVOR_WQE_SEND_SOLICIT_MASK 0x200000000ULL
2N/A#define TAVOR_WQE_SEND_IMMEDIATE_MASK 0x100000000ULL
2N/A
2N/A#define TAVOR_WQE_SENDHDR_UD_AV_MASK 0xFFFFFFFFFFFFFFE0
2N/A#define TAVOR_WQE_SENDHDR_UD_DQPN_MASK 0xFFFFFF
2N/A
2N/Atypedef struct tavor_hw_snd_wqe_bind_s {
2N/A uint32_t ae :1;
2N/A uint32_t rw :1;
2N/A uint32_t rr :1;
2N/A uint32_t :29;
2N/A uint32_t :32;
2N/A uint32_t new_rkey;
2N/A uint32_t reg_lkey;
2N/A uint64_t addr;
2N/A uint64_t len;
2N/A} tavor_hw_snd_wqe_bind_t;
2N/A#define TAVOR_WQE_SENDHDR_BIND_ATOM 0x8000000000000000ULL
2N/A#define TAVOR_WQE_SENDHDR_BIND_WR 0x4000000000000000ULL
2N/A#define TAVOR_WQE_SENDHDR_BIND_RD 0x2000000000000000ULL
2N/A
2N/Atypedef struct tavor_hw_snd_wqe_remaddr_s {
2N/A uint64_t vaddr;
2N/A uint32_t rkey;
2N/A uint32_t :32;
2N/A} tavor_hw_snd_wqe_remaddr_t;
2N/A
2N/A/*
2N/A * Tavor Receive Work Queue Element (WQE)
2N/A * Like the Send WQE, the Receive WQE is built of 16-byte segments. The
2N/A * segment is the "Next/Ctrl" segment (defined below). It is followed by
2N/A * some number of scatter list entries for the incoming message.
2N/A *
2N/A * The format of the scatter-gather list entries is also shown below. For
2N/A * Receive WQEs the "inline_data" field must be cleared (i.e. data segments
2N/A * cannot contain inline data).
2N/A */
2N/Atypedef struct tavor_hw_rcv_wqe_nextctrl_s {
2N/A uint32_t next_wqe_addr :26;
2N/A uint32_t :5;
2N/A uint32_t one :1;
2N/A uint32_t :24;
2N/A uint32_t dbd :1;
2N/A uint32_t :1;
2N/A uint32_t nds :6;
2N/A
2N/A uint32_t :28;
2N/A uint32_t c :1;
2N/A uint32_t e :1;
2N/A uint32_t :2;
2N/A uint32_t :32;
2N/A} tavor_hw_rcv_wqe_nextctrl_t;
2N/A
2N/A/*
2N/A * This bit must be set in the next/ctrl field of all Receive WQEs
2N/A * as a workaround to a Tavor hardware erratum related to having
2N/A * the first 32-bits in the WQE set to zero.
2N/A */
2N/A#define TAVOR_RCV_WQE_NDA0_WA_MASK 0x0000000100000000ULL
2N/A#define TAVOR_WQE_RCV_SIGNALED_MASK 0x800000000ULL
2N/A#define TAVOR_WQE_RCV_EVENT_MASK 0x400000000ULL
2N/A
2N/Atypedef struct tavor_hw_wqe_sgl_s {
2N/A uint32_t inline_data :1;
2N/A uint32_t byte_cnt :31;
2N/A uint32_t lkey;
2N/A uint64_t addr;
2N/A} tavor_hw_wqe_sgl_t;
2N/A#define TAVOR_WQE_SGL_BYTE_CNT_MASK 0x7FFFFFFF
2N/A#define TAVOR_WQE_SGL_INLINE_MASK 0x80000000
2N/A/*
2N/A * The tavor_sw_wqe_dbinfo_t structure is used internally by the Tavor
2N/A * driver to return information (from the tavor_wqe_mlx_build_nextctl() and
2N/A * tavor_wqe_send_build_nextctl() routines) regarding the type of Tavor
2N/A * doorbell necessary.
2N/A */
2N/Atypedef struct tavor_sw_wqe_dbinfo_s {
2N/A uint_t db_nopcode;
2N/A uint_t db_fence;
2N/A} tavor_sw_wqe_dbinfo_t;
2N/A
2N/A
2N/A/*
2N/A * The following macros are used for building each of the individual
2N/A * segments that can make up a Tavor WQE. Note: We try not to use the
2N/A * structures (with their associated bitfields) here, instead opting to
2N/A * build and put 64-bit or 32-bit chunks to the WQEs as appropriate,
2N/A * primarily because using the bitfields appears to force more read-modify-
2N/A * write operations.
2N/A *
2N/A * TAVOR_WQE_BUILD_REMADDR - Builds Remote Address Segment using
2N/A * RDMA info from the work request
2N/A * TAVOR_WQE_BUILD_BIND - Builds the Bind Memory Window
2N/A * Segment using bind info from the
2N/A * work request
2N/A * TAVOR_WQE_LINKNEXT - Links the current WQE to the
2N/A * previous one
2N/A * TAVOR_WQE_LINKFIRST - Links the first WQE on the current
2N/A * chain to the previous WQE
2N/A */
2N/A
2N/A#define TAVOR_WQE_BUILD_REMADDR(ra, wr_rdma) \
2N/A{ \
2N/A uint64_t *tmp; \
2N/A \
2N/A tmp = (uint64_t *)(ra); \
2N/A tmp[0] = HTOBE_64((wr_rdma)->rdma_raddr); \
2N/A tmp[1] = HTOBE_64((uint64_t)(wr_rdma)->rdma_rkey << 32); \
2N/A}
2N/A#define TAVOR_WQE_BUILD_BIND(bn, wr_bind) \
2N/A{ \
2N/A uint64_t *tmp; \
2N/A uint64_t bn0_tmp; \
2N/A ibt_bind_flags_t bind_flags; \
2N/A \
2N/A tmp = (uint64_t *)(bn); \
2N/A bind_flags = (wr_bind)->bind_flags; \
2N/A bn0_tmp = (bind_flags & IBT_WR_BIND_ATOMIC) ? \
2N/A TAVOR_WQE_SENDHDR_BIND_ATOM : 0; \
2N/A bn0_tmp |= (bind_flags & IBT_WR_BIND_WRITE) ? \
2N/A TAVOR_WQE_SENDHDR_BIND_WR : 0; \
2N/A bn0_tmp |= (bind_flags & IBT_WR_BIND_READ) ? \
2N/A TAVOR_WQE_SENDHDR_BIND_RD : 0; \
2N/A tmp[0] = HTOBE_64(bn0_tmp); \
2N/A tmp[1] = HTOBE_64(((uint64_t)(wr_bind)->bind_rkey_out << 32) | \
2N/A (wr_bind)->bind_lkey); \
2N/A tmp[2] = HTOBE_64((wr_bind)->bind_va); \
2N/A tmp[3] = HTOBE_64((wr_bind)->bind_len); \
2N/A}
2N/A
2N/A#define TAVOR_WQE_BUILD_DATA_SEG(ds, sgl) \
2N/A{ \
2N/A uint64_t *tmp; \
2N/A \
2N/A tmp = (uint64_t *)(ds); \
2N/A tmp[0] = HTOBE_64(((uint64_t)((sgl)->ds_len & \
2N/A TAVOR_WQE_SGL_BYTE_CNT_MASK) << 32) | (sgl)->ds_key); \
2N/A tmp[1] = HTOBE_64((sgl)->ds_va); \
2N/A}
2N/A
2N/A#define TAVOR_WQE_LINKNEXT(prev, ctrl, next) \
2N/A{ \
2N/A ((uint64_t *)(prev))[1] = HTOBE_64((ctrl)); \
2N/A ((uint64_t *)(prev))[0] = HTOBE_64((next)); \
2N/A}
2N/A
2N/A#define TAVOR_WQE_LINKFIRST(prev, next) \
2N/A{ \
2N/A ((uint64_t *)(prev))[0] = HTOBE_64((next)); \
2N/A}
2N/A
2N/A/*
2N/A * The following macro is used to convert WQE address and size into the
2N/A * "wqeaddrsz" value needed in the tavor_wrid_entry_t (see below).
2N/A */
2N/A#define TAVOR_QP_WQEADDRSZ(addr, size) \
2N/A ((((uintptr_t)(addr)) & ~TAVOR_WQE_NDS_MASK) | \
2N/A ((size) & TAVOR_WQE_NDS_MASK))
2N/A
2N/A/*
2N/A * The following macros are used to calculate pointers to the Send or Receive
2N/A * WQEs on a given QP, respectively
2N/A */
2N/A#define TAVOR_QP_SQ_ENTRY(qp, tail) \
2N/A ((uint64_t *)((uintptr_t)((qp)->qp_sq_buf) + \
2N/A ((tail) * (qp)->qp_sq_wqesz)))
2N/A#define TAVOR_QP_SQ_DESC(qp, tail) \
2N/A ((uint32_t)((qp)->qp_sq_desc_addr + \
2N/A ((tail) * (qp)->qp_sq_wqesz)))
2N/A#define TAVOR_QP_RQ_ENTRY(qp, tail) \
2N/A ((uint64_t *)((uintptr_t)((qp)->qp_rq_buf) + \
2N/A ((tail) * (qp)->qp_rq_wqesz)))
2N/A#define TAVOR_QP_RQ_DESC(qp, tail) \
2N/A ((uint32_t)((qp)->qp_rq_desc_addr + \
2N/A ((tail) * (qp)->qp_rq_wqesz)))
2N/A#define TAVOR_SRQ_RQ_ENTRY(srq, tail) \
2N/A ((uint64_t *)((uintptr_t)((srq)->srq_wq_buf) + \
2N/A ((tail) * (srq)->srq_wq_wqesz)))
2N/A#define TAVOR_SRQ_RQ_DESC(srq, tail) \
2N/A ((uint32_t)((srq)->srq_wq_desc_addr + \
2N/A ((tail) * (srq)->srq_wq_wqesz)))
2N/A#define TAVOR_SRQ_WQ_INDEX(srq_wq_desc_addr, desc_addr, wqesz) \
2N/A ((uint32_t)(((desc_addr) - (srq_wq_desc_addr)) / (wqesz)))
2N/A#define TAVOR_SRQ_WQ_ENTRY(srq, index) \
2N/A ((uint64_t *)(((uintptr_t)(srq)->srq_addr) + \
2N/A ((index) * (srq)->srq_wq_wqesz)))
2N/A
2N/A/*
2N/A * Maximum header before the data bytes when inlining data.
2N/A * "Header" includes the link (nextctrl) struct, a remote address struct
2N/A * (only for RDMA Write, not for Send) and the 32-bit byte count field.
2N/A */
2N/A#define TAVOR_INLINE_HEADER_SIZE_MAX 0x40 /* from tavor driver */
2N/A#define TAVOR_INLINE_HEADER_SIZE_RDMAW \
2N/A (sizeof (tavor_hw_snd_wqe_nextctrl_t) + \
2N/A sizeof (tavor_hw_snd_wqe_remaddr_t) + \
2N/A sizeof (uint32_t))
2N/A#define TAVOR_INLINE_HEADER_SIZE_SEND \
2N/A (sizeof (tavor_hw_snd_wqe_nextctrl_t) + \
2N/A sizeof (uint32_t))
2N/A
2N/A/*
2N/A * Function signatures
2N/A */
2N/Aextern int dapls_tavor_max_inline(void);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DAPL_TAVOR_HW_H */