19e39c5baSBill Taylor /*
29e39c5baSBill Taylor  * CDDL HEADER START
39e39c5baSBill Taylor  *
49e39c5baSBill Taylor  * The contents of this file are subject to the terms of the
59e39c5baSBill Taylor  * Common Development and Distribution License (the "License").
69e39c5baSBill Taylor  * You may not use this file except in compliance with the License.
79e39c5baSBill Taylor  *
89e39c5baSBill Taylor  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99e39c5baSBill Taylor  * or http://www.opensolaris.org/os/licensing.
109e39c5baSBill Taylor  * See the License for the specific language governing permissions
119e39c5baSBill Taylor  * and limitations under the License.
129e39c5baSBill Taylor  *
139e39c5baSBill Taylor  * When distributing Covered Code, include this CDDL HEADER in each
149e39c5baSBill Taylor  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159e39c5baSBill Taylor  * If applicable, add the following below this CDDL HEADER, with the
169e39c5baSBill Taylor  * fields enclosed by brackets "[]" replaced with your own identifying
179e39c5baSBill Taylor  * information: Portions Copyright [yyyy] [name of copyright owner]
189e39c5baSBill Taylor  *
199e39c5baSBill Taylor  * CDDL HEADER END
209e39c5baSBill Taylor  */
219e39c5baSBill Taylor 
229e39c5baSBill Taylor /*
23*17a2b317SBill Taylor  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249e39c5baSBill Taylor  */
259e39c5baSBill Taylor 
269e39c5baSBill Taylor #ifndef	_SYS_IB_ADAPTERS_TAVOR_MR_H
279e39c5baSBill Taylor #define	_SYS_IB_ADAPTERS_TAVOR_MR_H
289e39c5baSBill Taylor 
299e39c5baSBill Taylor /*
309e39c5baSBill Taylor  * tavor_mr.h
319e39c5baSBill Taylor  *    Contains all of the prototypes, #defines, and structures necessary
329e39c5baSBill Taylor  *    for the Tavor Memory Region/Window routines.
339e39c5baSBill Taylor  *    Specifically it contains #defines, macros, and prototypes for each of
349e39c5baSBill Taylor  *    the required memory region/window verbs that can be accessed through
359e39c5baSBill Taylor  *    the IBTF's CI interfaces.  In particular each of the prototypes defined
369e39c5baSBill Taylor  *    below is called from a corresponding CI interface routine (as specified
379e39c5baSBill Taylor  *    in the tavor_ci.c file).
389e39c5baSBill Taylor  */
399e39c5baSBill Taylor 
409e39c5baSBill Taylor #include <sys/types.h>
419e39c5baSBill Taylor #include <sys/conf.h>
429e39c5baSBill Taylor #include <sys/ddi.h>
439e39c5baSBill Taylor #include <sys/sunddi.h>
449e39c5baSBill Taylor 
459e39c5baSBill Taylor #ifdef __cplusplus
469e39c5baSBill Taylor extern "C" {
479e39c5baSBill Taylor #endif
489e39c5baSBill Taylor 
499e39c5baSBill Taylor /*
509e39c5baSBill Taylor  * The following defines specify the default number of MPT entries and their
519e39c5baSBill Taylor  * individual entry size.  Settings exist for the supported DDR DIMM sizes of
529e39c5baSBill Taylor  * 128MB and 256MB.  If a DIMM greater than 256 is found, then the 256MB
539e39c5baSBill Taylor  * profile is used.  See tavor_cfg.c for more discussion on config profiles.
549e39c5baSBill Taylor  *
559e39c5baSBill Taylor  * For manual configuration (not using config profiles), this value is
569e39c5baSBill Taylor  * controllable through the "tavor_log_num_mpt" configuration variable.  To
579e39c5baSBill Taylor  * override config profile settings the 'tavor_alt_config_enable' configuration
589e39c5baSBill Taylor  * variable must first be set.
599e39c5baSBill Taylor  */
609e39c5baSBill Taylor #define	TAVOR_NUM_MPT_SHIFT_128		0x14
619e39c5baSBill Taylor #define	TAVOR_NUM_MPT_SHIFT_256		0x15
629e39c5baSBill Taylor #define	TAVOR_MPT_SIZE_SHIFT		0x6
639e39c5baSBill Taylor #define	TAVOR_MPT_SIZE			(1 << TAVOR_MPT_SIZE_SHIFT)
649e39c5baSBill Taylor 
659e39c5baSBill Taylor /*
669e39c5baSBill Taylor  * Minimal configuration value.
679e39c5baSBill Taylor  */
689e39c5baSBill Taylor #define	TAVOR_NUM_MPT_SHIFT_MIN		0xD
699e39c5baSBill Taylor 
709e39c5baSBill Taylor /*
719e39c5baSBill Taylor  * The following defines specify the size of each individual MTT entry and
729e39c5baSBill Taylor  * the number of MTT entries that make up an MTT segment (TAVOR_MTTSEG_SIZE)
739e39c5baSBill Taylor  */
749e39c5baSBill Taylor #define	TAVOR_MTT_SIZE_SHIFT		0x3
759e39c5baSBill Taylor #define	TAVOR_MTT_SIZE			(1 << TAVOR_MTT_SIZE_SHIFT)
769e39c5baSBill Taylor #define	TAVOR_MTTSEG_SIZE_SHIFT		0x0
779e39c5baSBill Taylor #define	TAVOR_MTTSEG_SIZE		(8 << TAVOR_MTTSEG_SIZE_SHIFT)
789e39c5baSBill Taylor 
799e39c5baSBill Taylor /*
809e39c5baSBill Taylor  * These define the total number of MTT segments.  By default we are setting
819e39c5baSBill Taylor  * this number of MTT segments (the MTT table size) to 2M segments.  This
829e39c5baSBill Taylor  * default value is used to initialize the "tavor_log_num_mttseg" config
839e39c5baSBill Taylor  * variable.
849e39c5baSBill Taylor  * Note: Each segment is currently set to 8 MTT entries (TAVOR_MTTSEG_SIZE).
859e39c5baSBill Taylor  * This means that we can support up to 16M MTT entries (i.e. "pages").
869e39c5baSBill Taylor  */
879e39c5baSBill Taylor #define	TAVOR_NUM_MTTSEG_SHIFT		0x15
889e39c5baSBill Taylor #define	TAVOR_NUM_MTTSEG		(1 << TAVOR_NUM_MTTSEG_SHIFT)
899e39c5baSBill Taylor 
909e39c5baSBill Taylor /*
919e39c5baSBill Taylor  * Minimal configuration value.
929e39c5baSBill Taylor  */
939e39c5baSBill Taylor #define	TAVOR_NUM_MTTSEG_SHIFT_MIN	0x11
949e39c5baSBill Taylor 
959e39c5baSBill Taylor /*
969e39c5baSBill Taylor  * Macro to round a number of MTT entries to the number of MTT segments.
979e39c5baSBill Taylor  */
989e39c5baSBill Taylor #define	TAVOR_NUMMTT_TO_MTTSEG(num)		\
999e39c5baSBill Taylor 	(((num) + TAVOR_MTTSEG_SIZE - 1) >>	\
1009e39c5baSBill Taylor 	(TAVOR_MTTSEG_SIZE_SHIFT + TAVOR_MTT_SIZE_SHIFT))
1019e39c5baSBill Taylor 
1029e39c5baSBill Taylor /*
1039e39c5baSBill Taylor  * This define is used to specify the "MTT page walk version" in the Tavor
1049e39c5baSBill Taylor  * INIT_HCA command.
1059e39c5baSBill Taylor  */
1069e39c5baSBill Taylor #define	TAVOR_MTT_PG_WALK_VER		0
1079e39c5baSBill Taylor 
1089e39c5baSBill Taylor /*
1099e39c5baSBill Taylor  * This define is the maximum size of a memory region or window (log 2).  It is
1109e39c5baSBill Taylor  * set depending on size of the DDR being either 128MB or 256MB.  These defines
1119e39c5baSBill Taylor  * are used to initialize the "tavor_log_max_mrw_sz" configuration variable,
1129e39c5baSBill Taylor  * and are proportional to the max MPT size set above.
1139e39c5baSBill Taylor  */
1149e39c5baSBill Taylor #define	TAVOR_MAX_MEM_MPT_SHIFT_128		0x23
1159e39c5baSBill Taylor #define	TAVOR_MAX_MEM_MPT_SHIFT_256		0x24
1169e39c5baSBill Taylor 
1179e39c5baSBill Taylor /*
1189e39c5baSBill Taylor  * Minimal configuration value.
1199e39c5baSBill Taylor  */
1209e39c5baSBill Taylor #define	TAVOR_MAX_MEM_MPT_SHIFT_MIN		0x1E
1219e39c5baSBill Taylor 
1229e39c5baSBill Taylor /*
1239e39c5baSBill Taylor  * Defines used by tavor_mr_deregister() to specify how much/to what extent
1249e39c5baSBill Taylor  * a given memory regions resources should be freed up.  TAVOR_MR_DEREG_ALL
1259e39c5baSBill Taylor  * says what it means, free up all the resources associated with the region.
1269e39c5baSBill Taylor  * TAVOR_MR_DEREG_NO_HW2SW_MPT indicates that it is unnecessary to attempt
1279e39c5baSBill Taylor  * the ownership transfer (from hardware to software) for the given MPT entry.
1289e39c5baSBill Taylor  * And TAVOR_MR_DEREG_NO_HW2SW_MPT_OR_UNBIND indicates that it is not only
1299e39c5baSBill Taylor  * unnecessary to attempt the ownership transfer for MPT, but it is also
1309e39c5baSBill Taylor  * unnecessary to attempt to unbind the memory.
1319e39c5baSBill Taylor  * In general, these last two are specified when tavor_mr_deregister() is
1329e39c5baSBill Taylor  * called from tavor_mr_reregister(), where the MPT ownership transfer or
1339e39c5baSBill Taylor  * memory unbinding may have already been successfully performed.
1349e39c5baSBill Taylor  */
1359e39c5baSBill Taylor #define	TAVOR_MR_DEREG_ALL			3
1369e39c5baSBill Taylor #define	TAVOR_MR_DEREG_NO_HW2SW_MPT		2
1379e39c5baSBill Taylor #define	TAVOR_MR_DEREG_NO_HW2SW_MPT_OR_UNBIND	1
1389e39c5baSBill Taylor 
1399e39c5baSBill Taylor /*
1409e39c5baSBill Taylor  * The following define is used by tavor_mr_rereg_xlat_helper() to determine
1419e39c5baSBill Taylor  * whether or not a given DMA handle can be reused.  If the DMA handle was
1429e39c5baSBill Taylor  * previously initialized for IOMMU bypass mapping, then it can not be reused
1439e39c5baSBill Taylor  * to reregister a region for DDI_DMA_STREAMING access.
1449e39c5baSBill Taylor  */
1459e39c5baSBill Taylor #define	TAVOR_MR_REUSE_DMAHDL(mr, flags)				\
1469e39c5baSBill Taylor 	(((mr)->mr_bindinfo.bi_bypass != TAVOR_BINDMEM_BYPASS) ||	\
1479e39c5baSBill Taylor 	    !((flags) & IBT_MR_NONCOHERENT))
1489e39c5baSBill Taylor 
1499e39c5baSBill Taylor /*
1509e39c5baSBill Taylor  * The tavor_sw_refcnt_t structure is used internally by the Tavor driver to
1519e39c5baSBill Taylor  * track all the information necessary to manage shared memory regions.  Since
1529e39c5baSBill Taylor  * a shared memory region _will_ have its own distinct MPT entry, but will
1539e39c5baSBill Taylor  * _share_ its MTT entries with another region, it is necessary to track the
1549e39c5baSBill Taylor  * number of times a given MTT structure is shared.  This ensures that it will
1559e39c5baSBill Taylor  * not be prematurely freed up and that can be destroyed only when it is
1569e39c5baSBill Taylor  * appropriate to do so.
1579e39c5baSBill Taylor  *
1589e39c5baSBill Taylor  * Each tavor_sw_refcnt_t structure contains a lock and a reference count
1599e39c5baSBill Taylor  * variable which are used to track the necessary information.
1609e39c5baSBill Taylor  *
1619e39c5baSBill Taylor  * The following macros (below) are used to manipulate and query the MTT
1629e39c5baSBill Taylor  * reference count parameters.  TAVOR_MTT_REFCNT_INIT() is used to initialize
1639e39c5baSBill Taylor  * a newly allocated tavor_sw_refcnt_t struct (setting the "swrc_refcnt" to 1).
1649e39c5baSBill Taylor  * And the TAVOR_MTT_IS_NOT_SHARED() and TAVOR_MTT_IS_SHARED() macros are
1659e39c5baSBill Taylor  * used to query the current status of tavor_sw_refcnt_t struct to determine
1669e39c5baSBill Taylor  * if its "swrc_refcnt" is one or not.
1679e39c5baSBill Taylor  */
1689e39c5baSBill Taylor typedef struct tavor_sw_refcnt_s {
1699e39c5baSBill Taylor 	kmutex_t		swrc_lock;
1709e39c5baSBill Taylor 	uint_t			swrc_refcnt;
1719e39c5baSBill Taylor } tavor_sw_refcnt_t;
1729e39c5baSBill Taylor _NOTE(DATA_READABLE_WITHOUT_LOCK(tavor_sw_refcnt_t::swrc_refcnt))
1739e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_refcnt_t::swrc_lock,
1749e39c5baSBill Taylor     tavor_sw_refcnt_t::swrc_refcnt))
1759e39c5baSBill Taylor #define	TAVOR_MTT_REFCNT_INIT(swrc_tmp)		((swrc_tmp)->swrc_refcnt = 1)
1769e39c5baSBill Taylor #define	TAVOR_MTT_IS_NOT_SHARED(swrc_tmp)	((swrc_tmp)->swrc_refcnt == 1)
1779e39c5baSBill Taylor #define	TAVOR_MTT_IS_SHARED(swrc_tmp)		((swrc_tmp)->swrc_refcnt != 1)
1789e39c5baSBill Taylor 
1799e39c5baSBill Taylor 
1809e39c5baSBill Taylor /*
1819e39c5baSBill Taylor  * The tavor_bind_info_t structure is used internally by the Tavor driver to
1829e39c5baSBill Taylor  * track all the information necessary to perform the DMA mappings necessary
1839e39c5baSBill Taylor  * for memory registration.  It is specifically passed into both the
1849e39c5baSBill Taylor  * tavor_mr_mem_bind() and tavor_mr_mtt_write() functions which perform most
1859e39c5baSBill Taylor  * of the necessary operations for Tavor memory registration.
1869e39c5baSBill Taylor  *
1879e39c5baSBill Taylor  * This structure is used to pass all the information necessary for a call
1889e39c5baSBill Taylor  * to either ddi_dma_addr_bind_handle() or ddi_dma_buf_bind_handle().  Note:
1899e39c5baSBill Taylor  * the fields which need to be valid for each type of binding are slightly
1909e39c5baSBill Taylor  * different and that it indicated by the value in the "bi_type" field.  The
1919e39c5baSBill Taylor  * "bi_type" field may be set to either of the following defined values:
1929e39c5baSBill Taylor  * TAVOR_BINDHDL_VADDR (to indicate an "addr" bind) or TAVOR_BINDHDL_BUF (to
1939e39c5baSBill Taylor  * indicate a "buf" bind).
1949e39c5baSBill Taylor  *
1959e39c5baSBill Taylor  * Upon return from tavor_mr_mem_bind(), the tavor_bind_info_t struct will
1969e39c5baSBill Taylor  * have its "bi_dmahdl", "bi_dmacookie", and "bi_cookiecnt" fields filled in.
1979e39c5baSBill Taylor  * It is these values which are of particular interest to the
1989e39c5baSBill Taylor  * tavor_mr_mtt_write() routine (they hold the PCI mapped addresses).
1999e39c5baSBill Taylor  *
2009e39c5baSBill Taylor  * Once initialized and used in this way, the tavor_bind_info_t will not to be
2019e39c5baSBill Taylor  * modified in anyway until it is subsequently passed to tavor_mr_mem_unbind()
2029e39c5baSBill Taylor  * where the memory and resources will be unbound and reclaimed.  Note:  the
2039e39c5baSBill Taylor  * "bi_free_dmahdl" flag indicated whether the ddi_dma_handle_t should be
2049e39c5baSBill Taylor  * freed as part of the tavor_mr_mem_unbind() operation or whether it will
2059e39c5baSBill Taylor  * be freed later elsewhere.
2069e39c5baSBill Taylor  */
2079e39c5baSBill Taylor typedef struct tavor_bind_info_s {
2089e39c5baSBill Taylor 	uint64_t		bi_addr;
2099e39c5baSBill Taylor 	uint64_t		bi_len;
2109e39c5baSBill Taylor 	struct as		*bi_as;
2119e39c5baSBill Taylor 	struct buf		*bi_buf;
2129e39c5baSBill Taylor 	ddi_dma_handle_t	bi_dmahdl;
2139e39c5baSBill Taylor 	ddi_dma_cookie_t	bi_dmacookie;
2149e39c5baSBill Taylor 	uint_t			bi_cookiecnt;
2159e39c5baSBill Taylor 	uint_t			bi_type;
2169e39c5baSBill Taylor 	uint_t			bi_flags;
2179e39c5baSBill Taylor 	uint_t			bi_bypass;
2189e39c5baSBill Taylor 	uint_t			bi_free_dmahdl;
2199e39c5baSBill Taylor } tavor_bind_info_t;
2209e39c5baSBill Taylor #define	TAVOR_BINDHDL_NONE		0
2219e39c5baSBill Taylor #define	TAVOR_BINDHDL_VADDR		1
2229e39c5baSBill Taylor #define	TAVOR_BINDHDL_BUF		2
2239e39c5baSBill Taylor #define	TAVOR_BINDHDL_UBUF		3
2249e39c5baSBill Taylor 
2259e39c5baSBill Taylor /*
2269e39c5baSBill Taylor  * The tavor_sw_mr_s structure is also referred to using the "tavor_mrhdl_t"
2279e39c5baSBill Taylor  * typedef (see tavor_typedef.h).  It encodes all the information necessary
2289e39c5baSBill Taylor  * to track the various resources needed to register, reregister, deregister,
2299e39c5baSBill Taylor  * and perform all the myriad other operations on both memory regions _and_
2309e39c5baSBill Taylor  * memory windows.
2319e39c5baSBill Taylor  *
2329e39c5baSBill Taylor  * A pointer to this structure is returned from many of the IBTF's CI verbs
2339e39c5baSBill Taylor  * interfaces for memory registration.
2349e39c5baSBill Taylor  *
2359e39c5baSBill Taylor  * It contains pointers to the various resources allocated for a memory
2369e39c5baSBill Taylor  * region, i.e. MPT resource, MTT resource, and MTT reference count resource.
2379e39c5baSBill Taylor  * In addition it contains the tavor_bind_info_t struct used for the memory
2389e39c5baSBill Taylor  * bind operation on a given memory region.
2399e39c5baSBill Taylor  *
2409e39c5baSBill Taylor  * It also has a pointers to the associated PD handle, placeholders for access
2419e39c5baSBill Taylor  * flags, memory keys, and suggested page size for the region.  It also has
2429e39c5baSBill Taylor  * the necessary backpointer to the resource that corresponds to the structure
2439e39c5baSBill Taylor  * itself.  And lastly, it contains a placeholder for a callback which should
2449e39c5baSBill Taylor  * be called on memory region unpinning.
2459e39c5baSBill Taylor  */
2469e39c5baSBill Taylor struct tavor_sw_mr_s {
2479e39c5baSBill Taylor 	kmutex_t		mr_lock;
2489e39c5baSBill Taylor 	tavor_rsrc_t		*mr_mptrsrcp;
2499e39c5baSBill Taylor 	tavor_rsrc_t		*mr_mttrsrcp;
2509e39c5baSBill Taylor 	tavor_rsrc_t		*mr_mttrefcntp;
2519e39c5baSBill Taylor 	tavor_pdhdl_t		mr_pdhdl;
2529e39c5baSBill Taylor 	tavor_bind_info_t	mr_bindinfo;
2539e39c5baSBill Taylor 	ibt_mr_attr_flags_t	mr_accflag;
2549e39c5baSBill Taylor 	uint32_t		mr_lkey;
2559e39c5baSBill Taylor 	uint32_t		mr_rkey;
2569e39c5baSBill Taylor 	uint32_t		mr_logmttpgsz;
2579e39c5baSBill Taylor 	tavor_rsrc_t		*mr_rsrcp;
2589e39c5baSBill Taylor 	uint_t			mr_is_umem;
2599e39c5baSBill Taylor 	ddi_umem_cookie_t	mr_umemcookie;
2609e39c5baSBill Taylor 	void 			(*mr_umem_cbfunc)(void *, void *);
2619e39c5baSBill Taylor 	void			*mr_umem_cbarg1;
2629e39c5baSBill Taylor 	void			*mr_umem_cbarg2;
2639e39c5baSBill Taylor };
2649e39c5baSBill Taylor _NOTE(DATA_READABLE_WITHOUT_LOCK(tavor_sw_mr_s::mr_bindinfo
2659e39c5baSBill Taylor     tavor_sw_mr_s::mr_lkey
266c7facc54SBill Taylor     tavor_sw_mr_s::mr_is_umem))
2679e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_mr_s::mr_lock,
2689e39c5baSBill Taylor     tavor_sw_mr_s::mr_mptrsrcp
2699e39c5baSBill Taylor     tavor_sw_mr_s::mr_mttrsrcp
2709e39c5baSBill Taylor     tavor_sw_mr_s::mr_mttrefcntp
2719e39c5baSBill Taylor     tavor_sw_mr_s::mr_bindinfo
2729e39c5baSBill Taylor     tavor_sw_mr_s::mr_lkey
2739e39c5baSBill Taylor     tavor_sw_mr_s::mr_rkey
2749e39c5baSBill Taylor     tavor_sw_mr_s::mr_logmttpgsz
2759e39c5baSBill Taylor     tavor_sw_mr_s::mr_rsrcp
2769e39c5baSBill Taylor     tavor_sw_mr_s::mr_is_umem
2779e39c5baSBill Taylor     tavor_sw_mr_s::mr_umemcookie
2789e39c5baSBill Taylor     tavor_sw_mr_s::mr_umem_cbfunc
2799e39c5baSBill Taylor     tavor_sw_mr_s::mr_umem_cbarg1
2809e39c5baSBill Taylor     tavor_sw_mr_s::mr_umem_cbarg2))
2819e39c5baSBill Taylor 
2829e39c5baSBill Taylor /*
2839e39c5baSBill Taylor  * The tavor_mr_options_t structure is used in several of the Tavor memory
2849e39c5baSBill Taylor  * registration routines to provide additional option functionality.  When
2859e39c5baSBill Taylor  * a NULL pointer is passed in place of a pointer to this struct, it is a
2869e39c5baSBill Taylor  * way of specifying the "default" behavior.  Using this structure, however,
2879e39c5baSBill Taylor  * is a way of controlling any extended behavior.
2889e39c5baSBill Taylor  *
2899e39c5baSBill Taylor  * Currently, the only defined "extended" behaviors are for specifying whether
2909e39c5baSBill Taylor  * a given memory region should bypass the PCI IOMMU (TAVOR_BINDMEM_BYPASS)
2919e39c5baSBill Taylor  * or be mapped into the IOMMU (TAVOR_BINDMEM_NORMAL), for specifying whether
2929e39c5baSBill Taylor  * a given ddi_dma_handle_t should be used in the bind operation, and for
2939e39c5baSBill Taylor  * specifying whether a memory registration should attempt to return an IB
2949e39c5baSBill Taylor  * vaddr which is "zero-based" (aids in alignment contraints for QPs).
2959e39c5baSBill Taylor  *
2969e39c5baSBill Taylor  * This defaults today to always bypassing the IOMMU (can be changed by using
2979e39c5baSBill Taylor  * the "tavor_iommu_bypass" configuration variable), to always allocating
2989e39c5baSBill Taylor  * a new dma handle, and to using the virtual address passed in (i.e. not
2999e39c5baSBill Taylor  * "zero-based").
3009e39c5baSBill Taylor  */
3019e39c5baSBill Taylor typedef struct tavor_mr_options_s {
3029e39c5baSBill Taylor 	ddi_dma_handle_t	mro_bind_dmahdl;
3039e39c5baSBill Taylor 	uint_t			mro_bind_type;
3049e39c5baSBill Taylor 	uint_t			mro_bind_override_addr;
3059e39c5baSBill Taylor } tavor_mr_options_t;
3069e39c5baSBill Taylor #define	TAVOR_BINDMEM_NORMAL		1
3079e39c5baSBill Taylor #define	TAVOR_BINDMEM_BYPASS		0
3089e39c5baSBill Taylor 
309*17a2b317SBill Taylor int tavor_dma_mr_register(tavor_state_t *state, tavor_pdhdl_t pdhdl,
310*17a2b317SBill Taylor     ibt_dmr_attr_t *attr_p, tavor_mrhdl_t *mrhdl);
3119e39c5baSBill Taylor int tavor_mr_register(tavor_state_t *state, tavor_pdhdl_t pdhdl,
3129e39c5baSBill Taylor     ibt_mr_attr_t *attr_p, tavor_mrhdl_t *mrhdl, tavor_mr_options_t *op);
3139e39c5baSBill Taylor int tavor_mr_register_buf(tavor_state_t *state, tavor_pdhdl_t pdhdl,
3149e39c5baSBill Taylor     ibt_smr_attr_t *attrp, struct buf *buf, tavor_mrhdl_t *mrhdl,
3159e39c5baSBill Taylor     tavor_mr_options_t *op);
3169e39c5baSBill Taylor int tavor_mr_mtt_bind(tavor_state_t *state, tavor_bind_info_t *bind,
3179e39c5baSBill Taylor     ddi_dma_handle_t bind_dmahdl, tavor_rsrc_t **mtt, uint_t *mtt_pgsz_bits);
3189e39c5baSBill Taylor int tavor_mr_mtt_unbind(tavor_state_t *state, tavor_bind_info_t *bind,
3199e39c5baSBill Taylor     tavor_rsrc_t *mtt);
3209e39c5baSBill Taylor int tavor_mr_register_shared(tavor_state_t *state, tavor_mrhdl_t mrhdl,
3219e39c5baSBill Taylor     tavor_pdhdl_t pdhdl, ibt_smr_attr_t *attr_p, tavor_mrhdl_t *mrhdl_new);
3229e39c5baSBill Taylor int tavor_mr_deregister(tavor_state_t *state, tavor_mrhdl_t *mrhdl,
3239e39c5baSBill Taylor     uint_t level, uint_t sleep);
3249e39c5baSBill Taylor int tavor_mr_query(tavor_state_t *state, tavor_mrhdl_t mrhdl,
3259e39c5baSBill Taylor     ibt_mr_query_attr_t *attr);
3269e39c5baSBill Taylor int tavor_mr_reregister(tavor_state_t *state, tavor_mrhdl_t mrhdl,
3279e39c5baSBill Taylor     tavor_pdhdl_t pdhdl, ibt_mr_attr_t *attr_p, tavor_mrhdl_t *mrhdl_new,
3289e39c5baSBill Taylor     tavor_mr_options_t *op);
3299e39c5baSBill Taylor int tavor_mr_reregister_buf(tavor_state_t *state, tavor_mrhdl_t mr,
3309e39c5baSBill Taylor     tavor_pdhdl_t pd, ibt_smr_attr_t *mr_attr, struct buf *buf,
3319e39c5baSBill Taylor     tavor_mrhdl_t *mrhdl_new, tavor_mr_options_t *op);
3329e39c5baSBill Taylor int tavor_mr_sync(tavor_state_t *state, ibt_mr_sync_t *mr_segs,
3339e39c5baSBill Taylor     size_t num_segs);
3349e39c5baSBill Taylor int tavor_mw_alloc(tavor_state_t *state, tavor_pdhdl_t pdhdl,
3359e39c5baSBill Taylor     ibt_mw_flags_t flags, tavor_mwhdl_t *mwhdl);
3369e39c5baSBill Taylor int tavor_mw_free(tavor_state_t *state, tavor_mwhdl_t *mwhdl, uint_t sleep);
3379e39c5baSBill Taylor void tavor_mr_keycalc(tavor_state_t *state, uint32_t indx, uint32_t *key);
3389e39c5baSBill Taylor 
3399e39c5baSBill Taylor #ifdef __cplusplus
3409e39c5baSBill Taylor }
3419e39c5baSBill Taylor #endif
3429e39c5baSBill Taylor 
3439e39c5baSBill Taylor #endif	/* _SYS_IB_ADAPTERS_TAVOR_MR_H */
344