xref: /onnv-gate/usr/src/uts/common/sys/ib/adapters/hermon/hermon_misc.h (revision 12965:b65a8427f8fe)
19517SBill.Taylor@Sun.COM /*
29517SBill.Taylor@Sun.COM  * CDDL HEADER START
39517SBill.Taylor@Sun.COM  *
49517SBill.Taylor@Sun.COM  * The contents of this file are subject to the terms of the
59517SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
69517SBill.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
79517SBill.Taylor@Sun.COM  *
89517SBill.Taylor@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99517SBill.Taylor@Sun.COM  * or http://www.opensolaris.org/os/licensing.
109517SBill.Taylor@Sun.COM  * See the License for the specific language governing permissions
119517SBill.Taylor@Sun.COM  * and limitations under the License.
129517SBill.Taylor@Sun.COM  *
139517SBill.Taylor@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
149517SBill.Taylor@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159517SBill.Taylor@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
169517SBill.Taylor@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
179517SBill.Taylor@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
189517SBill.Taylor@Sun.COM  *
199517SBill.Taylor@Sun.COM  * CDDL HEADER END
209517SBill.Taylor@Sun.COM  */
219517SBill.Taylor@Sun.COM 
229517SBill.Taylor@Sun.COM /*
23*12965SWilliam.Taylor@Oracle.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249517SBill.Taylor@Sun.COM  */
259517SBill.Taylor@Sun.COM 
269517SBill.Taylor@Sun.COM #ifndef	_SYS_IB_ADAPTERS_HERMON_MISC_H
279517SBill.Taylor@Sun.COM #define	_SYS_IB_ADAPTERS_HERMON_MISC_H
289517SBill.Taylor@Sun.COM 
299517SBill.Taylor@Sun.COM /*
309517SBill.Taylor@Sun.COM  * hermon_misc.h
319517SBill.Taylor@Sun.COM  *    Contains all of the prototypes, #defines, and structures necessary
329517SBill.Taylor@Sun.COM  *    for the Hermon Miscellaneous routines - Address Handle, Multicast,
339517SBill.Taylor@Sun.COM  *    Protection Domain, port-related, statistics (kstat) routines, and
349517SBill.Taylor@Sun.COM  *    extra VTS related routines.
359517SBill.Taylor@Sun.COM  *    Many of these functions are called by other parts of the Hermon driver
369517SBill.Taylor@Sun.COM  *    (and several routines are directly exposed through the IBTF CI
379517SBill.Taylor@Sun.COM  *    interface and/or kstat interface).
389517SBill.Taylor@Sun.COM  */
399517SBill.Taylor@Sun.COM 
409517SBill.Taylor@Sun.COM #include <sys/types.h>
419517SBill.Taylor@Sun.COM #include <sys/conf.h>
429517SBill.Taylor@Sun.COM #include <sys/ddi.h>
439517SBill.Taylor@Sun.COM #include <sys/sunddi.h>
449517SBill.Taylor@Sun.COM 
459517SBill.Taylor@Sun.COM #include <sys/ib/adapters/hermon/hermon_typedef.h>
469517SBill.Taylor@Sun.COM #include <sys/ib/adapters/hermon/hermon_ioctl.h>
479517SBill.Taylor@Sun.COM #include <sys/ib/adapters/hermon/hermon_rsrc.h>
489517SBill.Taylor@Sun.COM #include <sys/ib/adapters/hermon/hermon_hw.h>
499517SBill.Taylor@Sun.COM 
509517SBill.Taylor@Sun.COM 
519517SBill.Taylor@Sun.COM #ifdef __cplusplus
529517SBill.Taylor@Sun.COM extern "C" {
539517SBill.Taylor@Sun.COM #endif
549517SBill.Taylor@Sun.COM 
559517SBill.Taylor@Sun.COM /*
569517SBill.Taylor@Sun.COM  * The following defines specify the default number of Address Handles (AH)
579517SBill.Taylor@Sun.COM  * and their size (in the hardware).  By default the maximum number of address
589517SBill.Taylor@Sun.COM  * handles is set to 32K.  This value is controllable through the
599517SBill.Taylor@Sun.COM  * "hermon_log_num_ah" configuration variable.  Note:  Hermon Address Handles
609517SBill.Taylor@Sun.COM  * are also referred to as UD Address Vectors (UDAV).
619517SBill.Taylor@Sun.COM  */
629517SBill.Taylor@Sun.COM #define	HERMON_NUM_AH_SHIFT		0xF
639517SBill.Taylor@Sun.COM #define	HERMON_NUM_AH			(1 << HERMON_NUM_AH_SHIFT)
649517SBill.Taylor@Sun.COM #define	HERMON_UDAV_SIZE_SHIFT		0x5
659517SBill.Taylor@Sun.COM #define	HERMON_UDAV_SIZE			(1 << HERMON_UDAV_SIZE_SHIFT)
669517SBill.Taylor@Sun.COM 
679517SBill.Taylor@Sun.COM /*
689517SBill.Taylor@Sun.COM  * The following macro determines whether the contents of a UDAV need to be
699517SBill.Taylor@Sun.COM  * sync'd (with ddi_dma_sync()).  This decision is based on whether the
709517SBill.Taylor@Sun.COM  * UDAV is in DDR memory (no sync) or system memory (sync required).
719517SBill.Taylor@Sun.COM  */
729517SBill.Taylor@Sun.COM 
739517SBill.Taylor@Sun.COM #define	HERMON_UDAV_IS_SYNC_REQ(state)					\
749517SBill.Taylor@Sun.COM 	(((&((state)->ts_rsrc_hdl[HERMON_UDAV]))->rsrc_loc ==		\
759517SBill.Taylor@Sun.COM 	HERMON_IN_DDR) ? 0 : 1)
769517SBill.Taylor@Sun.COM 
779517SBill.Taylor@Sun.COM /*
789517SBill.Taylor@Sun.COM  * These defines are used by hermon_get_addr_path() and hermon_set_addr_path()
799517SBill.Taylor@Sun.COM  * below.  They indicate the type of hardware context being passed in the
809517SBill.Taylor@Sun.COM  * "path" argument.  Because the Hermon hardware formats for the QP address
819517SBill.Taylor@Sun.COM  * path and UDAV address path structures is so similar, but not exactly the
829517SBill.Taylor@Sun.COM  * same, we use these flags to indicate which type of structure is being
839517SBill.Taylor@Sun.COM  * read from or written to.
849517SBill.Taylor@Sun.COM  */
859517SBill.Taylor@Sun.COM #define	HERMON_ADDRPATH_QP		0x0
869517SBill.Taylor@Sun.COM #define	HERMON_ADDRPATH_UDAV		0x1
879517SBill.Taylor@Sun.COM 
889517SBill.Taylor@Sun.COM /*
899517SBill.Taylor@Sun.COM  * The following defines specify the default number of Multicast Groups (MCG)
909517SBill.Taylor@Sun.COM  * and the maximum number of QP which can be associated with each.  By default
919517SBill.Taylor@Sun.COM  * the maximum number of multicast groups is set to 256, and the maximum number
9210009SGiri.Adari@Sun.COM  * of QP per multicast group is set to 248 (256 4-byte slots minus the 8 slots
9310009SGiri.Adari@Sun.COM  * in the header).  The first of these values is controllable through the
9410009SGiri.Adari@Sun.COM  * "hermon_log_num_mcg" configuration variable.  "hermon_num_qp_per_mcg" is
9510009SGiri.Adari@Sun.COM  * also available if the customer needs such a large capability.
969517SBill.Taylor@Sun.COM  */
9710009SGiri.Adari@Sun.COM #define	HERMON_NUM_MCG_SHIFT		0x8
9810009SGiri.Adari@Sun.COM #define	HERMON_NUM_QP_PER_MCG_MIN	0x8
9910009SGiri.Adari@Sun.COM #define	HERMON_NUM_QP_PER_MCG		0xf8
1009517SBill.Taylor@Sun.COM 
10110009SGiri.Adari@Sun.COM #define	HERMON_MCGMEM_SZ(state)						\
10210009SGiri.Adari@Sun.COM 	((((state)->hs_cfg_profile->cp_num_qp_per_mcg) + 8) << 2)
1039517SBill.Taylor@Sun.COM 
1049517SBill.Taylor@Sun.COM /*
1059517SBill.Taylor@Sun.COM  * Macro to compute the offset of the QP list in a given MCG entry.
1069517SBill.Taylor@Sun.COM  */
1079517SBill.Taylor@Sun.COM #define	HERMON_MCG_GET_QPLIST_PTR(mcg)					\
1089517SBill.Taylor@Sun.COM 	((hermon_hw_mcg_qp_list_t *)((uintptr_t)(mcg) +			\
1099517SBill.Taylor@Sun.COM 	sizeof (hermon_hw_mcg_t)))
1109517SBill.Taylor@Sun.COM 
1119517SBill.Taylor@Sun.COM /*
1129517SBill.Taylor@Sun.COM  * The following defines specify the characteristics of the Hermon multicast
1139517SBill.Taylor@Sun.COM  * group hash table.  The HERMON_NUM_MCG_HASH_SHIFT defines the size of the
1149517SBill.Taylor@Sun.COM  * hash table (as a power-of-2), which is set to 16 by default.  This value
1159517SBill.Taylor@Sun.COM  * is controllable through the "hermon_log_num_mcg_hash" configuration variable,
1169517SBill.Taylor@Sun.COM  * but serious consideration should be taken before changing this value.  Note:
1179517SBill.Taylor@Sun.COM  * its appropriate size should be a function of the entire table size (as
1189517SBill.Taylor@Sun.COM  * defined by "hermon_log_num_mcg" and HERMON_NUM_MCG_SHIFT above).
1199517SBill.Taylor@Sun.COM  */
1209517SBill.Taylor@Sun.COM #define	HERMON_NUM_MCG_HASH_SHIFT	0x4
1219517SBill.Taylor@Sun.COM 
1229517SBill.Taylor@Sun.COM /*
1239517SBill.Taylor@Sun.COM  * The following defines are used by the multicast routines to determine
1249517SBill.Taylor@Sun.COM  * if a given "multicast GID" is valid or not (see hermon_mcg_is_mgid_valid
1259517SBill.Taylor@Sun.COM  * for more details.  These values are pulled from the IBA specification,
1269517SBill.Taylor@Sun.COM  * rev. 1.1
1279517SBill.Taylor@Sun.COM  */
1289517SBill.Taylor@Sun.COM #define	HERMON_MCG_TOPBITS_SHIFT	56
1299517SBill.Taylor@Sun.COM #define	HERMON_MCG_TOPBITS_MASK		0xFF
1309517SBill.Taylor@Sun.COM #define	HERMON_MCG_TOPBITS		0xFF
1319517SBill.Taylor@Sun.COM 
1329517SBill.Taylor@Sun.COM #define	HERMON_MCG_FLAGS_SHIFT		52
1339517SBill.Taylor@Sun.COM #define	HERMON_MCG_FLAGS_MASK		0xF
1349517SBill.Taylor@Sun.COM #define	HERMON_MCG_FLAGS_PERM		0x0
1359517SBill.Taylor@Sun.COM #define	HERMON_MCG_FLAGS_NONPERM	0x1
1369517SBill.Taylor@Sun.COM 
1379517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_SHIFT		48
1389517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_MASK		0xF
1399517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_LINKLOC	0x2
1409517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_SITELOC	0x5
1419517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_ORGLOC		0x8
1429517SBill.Taylor@Sun.COM #define	HERMON_MCG_SCOPE_GLOBAL		0xE
1439517SBill.Taylor@Sun.COM 
1449517SBill.Taylor@Sun.COM 
1459517SBill.Taylor@Sun.COM /*
1469517SBill.Taylor@Sun.COM  * The following defines specify the default number of Protection Domains (PD).
1479517SBill.Taylor@Sun.COM  * By default the maximum number of protection domains is set to 64K.  This
1489517SBill.Taylor@Sun.COM  * value is controllable through the "hermon_log_num_pd" configuration variable.
1499517SBill.Taylor@Sun.COM  */
1509517SBill.Taylor@Sun.COM #define	HERMON_NUM_PD_SHIFT		0x10
1519517SBill.Taylor@Sun.COM 
1529517SBill.Taylor@Sun.COM /*
1539517SBill.Taylor@Sun.COM  * The following defines specify the default number of Partition Keys (PKey)
1549517SBill.Taylor@Sun.COM  * per port.  By default the maximum number of PKeys is set to 32 per port, for
1559517SBill.Taylor@Sun.COM  * a total of 64 (assuming two ports) .  This value is controllable through the
1569517SBill.Taylor@Sun.COM  * "hermon_log_max_pkeytbl" configuration variable.
1579517SBill.Taylor@Sun.COM  */
1589517SBill.Taylor@Sun.COM #define	HERMON_NUM_PKEYTBL_SHIFT		0x5
1599517SBill.Taylor@Sun.COM #define	HERMON_NUM_PKEYTBL		(1 << HERMON_NUM_PKEYTBL_SHIFT)
1609517SBill.Taylor@Sun.COM 
1619517SBill.Taylor@Sun.COM /*
1629517SBill.Taylor@Sun.COM  * The following defines specify the default number of SGIDs per port.  By
1639517SBill.Taylor@Sun.COM  * default the maximum number of GIDS per port is set to 16.  This value
1649517SBill.Taylor@Sun.COM  * is controllable through the "hermon_log_max_gidtbl" configuration variable.
1659517SBill.Taylor@Sun.COM  */
1669517SBill.Taylor@Sun.COM #define	HERMON_NUM_GIDTBL_SHIFT		0x4
1679517SBill.Taylor@Sun.COM #define	HERMON_NUM_GIDTBL		(1 << HERMON_NUM_GIDTBL_SHIFT)
1689517SBill.Taylor@Sun.COM 
1699517SBill.Taylor@Sun.COM /*
1709517SBill.Taylor@Sun.COM  * Below is a define which is the default number of UAR pages.  By default, the
1719517SBill.Taylor@Sun.COM  * maximum number of UAR pages is set to 1024 for hermon.  Note that
1729517SBill.Taylor@Sun.COM  * BlueFlame (if enabled) will  take 1/2 the space behind BAR1 (the UAR BAR)
1739517SBill.Taylor@Sun.COM  * and therefore we must limit this even further.  This value is controllable
1749517SBill.Taylor@Sun.COM  * through the "hermon_log_num_uar" configuration variable. NOTE: This value
1759517SBill.Taylor@Sun.COM  * should not be set larger than 15 (0xF) because the UAR index number is
1769517SBill.Taylor@Sun.COM  * used as part of the minor number calculation (see hermon_open() for details)
1779517SBill.Taylor@Sun.COM  * and the minor numbers should not be larger than eighteen bits (i.e. 15 bits
1789517SBill.Taylor@Sun.COM  * of UAR index, 3 bits of driver instance number).  This is especially true
1799517SBill.Taylor@Sun.COM  * for 32-bit kernels.
1809517SBill.Taylor@Sun.COM  */
1819517SBill.Taylor@Sun.COM #define	HERMON_NUM_UAR_SHIFT		0xA
1829517SBill.Taylor@Sun.COM 
1839517SBill.Taylor@Sun.COM /*
1849517SBill.Taylor@Sun.COM  * A DoorBell record (DBr) will be handled uniquely.  They are not in ICM now,
1859517SBill.Taylor@Sun.COM  * so they don't need the mapping.  And they just need to be accessible to the
1869517SBill.Taylor@Sun.COM  * HCA as an address, so we don't need to register the memory.  AND, since
1879517SBill.Taylor@Sun.COM  * user level (uDAPL, OPEN verbs) won't ever do the unmapping of them we don't
1889517SBill.Taylor@Sun.COM  * really need to worry about that either.  And the DBrs will have to live in
1899517SBill.Taylor@Sun.COM  * user mappable memory.  So, we can shortcut a lot of things given these
1909517SBill.Taylor@Sun.COM  * assumptions.
1919517SBill.Taylor@Sun.COM  *
1929517SBill.Taylor@Sun.COM  * Other facts:  the DBrs for Hermon are only two per qp - one for the Receive
1939517SBill.Taylor@Sun.COM  * side (RQ or SRQ) and one for the CQ.  If a QP is associated with an SRQ, we
1949517SBill.Taylor@Sun.COM  * only need the ONE for the SRQ.  Also, although the RQ/SRQ DBr is only 4-bytes
1959517SBill.Taylor@Sun.COM  * while the CQ DBr is 8-bytes, all DBrs will be 8-bytes (see the union below).
1969517SBill.Taylor@Sun.COM  * Though it may lead to minor wastage, it also means that reuse is easier since
1979517SBill.Taylor@Sun.COM  * any DBr can be used for either, and we don't have to play allocation games.
1989517SBill.Taylor@Sun.COM  *
19910027SGiri.Adari@Sun.COM  * The state structure will hold the pointer to the start of a list of struct
20010027SGiri.Adari@Sun.COM  * hermon_dbr_info_s, each one containing the necessary information to manage
20110027SGiri.Adari@Sun.COM  * a page of DBr's.
2029517SBill.Taylor@Sun.COM  */
2039517SBill.Taylor@Sun.COM 
2049517SBill.Taylor@Sun.COM typedef uint64_t hermon_dbr_t;
2059517SBill.Taylor@Sun.COM 
2069517SBill.Taylor@Sun.COM typedef struct hermon_dbr_info_s {
20710027SGiri.Adari@Sun.COM 	struct hermon_dbr_info_s *dbr_link;
20810027SGiri.Adari@Sun.COM 	hermon_dbr_t		*dbr_page;	/* virtual addr of page */
20910027SGiri.Adari@Sun.COM 	uint64_t		dbr_paddr;	/* physical addr of page */
2109517SBill.Taylor@Sun.COM 	ddi_acc_handle_t	dbr_acchdl;
2119517SBill.Taylor@Sun.COM 	ddi_dma_handle_t	dbr_dmahdl;
21210027SGiri.Adari@Sun.COM 	uint32_t		dbr_nfree;	/* #free DBrs in this page */
21310027SGiri.Adari@Sun.COM 	uint32_t		dbr_firstfree;	/* idx of first free DBr */
2149517SBill.Taylor@Sun.COM } hermon_dbr_info_t;
2159517SBill.Taylor@Sun.COM 
21610027SGiri.Adari@Sun.COM #define	HERMON_NUM_DBR_PER_PAGE	(PAGESIZE / sizeof (hermon_dbr_t))
2179517SBill.Taylor@Sun.COM 
2189517SBill.Taylor@Sun.COM 
2199517SBill.Taylor@Sun.COM /*
2209517SBill.Taylor@Sun.COM  * These defines specify some miscellaneous port-related configuration
2219517SBill.Taylor@Sun.COM  * information.  Specifically, HERMON_MAX_MTU is used to define the maximum
2229517SBill.Taylor@Sun.COM  * MTU supported for each Hermon port, HERMON_MAX_PORT_WIDTH is used to define
2239517SBill.Taylor@Sun.COM  * the maximum supported port width, and the HERMON_MAX_VLCAP define is used
2249517SBill.Taylor@Sun.COM  * to specify the maximum number of VLs supported, excluding VL15.  Both
2259517SBill.Taylor@Sun.COM  * of these values are controllable and get be set using the "hermon_max_mtu"
2269517SBill.Taylor@Sun.COM  * and "hermon_max_vlcap" configuration variables.  Note: as with many of the
2279517SBill.Taylor@Sun.COM  * configurable variables, caution should be exercised when changing these
2289517SBill.Taylor@Sun.COM  * values.  These values, specifically, should not be set any larger than
2299517SBill.Taylor@Sun.COM  * they are defined here as these are set to the current Hermon device
2309517SBill.Taylor@Sun.COM  * maximums.
2319517SBill.Taylor@Sun.COM  *
2329517SBill.Taylor@Sun.COM  * Note that:  with Hermon, these capabilities that were formerly retrieved
2339517SBill.Taylor@Sun.COM  * 	as part of QUERY_DEV_LIM/CAP must now be retrieved with QUERY_PORT.
2349517SBill.Taylor@Sun.COM  *	The init sequence will have to be altered vis-a-vis the older HCAs to
2359517SBill.Taylor@Sun.COM  *	accommodate this change.
2369517SBill.Taylor@Sun.COM  *
2379517SBill.Taylor@Sun.COM  *	Also, the maximums will be changed here for now.
2389517SBill.Taylor@Sun.COM  */
2399517SBill.Taylor@Sun.COM #define	HERMON_MAX_MTU		0x5 /* was 0x4, 2048 but moved to 4096 */
2409517SBill.Taylor@Sun.COM #define	HERMON_MAX_PORT_WIDTH	0x7 /* was 0x3 (1x/4x) but now 1/4/8x */
2419517SBill.Taylor@Sun.COM #define	HERMON_MAX_VLCAP	0x8 /* remain the same for now */
2429517SBill.Taylor@Sun.COM 
2439517SBill.Taylor@Sun.COM /*
2449517SBill.Taylor@Sun.COM  * These last defines are used by the statistics counting routines (kstats)
2459517SBill.Taylor@Sun.COM  * for initialization of the structures associated with the IB statistics
2469517SBill.Taylor@Sun.COM  * access routines.  The HERMON_CNTR_MASK and HERMON_CNTR_SIZE defines are
2479517SBill.Taylor@Sun.COM  * used to divide the "pcr" register into two 32-bit counters (one for "pic0"
2489517SBill.Taylor@Sun.COM  * and the other for "pic1")
2499517SBill.Taylor@Sun.COM  */
2509517SBill.Taylor@Sun.COM #define	HERMON_CNTR_MASK		0xFFFFFFFF
2519517SBill.Taylor@Sun.COM #define	HERMON_CNTR_SIZE		32
2529517SBill.Taylor@Sun.COM #define	HERMON_CNTR_NUMENTRIES	17
2539517SBill.Taylor@Sun.COM 
2549517SBill.Taylor@Sun.COM 
2559517SBill.Taylor@Sun.COM 
2569517SBill.Taylor@Sun.COM #define	HERMON_QUEUE_LOCATION_NORMAL	0x1
2579517SBill.Taylor@Sun.COM #define	HERMON_QUEUE_LOCATION_USERLAND	0x2
2589517SBill.Taylor@Sun.COM 
2599517SBill.Taylor@Sun.COM /*
2609517SBill.Taylor@Sun.COM  * Minimum number of ticks to delay between successive polls of the CQ in
2619517SBill.Taylor@Sun.COM  * VTS ioctl loopback test
2629517SBill.Taylor@Sun.COM  */
2639517SBill.Taylor@Sun.COM #define	HERMON_VTS_LOOPBACK_MIN_WAIT_DUR	50
2649517SBill.Taylor@Sun.COM 
2659517SBill.Taylor@Sun.COM /*
2669517SBill.Taylor@Sun.COM  * UAR software table, layout and associated structures
2679517SBill.Taylor@Sun.COM  */
2689517SBill.Taylor@Sun.COM 
2699517SBill.Taylor@Sun.COM /*
2709517SBill.Taylor@Sun.COM  * Doorbell record table bitmap macros
2719517SBill.Taylor@Sun.COM  */
2729517SBill.Taylor@Sun.COM #define	HERMON_IND_BYTE(ind)		((ind) >> 3)
2739517SBill.Taylor@Sun.COM #define	HERMON_IND_BIT(ind)		(1 << ((ind) & 0x7))
2749517SBill.Taylor@Sun.COM 
2759517SBill.Taylor@Sun.COM #define	HERMON_BMAP_BIT_SET(bmap, ind)	\
2769517SBill.Taylor@Sun.COM 	((bmap)[HERMON_IND_BYTE(ind)] |= HERMON_IND_BIT(ind))
2779517SBill.Taylor@Sun.COM #define	HERMON_BMAP_BIT_CLR(bmap, ind)	\
2789517SBill.Taylor@Sun.COM 	((bmap)[HERMON_IND_BYTE(ind)] &= ~HERMON_IND_BIT(ind))
2799517SBill.Taylor@Sun.COM #define	HERMON_BMAP_BIT_ISSET(bmap, ind)	\
2809517SBill.Taylor@Sun.COM 	((bmap)[HERMON_IND_BYTE(ind)] & HERMON_IND_BIT(ind))
2819517SBill.Taylor@Sun.COM 
2829517SBill.Taylor@Sun.COM 
2839517SBill.Taylor@Sun.COM /*
2849517SBill.Taylor@Sun.COM  * User doorbell record page tracking
2859517SBill.Taylor@Sun.COM  */
2869517SBill.Taylor@Sun.COM typedef struct hermon_udbr_page_s hermon_udbr_page_t;
2879517SBill.Taylor@Sun.COM 
2889517SBill.Taylor@Sun.COM struct hermon_udbr_page_s {
2899517SBill.Taylor@Sun.COM 	hermon_udbr_page_t	*upg_link;
2909517SBill.Taylor@Sun.COM 	uint_t			upg_index;
2919517SBill.Taylor@Sun.COM 	uint_t			upg_nfree;
29211586SBill.Taylor@Sun.COM 	uint64_t		*upg_free;
2939517SBill.Taylor@Sun.COM 	caddr_t			upg_kvaddr;
2949517SBill.Taylor@Sun.COM 	struct buf		*upg_buf;
2959517SBill.Taylor@Sun.COM 	ddi_umem_cookie_t	upg_umemcookie;
2969517SBill.Taylor@Sun.COM 	ddi_dma_handle_t	upg_dmahdl;
2979517SBill.Taylor@Sun.COM 	ddi_dma_cookie_t 	upg_dmacookie;
2989517SBill.Taylor@Sun.COM };
2999517SBill.Taylor@Sun.COM 
3009517SBill.Taylor@Sun.COM typedef struct hermon_udbr_mgmt_s hermon_user_dbr_t;
3019517SBill.Taylor@Sun.COM 
3029517SBill.Taylor@Sun.COM struct hermon_udbr_mgmt_s {
3039517SBill.Taylor@Sun.COM 	hermon_user_dbr_t	*udbr_link;
3049517SBill.Taylor@Sun.COM 	uint_t			udbr_index;	/* same as uarpg */
3059517SBill.Taylor@Sun.COM 	hermon_udbr_page_t	*udbr_pagep;
3069517SBill.Taylor@Sun.COM };
3079517SBill.Taylor@Sun.COM 
3089517SBill.Taylor@Sun.COM 
3099517SBill.Taylor@Sun.COM /*
3109517SBill.Taylor@Sun.COM  * doorbell tracking end
3119517SBill.Taylor@Sun.COM  */
3129517SBill.Taylor@Sun.COM 
3139517SBill.Taylor@Sun.COM /*
3149517SBill.Taylor@Sun.COM  * The hermon_sw_ah_s structure is also referred to using the "hermon_ahhdl_t"
3159517SBill.Taylor@Sun.COM  * typedef (see hermon_typedef.h).  It encodes all the information necessary
3169517SBill.Taylor@Sun.COM  * to track the various resources needed to allocate, query, modify, and
3179517SBill.Taylor@Sun.COM  * free an address handle.
3189517SBill.Taylor@Sun.COM  *
3199517SBill.Taylor@Sun.COM  * In specific, it has a lock to ensure single-threaded access. It stores a
3209517SBill.Taylor@Sun.COM  * pointer to the associated PD handle, and also contains a copy of the
3219517SBill.Taylor@Sun.COM  * GUID stored into the address handle.  The reason for this extra copy of
3229517SBill.Taylor@Sun.COM  * the GUID info has to do with Hermon PRM compliance and is fully explained
3239517SBill.Taylor@Sun.COM  * in hermon_misc.c
3249517SBill.Taylor@Sun.COM  *
3259517SBill.Taylor@Sun.COM  * To serve in it's primary function, it also contains a UDAV, which contains
3269517SBill.Taylor@Sun.COM  * all of the data associated with the UD address vector that is being
3279517SBill.Taylor@Sun.COM  * utilized by the holder of the address handle. The hardware-specific format
3289517SBill.Taylor@Sun.COM  * of the UDAV is defined in the hermon_hw.h file.
3299517SBill.Taylor@Sun.COM  *
3309517SBill.Taylor@Sun.COM  * It also has the always necessary backpointer to the resource for the AH
3319517SBill.Taylor@Sun.COM  * handle structure itself.
3329517SBill.Taylor@Sun.COM  */
3339517SBill.Taylor@Sun.COM struct hermon_sw_ah_s {
3349517SBill.Taylor@Sun.COM 	kmutex_t	ah_lock;
3359517SBill.Taylor@Sun.COM 	hermon_pdhdl_t	ah_pdhdl;
3369517SBill.Taylor@Sun.COM 	hermon_hw_udav_t *ah_udav;
3379517SBill.Taylor@Sun.COM 	hermon_rsrc_t	*ah_rsrcp;
3389517SBill.Taylor@Sun.COM 	uint64_t	ah_save_guid;
3399517SBill.Taylor@Sun.COM };
3409517SBill.Taylor@Sun.COM _NOTE(READ_ONLY_DATA(hermon_sw_ah_s::ah_udav))
3419517SBill.Taylor@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_ah_s::ah_lock,
3429517SBill.Taylor@Sun.COM     hermon_sw_ah_s::ah_pdhdl
3439517SBill.Taylor@Sun.COM     hermon_sw_ah_s::ah_rsrcp
3449517SBill.Taylor@Sun.COM     hermon_sw_ah_s::ah_save_guid))
3459517SBill.Taylor@Sun.COM 
3469517SBill.Taylor@Sun.COM /*
3479517SBill.Taylor@Sun.COM  * The hermon_sw_mcg_list_s structure is also referred to using the
3489517SBill.Taylor@Sun.COM  * "hermon_mcghdl_t" typedef (see hermon_typedef.h).  It encodes all the
3499517SBill.Taylor@Sun.COM  * information necessary to track the various resources needed to for attaching
3509517SBill.Taylor@Sun.COM  * and detaching QP from multicast groups.
3519517SBill.Taylor@Sun.COM  *
3529517SBill.Taylor@Sun.COM  * The Hermon driver keeps an array of these and uses them as a shadow for
3539517SBill.Taylor@Sun.COM  * the real HW-based MCG table.  They hold all the necessary information
3549517SBill.Taylor@Sun.COM  * to track the resources and to allow fast access to the MCG table.  First,
3559517SBill.Taylor@Sun.COM  * it had a 128-bit multicast GID (stored in "mcg_mgid_h" and "mcg_mgid_l".
3569517SBill.Taylor@Sun.COM  * next if has a field to indicate the index of the next hermon_mcghdl_t in
3579517SBill.Taylor@Sun.COM  * the current hash chain (zero is the end of the chain).  Note: this very
3589517SBill.Taylor@Sun.COM  * closely mimics what the hardware MCG entry has. Then it has a field to
3599517SBill.Taylor@Sun.COM  * indicate how many QP are currently attached to the given MCG.  And, lastly,
3609517SBill.Taylor@Sun.COM  * it has the obligatory backpointer to the resource for the MCH handle
3619517SBill.Taylor@Sun.COM  * structure itself.
3629517SBill.Taylor@Sun.COM  */
3639517SBill.Taylor@Sun.COM struct hermon_sw_mcg_list_s {
3649517SBill.Taylor@Sun.COM 	uint64_t	mcg_mgid_h;
3659517SBill.Taylor@Sun.COM 	uint64_t	mcg_mgid_l;
3669517SBill.Taylor@Sun.COM 	uint_t		mcg_next_indx;
3679517SBill.Taylor@Sun.COM 	uint_t		mcg_num_qps;
3689517SBill.Taylor@Sun.COM 	hermon_rsrc_t	*mcg_rsrcp;
3699517SBill.Taylor@Sun.COM };
3709517SBill.Taylor@Sun.COM 
3719517SBill.Taylor@Sun.COM /*
3729517SBill.Taylor@Sun.COM  * The hermon_sw_pd_s structure is also referred to using the "hermon_pdhdl_t"
3739517SBill.Taylor@Sun.COM  * typedef (see hermon_typedef.h).  It encodes all the information necessary
3749517SBill.Taylor@Sun.COM  * to track the various resources needed to allocate and free protection
3759517SBill.Taylor@Sun.COM  * domains
3769517SBill.Taylor@Sun.COM  *
3779517SBill.Taylor@Sun.COM  * Specifically, it has reference count and a lock to ensure single threaded
3789517SBill.Taylor@Sun.COM  * access to it.  It has a field for the protection domain number ("pd_pdnum").
3799517SBill.Taylor@Sun.COM  * And it also has the obligatory backpointer to the resource for the PD
3809517SBill.Taylor@Sun.COM  * handle structure itself.
3819517SBill.Taylor@Sun.COM  */
3829517SBill.Taylor@Sun.COM struct hermon_sw_pd_s {
3839517SBill.Taylor@Sun.COM 	kmutex_t	pd_lock;
3849517SBill.Taylor@Sun.COM 	uint32_t	pd_pdnum;
3859517SBill.Taylor@Sun.COM 	uint32_t	pd_refcnt;
3869517SBill.Taylor@Sun.COM 	hermon_rsrc_t	*pd_rsrcp;
3879517SBill.Taylor@Sun.COM };
3889517SBill.Taylor@Sun.COM _NOTE(READ_ONLY_DATA(hermon_sw_pd_s::pd_pdnum
3899517SBill.Taylor@Sun.COM     hermon_sw_pd_s::pd_rsrcp))
3909517SBill.Taylor@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_pd_s::pd_lock,
3919517SBill.Taylor@Sun.COM     hermon_sw_pd_s::pd_refcnt))
3929517SBill.Taylor@Sun.COM 
3939517SBill.Taylor@Sun.COM /*
3949517SBill.Taylor@Sun.COM  * The hermon_qalloc_info_s structure is also referred to using the
3959517SBill.Taylor@Sun.COM  * "hermon_qalloc_info_t" typedef (see hermon_typedef.h).  It holds all the
3969517SBill.Taylor@Sun.COM  * information necessary to track the resources for each of the various Hermon
3979517SBill.Taylor@Sun.COM  * queue types (i.e. Event Queue, Completion Queue, Work Queue).
3989517SBill.Taylor@Sun.COM  *
3999517SBill.Taylor@Sun.COM  * Specifically, it has the size, alignment restrictions, and location (in DDR
4009517SBill.Taylor@Sun.COM  * or in system memory).  And depending on the location, it also has the
4019517SBill.Taylor@Sun.COM  * ddi_dma_handle_t, ddi_acc_handle_t, and pointers used for reading/writing to
4029517SBill.Taylor@Sun.COM  * the queue's memory.
4039517SBill.Taylor@Sun.COM  */
4049517SBill.Taylor@Sun.COM struct hermon_qalloc_info_s {
4059517SBill.Taylor@Sun.COM 	uint64_t		qa_size;
4069517SBill.Taylor@Sun.COM 	uint64_t		qa_alloc_align;
4079517SBill.Taylor@Sun.COM 	uint64_t		qa_bind_align;
4089517SBill.Taylor@Sun.COM 	uint32_t		*qa_buf_real;
4099517SBill.Taylor@Sun.COM 	uint32_t		*qa_buf_aligned;
4109517SBill.Taylor@Sun.COM 	uint64_t		qa_buf_realsz;
4119517SBill.Taylor@Sun.COM 	uint_t			qa_pgoffs;
4129517SBill.Taylor@Sun.COM 	uint_t			qa_location;
4139517SBill.Taylor@Sun.COM 	ddi_dma_handle_t	qa_dmahdl;
4149517SBill.Taylor@Sun.COM 	ddi_acc_handle_t	qa_acchdl;
4159517SBill.Taylor@Sun.COM 	ddi_umem_cookie_t	qa_umemcookie;
4169517SBill.Taylor@Sun.COM };
4179517SBill.Taylor@Sun.COM 
4189517SBill.Taylor@Sun.COM /*
4199517SBill.Taylor@Sun.COM  * The hermon_ks_mask_t structure encodes all the information necessary for
4209517SBill.Taylor@Sun.COM  * the individual kstat entries.  The "ks_reg_offset" field contains the
4219517SBill.Taylor@Sun.COM  * hardware offset for the corresponding counter, and "ks_reg_shift" and
4229517SBill.Taylor@Sun.COM  * "ks_reg_mask" contain shift and mask registers used by the access routines.
4239517SBill.Taylor@Sun.COM  * Also the "ks_old_pic0" and "ks_old_pic1" fields contain the most recently
4249517SBill.Taylor@Sun.COM  * read value for the corresponding port ("pic").  Note:  An array of these
4259517SBill.Taylor@Sun.COM  * structures is part of the "hermon_ks_info_t" structure below.
4269517SBill.Taylor@Sun.COM  */
4279517SBill.Taylor@Sun.COM typedef struct hermon_ks_mask_s {
4289517SBill.Taylor@Sun.COM 	char		*ks_evt_name;
4299517SBill.Taylor@Sun.COM 	uint32_t	ks_old_pic0;
4309517SBill.Taylor@Sun.COM 	uint32_t	ks_old_pic1;
4319517SBill.Taylor@Sun.COM } hermon_ks_mask_t;
4329517SBill.Taylor@Sun.COM 
4339517SBill.Taylor@Sun.COM /*
4349879SRamaswamy.Tummala@Sun.COM  * Index into the named data components of 64 bit "perf_counters" kstat.
4359879SRamaswamy.Tummala@Sun.COM  */
4369879SRamaswamy.Tummala@Sun.COM enum {
4379879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_ENABLE_IDX = 0,
4389879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_XMIT_DATA_IDX,
4399879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_RECV_DATA_IDX,
4409879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_XMIT_PKTS_IDX,
4419879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_RECV_PKTS_IDX,
4429879SRamaswamy.Tummala@Sun.COM 	HERMON_PERFCNTR64_NUM_COUNTERS
4439879SRamaswamy.Tummala@Sun.COM };
4449879SRamaswamy.Tummala@Sun.COM 
4459879SRamaswamy.Tummala@Sun.COM /*
4469879SRamaswamy.Tummala@Sun.COM  * Data associated with the 64 bit "perf_counters" kstat. One for each port.
4479879SRamaswamy.Tummala@Sun.COM  */
4489879SRamaswamy.Tummala@Sun.COM typedef struct hermon_perfcntr64_ks_info_s {
4499879SRamaswamy.Tummala@Sun.COM 	struct kstat	*hki64_ksp;
45011190SRamaswamy.Tummala@Sun.COM 	int		hki64_ext_port_counters_supported;
4519879SRamaswamy.Tummala@Sun.COM 	int		hki64_enabled;
4529879SRamaswamy.Tummala@Sun.COM 	uint64_t	hki64_counters[HERMON_PERFCNTR64_NUM_COUNTERS];
4539879SRamaswamy.Tummala@Sun.COM 	uint32_t	hki64_last_read[HERMON_PERFCNTR64_NUM_COUNTERS];
4549879SRamaswamy.Tummala@Sun.COM 	uint_t		hki64_port_num;
4559879SRamaswamy.Tummala@Sun.COM 	hermon_state_t	*hki64_state;
4569879SRamaswamy.Tummala@Sun.COM } hermon_perfcntr64_ks_info_t;
4579879SRamaswamy.Tummala@Sun.COM 
4589879SRamaswamy.Tummala@Sun.COM /*
4599517SBill.Taylor@Sun.COM  * The hermon_ks_info_t structure stores all the information necessary for
4609517SBill.Taylor@Sun.COM  * tracking the resources associated with each of the various kstats.  In
4619517SBill.Taylor@Sun.COM  * addition to containing pointers to each of the counter and pic kstats,
4629517SBill.Taylor@Sun.COM  * this structure also contains "hki_pcr" which is the control register that
4639517SBill.Taylor@Sun.COM  * determines which of the countable entries (from the "hki_ib_perfcnt[]"
4649517SBill.Taylor@Sun.COM  * array) is being currently accessed.
4659517SBill.Taylor@Sun.COM  */
4669517SBill.Taylor@Sun.COM typedef struct hermon_ks_info_s {
4679517SBill.Taylor@Sun.COM 	struct kstat	*hki_cntr_ksp;
4689517SBill.Taylor@Sun.COM 	struct kstat	*hki_picN_ksp[HERMON_MAX_PORTS];
4699517SBill.Taylor@Sun.COM 	uint64_t	hki_pcr;
4709517SBill.Taylor@Sun.COM 	uint64_t	hki_pic0;
4719517SBill.Taylor@Sun.COM 	uint64_t	hki_pic1;
4729517SBill.Taylor@Sun.COM 	hermon_ks_mask_t	hki_ib_perfcnt[HERMON_CNTR_NUMENTRIES];
4739879SRamaswamy.Tummala@Sun.COM 	kt_did_t	hki_perfcntr64_thread_id;
4749879SRamaswamy.Tummala@Sun.COM 	kmutex_t	hki_perfcntr64_lock;
4759879SRamaswamy.Tummala@Sun.COM 	kcondvar_t	hki_perfcntr64_cv;
4769879SRamaswamy.Tummala@Sun.COM 	uint_t		hki_perfcntr64_flags;	/* see below */
4779879SRamaswamy.Tummala@Sun.COM 	hermon_perfcntr64_ks_info_t	hki_perfcntr64[HERMON_MAX_PORTS];
4789517SBill.Taylor@Sun.COM } hermon_ks_info_t;
4799517SBill.Taylor@Sun.COM 
4809879SRamaswamy.Tummala@Sun.COM /* hki_perfcntr64_flags */
4819879SRamaswamy.Tummala@Sun.COM #define	HERMON_PERFCNTR64_THREAD_CREATED	0x0001
4829879SRamaswamy.Tummala@Sun.COM #define	HERMON_PERFCNTR64_THREAD_EXIT		0x0002
4839879SRamaswamy.Tummala@Sun.COM 
4849517SBill.Taylor@Sun.COM /*
4859517SBill.Taylor@Sun.COM  * The hermon_ports_ioctl32_t, hermon_loopback_ioctl32_t, and
4869517SBill.Taylor@Sun.COM  * hermon_flash_ioctl32_s structures are used internally by the Hermon
4879517SBill.Taylor@Sun.COM  * driver to accomodate 32-bit applications which need to access the
4889517SBill.Taylor@Sun.COM  * Hermon ioctls.  They are 32-bit versions of externally available
4899517SBill.Taylor@Sun.COM  * structures defined in hermon_ioctl.h
4909517SBill.Taylor@Sun.COM  */
4919517SBill.Taylor@Sun.COM typedef struct hermon_ports_ioctl32_s {
4929517SBill.Taylor@Sun.COM 	uint_t			ap_revision;
4939517SBill.Taylor@Sun.COM 	caddr32_t		ap_ports;
4949517SBill.Taylor@Sun.COM 	uint8_t			ap_num_ports;
4959517SBill.Taylor@Sun.COM } hermon_ports_ioctl32_t;
4969517SBill.Taylor@Sun.COM 
4979517SBill.Taylor@Sun.COM typedef struct hermon_loopback_ioctl32_s {
4989517SBill.Taylor@Sun.COM 	uint_t			alb_revision;
4999517SBill.Taylor@Sun.COM 	caddr32_t		alb_send_buf;
5009517SBill.Taylor@Sun.COM 	caddr32_t		alb_fail_buf;
5019517SBill.Taylor@Sun.COM 	uint_t			alb_buf_sz;
5029517SBill.Taylor@Sun.COM 	uint_t			alb_num_iter;
5039517SBill.Taylor@Sun.COM 	uint_t			alb_pass_done;
5049517SBill.Taylor@Sun.COM 	uint_t			alb_timeout;
5059517SBill.Taylor@Sun.COM 	hermon_loopback_error_t	alb_error_type;
5069517SBill.Taylor@Sun.COM 	uint8_t			alb_port_num;
5079517SBill.Taylor@Sun.COM 	uint8_t			alb_num_retry;
5089517SBill.Taylor@Sun.COM } hermon_loopback_ioctl32_t;
5099517SBill.Taylor@Sun.COM 
5109517SBill.Taylor@Sun.COM typedef struct hermon_flash_ioctl32_s {
5119517SBill.Taylor@Sun.COM 	uint32_t	af_type;
5129517SBill.Taylor@Sun.COM 	caddr32_t	af_sector;
5139517SBill.Taylor@Sun.COM 	uint32_t	af_sector_num;
5149517SBill.Taylor@Sun.COM 	uint32_t	af_addr;
5159517SBill.Taylor@Sun.COM 	uint32_t	af_quadlet;
5169517SBill.Taylor@Sun.COM 	uint8_t		af_byte;
5179517SBill.Taylor@Sun.COM } hermon_flash_ioctl32_t;
5189517SBill.Taylor@Sun.COM 
5199517SBill.Taylor@Sun.COM /*
5209517SBill.Taylor@Sun.COM  * The hermon_loopback_comm_t and hermon_loopback_state_t structures below
5219517SBill.Taylor@Sun.COM  * are used to store all of the relevant state information needed to keep
5229517SBill.Taylor@Sun.COM  * track of a single VTS ioctl loopback test run.
5239517SBill.Taylor@Sun.COM  */
5249517SBill.Taylor@Sun.COM typedef struct hermon_loopback_comm_s {
5259517SBill.Taylor@Sun.COM 	uint8_t			*hlc_buf;
5269517SBill.Taylor@Sun.COM 	size_t			hlc_buf_sz;
5279517SBill.Taylor@Sun.COM 	ibt_mr_desc_t		hlc_mrdesc;
5289517SBill.Taylor@Sun.COM 
5299517SBill.Taylor@Sun.COM 	hermon_mrhdl_t		hlc_mrhdl;
5309517SBill.Taylor@Sun.COM 	hermon_cqhdl_t		hlc_cqhdl[2];
5319517SBill.Taylor@Sun.COM 	hermon_qphdl_t		hlc_qp_hdl;
5329517SBill.Taylor@Sun.COM 
5339517SBill.Taylor@Sun.COM 	ibt_mr_attr_t		hlc_memattr;
5349517SBill.Taylor@Sun.COM 	uint_t			hlc_qp_num;
5359517SBill.Taylor@Sun.COM 	ibt_cq_attr_t		hlc_cq_attr;
5369517SBill.Taylor@Sun.COM 	ibt_qp_alloc_attr_t	hlc_qp_attr;
5379517SBill.Taylor@Sun.COM 	ibt_chan_sizes_t	hlc_chan_sizes;
5389517SBill.Taylor@Sun.COM 	ibt_qp_info_t		hlc_qp_info;
5399517SBill.Taylor@Sun.COM 	ibt_queue_sizes_t	hlc_queue_sizes;
5409517SBill.Taylor@Sun.COM 	ibt_send_wr_t		hlc_wr;
5419517SBill.Taylor@Sun.COM 	ibt_wr_ds_t		hlc_sgl;
5429517SBill.Taylor@Sun.COM 	ibt_wc_t		hlc_wc;
5439517SBill.Taylor@Sun.COM 	uint_t			hlc_num_polled;
5449517SBill.Taylor@Sun.COM 	ibt_status_t		hlc_status;
5459517SBill.Taylor@Sun.COM 	int			hlc_complete;
5469517SBill.Taylor@Sun.COM 	int			hlc_wrid;
5479517SBill.Taylor@Sun.COM } hermon_loopback_comm_t;
5489517SBill.Taylor@Sun.COM 
5499517SBill.Taylor@Sun.COM typedef struct hermon_loopback_state_s {
5509517SBill.Taylor@Sun.COM 	uint8_t			hls_port;
5519517SBill.Taylor@Sun.COM 	uint_t			hls_lid;
5529517SBill.Taylor@Sun.COM 	uint8_t			hls_retry;
5539517SBill.Taylor@Sun.COM 	hermon_state_t		*hls_state;
5549517SBill.Taylor@Sun.COM 	ibc_hca_hdl_t		hls_hca_hdl;
5559517SBill.Taylor@Sun.COM 	hermon_pdhdl_t		hls_pd_hdl;
5569517SBill.Taylor@Sun.COM 	hermon_loopback_comm_t	hls_tx;
5579517SBill.Taylor@Sun.COM 	hermon_loopback_comm_t	hls_rx;
5589517SBill.Taylor@Sun.COM 	ibt_status_t		hls_status;
5599517SBill.Taylor@Sun.COM 	int			hls_err;
5609517SBill.Taylor@Sun.COM 	int			hls_pkey_ix;
5619517SBill.Taylor@Sun.COM 	int			hls_timeout;
5629517SBill.Taylor@Sun.COM } hermon_loopback_state_t;
5639517SBill.Taylor@Sun.COM 
5649517SBill.Taylor@Sun.COM /*
5659517SBill.Taylor@Sun.COM  * Mellanox FMR
5669517SBill.Taylor@Sun.COM  */
5679517SBill.Taylor@Sun.COM typedef struct hermon_fmr_list_s {
5689517SBill.Taylor@Sun.COM 	struct hermon_fmr_list_s		*fmr_next;
5699517SBill.Taylor@Sun.COM 
5709517SBill.Taylor@Sun.COM 	hermon_mrhdl_t			fmr;
5719517SBill.Taylor@Sun.COM 	hermon_fmrhdl_t			fmr_pool;
5729517SBill.Taylor@Sun.COM 	uint_t				fmr_remaps;
573*12965SWilliam.Taylor@Oracle.COM 	uint_t				fmr_remap_gen; /* generation */
5749517SBill.Taylor@Sun.COM } hermon_fmr_list_t;
5759517SBill.Taylor@Sun.COM 
5769517SBill.Taylor@Sun.COM struct hermon_sw_fmr_s {
5779517SBill.Taylor@Sun.COM 	hermon_state_t			*fmr_state;
5789517SBill.Taylor@Sun.COM 
5799517SBill.Taylor@Sun.COM 	kmutex_t			fmr_lock;
580*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		*fmr_free_list;
581*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		**fmr_free_list_tail;
582*12965SWilliam.Taylor@Oracle.COM 	int				fmr_free_len;
583*12965SWilliam.Taylor@Oracle.COM 	int				fmr_pool_size;
584*12965SWilliam.Taylor@Oracle.COM 	int				fmr_max_pages;
585*12965SWilliam.Taylor@Oracle.COM 	int				fmr_flags;
586*12965SWilliam.Taylor@Oracle.COM 	int				fmr_stat_register;
5879517SBill.Taylor@Sun.COM 
5889517SBill.Taylor@Sun.COM 	ibt_fmr_flush_handler_t		fmr_flush_function;
5899517SBill.Taylor@Sun.COM 	void				*fmr_flush_arg;
5909517SBill.Taylor@Sun.COM 
591*12965SWilliam.Taylor@Oracle.COM 	int				fmr_max_remaps;
592*12965SWilliam.Taylor@Oracle.COM 	uint_t				fmr_remap_gen; /* generation */
5939517SBill.Taylor@Sun.COM 	int				fmr_page_sz;
594*12965SWilliam.Taylor@Oracle.COM 
595*12965SWilliam.Taylor@Oracle.COM 	kmutex_t			remap_lock;
596*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		*fmr_remap_list;
597*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		**fmr_remap_list_tail;
598*12965SWilliam.Taylor@Oracle.COM 	int				fmr_remap_watermark;
599*12965SWilliam.Taylor@Oracle.COM 	int				fmr_remap_len;
600*12965SWilliam.Taylor@Oracle.COM 
601*12965SWilliam.Taylor@Oracle.COM 	kmutex_t			dirty_lock;
602*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		*fmr_dirty_list;
603*12965SWilliam.Taylor@Oracle.COM 	hermon_fmr_list_t		**fmr_dirty_list_tail;
6049517SBill.Taylor@Sun.COM 	int				fmr_dirty_watermark;
6059517SBill.Taylor@Sun.COM 	int				fmr_dirty_len;
6069517SBill.Taylor@Sun.COM };
6079517SBill.Taylor@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_fmr_s::fmr_lock,
6089517SBill.Taylor@Sun.COM     hermon_sw_fmr_s::fmr_pool_size
6099517SBill.Taylor@Sun.COM     hermon_sw_fmr_s::fmr_page_sz
610*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_flags
611*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_free_list))
612*12965SWilliam.Taylor@Oracle.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_fmr_s::dirty_lock,
6139517SBill.Taylor@Sun.COM     hermon_sw_fmr_s::fmr_dirty_watermark
6149517SBill.Taylor@Sun.COM     hermon_sw_fmr_s::fmr_dirty_len
615*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_dirty_list))
616*12965SWilliam.Taylor@Oracle.COM _NOTE(DATA_READABLE_WITHOUT_LOCK(hermon_sw_fmr_s::fmr_remap_gen
617*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_state
618*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_max_pages
619*12965SWilliam.Taylor@Oracle.COM     hermon_sw_fmr_s::fmr_max_remaps))
6209517SBill.Taylor@Sun.COM 
621*12965SWilliam.Taylor@Oracle.COM /* FRWR guarantees 8 bits of key; avoid corner cases by using "-2" */
622*12965SWilliam.Taylor@Oracle.COM #define	HERMON_FMR_MAX_REMAPS		(256 - 2)
6239517SBill.Taylor@Sun.COM 
6249517SBill.Taylor@Sun.COM /* Hermon doorbell record routines */
6259517SBill.Taylor@Sun.COM 
6269517SBill.Taylor@Sun.COM int hermon_dbr_page_alloc(hermon_state_t *state, hermon_dbr_info_t **info);
6279517SBill.Taylor@Sun.COM int hermon_dbr_alloc(hermon_state_t *state, uint_t index,
6289517SBill.Taylor@Sun.COM     ddi_acc_handle_t *acchdl, hermon_dbr_t **vdbr, uint64_t *pdbr,
6299517SBill.Taylor@Sun.COM     uint64_t *mapoffset);
6309517SBill.Taylor@Sun.COM void hermon_dbr_free(hermon_state_t *state, uint_t indx, hermon_dbr_t *record);
6319517SBill.Taylor@Sun.COM void hermon_dbr_kern_free(hermon_state_t *state);
6329517SBill.Taylor@Sun.COM 
6339517SBill.Taylor@Sun.COM /* Hermon Fast Memory Registration Routines */
6349517SBill.Taylor@Sun.COM int hermon_create_fmr_pool(hermon_state_t *state, hermon_pdhdl_t pdhdl,
6359517SBill.Taylor@Sun.COM     ibt_fmr_pool_attr_t *params, hermon_fmrhdl_t *fmrhdl);
6369517SBill.Taylor@Sun.COM int hermon_destroy_fmr_pool(hermon_state_t *state, hermon_fmrhdl_t fmrhdl);
6379517SBill.Taylor@Sun.COM int hermon_flush_fmr_pool(hermon_state_t *state, hermon_fmrhdl_t fmrhdl);
6389517SBill.Taylor@Sun.COM int hermon_register_physical_fmr(hermon_state_t *state, hermon_fmrhdl_t fmrhdl,
6399517SBill.Taylor@Sun.COM     ibt_pmr_attr_t *mem_pattr_p, hermon_mrhdl_t *mrhdl,
6409517SBill.Taylor@Sun.COM     ibt_pmr_desc_t *mem_desc_p);
6419517SBill.Taylor@Sun.COM int hermon_deregister_fmr(hermon_state_t *state, hermon_mrhdl_t mr);
6429517SBill.Taylor@Sun.COM 
6439517SBill.Taylor@Sun.COM 
6449517SBill.Taylor@Sun.COM /* Hermon Address Handle routines */
6459517SBill.Taylor@Sun.COM int hermon_ah_alloc(hermon_state_t *state, hermon_pdhdl_t pd,
6469517SBill.Taylor@Sun.COM     ibt_adds_vect_t *attr_p, hermon_ahhdl_t *ahhdl, uint_t sleepflag);
6479517SBill.Taylor@Sun.COM int hermon_ah_free(hermon_state_t *state, hermon_ahhdl_t *ahhdl,
6489517SBill.Taylor@Sun.COM     uint_t sleepflag);
6499517SBill.Taylor@Sun.COM int hermon_ah_query(hermon_state_t *state, hermon_ahhdl_t ahhdl,
6509517SBill.Taylor@Sun.COM     hermon_pdhdl_t *pdhdl, ibt_adds_vect_t *attr_p);
6519517SBill.Taylor@Sun.COM int hermon_ah_modify(hermon_state_t *state, hermon_ahhdl_t ahhdl,
6529517SBill.Taylor@Sun.COM     ibt_adds_vect_t *attr_p);
6539517SBill.Taylor@Sun.COM 
6549517SBill.Taylor@Sun.COM /* Hermon Multicast Group routines */
6559517SBill.Taylor@Sun.COM int hermon_mcg_attach(hermon_state_t *state, hermon_qphdl_t qphdl, ib_gid_t gid,
6569517SBill.Taylor@Sun.COM     ib_lid_t lid);
6579517SBill.Taylor@Sun.COM int hermon_mcg_detach(hermon_state_t *state, hermon_qphdl_t qphdl, ib_gid_t gid,
6589517SBill.Taylor@Sun.COM     ib_lid_t lid);
6599517SBill.Taylor@Sun.COM 
6609517SBill.Taylor@Sun.COM /* Hermon Protection Domain routines */
6619517SBill.Taylor@Sun.COM int hermon_pd_alloc(hermon_state_t *state, hermon_pdhdl_t *pdhdl,
6629517SBill.Taylor@Sun.COM     uint_t sleepflag);
6639517SBill.Taylor@Sun.COM int hermon_pd_free(hermon_state_t *state, hermon_pdhdl_t *pdhdl);
6649517SBill.Taylor@Sun.COM void hermon_pd_refcnt_inc(hermon_pdhdl_t pd);
6659517SBill.Taylor@Sun.COM void hermon_pd_refcnt_dec(hermon_pdhdl_t pd);
6669517SBill.Taylor@Sun.COM 
6679517SBill.Taylor@Sun.COM /* Hermon port-related routines */
6689517SBill.Taylor@Sun.COM int hermon_port_query(hermon_state_t *state, uint_t port,
6699517SBill.Taylor@Sun.COM     ibt_hca_portinfo_t *pi);
6709517SBill.Taylor@Sun.COM int hermon_port_modify(hermon_state_t *state, uint8_t port,
6719517SBill.Taylor@Sun.COM     ibt_port_modify_flags_t flags, uint8_t init_type);
6729517SBill.Taylor@Sun.COM 
6739517SBill.Taylor@Sun.COM /* Hermon statistics (kstat) routines */
6749517SBill.Taylor@Sun.COM int hermon_kstat_init(hermon_state_t *state);
6759517SBill.Taylor@Sun.COM void hermon_kstat_fini(hermon_state_t *state);
6769517SBill.Taylor@Sun.COM 
6779517SBill.Taylor@Sun.COM /* Miscellaneous routines */
6789517SBill.Taylor@Sun.COM int hermon_set_addr_path(hermon_state_t *state, ibt_adds_vect_t *av,
6799517SBill.Taylor@Sun.COM     hermon_hw_addr_path_t *path, uint_t type);
6809517SBill.Taylor@Sun.COM void hermon_get_addr_path(hermon_state_t *state, hermon_hw_addr_path_t *path,
6819517SBill.Taylor@Sun.COM     ibt_adds_vect_t *av, uint_t type);
6829517SBill.Taylor@Sun.COM int hermon_portnum_is_valid(hermon_state_t *state, uint_t portnum);
6839517SBill.Taylor@Sun.COM int hermon_pkeyindex_is_valid(hermon_state_t *state, uint_t pkeyindx);
6849517SBill.Taylor@Sun.COM int hermon_queue_alloc(hermon_state_t *state, hermon_qalloc_info_t *qa_info,
6859517SBill.Taylor@Sun.COM     uint_t sleepflag);
6869517SBill.Taylor@Sun.COM void hermon_queue_free(hermon_qalloc_info_t *qa_info);
6879517SBill.Taylor@Sun.COM 
6889517SBill.Taylor@Sun.COM #ifdef __cplusplus
6899517SBill.Taylor@Sun.COM }
6909517SBill.Taylor@Sun.COM #endif
6919517SBill.Taylor@Sun.COM 
6929517SBill.Taylor@Sun.COM #endif	/* _SYS_IB_ADAPTERS_HERMON_MISC_H */
693