17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5eb9424bhiremath * Common Development and Distribution License (the "License").
6eb9424bhiremath * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
2217a2b31Bill Taylor * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bdstevel@tonic-gate */
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate#ifndef	_SYS_IB_IBTL_IBTL_TYPES_H
267c478bdstevel@tonic-gate#define	_SYS_IB_IBTL_IBTL_TYPES_H
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate/*
297c478bdstevel@tonic-gate * ibtl_types.h
307c478bdstevel@tonic-gate *
317c478bdstevel@tonic-gate * All common IBTL defined types. These are common data types
327c478bdstevel@tonic-gate * that are shared by the IBTI and IBCI interfaces, it is only included
337c478bdstevel@tonic-gate * by ibti.h and ibci.h
347c478bdstevel@tonic-gate */
357c478bdstevel@tonic-gate#include <sys/ddi.h>
367c478bdstevel@tonic-gate#include <sys/sunddi.h>
377c478bdstevel@tonic-gate#include <sys/ib/ib_types.h>
387c478bdstevel@tonic-gate#include <sys/ib/ibtl/ibtl_status.h>
39015f8ffhiremath#include <sys/socket.h>
4003494a9Bill Taylor#include <sys/byteorder.h>
41015f8ffhiremath
427c478bdstevel@tonic-gate
437c478bdstevel@tonic-gate#ifdef	__cplusplus
447c478bdstevel@tonic-gateextern "C" {
457c478bdstevel@tonic-gate#endif
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gate/*
485d42b47eota * Endian Macros
495d42b47eota *    h2b - host endian to big endian protocol
505d42b47eota *    b2h - big endian protocol to host endian
515d42b47eota *    h2l - host endian to little endian protocol
525d42b47eota *    l2h - little endian protocol to host endian
535d42b47eota */
545d42b47eota#if defined(_LITTLE_ENDIAN)
555d42b47eota#define	h2b16(x)	(htons(x))
565d42b47eota#define	h2b32(x)	(htonl(x))
5703494a9Bill Taylor#define	h2b64(x)	(htonll(x))
585d42b47eota#define	b2h16(x)	(ntohs(x))
595d42b47eota#define	b2h32(x)	(ntohl(x))
6003494a9Bill Taylor#define	b2h64(x)	(htonll(x))
615d42b47eota
625d42b47eota#define	h2l16(x)	(x)
635d42b47eota#define	h2l32(x)	(x)
645d42b47eota#define	h2l64(x)	(x)
655d42b47eota#define	l2h16(x)	(x)
665d42b47eota#define	l2h32(x)	(x)
675d42b47eota#define	l2h64(x)	(x)
685d42b47eota
695d42b47eota#elif defined(_BIG_ENDIAN)
705d42b47eota#define	h2b16(x)	(x)
715d42b47eota#define	h2b32(x)	(x)
725d42b47eota#define	h2b64(x)	(x)
735d42b47eota#define	b2h16(x)	(x)
745d42b47eota#define	b2h32(x)	(x)
755d42b47eota#define	b2h64(x)	(x)
765d42b47eota
775d42b47eota#define	h2l16(x)	(ddi_swap16(x))
785d42b47eota#define	h2l32(x)	(ddi_swap32(x))
795d42b47eota#define	h2l64(x)	(ddi_swap64(x))
805d42b47eota#define	l2h16(x)	(ddi_swap16(x))
815d42b47eota#define	l2h32(x)	(ddi_swap32(x))
825d42b47eota#define	l2h64(x)	(ddi_swap64(x))
835d42b47eota
845d42b47eota#else
855d42b47eota#error	"what endian is this machine?"
865d42b47eota#endif
875d42b47eota
885d42b47eota/*
897c478bdstevel@tonic-gate * Define Internal IBTL handles
907c478bdstevel@tonic-gate */
917c478bdstevel@tonic-gatetypedef	struct	ibtl_clnt_s	*ibt_clnt_hdl_t;    /* ibt_attach() */
927c478bdstevel@tonic-gatetypedef	struct	ibtl_hca_s	*ibt_hca_hdl_t;	    /* ibt_open_hca() */
937c478bdstevel@tonic-gatetypedef	struct	ibtl_channel_s	*ibt_channel_hdl_t; /* alloc_rc|ud_channel() */
947c478bdstevel@tonic-gatetypedef	struct	ibtl_srq_s	*ibt_srq_hdl_t;	    /* ibt_alloc_srq() */
957c478bdstevel@tonic-gatetypedef	struct	ibtl_cq_s	*ibt_cq_hdl_t;	    /* ibt_alloc_cq() */
967c478bdstevel@tonic-gatetypedef	struct	ibcm_svc_info_s	*ibt_srv_hdl_t;	    /* ibt_register_service() */
977c478bdstevel@tonic-gatetypedef	struct	ibcm_svc_bind_s	*ibt_sbind_hdl_t;   /* ibt_bind_service() */
987c478bdstevel@tonic-gate
9943ed929srusttypedef	struct	ibc_fmr_pool_s	*ibt_fmr_pool_hdl_t; /* ibt_create_fmr_pool() */
1007c478bdstevel@tonic-gatetypedef	struct	ibc_ma_s	*ibt_ma_hdl_t;	    /* ibt_map_mem_area() */
1017c478bdstevel@tonic-gatetypedef	struct	ibc_pd_s	*ibt_pd_hdl_t;	    /* ibt_alloc_pd() */
1027c478bdstevel@tonic-gatetypedef	struct	ibc_sched_s	*ibt_sched_hdl_t;   /* ibt_alloc_cq_sched() */
1037c478bdstevel@tonic-gatetypedef	struct	ibc_mr_s	*ibt_mr_hdl_t;	    /* ibt_register_mr() */
1047c478bdstevel@tonic-gatetypedef	struct	ibc_mw_s	*ibt_mw_hdl_t;	    /* ibt_alloc_mw() */
1057c478bdstevel@tonic-gatetypedef	struct	ibt_ud_dest_s	*ibt_ud_dest_hdl_t; /* UD dest handle */
1067c478bdstevel@tonic-gatetypedef	struct	ibc_ah_s	*ibt_ah_hdl_t;	    /* ibt_alloc_ah() */
1077c478bdstevel@tonic-gatetypedef struct	ibtl_eec_s	*ibt_eec_hdl_t;
1087c478bdstevel@tonic-gatetypedef	struct	ibt_rd_dest_s	*ibt_rd_dest_hdl_t;	/* Reserved for */
1097c478bdstevel@tonic-gate							/* Future use */
11003494a9Bill Taylortypedef struct  ibc_mem_alloc_s *ibt_mem_alloc_hdl_t; /* ibt_alloc_io_mem() */
11103494a9Bill Taylortypedef struct	ibc_mi_s	*ibt_mi_hdl_t;		/* ibt_map_mem_iov() */
1127c478bdstevel@tonic-gate
1137c478bdstevel@tonic-gate/*
1147c478bdstevel@tonic-gate * Some General Types.
1157c478bdstevel@tonic-gate */
1167c478bdstevel@tonic-gatetypedef uint32_t	ibt_lkey_t;		/* L_Key */
1177c478bdstevel@tonic-gatetypedef uint32_t	ibt_rkey_t;		/* R_Key */
1187c478bdstevel@tonic-gatetypedef uint64_t	ibt_wrid_t;		/* Client assigned WR ID */
1197c478bdstevel@tonic-gatetypedef uint32_t	ibt_immed_t;		/* WR Immediate Data */
1207c478bdstevel@tonic-gatetypedef uint64_t	ibt_atom_arg_t;		/* WR Atomic Operation arg */
1217c478bdstevel@tonic-gatetypedef	uint_t		ibt_cq_handler_id_t;	/* Event handler ID */
1227c478bdstevel@tonic-gate
1237c478bdstevel@tonic-gate/*
1247c478bdstevel@tonic-gate * IBT selector type, used when looking up/requesting either an
1257c478bdstevel@tonic-gate * MTU, Pkt lifetime, or Static rate.
1267c478bdstevel@tonic-gate * The interpretation of IBT_BEST depends on the attribute being selected.
1277c478bdstevel@tonic-gate */
1287c478bdstevel@tonic-gatetypedef enum ibt_selector_e {
1297c478bdstevel@tonic-gate	IBT_GT		= 0,	/* Greater than */
1307c478bdstevel@tonic-gate	IBT_LT		= 1,	/* Less than */
1317c478bdstevel@tonic-gate	IBT_EQU		= 2,	/* Equal to */
1327c478bdstevel@tonic-gate	IBT_BEST	= 3	/* Best */
1337c478bdstevel@tonic-gate} ibt_selector_t;
1347c478bdstevel@tonic-gate
1357c478bdstevel@tonic-gate
1367c478bdstevel@tonic-gate/*
1377c478bdstevel@tonic-gate * Static rate definitions.
1387c478bdstevel@tonic-gate */
1397c478bdstevel@tonic-gatetypedef enum ibt_srate_e {
1407c478bdstevel@tonic-gate	IBT_SRATE_NOT_SPECIFIED	= 0,
141eb9424bhiremath	IBT_SRATE_2		= 2,	/*  1X SDR i.e 2.5 Gbps */
142eb9424bhiremath	IBT_SRATE_10		= 3,	/*  4X SDR or 1X QDR i.e 10 Gbps */
143eb9424bhiremath	IBT_SRATE_30		= 4,	/* 12X SDR i.e 30 Gbps */
144eb9424bhiremath
145eb9424bhiremath	IBT_SRATE_5		= 5,	/*  1X DDR i.e  5 Gbps */
146eb9424bhiremath	IBT_SRATE_20		= 6,	/*  4X DDR or 8X SDR i.e 20 Gbps */
147eb9424bhiremath	IBT_SRATE_40		= 7,	/*  8X DDR or 4X QDR i.e 40 Gbps */
148eb9424bhiremath
149eb9424bhiremath	IBT_SRATE_60		= 8,	/* 12X DDR i.e 60 Gbps */
150eb9424bhiremath	IBT_SRATE_80		= 9,	/*  8X QDR i.e 80 Gbps */
151eb9424bhiremath	IBT_SRATE_120		= 10	/* 12X QDR i.e 120 Gbps */
1527c478bdstevel@tonic-gate} ibt_srate_t;
1537c478bdstevel@tonic-gate
154eb9424bhiremath/* retain old definition to be compatible with older bits. */
155eb9424bhiremath#define	IBT_SRATE_1X	IBT_SRATE_2
156eb9424bhiremath#define	IBT_SRATE_4X	IBT_SRATE_10
157eb9424bhiremath#define	IBT_SRATE_12X	IBT_SRATE_30
158eb9424bhiremath
1597c478bdstevel@tonic-gate/*
1607c478bdstevel@tonic-gate * Static rate request type.
1617c478bdstevel@tonic-gate */
1627c478bdstevel@tonic-gatetypedef struct ibt_srate_req_s {
1637c478bdstevel@tonic-gate	ibt_srate_t	r_srate;	/* Requested srate */
1647c478bdstevel@tonic-gate	ibt_selector_t	r_selector;	/* Qualifier for r_srate */
1657c478bdstevel@tonic-gate} ibt_srate_req_t;
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate/*
1687c478bdstevel@tonic-gate * Packet Life Time Request Type.
1697c478bdstevel@tonic-gate */
1707c478bdstevel@tonic-gatetypedef struct ibt_pkt_lt_req_s {
1717c478bdstevel@tonic-gate	clock_t		p_pkt_lt;	/* Requested Packet Life Time */
1727c478bdstevel@tonic-gate	ibt_selector_t	p_selector;	/* Qualifier for p_pkt_lt */
1737c478bdstevel@tonic-gate} ibt_pkt_lt_req_t;
1747c478bdstevel@tonic-gate
1757c478bdstevel@tonic-gate/*
1767c478bdstevel@tonic-gate * Queue size struct.
1777c478bdstevel@tonic-gate */
1787c478bdstevel@tonic-gatetypedef struct ibt_queue_sizes_s {
1797c478bdstevel@tonic-gate	uint_t	qs_sq;		/* SendQ size. */
1807c478bdstevel@tonic-gate	uint_t	qs_rq;		/* RecvQ size. */
1817c478bdstevel@tonic-gate} ibt_queue_sizes_t;
1827c478bdstevel@tonic-gate
1837c478bdstevel@tonic-gate/*
1847c478bdstevel@tonic-gate * Channel sizes struct, used by functions that allocate/query RC or UD
1857c478bdstevel@tonic-gate * channels.
1867c478bdstevel@tonic-gate */
1877c478bdstevel@tonic-gatetypedef struct ibt_chan_sizes_s {
1887c478bdstevel@tonic-gate	uint_t	cs_sq;		/* SendQ size. */
1897c478bdstevel@tonic-gate	uint_t	cs_rq;		/* ReceiveQ size. */
1907c478bdstevel@tonic-gate	uint_t	cs_sq_sgl;	/* Max SGL elements in a SQ WR. */
1917c478bdstevel@tonic-gate	uint_t	cs_rq_sgl;	/* Max SGL elements in a RQ Wr. */
19203494a9Bill Taylor	uint_t  cs_inline;	/* max inline payload size */
1937c478bdstevel@tonic-gate} ibt_chan_sizes_t;
1947c478bdstevel@tonic-gate
1957c478bdstevel@tonic-gate/*
1967c478bdstevel@tonic-gate * Shared Queue size struct.
1977c478bdstevel@tonic-gate */
1987c478bdstevel@tonic-gatetypedef struct ibt_srq_sizes_s {
1997c478bdstevel@tonic-gate	uint_t	srq_wr_sz;
2007c478bdstevel@tonic-gate	uint_t	srq_sgl_sz;
2017c478bdstevel@tonic-gate} ibt_srq_sizes_t;
2027c478bdstevel@tonic-gate
2037c478bdstevel@tonic-gate/*
2047c478bdstevel@tonic-gate * SRQ Modify Flags
2057c478bdstevel@tonic-gate */
2067c478bdstevel@tonic-gatetypedef enum ibt_srq_modify_flags_e {
2077c478bdstevel@tonic-gate	IBT_SRQ_SET_NOTHING		= 0,
2087c478bdstevel@tonic-gate	IBT_SRQ_SET_SIZE		= (1 << 1),
2097c478bdstevel@tonic-gate	IBT_SRQ_SET_LIMIT		= (1 << 2)
2107c478bdstevel@tonic-gate} ibt_srq_modify_flags_t;
2117c478bdstevel@tonic-gate
2127c478bdstevel@tonic-gate
2137c478bdstevel@tonic-gate/*
2147c478bdstevel@tonic-gate * Execution flags, indicates if the function should block or not.
2157c478bdstevel@tonic-gate * Note: in some cases, e.g., a NULL rc_cm_handler, IBT_NONBLOCKING
2167c478bdstevel@tonic-gate * will not have an effect, and the thread will block.
2177c478bdstevel@tonic-gate * IBT_NOCALLBACKS is valid for ibt_close_rc_channel only.
2187c478bdstevel@tonic-gate */
2197c478bdstevel@tonic-gatetypedef enum ibt_execution_mode_e {
2207c478bdstevel@tonic-gate	IBT_BLOCKING	= 0,	/* Block */
2217c478bdstevel@tonic-gate	IBT_NONBLOCKING	= 1,	/* Return as soon as possible */
2227c478bdstevel@tonic-gate	IBT_NOCALLBACKS	= 2	/* cm_handler is not invoked after */
2237c478bdstevel@tonic-gate				/* ibt_close_rc_channel returns */
2247c478bdstevel@tonic-gate} ibt_execution_mode_t;
2257c478bdstevel@tonic-gate
2267c478bdstevel@tonic-gate/*
2277c478bdstevel@tonic-gate * Memory window alloc flags
2287c478bdstevel@tonic-gate */
2297c478bdstevel@tonic-gatetypedef enum ibt_mw_flags_e {
2307c478bdstevel@tonic-gate	IBT_MW_SLEEP		= 0,		/* Can block */
2317c478bdstevel@tonic-gate	IBT_MW_NOSLEEP		= (1 << 0),	/* Can't block */
2327c478bdstevel@tonic-gate	IBT_MW_USER_MAP		= (1 << 1),
2337c478bdstevel@tonic-gate	IBT_MW_DEFER_ALLOC	= (1 << 2),
2347c478bdstevel@tonic-gate	IBT_MW_TYPE_1		= (1 << 3),
2357c478bdstevel@tonic-gate	IBT_MW_TYPE_2		= (1 << 4)
2367c478bdstevel@tonic-gate} ibt_mw_flags_t;
2377c478bdstevel@tonic-gate
2387c478bdstevel@tonic-gate/*
2397c478bdstevel@tonic-gate * PD alloc flags
2407c478bdstevel@tonic-gate */
2417c478bdstevel@tonic-gatetypedef enum ibt_pd_flags_e {
2427c478bdstevel@tonic-gate	IBT_PD_NO_FLAGS		= 0,
2437c478bdstevel@tonic-gate	IBT_PD_USER_MAP		= (1 << 0),
2447c478bdstevel@tonic-gate	IBT_PD_DEFER_ALLOC	= (1 << 1)
2457c478bdstevel@tonic-gate} ibt_pd_flags_t;
2467c478bdstevel@tonic-gate
2477c478bdstevel@tonic-gate/*
2487c478bdstevel@tonic-gate * UD Dest alloc flags
2497c478bdstevel@tonic-gate */
2507c478bdstevel@tonic-gatetypedef enum ibt_ud_dest_flags_e {
2517c478bdstevel@tonic-gate	IBT_UD_DEST_NO_FLAGS	= 0,
2527c478bdstevel@tonic-gate	IBT_UD_DEST_USER_MAP	= (1 << 0),
2537c478bdstevel@tonic-gate	IBT_UD_DEST_DEFER_ALLOC	= (1 << 1)
2547c478bdstevel@tonic-gate} ibt_ud_dest_flags_t;
2557c478bdstevel@tonic-gate
2567c478bdstevel@tonic-gate/*
2577c478bdstevel@tonic-gate * SRQ alloc flags
2587c478bdstevel@tonic-gate */
2597c478bdstevel@tonic-gatetypedef enum ibt_srq_flags_e {
2607c478bdstevel@tonic-gate	IBT_SRQ_NO_FLAGS	= 0,
2617c478bdstevel@tonic-gate	IBT_SRQ_USER_MAP	= (1 << 0),
2627c478bdstevel@tonic-gate	IBT_SRQ_DEFER_ALLOC	= (1 << 1)
2637c478bdstevel@tonic-gate} ibt_srq_flags_t;
2647c478bdstevel@tonic-gate
2657c478bdstevel@tonic-gate/*
26624b28d0hiremath * ibt_alloc_lkey() alloc flags
2677c478bdstevel@tonic-gate */
2687c478bdstevel@tonic-gatetypedef enum ibt_lkey_flags_e {
269c7facc5Bill Taylor	IBT_KEY_SLEEP		= 0,
270c7facc5Bill Taylor	IBT_KEY_NOSLEEP		= (1 << 0),
271c7facc5Bill Taylor	IBT_KEY_REMOTE		= (1 << 1)
2727c478bdstevel@tonic-gate} ibt_lkey_flags_t;
2737c478bdstevel@tonic-gate
2747c478bdstevel@tonic-gate/*
2757c478bdstevel@tonic-gate *  RNR NAK retry counts.
2767c478bdstevel@tonic-gate */
2777c478bdstevel@tonic-gatetypedef enum ibt_rnr_retry_cnt_e {
2787c478bdstevel@tonic-gate	IBT_RNR_NO_RETRY	= 0x0,	/* Don't retry, fail on first timeout */
2797c478bdstevel@tonic-gate	IBT_RNR_RETRY_1		= 0x1,	/* Retry once */
2807c478bdstevel@tonic-gate	IBT_RNR_RETRY_2		= 0x2,	/* Retry twice */
2817c478bdstevel@tonic-gate	IBT_RNR_RETRY_3		= 0x3,	/* Retry three times */
2827c478bdstevel@tonic-gate	IBT_RNR_RETRY_4		= 0x4,	/* Retry four times */
2837c478bdstevel@tonic-gate	IBT_RNR_RETRY_5		= 0x5,	/* Retry five times */
2847c478bdstevel@tonic-gate	IBT_RNR_RETRY_6		= 0x6,	/* Retry six times */
2857c478bdstevel@tonic-gate	IBT_RNR_INFINITE_RETRY	= 0x7	/* Retry forever */
2867c478bdstevel@tonic-gate} ibt_rnr_retry_cnt_t;
2877c478bdstevel@tonic-gate
2887c478bdstevel@tonic-gate/*
2897c478bdstevel@tonic-gate * Valid values for RNR NAK timer fields, part of a channel's context.
2907c478bdstevel@tonic-gate */
2917c478bdstevel@tonic-gatetypedef enum ibt_rnr_nak_time_e {
2927c478bdstevel@tonic-gate	IBT_RNR_NAK_655ms	= 0x0,
2937c478bdstevel@tonic-gate	IBT_RNR_NAK_10us	= 0x1,
2947c478bdstevel@tonic-gate	IBT_RNR_NAK_20us	= 0x2,
2957c478bdstevel@tonic-gate	IBT_RNR_NAK_30us	= 0x3,
2967c478bdstevel@tonic-gate	IBT_RNR_NAK_40us	= 0x4,
2977c478bdstevel@tonic-gate	IBT_RNR_NAK_60us	= 0x5,
2987c478bdstevel@tonic-gate	IBT_RNR_NAK_80us	= 0x6,
2997c478bdstevel@tonic-gate	IBT_RNR_NAK_120us	= 0x7,
3007c478bdstevel@tonic-gate	IBT_RNR_NAK_160us	= 0x8,
3017c478bdstevel@tonic-gate	IBT_RNR_NAK_240us	= 0x9,
3027c478bdstevel@tonic-gate	IBT_RNR_NAK_320us	= 0xA,
3037c478bdstevel@tonic-gate	IBT_RNR_NAK_480us	= 0xB,
3047c478bdstevel@tonic-gate	IBT_RNR_NAK_640us	= 0xC,
3057c478bdstevel@tonic-gate	IBT_RNR_NAK_960us	= 0xD,
3067c478bdstevel@tonic-gate	IBT_RNR_NAK_1280us	= 0xE,
3077c478bdstevel@tonic-gate	IBT_RNR_NAK_1920us	= 0xF,
3087c478bdstevel@tonic-gate	IBT_RNR_NAK_2560us	= 0x10,
3097c478bdstevel@tonic-gate	IBT_RNR_NAK_3840us	= 0x11,
3107c478bdstevel@tonic-gate	IBT_RNR_NAK_5120us	= 0x12,
3117c478bdstevel@tonic-gate	IBT_RNR_NAK_7680us	= 0x13,
3127c478bdstevel@tonic-gate	IBT_RNR_NAK_10ms	= 0x14,
3137c478bdstevel@tonic-gate	IBT_RNR_NAK_15ms	= 0x15,
3147c478bdstevel@tonic-gate	IBT_RNR_NAK_20ms	= 0x16,
3157c478bdstevel@tonic-gate	IBT_RNR_NAK_31ms	= 0x17,
3167c478bdstevel@tonic-gate	IBT_RNR_NAK_41ms	= 0x18,
3177c478bdstevel@tonic-gate	IBT_RNR_NAK_61ms	= 0x19,
3187c478bdstevel@tonic-gate	IBT_RNR_NAK_82ms	= 0x1A,
3197c478bdstevel@tonic-gate	IBT_RNR_NAK_123ms	= 0x1B,
3207c478bdstevel@tonic-gate	IBT_RNR_NAK_164ms	= 0x1C,
3217c478bdstevel@tonic-gate	IBT_RNR_NAK_246ms	= 0x1D,
3227c478bdstevel@tonic-gate	IBT_RNR_NAK_328ms	= 0x1E,
3237c478bdstevel@tonic-gate	IBT_RNR_NAK_492ms	= 0x1F
3247c478bdstevel@tonic-gate} ibt_rnr_nak_time_t;
3257c478bdstevel@tonic-gate
3267c478bdstevel@tonic-gate/*
3277c478bdstevel@tonic-gate * The definition of HCA capabilities etc as a bitfield.
3287c478bdstevel@tonic-gate */
3297c478bdstevel@tonic-gatetypedef enum ibt_hca_flags_e {
3307c478bdstevel@tonic-gate	IBT_HCA_NO_FLAGS	= 0,
3317c478bdstevel@tonic-gate
3327c478bdstevel@tonic-gate	IBT_HCA_RD		= 1 << 0,
3337c478bdstevel@tonic-gate	IBT_HCA_UD_MULTICAST	= 1 << 1,
3347c478bdstevel@tonic-gate	IBT_HCA_RAW_MULTICAST	= 1 << 2,
3357c478bdstevel@tonic-gate
3367c478bdstevel@tonic-gate	IBT_HCA_ATOMICS_HCA	= 1 << 3,
3377c478bdstevel@tonic-gate	IBT_HCA_ATOMICS_GLOBAL	= 1 << 4,
3387c478bdstevel@tonic-gate
3397c478bdstevel@tonic-gate	IBT_HCA_RESIZE_CHAN	= 1 << 5,	/* Is resize supported? */
3407c478bdstevel@tonic-gate	IBT_HCA_AUTO_PATH_MIG	= 1 << 6,	/* Is APM supported? */
3417c478bdstevel@tonic-gate	IBT_HCA_SQD_SQD_PORT	= 1 << 7,	/* Can change physical port */
3427c478bdstevel@tonic-gate						/* on transit from SQD to SQD */
3437c478bdstevel@tonic-gate	IBT_HCA_PKEY_CNTR	= 1 << 8,
3447c478bdstevel@tonic-gate	IBT_HCA_QKEY_CNTR	= 1 << 9,
3457c478bdstevel@tonic-gate	IBT_HCA_AH_PORT_CHECK	= 1 << 10,	/* HCA checks AH port match */
3467c478bdstevel@tonic-gate						/* in UD WRs */
3477c478bdstevel@tonic-gate	IBT_HCA_PORT_UP		= 1 << 11,	/* PortActive event supported */
3487c478bdstevel@tonic-gate	IBT_HCA_INIT_TYPE	= 1 << 12,	/* InitType supported */
3497c478bdstevel@tonic-gate	IBT_HCA_SI_GUID		= 1 << 13,	/* System Image GUID */
3507c478bdstevel@tonic-gate						/* supported */
3517c478bdstevel@tonic-gate	IBT_HCA_SHUTDOWN_PORT	= 1 << 14,	/* ShutdownPort supported */
3527c478bdstevel@tonic-gate	IBT_HCA_RNR_NAK		= 1 << 15,	/* RNR-NAK supported for RC */
3537c478bdstevel@tonic-gate	IBT_HCA_CURRENT_QP_STATE = 1 << 16,	/* Does modify_qp support */
3547c478bdstevel@tonic-gate						/* checking of current state? */
35503494a9Bill Taylor	IBT_HCA_SRQ 		= 1 << 17,	/* Shared Receive Queue (RC) */
35603494a9Bill Taylor	IBT_HCA_RC_SRQ 		= IBT_HCA_SRQ,
3577c478bdstevel@tonic-gate	IBT_HCA_RESIZE_SRQ	= 1 << 18,	/* Is resize SRQ supported? */
35803494a9Bill Taylor	IBT_HCA_UD_SRQ		= 1 << 19,	/* UD with SRQ */
35903494a9Bill Taylor
3607c478bdstevel@tonic-gate	IBT_HCA_MULT_PAGE_SZ_MR	= 1 << 20,	/* Support of multiple page */
3617c478bdstevel@tonic-gate						/* sizes per memory region? */
3627c478bdstevel@tonic-gate	IBT_HCA_BLOCK_LIST	= 1 << 21,	/* Block list physical buffer */
3637c478bdstevel@tonic-gate						/* lists supported? */
3647c478bdstevel@tonic-gate	IBT_HCA_ZERO_BASED_VA	= 1 << 22,	/* Zero Based Virtual */
3657c478bdstevel@tonic-gate						/* Addresses supported? */
3667c478bdstevel@tonic-gate	IBT_HCA_LOCAL_INVAL_FENCE = 1 << 23,	/* Local invalidate fencing? */
3677c478bdstevel@tonic-gate	IBT_HCA_BASE_QUEUE_MGT	= 1 << 24,	/* Base Queue Mgt supported? */
3687c478bdstevel@tonic-gate	IBT_HCA_CKSUM_FULL	= 1 << 25,	/* Checksum offload supported */
3697c478bdstevel@tonic-gate	IBT_HCA_MEM_WIN_TYPE_2B	= 1 << 26,	/* Type 2B memory windows */
37043ed929srust	IBT_HCA_PHYS_BUF_BLOCK	= 1 << 27,	/* Block mode phys buf lists */
37103494a9Bill Taylor	IBT_HCA_FMR		= 1 << 28,	/* FMR Support */
37203494a9Bill Taylor	IBT_HCA_WQE_SIZE_INFO	= 1 << 29,	/* detailed WQE size info */
37303494a9Bill Taylor	IBT_HCA_SQD_STATE	= 1 << 30	/* SQD QP state */
3747c478bdstevel@tonic-gate} ibt_hca_flags_t;
3757c478bdstevel@tonic-gate
37603494a9Bill Taylortypedef enum ibt_hca_flags2_e {
37703494a9Bill Taylor	IBT_HCA2_NO_FLAGS	= 0,
37803494a9Bill Taylor
37903494a9Bill Taylor	IBT_HCA2_UC		= 1 << 1,	/* Unreliable Connected */
38003494a9Bill Taylor	IBT_HCA2_UC_SRQ		= 1 << 2,	/* UC with SRQ */
38103494a9Bill Taylor	IBT_HCA2_RES_LKEY	= 1 << 3,	/* Reserved L_Key */
38203494a9Bill Taylor	IBT_HCA2_PORT_CHANGE	= 1 << 4,	/* Port Change event */
38303494a9Bill Taylor	IBT_HCA2_IP_CLASS	= 1 << 5,	/* IP Classification flags */
38403494a9Bill Taylor	IBT_HCA2_RSS_TPL_ALG	= 1 << 6,	/* RSS: Toeplitz algorithm */
38503494a9Bill Taylor	IBT_HCA2_RSS_XOR_ALG	= 1 << 7,	/* RSS: XOR algorithm */
38603494a9Bill Taylor	IBT_HCA2_XRC		= 1 << 8,	/* Extended RC (XRC) */
38703494a9Bill Taylor	IBT_HCA2_XRC_SRQ_RESIZE	= 1 << 9,	/* resize XRC SRQ */
38817a2b31Bill Taylor	IBT_HCA2_MEM_MGT_EXT	= 1 << 10, /* FMR-WR, send-inv, local-inv */
38917a2b31Bill Taylor	IBT_HCA2_DMA_MR		= 1 << 11,	/* DMA MR */
39017a2b31Bill Taylor	IBT_HCA2_FC		= 1 << 12	/* FCoIB or FCoE offload */
39103494a9Bill Taylor} ibt_hca_flags2_t;
39203494a9Bill Taylor
3937c478bdstevel@tonic-gate/*
3947c478bdstevel@tonic-gate * The definition of HCA page size capabilities as a bitfield
3957c478bdstevel@tonic-gate */
3967c478bdstevel@tonic-gatetypedef enum ibt_page_sizes_e {
3977c478bdstevel@tonic-gate	IBT_PAGE_4K		= 0x1 << 2,
3987c478bdstevel@tonic-gate	IBT_PAGE_8K		= 0x1 << 3,
3997c478bdstevel@tonic-gate	IBT_PAGE_16K		= 0x1 << 4,
4007c478bdstevel@tonic-gate	IBT_PAGE_32K		= 0x1 << 5,
4017c478bdstevel@tonic-gate	IBT_PAGE_64K		= 0x1 << 6,
4027c478bdstevel@tonic-gate	IBT_PAGE_128K		= 0x1 << 7,
4037c478bdstevel@tonic-gate	IBT_PAGE_256K		= 0x1 << 8,
4047c478bdstevel@tonic-gate	IBT_PAGE_512K		= 0x1 << 9,
4057c478bdstevel@tonic-gate	IBT_PAGE_1M		= 0x1 << 10,
4067c478bdstevel@tonic-gate	IBT_PAGE_2M		= 0x1 << 11,
4077c478bdstevel@tonic-gate	IBT_PAGE_4M		= 0x1 << 12,
4087c478bdstevel@tonic-gate	IBT_PAGE_8M		= 0x1 << 13,
4097c478bdstevel@tonic-gate	IBT_PAGE_16M		= 0x1 << 14,
4107c478bdstevel@tonic-gate	IBT_PAGE_32M		= 0x1 << 15,
4117c478bdstevel@tonic-gate	IBT_PAGE_64M		= 0x1 << 16,
4127c478bdstevel@tonic-gate	IBT_PAGE_128M		= 0x1 << 17,
4137c478bdstevel@tonic-gate	IBT_PAGE_256M		= 0x1 << 18,
4147c478bdstevel@tonic-gate	IBT_PAGE_512M		= 0x1 << 19,
4157c478bdstevel@tonic-gate	IBT_PAGE_1G		= 0x1 << 20,
4167c478bdstevel@tonic-gate	IBT_PAGE_2G		= 0x1 << 21,
4177c478bdstevel@tonic-gate	IBT_PAGE_4G		= 0x1 << 22,
4187c478bdstevel@tonic-gate	IBT_PAGE_8G		= 0x1 << 23,
4197c478bdstevel@tonic-gate	IBT_PAGE_16G		= 0x1 << 24
4207c478bdstevel@tonic-gate} ibt_page_sizes_t;
4217c478bdstevel@tonic-gate
4227c478bdstevel@tonic-gate/*
4237c478bdstevel@tonic-gate * Memory Window Type.
4247c478bdstevel@tonic-gate */
4257c478bdstevel@tonic-gatetypedef enum ibt_mem_win_type_e {
4267c478bdstevel@tonic-gate	IBT_MEM_WIN_TYPE_NOT_DEFINED	= 0,
4277c478bdstevel@tonic-gate	IBT_MEM_WIN_TYPE_1		= (1 << 0),
4287c478bdstevel@tonic-gate	IBT_MEM_WIN_TYPE_2		= (1 << 1)
4297c478bdstevel@tonic-gate} ibt_mem_win_type_t;
4307c478bdstevel@tonic-gate
4317c478bdstevel@tonic-gate/*
4327c478bdstevel@tonic-gate * HCA attributes.
4337c478bdstevel@tonic-gate * Contains all HCA static attributes.
4347c478bdstevel@tonic-gate */
4357c478bdstevel@tonic-gatetypedef struct ibt_hca_attr_s {
4367c478bdstevel@tonic-gate	ibt_hca_flags_t	hca_flags;		/* HCA capabilities etc */
43703494a9Bill Taylor	ibt_hca_flags2_t hca_flags2;
4387c478bdstevel@tonic-gate
4397c478bdstevel@tonic-gate	/* device/version inconsistency w/ NodeInfo and IOControllerProfile */
4407c478bdstevel@tonic-gate	uint32_t	hca_vendor_id:24;	/* 24 bit Vendor ID */
4417c478bdstevel@tonic-gate	uint16_t	hca_device_id;
4427c478bdstevel@tonic-gate	uint32_t	hca_version_id;
4437c478bdstevel@tonic-gate
4447c478bdstevel@tonic-gate	uint_t		hca_max_chans;		/* Max Chans supported */
4457c478bdstevel@tonic-gate	uint_t		hca_max_chan_sz;	/* Max outstanding WRs on any */
4467c478bdstevel@tonic-gate						/* channel */
4477c478bdstevel@tonic-gate
4487c478bdstevel@tonic-gate	uint_t		hca_max_sgl;		/* Max SGL entries per WR */
4497c478bdstevel@tonic-gate
4507c478bdstevel@tonic-gate	uint_t		hca_max_cq;		/* Max num of CQs supported  */
4517c478bdstevel@tonic-gate	uint_t		hca_max_cq_sz;		/* Max capacity of each CQ */
4527c478bdstevel@tonic-gate
4537c478bdstevel@tonic-gate	ibt_page_sizes_t	hca_page_sz;	/* Bit mask of page sizes */
4547c478bdstevel@tonic-gate
4557c478bdstevel@tonic-gate	uint_t		hca_max_memr;		/* Max num of HCA mem regions */
4567c478bdstevel@tonic-gate	ib_memlen_t	hca_max_memr_len;	/* Largest block, in bytes of */
4577c478bdstevel@tonic-gate						/* mem that can be registered */
4587c478bdstevel@tonic-gate	uint_t		hca_max_mem_win;	/* Max Memory windows in HCA */
4597c478bdstevel@tonic-gate
4607c478bdstevel@tonic-gate	uint_t		hca_max_rsc; 		/* Max Responder Resources of */
4617c478bdstevel@tonic-gate						/* this HCA for RDMAR/Atomics */
4627c478bdstevel@tonic-gate						/* with this HCA as target. */
4637c478bdstevel@tonic-gate	uint8_t		hca_max_rdma_in_chan;	/* Max RDMAR/Atomics in per */
4647c478bdstevel@tonic-gate						/* chan this HCA as target. */
4657c478bdstevel@tonic-gate	uint8_t		hca_max_rdma_out_chan;	/* Max RDMA Reads/Atomics out */
4667c478bdstevel@tonic-gate						/* per channel by this HCA */
4677c478bdstevel@tonic-gate	uint_t		hca_max_ipv6_chan;	/* Max IPV6 channels in HCA */
4687c478bdstevel@tonic-gate	uint_t		hca_max_ether_chan;	/* Max Ether channels in HCA */
4697c478bdstevel@tonic-gate
4707c478bdstevel@tonic-gate	uint_t		hca_max_mcg_chans;	/* Max number of channels */
4717c478bdstevel@tonic-gate						/* that can join multicast */
4727c478bdstevel@tonic-gate						/* groups */
4737c478bdstevel@tonic-gate	uint_t		hca_max_mcg;		/* Max multicast groups */
4747c478bdstevel@tonic-gate	uint_t		hca_max_chan_per_mcg;	/* Max number of channels per */
4757c478bdstevel@tonic-gate						/* Multicast group in HCA */
4767c478bdstevel@tonic-gate
4777c478bdstevel@tonic-gate	uint16_t	hca_max_partitions;	/* Max partitions in HCA */
4787c478bdstevel@tonic-gate	uint8_t		hca_nports;		/* Number of physical ports */
4797c478bdstevel@tonic-gate	ib_guid_t	hca_node_guid;		/* Node GUID */
4807c478bdstevel@tonic-gate
4817c478bdstevel@tonic-gate	ib_time_t	hca_local_ack_delay;
4827c478bdstevel@tonic-gate
4837c478bdstevel@tonic-gate	uint_t		hca_max_port_sgid_tbl_sz;
4847c478bdstevel@tonic-gate	uint16_t	hca_max_port_pkey_tbl_sz;
4857c478bdstevel@tonic-gate	uint_t		hca_max_pd;		/* Max# of Protection Domains */
4867c478bdstevel@tonic-gate	ib_guid_t	hca_si_guid;		/* Optional System Image GUID */
4877c478bdstevel@tonic-gate	uint_t		hca_hca_max_ci_priv_sz;
4887c478bdstevel@tonic-gate	uint_t		hca_chan_max_ci_priv_sz;
4897c478bdstevel@tonic-gate	uint_t		hca_cq_max_ci_priv_sz;
4907c478bdstevel@tonic-gate	uint_t		hca_pd_max_ci_priv_sz;
4917c478bdstevel@tonic-gate	uint_t		hca_mr_max_ci_priv_sz;
4927c478bdstevel@tonic-gate	uint_t		hca_mw_max_ci_priv_sz;
4937c478bdstevel@tonic-gate	uint_t		hca_ud_dest_max_ci_priv_sz;
4947c478bdstevel@tonic-gate	uint_t		hca_cq_sched_max_ci_priv_sz;
4957c478bdstevel@tonic-gate	uint_t		hca_max_ud_dest;
4967c478bdstevel@tonic-gate	uint_t		hca_opaque2;
4977c478bdstevel@tonic-gate	uint_t		hca_opaque3;
4987c478bdstevel@tonic-gate	uint_t		hca_opaque4;
4997c478bdstevel@tonic-gate	uint8_t		hca_opaque5;
5007c478bdstevel@tonic-gate	uint8_t		hca_opaque6;
50103494a9Bill Taylor	uint8_t		hca_rss_max_log2_table;	/* max RSS log2 table size */
5027c478bdstevel@tonic-gate	uint_t		hca_opaque7;
5037c478bdstevel@tonic-gate	uint_t		hca_opaque8;
5047c478bdstevel@tonic-gate	uint_t		hca_max_srqs;		/* Max SRQs supported */
5057c478bdstevel@tonic-gate	uint_t		hca_max_srqs_sz;	/* Max outstanding WRs on any */
5067c478bdstevel@tonic-gate						/* SRQ */
5077c478bdstevel@tonic-gate	uint_t		hca_max_srq_sgl;	/* Max SGL entries per SRQ WR */
5087c478bdstevel@tonic-gate	uint_t		hca_max_phys_buf_list_sz;
5097c478bdstevel@tonic-gate	size_t		hca_block_sz_lo;	/* Range of block sizes */
5107c478bdstevel@tonic-gate	size_t		hca_block_sz_hi;	/* supported by the HCA */
5117c478bdstevel@tonic-gate	uint_t		hca_max_cq_handlers;
51203494a9Bill Taylor	ibt_lkey_t	hca_reserved_lkey;	/* Reserved L_Key value */
51343ed929srust	uint_t		hca_max_fmrs;		/* Max FMR Supported */
51443ed929srust	uint_t		hca_opaque9;
51503494a9Bill Taylor
51603494a9Bill Taylor	uint_t		hca_max_lso_size;
51703494a9Bill Taylor	uint_t		hca_max_lso_hdr_size;
51803494a9Bill Taylor	uint_t		hca_max_inline_size;
51903494a9Bill Taylor
52003494a9Bill Taylor	uint_t		hca_max_cq_mod_count;	/* CQ notify moderation */
52103494a9Bill Taylor	uint_t		hca_max_cq_mod_usec;
52203494a9Bill Taylor
52303494a9Bill Taylor	uint32_t	hca_fw_major_version;	/* firmware version */
52403494a9Bill Taylor	uint16_t	hca_fw_minor_version;
52503494a9Bill Taylor	uint16_t	hca_fw_micro_version;
52603494a9Bill Taylor
52703494a9Bill Taylor	uint_t		hca_max_xrc_domains;	/* XRC items */
52803494a9Bill Taylor	uint_t		hca_max_xrc_srqs;
52903494a9Bill Taylor	uint_t		hca_max_xrc_srq_size;
53003494a9Bill Taylor	uint_t		hca_max_xrc_srq_sgl;
53103494a9Bill Taylor
53203494a9Bill Taylor	/* detailed WQE size info */
53303494a9Bill Taylor	uint_t		hca_ud_send_inline_sz;	/* inline size in bytes */
53403494a9Bill Taylor	uint_t		hca_conn_send_inline_sz;
53503494a9Bill Taylor	uint_t		hca_conn_rdmaw_inline_overhead;
53603494a9Bill Taylor	uint_t		hca_recv_sgl_sz;	/* detailed SGL sizes */
53703494a9Bill Taylor	uint_t		hca_ud_send_sgl_sz;
53803494a9Bill Taylor	uint_t		hca_conn_send_sgl_sz;
53917a2b31Bill Taylor	uint_t		hca_conn_rdma_read_sgl_sz;
54017a2b31Bill Taylor	uint_t		hca_conn_rdma_write_sgl_sz;
54103494a9Bill Taylor	uint_t		hca_conn_rdma_sgl_overhead;
54217a2b31Bill Taylor
54317a2b31Bill Taylor	/* FC Support */
54417a2b31Bill Taylor	uint8_t		hca_rfci_max_log2_qp;	/* max log2 RFCI QPs */
54517a2b31Bill Taylor	uint8_t		hca_fexch_max_log2_qp;	/* max log2 FEXCH QPs */
54617a2b31Bill Taylor	uint8_t		hca_fexch_max_log2_mem;	/* max log2 mem per FEXCH */
54717a2b31Bill Taylor
54817a2b31Bill Taylor	dev_info_t	*hca_dip;	/* HCA dev_info */
5497c478bdstevel@tonic-gate} ibt_hca_attr_t;
5507c478bdstevel@tonic-gate
5517c478bdstevel@tonic-gate/*
5527c478bdstevel@tonic-gate * HCA Port link states.
5537c478bdstevel@tonic-gate */
5547c478bdstevel@tonic-gatetypedef enum ibt_port_state_e {
5557c478bdstevel@tonic-gate	IBT_PORT_DOWN	= 1,
5567c478bdstevel@tonic-gate	IBT_PORT_INIT,
5577c478bdstevel@tonic-gate	IBT_PORT_ARM,
5587c478bdstevel@tonic-gate	IBT_PORT_ACTIVE
5597c478bdstevel@tonic-gate} ibt_port_state_t;
5607c478bdstevel@tonic-gate
5617c478bdstevel@tonic-gate/*
5627c478bdstevel@tonic-gate * HCA Port capabilities as a bitfield.
5637c478bdstevel@tonic-gate */
5647c478bdstevel@tonic-gatetypedef enum ibt_port_caps_e {
5657c478bdstevel@tonic-gate	IBT_PORT_CAP_NO_FLAGS		= 0,
5667c478bdstevel@tonic-gate	IBT_PORT_CAP_SM			= 1 << 0,	/* SM port */
5677c478bdstevel@tonic-gate	IBT_PORT_CAP_SM_DISABLED	= 1 << 1,
5687c478bdstevel@tonic-gate	IBT_PORT_CAP_SNMP_TUNNEL	= 1 << 2,	/* SNMP Tunneling */
5697c478bdstevel@tonic-gate	IBT_PORT_CAP_DM			= 1 << 3,	/* DM supported */
5705f4636eEiji Ota	IBT_PORT_CAP_VENDOR		= 1 << 4,	/* Vendor Class */
5715f4636eEiji Ota	IBT_PORT_CAP_CLNT_REREG		= 1 << 5	/* Client Rereg */
5727c478bdstevel@tonic-gate} ibt_port_caps_t;
5737c478bdstevel@tonic-gate
5747c478bdstevel@tonic-gate
575d9c882fBill Taylor/* LinkWidth fields from PortInfo */
576d9c882fBill Taylortypedef uint8_t ib_link_width_t;
577d9c882fBill Taylor
578d9c882fBill Taylor/*
579d9c882fBill Taylor * When reading LinkWidthSupported and LinkWidthEnabled, these
580d9c882fBill Taylor * values will be OR-ed together. See IB spec 14.2.5.6 for allowed
581d9c882fBill Taylor * combinations. For LinkWidthActive, only one will be returned.
582d9c882fBill Taylor */
583d9c882fBill Taylor#define	IBT_LINK_WIDTH_1X	(1)
584d9c882fBill Taylor#define	IBT_LINK_WIDTH_4X	(2)
585d9c882fBill Taylor#define	IBT_LINK_WIDTH_8X	(4)
586d9c882fBill Taylor#define	IBT_LINK_WIDTH_12X	(8)
587d9c882fBill Taylor
588d9c882fBill Taylor/* LinkSpeed fields from PortInfo */
589d9c882fBill Taylortypedef uint8_t ib_link_speed_t;
590d9c882fBill Taylor
591d9c882fBill Taylor/*
592d9c882fBill Taylor * When reading LinkSpeedSupported and LinkSpeedEnabled, these
593d9c882fBill Taylor * values will be OR-ed together. See IB spec 14.2.5.6 for allowed
594d9c882fBill Taylor * combinations. For LinkSpeedActive, only one will be returned.
595d9c882fBill Taylor */
596d9c882fBill Taylor#define	IBT_LINK_SPEED_SDR	(1)
597d9c882fBill Taylor#define	IBT_LINK_SPEED_DDR	(2)
598d9c882fBill Taylor#define	IBT_LINK_SPEED_QDR	(4)
599d9c882fBill Taylor
600d9c882fBill Taylor/* PortPhysicalState field from PortInfo */
601d9c882fBill Taylortypedef uint8_t ib_port_phys_state_t;
602d9c882fBill Taylor
603d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_SLEEP	(1)
604d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_POLLING	(2)
605d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_DISABLED	(3)
606d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_TRAINING	(4)
607d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_UP		(5)
608d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_RECOVERY	(6)
609d9c882fBill Taylor#define	IBT_PORT_PHYS_STATE_TEST	(7)
610d9c882fBill Taylor
6117c478bdstevel@tonic-gate/*
6127c478bdstevel@tonic-gate * HCA port attributes structure definition. The number of ports per HCA
6137c478bdstevel@tonic-gate * can be found from the "ibt_hca_attr_t" structure.
6147c478bdstevel@tonic-gate *
6157c478bdstevel@tonic-gate * p_pkey_tbl is a pointer to an array of ib_pkey_t, members are
6167c478bdstevel@tonic-gate * accessed as:
6177c478bdstevel@tonic-gate *		hca_portinfo->p_pkey_tbl[i]
6187c478bdstevel@tonic-gate *
6197c478bdstevel@tonic-gate * Where 0 <= i < hca_portinfo.p_pkey_tbl_sz
6207c478bdstevel@tonic-gate *
6217c478bdstevel@tonic-gate * Similarly p_sgid_tbl is a pointer to an array of ib_gid_t.
6227c478bdstevel@tonic-gate *
6237c478bdstevel@tonic-gate * The Query Port function - ibt_query_hca_ports() allocates the memory
6247c478bdstevel@tonic-gate * required for the ibt_hca_portinfo_t struct as well as the memory
6257c478bdstevel@tonic-gate * required for the SGID and P_Key tables. The memory is freed by calling
6267c478bdstevel@tonic-gate * ibt_free_portinfo().
6277c478bdstevel@tonic-gate */
6287c478bdstevel@tonic-gatetypedef struct ibt_hca_portinfo_s {
6297c478bdstevel@tonic-gate	ib_lid_t		p_opaque1;	/* Base LID of port */
6307c478bdstevel@tonic-gate	ib_qkey_cntr_t		p_qkey_violations; /* Bad Q_Key cnt */
6317c478bdstevel@tonic-gate	ib_pkey_cntr_t		p_pkey_violations; /* Optional bad P_Key cnt */
6327c478bdstevel@tonic-gate	uint8_t			p_sm_sl:4;	/* SM Service level */
633d9c882fBill Taylor	ib_port_phys_state_t	p_phys_state;
6347c478bdstevel@tonic-gate	ib_lid_t		p_sm_lid;	/* SM LID */
6357c478bdstevel@tonic-gate	ibt_port_state_t	p_linkstate;	/* Port state */
6367c478bdstevel@tonic-gate	uint8_t			p_port_num;
637d9c882fBill Taylor	ib_link_width_t		p_width_supported;
638d9c882fBill Taylor	ib_link_width_t		p_width_enabled;
639d9c882fBill Taylor	ib_link_width_t		p_width_active;
6407c478bdstevel@tonic-gate	ib_mtu_t		p_mtu;		/* Max transfer unit - pkt */
6417c478bdstevel@tonic-gate	uint8_t			p_lmc:3;	/* Local mask control */
642d9c882fBill Taylor	ib_link_speed_t		p_speed_supported;
643d9c882fBill Taylor	ib_link_speed_t		p_speed_enabled;
644d9c882fBill Taylor	ib_link_speed_t		p_speed_active;
6457c478bdstevel@tonic-gate	ib_gid_t		*p_sgid_tbl;	/* SGID Table */
6467c478bdstevel@tonic-gate	uint_t			p_sgid_tbl_sz;	/* Size of SGID table */
6477c478bdstevel@tonic-gate	uint16_t		p_pkey_tbl_sz;	/* Size of P_Key table */
6487c478bdstevel@tonic-gate	uint16_t		p_def_pkey_ix;	/* default pkey index for TI */
6497c478bdstevel@tonic-gate	ib_pkey_t		*p_pkey_tbl;	/* P_Key table */
6507c478bdstevel@tonic-gate	uint8_t			p_max_vl;	/* Max num of virtual lanes */
6517c478bdstevel@tonic-gate	uint8_t			p_init_type_reply; /* Optional InitTypeReply */
6527c478bdstevel@tonic-gate	ib_time_t		p_subnet_timeout; /* Max Subnet Timeout */
6537c478bdstevel@tonic-gate	ibt_port_caps_t		p_capabilities;	/* Port Capabilities */
6547c478bdstevel@tonic-gate	uint32_t		p_msg_sz;	/* Max message size */
6557c478bdstevel@tonic-gate} ibt_hca_portinfo_t;
6567c478bdstevel@tonic-gate
6577c478bdstevel@tonic-gate/*
6587c478bdstevel@tonic-gate * Modify HCA port attributes flags, specifies which HCA port
6597c478bdstevel@tonic-gate * attributes to modify.
6607c478bdstevel@tonic-gate */
6617c478bdstevel@tonic-gatetypedef enum ibt_port_modify_flags_e {
6627c478bdstevel@tonic-gate	IBT_PORT_NO_FLAGS	= 0,
6637c478bdstevel@tonic-gate
6647c478bdstevel@tonic-gate	IBT_PORT_RESET_QKEY	= 1 << 0,	/* Reset Q_Key violation */
6657c478bdstevel@tonic-gate						/* counter */
6667c478bdstevel@tonic-gate	IBT_PORT_RESET_SM	= 1 << 1,	/* SM */
6677c478bdstevel@tonic-gate	IBT_PORT_SET_SM		= 1 << 2,
6687c478bdstevel@tonic-gate	IBT_PORT_RESET_SNMP	= 1 << 3,	/* SNMP Tunneling */
6697c478bdstevel@tonic-gate	IBT_PORT_SET_SNMP	= 1 << 4,
6707c478bdstevel@tonic-gate	IBT_PORT_RESET_DEVMGT	= 1 << 5,	/* Device Management */
6717c478bdstevel@tonic-gate	IBT_PORT_SET_DEVMGT	= 1 << 6,
6727c478bdstevel@tonic-gate	IBT_PORT_RESET_VENDOR	= 1 << 7,	/* Vendor Class */
6737c478bdstevel@tonic-gate	IBT_PORT_SET_VENDOR	= 1 << 8,
6747c478bdstevel@tonic-gate	IBT_PORT_SHUTDOWN	= 1 << 9,	/* Shut down the port */
6757c478bdstevel@tonic-gate	IBT_PORT_SET_INIT_TYPE	= 1 << 10	/* InitTypeReply value */
6767c478bdstevel@tonic-gate} ibt_port_modify_flags_t;
6777c478bdstevel@tonic-gate
6787c478bdstevel@tonic-gate/*
67924b28d0hiremath * Modify HCA port InitType bit definitions, applicable only if
68024b28d0hiremath * IBT_PORT_SET_INIT_TYPE modify flag (ibt_port_modify_flags_t) is set.
6817c478bdstevel@tonic-gate */
6827c478bdstevel@tonic-gate#define	IBT_PINIT_NO_LOAD		0x1
6837c478bdstevel@tonic-gate#define	IBT_PINIT_PRESERVE_CONTENT	0x2
6847c478bdstevel@tonic-gate#define	IBT_PINIT_PRESERVE_PRESENCE	0x4
6857c478bdstevel@tonic-gate#define	IBT_PINIT_NO_RESUSCITATE	0x8
6867c478bdstevel@tonic-gate
6877c478bdstevel@tonic-gate
6887c478bdstevel@tonic-gate/*
6897c478bdstevel@tonic-gate * Address vector definition.
6907c478bdstevel@tonic-gate */
6917c478bdstevel@tonic-gatetypedef struct ibt_adds_vect_s {
6927c478bdstevel@tonic-gate	ib_gid_t	av_dgid;	/* IPV6 dest GID in GRH */
6937c478bdstevel@tonic-gate	ib_gid_t	av_sgid;	/* SGID */
6947c478bdstevel@tonic-gate	ibt_srate_t	av_srate;	/* Max static rate */
6957c478bdstevel@tonic-gate	uint8_t		av_srvl:4;	/* Service level in LRH */
6967c478bdstevel@tonic-gate	uint_t		av_flow:20;	/* 20 bit Flow Label */
6977c478bdstevel@tonic-gate	uint8_t		av_tclass;	/* Traffic Class */
6987c478bdstevel@tonic-gate	uint8_t		av_hop;		/* Hop Limit */
6997c478bdstevel@tonic-gate	uint8_t		av_port_num;	/* Port number for UD */
7007c478bdstevel@tonic-gate	boolean_t	av_opaque1;
7017c478bdstevel@tonic-gate	ib_lid_t	av_opaque2;
7027c478bdstevel@tonic-gate	ib_path_bits_t	av_opaque3;
7037c478bdstevel@tonic-gate	uint32_t	av_opaque4;
7047c478bdstevel@tonic-gate} ibt_adds_vect_t;
7057c478bdstevel@tonic-gate
7067c478bdstevel@tonic-gatetypedef struct ibt_cep_path_s {
7077c478bdstevel@tonic-gate	ibt_adds_vect_t	cep_adds_vect;		/* Address Vector */
7087c478bdstevel@tonic-gate	uint16_t	cep_pkey_ix;		/* P_Key Index */
7097c478bdstevel@tonic-gate	uint8_t		cep_hca_port_num;	/* Port number for connected */
7107c478bdstevel@tonic-gate						/* channels.  A value of 0 */
7117c478bdstevel@tonic-gate						/* indicates an invalid path */
7127c478bdstevel@tonic-gate	ib_time_t	cep_cm_opaque1;
7137c478bdstevel@tonic-gate} ibt_cep_path_t;
7147c478bdstevel@tonic-gate
7157c478bdstevel@tonic-gate/*
71603494a9Bill Taylor * Define Receive Side Scaling types for IP over IB.
71703494a9Bill Taylor */
71803494a9Bill Taylortypedef enum ibt_rss_flags_e {
71903494a9Bill Taylor	IBT_RSS_ALG_TPL		= (1 << 0),	/* RSS: Toeplitz hash */
72003494a9Bill Taylor	IBT_RSS_ALG_XOR		= (1 << 1),	/* RSS: XOR hash */
72103494a9Bill Taylor	IBT_RSS_HASH_IPV4	= (1 << 2),	/* RSS: hash IPv4 headers */
72203494a9Bill Taylor	IBT_RSS_HASH_IPV6	= (1 << 3),	/* RSS: hash IPv6 headers */
72303494a9Bill Taylor	IBT_RSS_HASH_TCP_IPV4	= (1 << 4),	/* RSS: hash TCP/IPv4 hdrs */
72403494a9Bill Taylor	IBT_RSS_HASH_TCP_IPV6	= (1 << 5)	/* RSS: hash TCP/IPv6 hdrs */
72503494a9Bill Taylor} ibt_rss_flags_t;
72603494a9Bill Taylor
72703494a9Bill Taylortypedef struct ibt_rss_attr_s {
72803494a9Bill Taylor	ibt_rss_flags_t	rss_flags;		/* RSS: flags */
72903494a9Bill Taylor	uint_t		rss_log2_table;		/* RSS: log2 table size */
73003494a9Bill Taylor	ib_qpn_t	rss_base_qpn;		/* RSS: base QPN */
73103494a9Bill Taylor	ib_qpn_t	rss_def_qpn;		/* RSS: default QPN */
73203494a9Bill Taylor	uint8_t		rss_toe_key[40];	/* RSS: Toeplitz hash key */
73303494a9Bill Taylor} ibt_rss_attr_t;
73403494a9Bill Taylor
73503494a9Bill Taylor/*
7367c478bdstevel@tonic-gate * Channel Migration State.
7377c478bdstevel@tonic-gate */
7387c478bdstevel@tonic-gatetypedef enum ibt_cep_cmstate_e {
7397c478bdstevel@tonic-gate	IBT_STATE_NOT_SUPPORTED	= 0,
7407c478bdstevel@tonic-gate	IBT_STATE_MIGRATED	= 1,
7417c478bdstevel@tonic-gate	IBT_STATE_REARMED	= 2,
7427c478bdstevel@tonic-gate	IBT_STATE_ARMED		= 3
7437c478bdstevel@tonic-gate} ibt_cep_cmstate_t;
7447c478bdstevel@tonic-gate
7457c478bdstevel@tonic-gate/*
7467c478bdstevel@tonic-gate * Transport service type
7477c478bdstevel@tonic-gate *
7487c478bdstevel@tonic-gate * NOTE: this was converted from an enum to a uint8_t to save space.
7497c478bdstevel@tonic-gate */
7507c478bdstevel@tonic-gatetypedef uint8_t ibt_tran_srv_t;
7517c478bdstevel@tonic-gate
7527c478bdstevel@tonic-gate#define	IBT_RC_SRV		0
7537c478bdstevel@tonic-gate#define	IBT_UC_SRV		1
7547c478bdstevel@tonic-gate#define	IBT_RD_SRV		2
7557c478bdstevel@tonic-gate#define	IBT_UD_SRV		3
7567c478bdstevel@tonic-gate#define	IBT_RAWIP_SRV		4
7577c478bdstevel@tonic-gate#define	IBT_RAWETHER_SRV	5
75817a2b31Bill Taylor#define	IBT_RFCI_SRV		6
75917a2b31Bill Taylor#define	IBT_FCMD_SRV		7
76017a2b31Bill Taylor#define	IBT_FEXCH_SRV		8
7617c478bdstevel@tonic-gate
7627c478bdstevel@tonic-gate/*
7637c478bdstevel@tonic-gate * Channel (QP/EEC) state definitions.
7647c478bdstevel@tonic-gate */
7657c478bdstevel@tonic-gatetypedef enum ibt_cep_state_e {
7667c478bdstevel@tonic-gate	IBT_STATE_RESET	= 0,		/* Reset */
7677c478bdstevel@tonic-gate	IBT_STATE_INIT,			/* Initialized */
7687c478bdstevel@tonic-gate	IBT_STATE_RTR,			/* Ready to Receive */
7697c478bdstevel@tonic-gate	IBT_STATE_RTS,			/* Ready to Send */
7707c478bdstevel@tonic-gate	IBT_STATE_SQD,			/* Send Queue Drained */
7717c478bdstevel@tonic-gate	IBT_STATE_SQE,			/* Send Queue Error */
7727c478bdstevel@tonic-gate	IBT_STATE_ERROR,		/* Error */
7737c478bdstevel@tonic-gate	IBT_STATE_SQDRAIN,		/* Send Queue Draining */
7747c478bdstevel@tonic-gate	IBT_STATE_NUM			/* Number of states */
7757c478bdstevel@tonic-gate} ibt_cep_state_t;
7767c478bdstevel@tonic-gate
7777c478bdstevel@tonic-gate
7787c478bdstevel@tonic-gate/*
7797c478bdstevel@tonic-gate * Channel Attribute flags.
7807c478bdstevel@tonic-gate */
7817c478bdstevel@tonic-gatetypedef enum ibt_attr_flags_e {
7827c478bdstevel@tonic-gate	IBT_ALL_SIGNALED	= 0,	/* All sends signaled */
7837c478bdstevel@tonic-gate	IBT_WR_SIGNALED		= 1,	/* Signaled on a WR basis */
78403494a9Bill Taylor	IBT_FAST_REG_RES_LKEY	= (1 << 1),
78503494a9Bill Taylor	IBT_USES_LSO		= (1 << 2)
7867c478bdstevel@tonic-gate} ibt_attr_flags_t;
7877c478bdstevel@tonic-gate
7887c478bdstevel@tonic-gate/*
7897c478bdstevel@tonic-gate * Channel End Point (CEP) Control Flags.
7907c478bdstevel@tonic-gate */
7917c478bdstevel@tonic-gatetypedef enum ibt_cep_flags_e {
7927c478bdstevel@tonic-gate	IBT_CEP_NO_FLAGS	= 0,		/* Enable Nothing */
7937c478bdstevel@tonic-gate	IBT_CEP_RDMA_RD		= (1 << 0),	/* Enable incoming RDMA RD's */
7947c478bdstevel@tonic-gate						/* RC & RD only */
7957c478bdstevel@tonic-gate	IBT_CEP_RDMA_WR		= (1 << 1),	/* Enable incoming RDMA WR's */
7967c478bdstevel@tonic-gate						/* RC & RD only */
7977c478bdstevel@tonic-gate	IBT_CEP_ATOMIC		= (1 << 2)	/* Enable incoming Atomics, */
7987c478bdstevel@tonic-gate						/* RC & RD only */
7997c478bdstevel@tonic-gate} ibt_cep_flags_t;
8007c478bdstevel@tonic-gate
8017c478bdstevel@tonic-gate/*
8027c478bdstevel@tonic-gate * Channel Modify Flags
8037c478bdstevel@tonic-gate */
8047c478bdstevel@tonic-gatetypedef enum ibt_cep_modify_flags_e {
8057c478bdstevel@tonic-gate	IBT_CEP_SET_NOTHING		= 0,
8067c478bdstevel@tonic-gate	IBT_CEP_SET_SQ_SIZE		= (1 << 1),
8077c478bdstevel@tonic-gate	IBT_CEP_SET_RQ_SIZE		= (1 << 2),
8087c478bdstevel@tonic-gate
8097c478bdstevel@tonic-gate	IBT_CEP_SET_RDMA_R		= (1 << 3),
8107c478bdstevel@tonic-gate	IBT_CEP_SET_RDMA_W		= (1 << 4),
8117c478bdstevel@tonic-gate	IBT_CEP_SET_ATOMIC		= (1 << 5),
8127c478bdstevel@tonic-gate
8137c478bdstevel@tonic-gate	IBT_CEP_SET_ALT_PATH		= (1 << 6),	/* Alternate Path */
8147c478bdstevel@tonic-gate
8157c478bdstevel@tonic-gate	IBT_CEP_SET_ADDS_VECT		= (1 << 7),
8167c478bdstevel@tonic-gate	IBT_CEP_SET_PORT		= (1 << 8),
8177c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE5		= (1 << 9),
8187c478bdstevel@tonic-gate	IBT_CEP_SET_RETRY		= (1 << 10),
8197c478bdstevel@tonic-gate	IBT_CEP_SET_RNR_NAK_RETRY 	= (1 << 11),
8207c478bdstevel@tonic-gate	IBT_CEP_SET_MIN_RNR_NAK		= (1 << 12),
8217c478bdstevel@tonic-gate
8227c478bdstevel@tonic-gate	IBT_CEP_SET_QKEY		= (1 << 13),
8237c478bdstevel@tonic-gate	IBT_CEP_SET_RDMARA_OUT		= (1 << 14),
8247c478bdstevel@tonic-gate	IBT_CEP_SET_RDMARA_IN		= (1 << 15),
8257c478bdstevel@tonic-gate
8267c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE1		= (1 << 16),
8277c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE2		= (1 << 17),
8287c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE3		= (1 << 18),
8297c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE4		= (1 << 19),
8307c478bdstevel@tonic-gate	IBT_CEP_SET_SQD_EVENT		= (1 << 20),
8317c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE6		= (1 << 21),
8327c478bdstevel@tonic-gate	IBT_CEP_SET_OPAQUE7		= (1 << 22),
83303494a9Bill Taylor	IBT_CEP_SET_OPAQUE8		= (1 << 23),
83417a2b31Bill Taylor	IBT_CEP_SET_RSS			= (1 << 24),
83517a2b31Bill Taylor	IBT_CEP_SET_FEXCH_RANGE		= (1 << 25)
8367c478bdstevel@tonic-gate} ibt_cep_modify_flags_t;
8377c478bdstevel@tonic-gate
8387c478bdstevel@tonic-gate/*
8397c478bdstevel@tonic-gate * CQ notify types.
8407c478bdstevel@tonic-gate */
8417c478bdstevel@tonic-gatetypedef enum ibt_cq_notify_flags_e {
8427c478bdstevel@tonic-gate	IBT_NEXT_COMPLETION	= 1,
8437c478bdstevel@tonic-gate	IBT_NEXT_SOLICITED	= 2
8447c478bdstevel@tonic-gate} ibt_cq_notify_flags_t;
8457c478bdstevel@tonic-gate
8467c478bdstevel@tonic-gate/*
8477c478bdstevel@tonic-gate * CQ types shared across TI and CI.
8487c478bdstevel@tonic-gate */
8497c478bdstevel@tonic-gatetypedef enum ibt_cq_flags_e {
8507c478bdstevel@tonic-gate	IBT_CQ_NO_FLAGS			= 0,
8517c478bdstevel@tonic-gate	IBT_CQ_HANDLER_IN_THREAD	= 1 << 0,	/* A thread calls the */
8527c478bdstevel@tonic-gate							/* CQ handler */
8537c478bdstevel@tonic-gate	IBT_CQ_USER_MAP			= 1 << 1,
85417a2b31Bill Taylor	IBT_CQ_DEFER_ALLOC		= 1 << 2,
85517a2b31Bill Taylor	IBT_CQ_HID			= 1 << 3
8567c478bdstevel@tonic-gate} ibt_cq_flags_t;
8577c478bdstevel@tonic-gate
8587c478bdstevel@tonic-gatetypedef enum ibt_cq_sched_flags_e {
8597c478bdstevel@tonic-gate	IBT_CQS_NO_FLAGS	= 0,
8607c478bdstevel@tonic-gate	IBT_CQS_WARM_CACHE	= 1 << 0, /* run on same CPU */
86117a2b31Bill Taylor	IBT_CQS_EXACT_SCHED_GROUP = 1 << 1,
8627c478bdstevel@tonic-gate	IBT_CQS_SCHED_GROUP	= 1 << 2,
8637c478bdstevel@tonic-gate	IBT_CQS_USER_MAP	= 1 << 3,
8647c478bdstevel@tonic-gate	IBT_CQS_DEFER_ALLOC	= 1 << 4
8657c478bdstevel@tonic-gate} ibt_cq_sched_flags_t;
8667c478bdstevel@tonic-gate
8677c478bdstevel@tonic-gate/*
86817a2b31Bill Taylor * Attributes when creating a Completion Queue Scheduling Handle.
86917a2b31Bill Taylor */
87017a2b31Bill Taylortypedef struct ibt_cq_sched_attr_s {
87117a2b31Bill Taylor	ibt_cq_sched_flags_t	cqs_flags;
87217a2b31Bill Taylor	char			*cqs_pool_name;
87317a2b31Bill Taylor} ibt_cq_sched_attr_t;
87417a2b31Bill Taylor
87517a2b31Bill Taylortypedef	void *ibt_intr_handle_t;
87617a2b31Bill Taylor
87717a2b31Bill Taylortypedef struct ibt_cq_handler_attr_s {
87817a2b31Bill Taylor	dev_info_t		*cha_dip;
87917a2b31Bill Taylor	ibt_intr_handle_t	cha_ih;
88017a2b31Bill Taylor} ibt_cq_handler_attr_t;
88117a2b31Bill Taylor
88217a2b31Bill Taylor/*
8837c478bdstevel@tonic-gate * Attributes when creating a Completion Queue.
8847c478bdstevel@tonic-gate *
8857c478bdstevel@tonic-gate * Note:
8867c478bdstevel@tonic-gate *	The IBT_CQ_HANDLER_IN_THREAD cq_flags bit should be ignored by the CI.
8877c478bdstevel@tonic-gate */
8887c478bdstevel@tonic-gatetypedef struct ibt_cq_attr_s {
8897c478bdstevel@tonic-gate	uint_t			cq_size;
8907c478bdstevel@tonic-gate	ibt_sched_hdl_t		cq_sched;	/* 0 = no hint, */
8917c478bdstevel@tonic-gate						/* other = cq_sched value */
8927c478bdstevel@tonic-gate	ibt_cq_flags_t		cq_flags;
89317a2b31Bill Taylor	ibt_cq_handler_id_t	cq_hid;
8947c478bdstevel@tonic-gate} ibt_cq_attr_t;
8957c478bdstevel@tonic-gate
8967c478bdstevel@tonic-gate/*
8977c478bdstevel@tonic-gate * Memory Management
8987c478bdstevel@tonic-gate */
8997c478bdstevel@tonic-gate
9007c478bdstevel@tonic-gate/* Memory management flags */
9017c478bdstevel@tonic-gatetypedef enum ibt_mr_flags_e {
9027c478bdstevel@tonic-gate	IBT_MR_SLEEP			= 0,
9037c478bdstevel@tonic-gate	IBT_MR_NOSLEEP			= (1 << 1),
9047c478bdstevel@tonic-gate	IBT_MR_NONCOHERENT		= (1 << 2),
9057c478bdstevel@tonic-gate	IBT_MR_PHYS_IOVA		= (1 << 3),  /* ibt_(re)register_buf */
9067c478bdstevel@tonic-gate
9077c478bdstevel@tonic-gate	/* Access control flags */
9087c478bdstevel@tonic-gate	IBT_MR_ENABLE_WINDOW_BIND	= (1 << 4),
9097c478bdstevel@tonic-gate	IBT_MR_ENABLE_LOCAL_WRITE	= (1 << 5),
9107c478bdstevel@tonic-gate	IBT_MR_ENABLE_REMOTE_READ	= (1 << 6),
9117c478bdstevel@tonic-gate	IBT_MR_ENABLE_REMOTE_WRITE	= (1 << 7),
9127c478bdstevel@tonic-gate	IBT_MR_ENABLE_REMOTE_ATOMIC	= (1 << 8),
9137c478bdstevel@tonic-gate
9147c478bdstevel@tonic-gate	/* Reregister flags */
9157c478bdstevel@tonic-gate	IBT_MR_CHANGE_TRANSLATION	= (1 << 9),
9167c478bdstevel@tonic-gate	IBT_MR_CHANGE_ACCESS		= (1 << 10),
9177c478bdstevel@tonic-gate	IBT_MR_CHANGE_PD		= (1 << 11),
9187c478bdstevel@tonic-gate
9197c478bdstevel@tonic-gate	/* Additional registration flags */
9207c478bdstevel@tonic-gate	IBT_MR_ZBVA			= (1 << 12),
9217c478bdstevel@tonic-gate
9227c478bdstevel@tonic-gate	/* Additional physical registration flags */
92303494a9Bill Taylor	IBT_MR_CONSUMER_KEY		= (1 << 13),	/* Consumer owns key */
9247c478bdstevel@tonic-gate							/* portion of keys */
92517a2b31Bill Taylor	IBT_MR_DISABLE_RO		= (1 << 14),
92617a2b31Bill Taylor	IBT_MR_USER_BUF			= (1 << 15)  /* ibt_(re)register_buf */
9277c478bdstevel@tonic-gate} ibt_mr_flags_t;
9287c478bdstevel@tonic-gate
9297c478bdstevel@tonic-gate
9307c478bdstevel@tonic-gate/* Memory Region attribute flags */
9317c478bdstevel@tonic-gatetypedef enum ibt_mr_attr_flags_e {
9327c478bdstevel@tonic-gate	/* Access control flags */
9337c478bdstevel@tonic-gate	IBT_MR_WINDOW_BIND		= (1 << 0),
9347c478bdstevel@tonic-gate	IBT_MR_LOCAL_WRITE		= (1 << 1),
9357c478bdstevel@tonic-gate	IBT_MR_REMOTE_READ		= (1 << 2),
9367c478bdstevel@tonic-gate	IBT_MR_REMOTE_WRITE		= (1 << 3),
9377c478bdstevel@tonic-gate	IBT_MR_REMOTE_ATOMIC		= (1 << 4),
9387c478bdstevel@tonic-gate	IBT_MR_ZERO_BASED_VA		= (1 << 5),
9397c478bdstevel@tonic-gate	IBT_MR_CONSUMER_OWNED_KEY	= (1 << 6),
94043ed929srust	IBT_MR_SHARED			= (1 << 7),
94103494a9Bill Taylor	IBT_MR_FMR			= (1 << 8),
94203494a9Bill Taylor	IBT_MR_RO_DISABLED		= (1 << 9)
9437c478bdstevel@tonic-gate} ibt_mr_attr_flags_t;
9447c478bdstevel@tonic-gate
9457c478bdstevel@tonic-gate/* Memory region physical descriptor. */
9467c478bdstevel@tonic-gatetypedef struct ibt_phys_buf_s {
9477c478bdstevel@tonic-gate	union {
9487c478bdstevel@tonic-gate		uint64_t	_p_ll;		/* 64 bit DMA address */
9497c478bdstevel@tonic-gate		uint32_t	_p_la[2];	/* 2 x 32 bit address */
9507c478bdstevel@tonic-gate	} _phys_buf;
9517c478bdstevel@tonic-gate	size_t	p_size;
9527c478bdstevel@tonic-gate} ibt_phys_buf_t;
9537c478bdstevel@tonic-gate
95403494a9Bill Taylor/* version of above for uniform buffer size */
95503494a9Bill Taylortypedef struct ib_phys_addr_t {
95603494a9Bill Taylor	union {
95703494a9Bill Taylor		uint64_t	_p_ll;		/* 64 bit DMA address */
95803494a9Bill Taylor		uint32_t	_p_la[2];	/* 2 x 32 bit address */
95903494a9Bill Taylor	} _phys_buf;
96003494a9Bill Taylor} ibt_phys_addr_t;
96103494a9Bill Taylor
9627c478bdstevel@tonic-gate#define	p_laddr		_phys_buf._p_ll
9637c478bdstevel@tonic-gate#ifdef	_LONG_LONG_HTOL
9647c478bdstevel@tonic-gate#define	p_notused	_phys_buf._p_la[0]
9657c478bdstevel@tonic-gate#define	p_addr		_phys_buf._p_la[1]
9667c478bdstevel@tonic-gate#else
9677c478bdstevel@tonic-gate#define	p_addr		_phys_buf._p_la[0]
9687c478bdstevel@tonic-gate#define	p_notused	_phys_buf._p_la[1]
9697c478bdstevel@tonic-gate#endif
9707c478bdstevel@tonic-gate
9717c478bdstevel@tonic-gate
9727c478bdstevel@tonic-gate/* Memory region descriptor. */
9737c478bdstevel@tonic-gatetypedef struct ibt_mr_desc_s {
9747c478bdstevel@tonic-gate	ib_vaddr_t	md_vaddr;	/* IB virtual adds of memory */
9757c478bdstevel@tonic-gate	ibt_lkey_t	md_lkey;
9767c478bdstevel@tonic-gate	ibt_rkey_t	md_rkey;
9777c478bdstevel@tonic-gate	boolean_t	md_sync_required;
9787c478bdstevel@tonic-gate} ibt_mr_desc_t;
9797c478bdstevel@tonic-gate
9807c478bdstevel@tonic-gate/* Physical Memory region descriptor. */
9817c478bdstevel@tonic-gatetypedef struct ibt_pmr_desc_s {
9827c478bdstevel@tonic-gate	ib_vaddr_t	pmd_iova;	/* Returned I/O Virtual Address */
9837c478bdstevel@tonic-gate	ibt_lkey_t	pmd_lkey;
9847c478bdstevel@tonic-gate	ibt_rkey_t	pmd_rkey;
9857c478bdstevel@tonic-gate	uint_t 		pmd_phys_buf_list_sz;	/* Allocated Phys buf sz */
9867c478bdstevel@tonic-gate	boolean_t	pmd_sync_required;
9877c478bdstevel@tonic-gate} ibt_pmr_desc_t;
9887c478bdstevel@tonic-gate
9897c478bdstevel@tonic-gate/* Memory region protection bounds. */
9907c478bdstevel@tonic-gatetypedef struct ibt_mr_prot_bounds_s {
9917c478bdstevel@tonic-gate	ib_vaddr_t	pb_addr;	/* Beginning address */
9927c478bdstevel@tonic-gate	size_t		pb_len;		/* Length of protected region */
9937c478bdstevel@tonic-gate} ibt_mr_prot_bounds_t;
9947c478bdstevel@tonic-gate
9957c478bdstevel@tonic-gate/* Memory Region (Re)Register attributes */
9967c478bdstevel@tonic-gatetypedef struct ibt_mr_attr_s {
9977c478bdstevel@tonic-gate	ib_vaddr_t	mr_vaddr;	/* Virtual address to register */
9987c478bdstevel@tonic-gate	ib_memlen_t	mr_len;		/* Length of region to register */
9997c478bdstevel@tonic-gate	struct as	*mr_as;		/* A pointer to an address space */
10007c478bdstevel@tonic-gate					/* structure. This parameter should */
10017c478bdstevel@tonic-gate					/* be set to NULL, which implies */
10027c478bdstevel@tonic-gate					/* kernel address space. */
10037c478bdstevel@tonic-gate	ibt_mr_flags_t	mr_flags;
10047c478bdstevel@tonic-gate} ibt_mr_attr_t;
10057c478bdstevel@tonic-gate
10067c478bdstevel@tonic-gate/* Physical Memory Region (Re)Register */
10077c478bdstevel@tonic-gatetypedef struct ibt_pmr_attr_s {
10087c478bdstevel@tonic-gate	ib_vaddr_t	pmr_iova;	/* I/O virtual address requested by */
10097c478bdstevel@tonic-gate					/* client for the first byte of the */
10107c478bdstevel@tonic-gate					/* region */
10117c478bdstevel@tonic-gate	ib_memlen_t	pmr_len;	/* Length of region to register */
10127c478bdstevel@tonic-gate	ib_memlen_t	pmr_offset;	/* Offset of the regions starting */
10137c478bdstevel@tonic-gate					/* IOVA within the 1st physical */
10147c478bdstevel@tonic-gate					/* buffer */
101503494a9Bill Taylor	ibt_ma_hdl_t	pmr_ma;		/* Memory handle used to obtain the */
101603494a9Bill Taylor					/* pmr_buf_list */
101703494a9Bill Taylor	ibt_phys_addr_t	*pmr_addr_list;	/* List of physical buffers accessed */
101803494a9Bill Taylor					/* as an array */
101903494a9Bill Taylor	size_t		pmr_buf_sz;
102003494a9Bill Taylor	uint_t		pmr_num_buf;	/* Num of entries in the pmr_buf_list */
10217c478bdstevel@tonic-gate	ibt_lkey_t	pmr_lkey;	/* Reregister only */
10227c478bdstevel@tonic-gate	ibt_rkey_t	pmr_rkey;	/* Reregister only */
102303494a9Bill Taylor	ibt_mr_flags_t	pmr_flags;
10247c478bdstevel@tonic-gate	uint8_t		pmr_key;	/* Key to use on new Lkey & Rkey */
10257c478bdstevel@tonic-gate} ibt_pmr_attr_t;
10267c478bdstevel@tonic-gate
102717a2b31Bill Taylor/* DMA Memory Region */
102817a2b31Bill Taylortypedef struct ibt_dmr_attr_s {
102917a2b31Bill Taylor	uint64_t	dmr_paddr;	/* starting physical addr */
103017a2b31Bill Taylor	ib_memlen_t	dmr_len;	/* length in bytes */
103117a2b31Bill Taylor	ibt_mr_flags_t	dmr_flags;	/* no sleep, memory permissions */
103217a2b31Bill Taylor} ibt_dmr_attr_t;
103317a2b31Bill Taylor
103403494a9Bill Taylor/* addr/length pair */
103503494a9Bill Taylortypedef struct ibt_iov_s {
103603494a9Bill Taylor	caddr_t	iov_addr;	/* Beginning address */
103703494a9Bill Taylor	size_t	iov_len;	/* Length */
103803494a9Bill Taylor} ibt_iov_t;
103903494a9Bill Taylor
104003494a9Bill Taylor/* Map memory IOV */
104103494a9Bill Taylortypedef enum ibt_iov_flags_e {
104203494a9Bill Taylor	IBT_IOV_SLEEP		= 0,
104303494a9Bill Taylor	IBT_IOV_NOSLEEP		= (1 << 0),
104403494a9Bill Taylor	IBT_IOV_BUF		= (1 << 1),
104517a2b31Bill Taylor	IBT_IOV_RECV		= (1 << 2),
104617a2b31Bill Taylor	IBT_IOV_USER_BUF	= (1 << 3),
104717a2b31Bill Taylor	IBT_IOV_ALT_LKEY	= (1 << 4)
104803494a9Bill Taylor} ibt_iov_flags_t;
104903494a9Bill Taylor
105003494a9Bill Taylortypedef struct ibt_iov_attr_s {
105103494a9Bill Taylor	struct as		*iov_as;
105203494a9Bill Taylor	ibt_iov_t		*iov;
105303494a9Bill Taylor	struct buf		*iov_buf;
105403494a9Bill Taylor	uint32_t		iov_list_len;
105503494a9Bill Taylor	uint32_t		iov_wr_nds;
105603494a9Bill Taylor	ib_msglen_t		iov_lso_hdr_sz;
105717a2b31Bill Taylor	ibt_lkey_t		iov_alt_lkey;
105803494a9Bill Taylor	ibt_iov_flags_t		iov_flags;
105903494a9Bill Taylor} ibt_iov_attr_t;
10607c478bdstevel@tonic-gate
10617c478bdstevel@tonic-gate/*
10627c478bdstevel@tonic-gate * Memory Region (Re)Register attributes - used by ibt_register_shared_mr(),
10637c478bdstevel@tonic-gate * ibt_register_buf() and ibt_reregister_buf().
10647c478bdstevel@tonic-gate */
10657c478bdstevel@tonic-gatetypedef struct ibt_smr_attr_s {
10667c478bdstevel@tonic-gate	ib_vaddr_t		mr_vaddr;
10677c478bdstevel@tonic-gate	ibt_mr_flags_t		mr_flags;
10687c478bdstevel@tonic-gate	uint8_t			mr_key;		/* Only for physical */
10697c478bdstevel@tonic-gate						/* ibt_(Re)register_buf() */
10707c478bdstevel@tonic-gate	ibt_lkey_t		mr_lkey;	/* Only for physical */
10717c478bdstevel@tonic-gate	ibt_rkey_t		mr_rkey;	/* ibt_Reregister_buf() */
10727c478bdstevel@tonic-gate} ibt_smr_attr_t;
10737c478bdstevel@tonic-gate
10747c478bdstevel@tonic-gate/*
10757c478bdstevel@tonic-gate * key states.
10767c478bdstevel@tonic-gate */
10777c478bdstevel@tonic-gatetypedef enum ibt_key_state_e {
10787c478bdstevel@tonic-gate	IBT_KEY_INVALID	= 0,
10797c478bdstevel@tonic-gate	IBT_KEY_FREE,
10807c478bdstevel@tonic-gate	IBT_KEY_VALID
10817c478bdstevel@tonic-gate} ibt_key_state_t;
10827c478bdstevel@tonic-gate
10837c478bdstevel@tonic-gate/* Memory region query attributes */
10847c478bdstevel@tonic-gatetypedef struct ibt_mr_query_attr_s {
10857c478bdstevel@tonic-gate	ibt_lkey_t		mr_lkey;
10867c478bdstevel@tonic-gate	ibt_rkey_t		mr_rkey;
10877c478bdstevel@tonic-gate	ibt_mr_prot_bounds_t	mr_lbounds;	/* Actual local CI protection */
10887c478bdstevel@tonic-gate						/* bounds */
10897c478bdstevel@tonic-gate	ibt_mr_prot_bounds_t	mr_rbounds;	/* Actual remote CI */
10907c478bdstevel@tonic-gate						/* protection bounds */
10917c478bdstevel@tonic-gate	ibt_mr_attr_flags_t	mr_attr_flags;	/* Access rights etc. */
10927c478bdstevel@tonic-gate	ibt_pd_hdl_t		mr_pd;		/* Protection domain */
10937c478bdstevel@tonic-gate	boolean_t		mr_sync_required;
10947c478bdstevel@tonic-gate	ibt_key_state_t		mr_lkey_state;
10957c478bdstevel@tonic-gate	uint_t			mr_phys_buf_list_sz;
10967c478bdstevel@tonic-gate} ibt_mr_query_attr_t;
10977c478bdstevel@tonic-gate
10987c478bdstevel@tonic-gate/* Memory window query attributes */
10997c478bdstevel@tonic-gatetypedef struct ibt_mw_query_attr_s {
11007c478bdstevel@tonic-gate	ibt_pd_hdl_t		mw_pd;
11017c478bdstevel@tonic-gate	ibt_mem_win_type_t	mw_type;
11027c478bdstevel@tonic-gate	ibt_rkey_t		mw_rkey;
11037c478bdstevel@tonic-gate	ibt_key_state_t		mw_state;
11047c478bdstevel@tonic-gate} ibt_mw_query_attr_t;
11057c478bdstevel@tonic-gate
11067c478bdstevel@tonic-gate
110724b28d0hiremath/* Memory Region Sync Flags. */
11087c478bdstevel@tonic-gate#define	IBT_SYNC_READ	0x1	/* Make memory changes visible to incoming */
11097c478bdstevel@tonic-gate				/* RDMA reads */
11107c478bdstevel@tonic-gate
11117c478bdstevel@tonic-gate#define	IBT_SYNC_WRITE	0x2	/* Make the affects of an incoming RDMA write */
11127c478bdstevel@tonic-gate				/* visible to the consumer */
11137c478bdstevel@tonic-gate
11147c478bdstevel@tonic-gate/* Memory region sync args */
11157c478bdstevel@tonic-gatetypedef struct ibt_mr_sync_s {
11167c478bdstevel@tonic-gate	ibt_mr_hdl_t	ms_handle;
11177c478bdstevel@tonic-gate	ib_vaddr_t	ms_vaddr;
11187c478bdstevel@tonic-gate	ib_memlen_t	ms_len;
11197c478bdstevel@tonic-gate	uint32_t	ms_flags;	/* IBT_SYNC_READ or  IBT_SYNC_WRITE */
11207c478bdstevel@tonic-gate} ibt_mr_sync_t;
11217c478bdstevel@tonic-gate
11227c478bdstevel@tonic-gate/*
11237c478bdstevel@tonic-gate * Flags for Virtual Address to HCA Physical Address translation.
11247c478bdstevel@tonic-gate */
11257c478bdstevel@tonic-gatetypedef enum ibt_va_flags_e {
112643ed929srust	IBT_VA_SLEEP		= 0,
112743ed929srust	IBT_VA_NOSLEEP		= (1 << 0),
112843ed929srust	IBT_VA_NONCOHERENT	= (1 << 1),
112943ed929srust	IBT_VA_FMR		= (1 << 2),
1130effa70dhiremath	IBT_VA_BLOCK_MODE	= (1 << 3),
1131c7facc5Bill Taylor	IBT_VA_BUF		= (1 << 4),
113217a2b31Bill Taylor	IBT_VA_REG_FN		= (1 << 5),
113317a2b31Bill Taylor	IBT_VA_USER_BUF		= (1 << 6)
11347c478bdstevel@tonic-gate} ibt_va_flags_t;
11357c478bdstevel@tonic-gate
11367c478bdstevel@tonic-gate
11377c478bdstevel@tonic-gate/*  Address Translation parameters */
11387c478bdstevel@tonic-gatetypedef struct ibt_va_attr_s {
11397c478bdstevel@tonic-gate	ib_vaddr_t	va_vaddr;	/* Virtual address to register */
11407c478bdstevel@tonic-gate	ib_memlen_t	va_len;		/* Length of region to register */
11417c478bdstevel@tonic-gate	struct as	*va_as;		/* A pointer to an address space */
11427c478bdstevel@tonic-gate					/* structure. */
114303494a9Bill Taylor	size_t		va_phys_buf_min;	/* block mode only */
114403494a9Bill Taylor	size_t		va_phys_buf_max;	/* block mode only */
11457c478bdstevel@tonic-gate	ibt_va_flags_t	va_flags;
1146effa70dhiremath	struct buf	*va_buf;
11477c478bdstevel@tonic-gate} ibt_va_attr_t;
11487c478bdstevel@tonic-gate
114943ed929srust
115043ed929srust/*
115143ed929srust * Fast Memory Registration (FMR) support.
115243ed929srust */
115343ed929srust
115443ed929srust/* FMR flush function handler. */
115543ed929srusttypedef void (*ibt_fmr_flush_handler_t)(ibt_fmr_pool_hdl_t fmr_pool,
115643ed929srust    void *fmr_func_arg);
115743ed929srust
115843ed929srust/* FMR Pool create attributes. */
115943ed929srusttypedef struct ibt_fmr_pool_attr_s {
116043ed929srust	uint_t			fmr_max_pages_per_fmr;
116143ed929srust	uint_t			fmr_pool_size;
116243ed929srust	uint_t			fmr_dirty_watermark;
116343ed929srust	size_t			fmr_page_sz;
116443ed929srust	boolean_t		fmr_cache;
116543ed929srust	ibt_mr_flags_t		fmr_flags;
116643ed929srust	ibt_fmr_flush_handler_t	fmr_func_hdlr;
116743ed929srust	void			*fmr_func_arg;
116843ed929srust} ibt_fmr_pool_attr_t;
116943ed929srust
117017a2b31Bill Taylor/*
117117a2b31Bill Taylor * Define types for Fibre Channel over IB (fcoib)
117217a2b31Bill Taylor */
117317a2b31Bill Taylortypedef enum ibt_fexch_query_flags_e {
117417a2b31Bill Taylor	IBT_FEXCH_NO_FLAGS =		0,
117517a2b31Bill Taylor	IBT_FEXCH_HEART_BEAT_OK =	(1 << 0)	/* FEXCH only */
117617a2b31Bill Taylor} ibt_fexch_query_flags_t;
117717a2b31Bill Taylor
117817a2b31Bill Taylortypedef struct ibt_fexch_query_attr_s {
117917a2b31Bill Taylor	ibt_pmr_desc_t	fq_uni_mem_desc; /* FEXCH: uni-directional MR attrs */
118017a2b31Bill Taylor	ibt_pmr_desc_t	fq_bi_mem_desc;	/* FEXCH: bi-directional MR attrs */
118117a2b31Bill Taylor	ibt_fexch_query_flags_t fq_flags;
118217a2b31Bill Taylor} ibt_fexch_query_attr_t;
118317a2b31Bill Taylor
118417a2b31Bill Taylortypedef struct ibt_fc_attr_s {
118517a2b31Bill Taylor	uint32_t	fc_src_id;	/* S_ID assigned to the RFCI QP */
118617a2b31Bill Taylor			/* FCMD, FEXCH: matching RFCI QP = RFCI base + idx */
118717a2b31Bill Taylor	ib_qpn_t	fc_rfci_qpn;
118817a2b31Bill Taylor	uint16_t	fc_exch_base_off; /* FCMD: FEXCH usable base */
118917a2b31Bill Taylor	uint8_t		fc_exch_log2_sz; /* FCMD: FEXCH log2 size */
119017a2b31Bill Taylor	uint8_t		fc_hca_port;	/* RFCI, FEXCH: HCA port number */
119117a2b31Bill Taylor} ibt_fc_attr_t;
119217a2b31Bill Taylor
119343ed929srust
11947c478bdstevel@tonic-gate/*
11957c478bdstevel@tonic-gate * WORK REQUEST AND WORK REQUEST COMPLETION DEFINITIONS.
11967c478bdstevel@tonic-gate */
11977c478bdstevel@tonic-gate
11987c478bdstevel@tonic-gate/*
11997c478bdstevel@tonic-gate * Work Request and Work Request Completion types - These types are used
12007c478bdstevel@tonic-gate *   to indicate the type of work requests posted to a work queue
12017c478bdstevel@tonic-gate *   or the type of completion received.  Immediate Data is indicated via
12027c478bdstevel@tonic-gate *   ibt_wr_flags_t or ibt_wc_flags_t.
12037c478bdstevel@tonic-gate *
12047c478bdstevel@tonic-gate *   IBT_WRC_RECV and IBT_WRC_RECV_RDMAWI are only used as opcodes in the
12057c478bdstevel@tonic-gate *   work completions.
12067c478bdstevel@tonic-gate *
12077c478bdstevel@tonic-gate * NOTE: this was converted from an enum to a uint8_t to save space.
12087c478bdstevel@tonic-gate */
12097c478bdstevel@tonic-gatetypedef uint8_t ibt_wrc_opcode_t;
12107c478bdstevel@tonic-gate
12117c478bdstevel@tonic-gate#define	IBT_WRC_SEND		1	/* Send */
12127c478bdstevel@tonic-gate#define	IBT_WRC_RDMAR		2	/* RDMA Read */
12137c478bdstevel@tonic-gate#define	IBT_WRC_RDMAW		3	/* RDMA Write */
12147c478bdstevel@tonic-gate#define	IBT_WRC_CSWAP		4	/* Compare & Swap Atomic */
12157c478bdstevel@tonic-gate#define	IBT_WRC_FADD		5	/* Fetch & Add Atomic */
12167c478bdstevel@tonic-gate#define	IBT_WRC_BIND		6	/* Bind Memory Window */
12177c478bdstevel@tonic-gate#define	IBT_WRC_RECV		7	/* Receive */
12187c478bdstevel@tonic-gate#define	IBT_WRC_RECV_RDMAWI	8	/* Received RDMA Write w/ Immediate */
12197c478bdstevel@tonic-gate#define	IBT_WRC_FAST_REG_PMR	9	/* Fast Register Physical mem region */
12207c478bdstevel@tonic-gate#define	IBT_WRC_LOCAL_INVALIDATE 10
122103494a9Bill Taylor#define	IBT_WRC_SEND_LSO	11
122217a2b31Bill Taylor#define	IBT_WRC_INIT_SEND_FCMD	12	/* Init & Send for FCMD initiator */
122317a2b31Bill Taylor#define	IBT_WRC_INIT_FEXCH	13	/* Init for FEXCH target */
12247c478bdstevel@tonic-gate
12257c478bdstevel@tonic-gate
12267c478bdstevel@tonic-gate/*
12277c478bdstevel@tonic-gate * Work Request Completion flags - These flags indicate what type
12287c478bdstevel@tonic-gate *   of data is present in the Work Request Completion structure
12297c478bdstevel@tonic-gate */
12307c478bdstevel@tonic-gatetypedef uint8_t ibt_wc_flags_t;
12317c478bdstevel@tonic-gate
12327c478bdstevel@tonic-gate#define	IBT_WC_NO_FLAGS			0
12337c478bdstevel@tonic-gate#define	IBT_WC_GRH_PRESENT		(1 << 0)
12347c478bdstevel@tonic-gate#define	IBT_WC_IMMED_DATA_PRESENT	(1 << 1)
12357c478bdstevel@tonic-gate#define	IBT_WC_RKEY_INVALIDATED		(1 << 2)
12367c478bdstevel@tonic-gate#define	IBT_WC_CKSUM_OK			(1 << 3)
123717a2b31Bill Taylor#define	IBT_WC_FEXCH_FMT		(1 << 4)
123817a2b31Bill Taylor#define	IBT_WC_DIF_ERROR		(1 << 5)
12397c478bdstevel@tonic-gate
124003494a9Bill Taylor/* IPoIB flags for wc_detail field */
124103494a9Bill Taylor#define	IBT_WC_DETAIL_ALL_FLAGS_MASK	(0x0FC00000)
124203494a9Bill Taylor#define	IBT_WC_DETAIL_IPV4		(1 << 22)
124303494a9Bill Taylor#define	IBT_WC_DETAIL_IPV4_FRAG		(1 << 23)
124403494a9Bill Taylor#define	IBT_WC_DETAIL_IPV6		(1 << 24)
124503494a9Bill Taylor#define	IBT_WC_DETAIL_IPV4_OPT		(1 << 25)
124603494a9Bill Taylor#define	IBT_WC_DETAIL_TCP		(1 << 26)
124703494a9Bill Taylor#define	IBT_WC_DETAIL_UDP		(1 << 27)
124803494a9Bill Taylor
124903494a9Bill Taylor#define	IBT_WC_DETAIL_RSS_MATCH_MASK	(0x003F0000)
125003494a9Bill Taylor#define	IBT_WC_DETAIL_RSS_TCP_IPV6	(1 << 18)
125103494a9Bill Taylor#define	IBT_WC_DETAIL_RSS_IPV6		(1 << 19)
125203494a9Bill Taylor#define	IBT_WC_DETAIL_RSS_TCP_IPV4	(1 << 20)
125303494a9Bill Taylor#define	IBT_WC_DETAIL_RSS_IPV4		(1 << 21)
12547c478bdstevel@tonic-gate
125517a2b31Bill Taylor/* FEXCH flags for wc_detail field */
125617a2b31Bill Taylor#define	IBT_WC_DETAIL_FC_MATCH_MASK	(0xE000000)
125717a2b31Bill Taylor#define	IBT_WC_DETAIL_FEXCH_INIT_XFER	(1 << 25)
125817a2b31Bill Taylor#define	IBT_WC_DETAIL_FEXCH_LAST	(1 << 26)
125917a2b31Bill Taylor#define	IBT_WC_DETAIL_RFCI_CRC_OK	(1 << 27)
126017a2b31Bill Taylor
12617c478bdstevel@tonic-gate/*
12627c478bdstevel@tonic-gate * Work Request Completion - This structure encapsulates the information
12637c478bdstevel@tonic-gate *   necessary to define a work request completion.
12647c478bdstevel@tonic-gate */
12657c478bdstevel@tonic-gatetypedef struct ibt_wc_s {
12667c478bdstevel@tonic-gate	ibt_wrid_t		wc_id;		/* Work Request Id */
12677c478bdstevel@tonic-gate	uint64_t		wc_fma_ena;	/* fault management err data */
12687c478bdstevel@tonic-gate	ib_msglen_t		wc_bytes_xfer;	/* Number of Bytes */
12697c478bdstevel@tonic-gate						/* Transferred */
12707c478bdstevel@tonic-gate	ibt_wc_flags_t		wc_flags;	/* WR Completion Flags */
12717c478bdstevel@tonic-gate	ibt_wrc_opcode_t	wc_type;	/* Operation Type */
12727c478bdstevel@tonic-gate	uint16_t		wc_cksum;	/* payload checksum */
12737c478bdstevel@tonic-gate	ibt_immed_t		wc_immed_data;	/* Immediate Data */
127403494a9Bill Taylor	uint32_t		wc_res_hash;	/* RD: Freed Res, RSS: hash */
12757c478bdstevel@tonic-gate	ibt_wc_status_t		wc_status;	/* Completion Status */
12767c478bdstevel@tonic-gate	uint8_t			wc_sl:4;	/* Remote SL */
12777c478bdstevel@tonic-gate	uint16_t		wc_ethertype;	/* Ethertype Field - RE */
12787c478bdstevel@tonic-gate	ib_lid_t		wc_opaque1;
12797c478bdstevel@tonic-gate	uint16_t		wc_opaque2;
12807c478bdstevel@tonic-gate	ib_qpn_t		wc_qpn;		/* Source QPN Datagram only */
128103494a9Bill Taylor	uint32_t		wc_detail;	/* RD: EECN, UD: IPoIB flags */
12827c478bdstevel@tonic-gate	ib_qpn_t		wc_local_qpn;
12837c478bdstevel@tonic-gate	ibt_rkey_t		wc_rkey;
12847c478bdstevel@tonic-gate	ib_path_bits_t		wc_opaque4;
12857c478bdstevel@tonic-gate} ibt_wc_t;
12867c478bdstevel@tonic-gate
128717a2b31Bill Taylor/* FC format alternative field names */
128817a2b31Bill Taylor#define	wc_fexch_seq_cnt	wc_cksum
128917a2b31Bill Taylor#define	wc_fexch_tx_bytes_xfer	wc_immed_data
129017a2b31Bill Taylor#define	wc_fexch_rx_bytes_xfer	wc_res_hash
129117a2b31Bill Taylor#define	wc_fexch_seq_id		wc_opaque2
129217a2b31Bill Taylor
129317a2b31Bill Taylor
12947c478bdstevel@tonic-gate/*
12957c478bdstevel@tonic-gate * WR Flags. Common for both RC and UD
12967c478bdstevel@tonic-gate *
12977c478bdstevel@tonic-gate * NOTE: this was converted from an enum to a uint8_t to save space.
12987c478bdstevel@tonic-gate */
12997c478bdstevel@tonic-gatetypedef uint8_t ibt_wr_flags_t;
13007c478bdstevel@tonic-gate
13017c478bdstevel@tonic-gate#define	IBT_WR_NO_FLAGS		0
13027c478bdstevel@tonic-gate#define	IBT_WR_SEND_IMMED	(1 << 0)	/* Immediate Data Indicator */
13037c478bdstevel@tonic-gate#define	IBT_WR_SEND_SIGNAL	(1 << 1)	/* Signaled, if set */
13047c478bdstevel@tonic-gate#define	IBT_WR_SEND_FENCE	(1 << 2)	/* Fence Indicator */
13057c478bdstevel@tonic-gate#define	IBT_WR_SEND_SOLICIT	(1 << 3)	/* Solicited Event Indicator */
13067c478bdstevel@tonic-gate#define	IBT_WR_SEND_REMOTE_INVAL	(1 << 4) /* Remote Invalidate */
13077c478bdstevel@tonic-gate#define	IBT_WR_SEND_CKSUM	(1 << 5)	/* Checksum offload Indicator */
130817a2b31Bill Taylor#define	IBT_WR_SEND_FC_CRC	IBT_WR_SEND_CKSUM	/* RFCI: FC CRC */
130903494a9Bill Taylor#define	IBT_WR_SEND_INLINE	(1 << 6)	/* INLINE required (no lkey) */
13107c478bdstevel@tonic-gate
13117c478bdstevel@tonic-gate/*
13127c478bdstevel@tonic-gate * Access control flags for Bind Memory Window operation,
13137c478bdstevel@tonic-gate * applicable for RC/UC/RD only.
13147c478bdstevel@tonic-gate *
13157c478bdstevel@tonic-gate * If IBT_WR_BIND_WRITE or IBT_WR_BIND_ATOMIC is desired then
13167c478bdstevel@tonic-gate * it is required that Memory Region should have Local Write Access.
13177c478bdstevel@tonic-gate */
13187c478bdstevel@tonic-gatetypedef enum ibt_bind_flags_e {
13197c478bdstevel@tonic-gate	IBT_WR_BIND_READ	= (1 << 0),	/* enable remote read */
13207c478bdstevel@tonic-gate	IBT_WR_BIND_WRITE	= (1 << 1),	/* enable remote write */
13217c478bdstevel@tonic-gate	IBT_WR_BIND_ATOMIC	= (1 << 2),	/* enable remote atomics */
13227c478bdstevel@tonic-gate	IBT_WR_BIND_ZBVA	= (1 << 3)	/* Zero Based Virtual Address */
13237c478bdstevel@tonic-gate} ibt_bind_flags_t;
13247c478bdstevel@tonic-gate
13257c478bdstevel@tonic-gate/*
13267c478bdstevel@tonic-gate * Data Segment for scatter-gather list
13277c478bdstevel@tonic-gate *
13287c478bdstevel@tonic-gate * SGL consists of an array of data segments and the length of the SGL.
13297c478bdstevel@tonic-gate */
13307c478bdstevel@tonic-gatetypedef struct ibt_wr_ds_s {
13317c478bdstevel@tonic-gate	ib_vaddr_t	ds_va;		/* Virtual Address */
13327c478bdstevel@tonic-gate	ibt_lkey_t	ds_key;		/* L_Key */
13337c478bdstevel@tonic-gate	ib_msglen_t	ds_len;		/* Length of DS */
13347c478bdstevel@tonic-gate} ibt_wr_ds_t;
13357c478bdstevel@tonic-gate
13367c478bdstevel@tonic-gate/*
13377c478bdstevel@tonic-gate * Bind Memory Window WR
13387c478bdstevel@tonic-gate *
13397c478bdstevel@tonic-gate * WR ID from ibt_send_wr_t applies here too, SWG_0038 errata.
13407c478bdstevel@tonic-gate */
13417c478bdstevel@tonic-gatetypedef struct ibt_wr_bind_s {
13427c478bdstevel@tonic-gate	ibt_bind_flags_t	bind_flags;
13437c478bdstevel@tonic-gate	ibt_rkey_t		bind_rkey;		/* Mem Window's R_key */
13447c478bdstevel@tonic-gate	ibt_lkey_t		bind_lkey;		/* Mem Region's L_Key */
13457c478bdstevel@tonic-gate	ibt_rkey_t		bind_rkey_out;		/* OUT: new R_Key */
13467c478bdstevel@tonic-gate	ibt_mr_hdl_t		bind_ibt_mr_hdl;	/* Mem Region handle */
13477c478bdstevel@tonic-gate	ibt_mw_hdl_t		bind_ibt_mw_hdl;	/* Mem Window handle */
13487c478bdstevel@tonic-gate	ib_vaddr_t		bind_va;		/* Virtual Address */
13497c478bdstevel@tonic-gate	ib_memlen_t		bind_len;		/* Length of Window */
13507c478bdstevel@tonic-gate} ibt_wr_bind_t;
13517c478bdstevel@tonic-gate
13527c478bdstevel@tonic-gate/*
13537c478bdstevel@tonic-gate * Atomic WR
13547c478bdstevel@tonic-gate *
13557c478bdstevel@tonic-gate * Operation type (compare & swap or fetch & add) in ibt_wrc_opcode_t.
13567c478bdstevel@tonic-gate *
13577c478bdstevel@tonic-gate * A copy of the original contents of the remote memory will be stored
13587c478bdstevel@tonic-gate * in the local data segment described by wr_sgl within ibt_send_wr_t,
13597c478bdstevel@tonic-gate * and wr_nds should be set to 1.
13607c478bdstevel@tonic-gate *
13617c478bdstevel@tonic-gate * Atomic operation operands:
13627c478bdstevel@tonic-gate *   Compare & Swap Operation:
13637c478bdstevel@tonic-gate *	atom_arg1 - Compare Operand
13647c478bdstevel@tonic-gate *	atom_arg2 - Swap Operand
13657c478bdstevel@tonic-gate *
13667c478bdstevel@tonic-gate *   Fetch & Add Operation:
13677c478bdstevel@tonic-gate *	atom_arg1 - Add Operand
13687c478bdstevel@tonic-gate *	atom_arg2 - ignored
13697c478bdstevel@tonic-gate */
13707c478bdstevel@tonic-gatetypedef struct ibt_wr_atomic_s {
13717c478bdstevel@tonic-gate	ib_vaddr_t	atom_raddr;	/* Remote address. */
13727c478bdstevel@tonic-gate	ibt_atom_arg_t	atom_arg1;	/* operand #1 */
13737c478bdstevel@tonic-gate	ibt_atom_arg_t	atom_arg2;	/* operand #2 */
13747c478bdstevel@tonic-gate	ibt_rkey_t	atom_rkey;	/* R_Key. */
13757c478bdstevel@tonic-gate} ibt_wr_atomic_t;
13767c478bdstevel@tonic-gate
13777c478bdstevel@tonic-gate/*
13787c478bdstevel@tonic-gate * RDMA WR
13797c478bdstevel@tonic-gate * Immediate Data indicator in ibt_wr_flags_t.
13807c478bdstevel@tonic-gate */
13817c478bdstevel@tonic-gatetypedef struct ibt_wr_rdma_s {
13827c478bdstevel@tonic-gate	ib_vaddr_t	rdma_raddr;	/* Remote address. */
13837c478bdstevel@tonic-gate	ibt_rkey_t	rdma_rkey;	/* R_Key. */
13847c478bdstevel@tonic-gate	ibt_immed_t	rdma_immed;	/* Immediate Data */
13857c478bdstevel@tonic-gate} ibt_wr_rdma_t;
13867c478bdstevel@tonic-gate
13877c478bdstevel@tonic-gate/*
13887c478bdstevel@tonic-gate * Fast Register Physical Memory Region Work Request.
13897c478bdstevel@tonic-gate */
13907c478bdstevel@tonic-gatetypedef struct ibt_wr_reg_pmr_s {
13917c478bdstevel@tonic-gate	ib_vaddr_t	pmr_iova;	/* I/O virtual address requested by */
13927c478bdstevel@tonic-gate					/* client for the first byte of the */
13937c478bdstevel@tonic-gate					/* region */
13947c478bdstevel@tonic-gate	ib_memlen_t	pmr_len;	/* Length of region to register */
1395c7facc5Bill Taylor	ib_memlen_t	pmr_offset;	/* Offset of the region's starting */
13967c478bdstevel@tonic-gate					/* IOVA within the 1st physical */
13977c478bdstevel@tonic-gate					/* buffer */
13987c478bdstevel@tonic-gate	ibt_mr_hdl_t	pmr_mr_hdl;
139903494a9Bill Taylor	ibt_phys_addr_t	*pmr_addr_list; /* List of physical buffers accessed */
14007c478bdstevel@tonic-gate					/* as an array */
140103494a9Bill Taylor	size_t		pmr_buf_sz;	/* size of uniform size PBEs */
1402c7facc5Bill Taylor	uint_t		pmr_num_buf;	/* #entries in the pmr_addr_list */
1403c7facc5Bill Taylor	ibt_lkey_t	pmr_lkey;	/* new lkey upon return */
1404c7facc5Bill Taylor	ibt_rkey_t	pmr_rkey;	/* new rkey upon return */
14057c478bdstevel@tonic-gate	ibt_mr_flags_t	pmr_flags;
14067c478bdstevel@tonic-gate	uint8_t		pmr_key;	/* Key to use on new Lkey & Rkey */
14077c478bdstevel@tonic-gate} ibt_wr_reg_pmr_t;
14087c478bdstevel@tonic-gate
140903494a9Bill Taylor/* phys reg function or WR */
141003494a9Bill Taylortypedef union ibt_reg_req_u {
1411