xref: /illumos-gate/usr/src/uts/common/sys/ib/adapters/hermon/hermon.h (revision 8d0c3d29bb99f6521f2dc5058a7e4debebad7899)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef	_SYS_IB_ADAPTERS_HERMON_H
27 #define	_SYS_IB_ADAPTERS_HERMON_H
28 
29 /*
30  * hermon.h
31  *    Contains the #defines and typedefs necessary for the Hermon softstate
32  *    structure and for proper attach() and detach() processing.  Also
33  *    includes all the other Hermon header files (and so is the only header
34  *    file that is directly included by the Hermon source files).
35  *    Lastly, this file includes everything necessary for implementing the
36  *    devmap interface and for maintaining the "mapped resource database".
37  */
38 
39 #include <sys/types.h>
40 #include <sys/conf.h>
41 #include <sys/ddi.h>
42 #include <sys/sunddi.h>
43 #include <sys/tnf_probe.h>
44 #include <sys/taskq.h>
45 #include <sys/atomic.h>
46 #ifdef FMA_TEST
47 #include <sys/modhash.h>
48 #endif
49 
50 #include <sys/ib/ibtl/ibci.h>
51 #include <sys/ib/ibtl/impl/ibtl_util.h>
52 #include <sys/ib/adapters/mlnx_umap.h>
53 
54 /*
55  * First include all the Hermon typedefs, then include all the other Hermon
56  * specific headers (many of which depend on the typedefs having already
57  * been defined).
58  */
59 #include <sys/ib/adapters/hermon/hermon_typedef.h>
60 #include <sys/ib/adapters/hermon/hermon_hw.h>
61 
62 #include <sys/ib/adapters/hermon/hermon_agents.h>
63 #include <sys/ib/adapters/hermon/hermon_cfg.h>
64 #include <sys/ib/adapters/hermon/hermon_cmd.h>
65 #include <sys/ib/adapters/hermon/hermon_cq.h>
66 #include <sys/ib/adapters/hermon/hermon_event.h>
67 #include <sys/ib/adapters/hermon/hermon_ioctl.h>
68 #include <sys/ib/adapters/hermon/hermon_misc.h>
69 #include <sys/ib/adapters/hermon/hermon_mr.h>
70 #include <sys/ib/adapters/hermon/hermon_wr.h>
71 #include <sys/ib/adapters/hermon/hermon_qp.h>
72 #include <sys/ib/adapters/hermon/hermon_srq.h>
73 #include <sys/ib/adapters/hermon/hermon_rsrc.h>
74 #include <sys/ib/adapters/hermon/hermon_fm.h>
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /*
81  * Number of initial states to setup. Used in call to ddi_soft_state_init()
82  */
83 #define	HERMON_INITIAL_STATES		3
84 
85 /*
86  * Macro and defines used to calculate device instance number from minor
87  * number (and vice versa).
88  */
89 #define	HERMON_MINORNUM_SHIFT		3
90 #define	HERMON_DEV_INSTANCE(dev)	(getminor((dev)) &	\
91 	((1 << HERMON_MINORNUM_SHIFT) - 1))
92 
93 /*
94  * Locations for the various Hermon hardware CMD,UAR & MSIx PCIe BARs
95  */
96 #define	HERMON_CMD_BAR			1 /* device config space */
97 #define	HERMON_UAR_BAR			2 /* UAR Region */
98 #define	HERMON_MSIX_BAR			3 /* MSI-X Table */
99 
100 #define	HERMON_ONCLOSE_FLASH_INPROGRESS		(1 << 0)
101 
102 #define	HERMON_MSIX_MAX			8 /* max # of interrupt vectors */
103 
104 /*
105  * VPD header size - or more rightfully, the area of interest for fwflash
106  * 	There's more, but we don't need it for our use so we don't read it
107  */
108 #define	HERMON_VPD_HDR_DWSIZE		0x10 /* 16 Dwords */
109 #define	HERMON_VPD_HDR_BSIZE		0x40 /* 64 Bytes */
110 
111 /*
112  * Offsets to be used w/ reset to save/restore PCI capability stuff
113  */
114 #define	HERMON_PCI_CAP_DEV_OFFS		0x08
115 #define	HERMON_PCI_CAP_LNK_OFFS		0x10
116 
117 
118 /*
119  * Some defines for the software reset.  These define the value that should
120  * be written to begin the reset (HERMON_SW_RESET_START), the delay before
121  * beginning to poll for completion (HERMON_SW_RESET_DELAY), the in-between
122  * polling delay (HERMON_SW_RESET_POLL_DELAY), and the value that indicates
123  * that the reset has not completed (HERMON_SW_RESET_NOTDONE).
124  */
125 #define	HERMON_SW_RESET_START		0x00000001
126 #define	HERMON_SW_RESET_DELAY		1000000	 /* 1000 ms, per 0.36 PRM */
127 #define	HERMON_SW_RESET_POLL_DELAY	100	 /* 100 us */
128 #define	HERMON_SW_RESET_NOTDONE		0xFFFFFFFF
129 
130 /*
131  * These defines are used in the Hermon software reset operation.  They define
132  * the total number PCI registers to read/restore during the reset.  And they
133  * also specify two config registers which should not be read or restored.
134  */
135 #define	HERMON_SW_RESET_NUMREGS		0x40
136 #define	HERMON_SW_RESET_REG22_RSVD	0x16	/* 22 dec */
137 #define	HERMON_SW_RESET_REG23_RSVD	0x17  	/* 23 dec */
138 
139 /*
140  * Macro used to output HCA warning messages.  Note: HCA warning messages
141  * are only generated when an unexpected condition has been detected.  This
142  * can be the result of a software bug or some other problem, but it is more
143  * often an indication that the HCA firmware (and/or hardware) has done
144  * something unexpected.  This warning message means that the driver state
145  * in unpredictable and that shutdown/restart is suggested.
146  */
147 #define	HERMON_WARNING(state, string)					\
148 	cmn_err(CE_WARN, "hermon%d: %s\n", (state)->hs_instance, string)
149 
150 
151 #define	HERMON_NOTE(state, string)					\
152 	cmn_err(CE_CONT, "hermon%d: %s\n", (state)->hs_instance, string)
153 
154 /*
155  * Macro used to set attach failure messages.  Also, the attach message buf
156  * size is set here.
157  */
158 #define	HERMON_ATTACH_MSGSIZE	80
159 #define	HERMON_ATTACH_MSG(attach_buf, attach_msg)		\
160 	(void) snprintf((attach_buf), HERMON_ATTACH_MSGSIZE, (attach_msg));
161 #define	HERMON_ATTACH_MSG_INIT(attach_buf)			\
162 	(attach_buf)[0] = '\0';
163 
164 /*
165  * Macros used for controlling whether or not event callbacks will be forwarded
166  * to the IBTF.  This is necessary because there are certain race conditions
167  * that can occur (e.g. calling IBTF with an asynch event before the IBTF
168  * registration has successfully completed or handling an event after we've
169  * detached from the IBTF.)
170  *
171  * HERMON_ENABLE_IBTF_CALLB() initializes the "hs_ibtfpriv" field in the Hermon
172  *    softstate.  When "hs_ibtfpriv" is non-NULL, it is OK to forward asynch
173  *    and CQ events to the IBTF.
174  *
175  * HERMON_DO_IBTF_ASYNC_CALLB() and HERMON_DO_IBTF_CQ_CALLB() both set and clear
176  *    the "hs_in_evcallb" flag, as necessary, to indicate that an IBTF
177  *    callback is currently in progress.  This is necessary so that we can
178  *    block on this condition in hermon_detach().
179  *
180  * HERMON_QUIESCE_IBTF_CALLB() is used in hermon_detach() to set the
181  *    "hs_ibtfpriv" to NULL (thereby disabling any further IBTF callbacks)
182  *    and to poll on the "hs_in_evcallb" flag.  When this flag is zero, all
183  *    IBTF callbacks have quiesced and it is safe to continue with detach
184  *    (i.e. continue detaching from IBTF).
185  */
186 #define	HERMON_ENABLE_IBTF_CALLB(state, tmp_ibtfpriv)		\
187 	(state)->hs_ibtfpriv = (tmp_ibtfpriv);
188 
189 #define	HERMON_DO_IBTF_ASYNC_CALLB(state, type, event)	\
190 	_NOTE(NOW_INVISIBLE_TO_OTHER_THREADS((state)->hs_in_evcallb))	\
191 	(state)->hs_in_evcallb = 1;					\
192 	ibc_async_handler((state)->hs_ibtfpriv, (type), (event));	\
193 	(state)->hs_in_evcallb = 0;
194 
195 #define	HERMON_DO_IBTF_CQ_CALLB(state, cq)			\
196 	_NOTE(NOW_INVISIBLE_TO_OTHER_THREADS((state)->hs_in_evcallb))	\
197 	(state)->hs_in_evcallb = 1;					\
198 	ibc_cq_handler((state)->hs_ibtfpriv, (cq)->cq_hdlrarg);		\
199 	(state)->hs_in_evcallb = 0;
200 
201 #define	HERMON_QUIESCE_IBTF_CALLB(state)			\
202 {									\
203 	uint_t		count = 0;					\
204 									\
205 	state->hs_ibtfpriv = NULL;					\
206 	while (((state)->hs_in_evcallb != 0) &&				\
207 	    (count++ < HERMON_QUIESCE_IBTF_CALLB_POLL_MAX)) {		\
208 		drv_usecwait(HERMON_QUIESCE_IBTF_CALLB_POLL_DELAY);	\
209 	}								\
210 }
211 
212 /*
213  * Defines used by the HERMON_QUIESCE_IBTF_CALLB() macro to determine the
214  * duration and number of times (at maximum) to poll while waiting for IBTF
215  * callbacks to quiesce.
216  */
217 #define	HERMON_QUIESCE_IBTF_CALLB_POLL_DELAY	1
218 #define	HERMON_QUIESCE_IBTF_CALLB_POLL_MAX	1000000
219 
220 /*
221  * Macros to retrieve PCI id's of the device
222  */
223 #define	HERMON_DDI_PROP_GET(dip, property) \
224 	(ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, \
225 	    property, -1))
226 
227 #define	HERMON_GET_VENDOR_ID(dip)	HERMON_DDI_PROP_GET(dip, "vendor-id")
228 #define	HERMON_GET_DEVICE_ID(dip)	HERMON_DDI_PROP_GET(dip, "device-id")
229 #define	HERMON_GET_REVISION_ID(dip)	HERMON_DDI_PROP_GET(dip, "revision-id")
230 
231 /*
232  * Defines used to record the device mode to which Hermon driver has been
233  * attached.  HERMON_MAINTENANCE_MODE is used when the device has
234  * come up in the "maintenance mode".  In this mode, no InfiniBand interfaces
235  * are enabled, but the device's firmware can be updated/flashed (and
236  * test/debug interfaces should be useable).
237  * HERMON_HCA_MODE isused when the device has come up in the
238  * normal HCA mode.  In this mode, all necessary InfiniBand interfaces are
239  * enabled (and, if necessary, HERMON firmware can be updated/flashed).
240  */
241 #define	HERMON_MAINTENANCE_MODE	1
242 #define	HERMON_HCA_MODE		2
243 
244 /*
245  * Used to determine if the device is operational, or not in maintenance mode.
246  * This means either the driver has attached successfully against an hermon
247  * device in hermon compatibility mode, or against a hermon device in full HCA
248  * mode.
249  */
250 #define	HERMON_IS_OPERATIONAL(mode)				\
251 	(mode == HERMON_HCA_MODE)
252 
253 /*
254  * The following define is used (in hermon_umap_db_set_onclose_cb()) to
255  * indicate that a cleanup callback is needed to undo initialization done
256  * by the firmware flash burn code.
257  */
258 #define	HERMON_ONCLOSE_FLASH_INPROGRESS		(1 << 0)
259 
260 /*
261  * The following enumerated type and structures are used during driver
262  * initialization.  Note: The HERMON_DRV_CLEANUP_ALL type is used as a marker
263  * for end of the cleanup steps.  No cleanup steps should be added after
264  * HERMON_DRV_CLEANUP_ALL.  Any addition steps should be added before it.
265  */
266 typedef enum {
267 	HERMON_DRV_CLEANUP_LEVEL0,
268 	HERMON_DRV_CLEANUP_LEVEL1,
269 	HERMON_DRV_CLEANUP_LEVEL2,
270 	HERMON_DRV_CLEANUP_LEVEL3,
271 	HERMON_DRV_CLEANUP_LEVEL4,
272 	HERMON_DRV_CLEANUP_LEVEL5,
273 	HERMON_DRV_CLEANUP_LEVEL6,
274 	HERMON_DRV_CLEANUP_LEVEL7,
275 	HERMON_DRV_CLEANUP_LEVEL8,
276 	HERMON_DRV_CLEANUP_LEVEL9,
277 	HERMON_DRV_CLEANUP_LEVEL10,
278 	HERMON_DRV_CLEANUP_LEVEL11,
279 	HERMON_DRV_CLEANUP_LEVEL12,
280 	HERMON_DRV_CLEANUP_LEVEL13,
281 	HERMON_DRV_CLEANUP_LEVEL14,
282 	HERMON_DRV_CLEANUP_LEVEL15,
283 	HERMON_DRV_CLEANUP_LEVEL16,
284 	HERMON_DRV_CLEANUP_LEVEL17,
285 	HERMON_DRV_CLEANUP_LEVEL18,
286 	HERMON_DRV_CLEANUP_LEVEL19,
287 	/* No more driver cleanup steps below this point! */
288 	HERMON_DRV_CLEANUP_ALL
289 } hermon_drv_cleanup_level_t;
290 
291 /*
292  * The hermon_dma_info_t structure is used to store information related to
293  * the various ICM resources' DMA allocations.  The related ICM table and
294  * virtual address are stored here.  The DMA and Access handles are stored
295  * here.  Also, the allocation length and virtual (host) address.
296  */
297 struct hermon_dma_info_s {
298 	ddi_dma_handle_t	dma_hdl;
299 	ddi_acc_handle_t	acc_hdl;
300 	uint64_t		icmaddr;	/* ICM virtual address */
301 	uint64_t		vaddr;  	/* host virtual address */
302 	uint_t			length;		/* length requested */
303 	uint_t			icm_refcnt;	/* refcnt */
304 };
305 _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
306     hermon_dma_info_s::icm_refcnt))
307 
308 
309 /*
310  * The hermon_cmd_reg_t structure is used to hold the address of the each of
311  * the most frequently accessed hardware registers.  Specifically, it holds
312  * the HCA Command Registers (HCR, used to pass command and mailbox
313  * information back and forth to Hermon firmware) and the lock used to guarantee
314  * mutually exclusive access to the registers.
315  * Related to this, is the "clr_int" register which is used to clear the
316  * interrupt once all EQs have been serviced.
317  * Finally, there is the software reset register which is used to reinitialize
318  * the Hermon device and to put it into a known state at driver startup time.
319  * Below we also have the offsets (into the CMD register space) for each of
320  * the various registers.
321  */
322 typedef struct hermon_cmd_reg_s {
323 	hermon_hw_hcr_t	*hcr;
324 	kmutex_t	hcr_lock;
325 	uint64_t	*clr_intr;
326 	uint64_t	*eq_arm;
327 	uint64_t	*eq_set_ci;
328 	uint32_t	*sw_reset;
329 	uint32_t	*sw_semaphore;
330 	uint32_t	*fw_err_buf;
331 } hermon_cmd_reg_t;
332 _NOTE(MUTEX_PROTECTS_DATA(hermon_cmd_reg_t::hcr_lock,
333     hermon_cmd_reg_t::hcr))
334 
335 /* SOME TEMPORARY PRINTING THINGS */
336 #define	HERMON_PRINT_CI		(0x01 << 0)
337 #define	HERMON_PRINT_MEM	(0x01 << 1)
338 #define	HERMON_PRINT_CQ		(0x01 << 2)
339 
340 
341 #define	HD_PRINT(state, mask)	\
342 	if (state->hs_debug_lev & mask)
343 
344 /* END PRINTING THINGS */
345 
346 /*
347  * The hermon_state_t structure is the HCA software state structure.  It
348  * contains all the pointers and placeholder for everything that the HCA
349  * driver needs to properly operate.  One of these structures exists for
350  * every instance of the HCA driver.
351  */
352 struct hermon_state_s {
353 	dev_info_t		*hs_dip;
354 	int			hs_instance;
355 int			hs_debug;	/* for debug, a way of tracing */
356 uint32_t		hs_debug_lev;	/* for controlling prints, a bit mask */
357 					/* see hermon.c for setting it */
358 	/* PCI device, vendor, and revision IDs */
359 	uint16_t		hs_vendor_id;
360 	uint16_t		hs_device_id;
361 	uint8_t			hs_revision_id;
362 
363 struct hermon_hw_qpc_s		hs_debug_qpc;
364 struct hermon_hw_cqc_s		hs_debug_cqc;
365 struct hermon_hw_eqc_s		hs_debug_eqc;
366 
367 	hermon_hw_sm_perfcntr_t	hs_debug_perf;
368 
369 
370 	/*
371 	 * DMA information for the InfiniHost Context Memory (ICM),
372 	 * ICM Auxiliary allocation and the firmware. Also, record
373 	 * of ICM and ICMA sizes, in bytes.
374 	 */
375 	/* JBDB -- store here hs_icm_table, with hs_icm_dma in */
376 
377 	uint64_t		hs_icm_sz;
378 	hermon_icm_table_t	*hs_icm;
379 	uint64_t		hs_icma_sz;
380 	hermon_dma_info_t	hs_icma_dma;
381 	hermon_dma_info_t	hs_fw_dma;
382 
383 	/* Hermon interrupt/MSI information */
384 	int			hs_intr_types_avail;
385 	uint_t			hs_intr_type_chosen;
386 	int			hs_intrmsi_count;
387 	int			hs_intrmsi_avail;
388 	int			hs_intrmsi_allocd;
389 	ddi_intr_handle_t	hs_intrmsi_hdl[HERMON_MSIX_MAX];
390 	uint_t			hs_intrmsi_pri;
391 	int			hs_intrmsi_cap;
392 
393 	/* assign EQs to CQs in a round robin fashion */
394 	uint_t			hs_eq_dist;	/* increment when used */
395 
396 	/* hermon HCA name and HCA part number */
397 	char			hs_hca_name[64];
398 	char			hs_hca_pn[64];
399 	int			hs_hca_pn_len;
400 
401 	/* Hermon device operational mode */
402 	int			hs_operational_mode;
403 
404 	/* Attach buffer saved per state to store detailed attach errors */
405 	char			hs_attach_buf[HERMON_ATTACH_MSGSIZE];
406 
407 	/* Hermon NodeGUID, SystemImageGUID, and NodeDescription */
408 	uint64_t		hs_nodeguid;
409 	uint64_t		hs_sysimgguid;
410 	char			hs_nodedesc[64];
411 
412 	/* Info passed to IBTF during registration */
413 	ibc_hca_info_t		hs_ibtfinfo;
414 	ibc_clnt_hdl_t		hs_ibtfpriv;
415 
416 	/*
417 	 * Hermon register mapping.  Holds the device access attributes,
418 	 * kernel mapped addresses, and DDI access handles for both
419 	 * Hermon's CMD and UAR BARs.
420 	 */
421 	ddi_device_acc_attr_t	hs_reg_accattr;
422 	caddr_t			hs_reg_cmd_baseaddr;	/* Hermon CMD BAR */
423 	ddi_acc_handle_t	hs_reg_cmdhdl;
424 	caddr_t			hs_reg_uar_baseaddr;	/* Hermon UAR BAR */
425 	ddi_acc_handle_t	hs_reg_uarhdl;
426 	caddr_t			hs_reg_msi_baseaddr;	/* Hermon MSIx BAR */
427 	ddi_acc_handle_t	hs_reg_msihdl;
428 
429 	/*
430 	 * Some additional things for UAR Pages
431 	 */
432 	uint64_t		hs_kernel_uar_index;	/* kernel UAR index */
433 	uint64_t		hs_bf_offset;		/* offset from UAR */
434 							/* Bar to Blueflame */
435 	caddr_t			hs_reg_bf_baseaddr;	/* blueflame base */
436 	ddi_acc_handle_t	hs_reg_bfhdl;  		/* blueflame handle */
437 
438 
439 	/*
440 	 * Hermon PCI config space registers.  This array is used to
441 	 * save and restore the PCI config registers before and after a
442 	 * software reset.
443 	 */
444 	uint32_t		hs_cfg_data[HERMON_SW_RESET_NUMREGS];
445 	/* for reset per Linux driver */
446 	uint32_t		hs_pci_cap_offset;
447 	uint32_t		hs_pci_cap_devctl;
448 	uint32_t		hs_pci_cap_lnkctl;
449 
450 	/*
451 	 * Hermon UAR page resources.  Holds the resource pointers for
452 	 * UAR page #0 (reserved) and for UAR page #1 (used for kernel
453 	 * driver doorbells).  In addition, we save a pointer to the
454 	 * UAR page #1 doorbells which will be used throughout the driver
455 	 * whenever it is necessary to ring one of them.  And, in case we
456 	 * are unable to do 64-bit writes to the page (because of system
457 	 * architecture), we include a lock (to ensure atomic 64-bit access).
458 	 */
459 	hermon_rsrc_t		*hs_uarpg0_rsrc_rsrvd;
460 	hermon_rsrc_t		*hs_uarkpg_rsrc;
461 	hermon_hw_uar_t		*hs_uar;
462 	kmutex_t		hs_uar_lock;
463 
464 	/*
465 	 * Used during a call to open() if we are in maintenance mode, this
466 	 * field serves as a semi-unique rolling count index value, used only
467 	 * in the setup of umap_db entries.  This is primarily needed to
468 	 * firmware device access ioctl operations can still be guaranteed to
469 	 * close in the event of an unplanned process exit, even in maintenance
470 	 * mode.
471 	 */
472 	uint_t			hs_open_ar_indx;
473 
474 	/*
475 	 * Hermon command registers.  This structure contains the addresses
476 	 * for each of the most frequently accessed CMD registers.  Since
477 	 * almost all accesses to the Hermon hardware are through the Hermon
478 	 * command interface (i.e. the HCR), we save away the pointer to
479 	 * the HCR, as well as pointers to the ECR and INT registers (as
480 	 * well as their corresponding "clear" registers) for interrupt
481 	 * processing.  And we also save away a pointer to the software
482 	 * reset register (see above).
483 	 */
484 	hermon_cmd_reg_t	hs_cmd_regs;
485 	uint32_t		hs_cmd_toggle;
486 
487 	/*
488 	 * Hermon resource pointers.  The following are pointers to the
489 	 * kmem cache (from which the Hermon resource handles are allocated),
490 	 * and the array of "resource pools" (which store all the pertinent
491 	 * information necessary to manage each of the various types of
492 	 * resources that are used by the driver.  See hermon_rsrc.h for
493 	 * more detail.
494 	 */
495 	kmem_cache_t		*hs_rsrc_cache;
496 	hermon_rsrc_pool_info_t	*hs_rsrc_hdl;
497 
498 	/*
499 	 * Hermon mailbox lists.  These hold the information necessary to
500 	 * manage the pools of pre-allocated Hermon mailboxes (both "In" and
501 	 * "Out" type).  See hermon_cmd.h for more detail.
502 	 */
503 	hermon_mboxlist_t	hs_in_mblist;
504 	hermon_mboxlist_t	hs_out_mblist;
505 
506 	/*
507 	 * Hermon interrupt mailbox lists.  We allocate both an "In" mailbox
508 	 * and an "Out" type mailbox for the interrupt context.  This is in
509 	 * order to guarantee that a mailbox entry will always be available in
510 	 * the interrupt context, and we can NOSLEEP without having to worry
511 	 * about possible failure allocating the mbox.  We create this as an
512 	 * mboxlist so that we have the potential for having multiple mboxes
513 	 * available based on the number of interrupts we can receive at once.
514 	 */
515 	hermon_mboxlist_t	hs_in_intr_mblist;
516 	hermon_mboxlist_t	hs_out_intr_mblist;
517 
518 	/*
519 	 * Hermon outstanding command list.  Used to hold all the information
520 	 * necessary to manage the Hermon "outstanding command list".  See
521 	 * hermon_cmd.h for more detail.
522 	 */
523 	hermon_cmdlist_t	hs_cmd_list;
524 
525 	/*
526 	 * This structure contains the Hermon driver's "configuration profile".
527 	 * This is the collected set of configuration information, such as
528 	 * number of QPs, CQs, mailboxes and other resources, sizes of
529 	 * individual resources, other system level configuration information,
530 	 * etc.  See hermon_cfg.h for more detail.
531 	 */
532 	hermon_cfg_profile_t	*hs_cfg_profile;
533 
534 	/*
535 	 * This flag contains the profile setting, selecting which profile the
536 	 * driver would use.  This is needed in the case where we have to
537 	 * fallback to a smaller profile based on some DDR conditions.  If we
538 	 * don't fallback, then it is set to the size of DDR in the system.
539 	 */
540 	uint32_t		hs_cfg_profile_setting;
541 
542 	/*
543 	 * The following are a collection of resource handles used by the
544 	 * Hermon driver (internally).  First is the protection domain (PD)
545 	 * handle that is used when mapping all kernel memory (work queues,
546 	 * completion queues, etc).  Next is an array of EQ handles.  This
547 	 * array is indexed by EQ number and allows the Hermon driver to quickly
548 	 * convert an EQ number into the software structure associated with the
549 	 * given EQ.  Likewise, we have three arrays for CQ, QP and SRQ
550 	 * handles.  These arrays are also indexed by CQ, QP or SRQ number and
551 	 * allow the driver to quickly find the corresponding CQ, QP or SRQ
552 	 * software structure.  Note: while the EQ table is of fixed size
553 	 * (because there are a maximum of 64 EQs), each of the CQ, QP and SRQ
554 	 * handle lists must be allocated at driver startup.
555 	 */
556 	hermon_pdhdl_t		hs_pdhdl_internal;
557 	hermon_eqhdl_t		hs_eqhdl[HERMON_NUM_EQ];
558 	hermon_cqhdl_t		*hs_cqhdl;
559 	hermon_qphdl_t		*hs_qphdl;
560 	hermon_srqhdl_t		*hs_srqhdl;
561 	kmutex_t		hs_dbr_lock;	/* lock for dbr mgmt */
562 
563 	/* linked list of kernel dbr resources */
564 	hermon_dbr_info_t	*hs_kern_dbr;
565 
566 	/* linked list of non-kernel dbr resources */
567 	hermon_user_dbr_t	*hs_user_dbr;
568 
569 	/*
570 	 * The AVL tree is used to store information regarding QP number
571 	 * allocations.  The lock protects access to the AVL tree.
572 	 */
573 	avl_tree_t		hs_qpn_avl;
574 	kmutex_t		hs_qpn_avl_lock;
575 
576 	/*
577 	 * This field is used to indicate whether or not the Hermon driver is
578 	 * currently in an IBTF event callback elsewhere in the system.  Note:
579 	 * It is "volatile" because we intend to poll on this value - in
580 	 * hermon_detach() - until we are assured that no further IBTF callbacks
581 	 * are currently being processed.
582 	 */
583 	volatile uint32_t	hs_in_evcallb;
584 
585 	/*
586 	 * The following structures are used to store the results of several
587 	 * device query commands passed to the Hermon hardware at startup.
588 	 * Specifically, we have hung onto the results of QUERY_DDR (which
589 	 * gives information about how much DDR memory is present and where
590 	 * it is located), QUERY_FW (which gives information about firmware
591 	 * version numbers and the location and extent of firmware's footprint
592 	 * in DDR, QUERY_DEVLIM (which gives the device limitations/resource
593 	 * maximums) and QUERY_PORT (where some of the specs from DEVLIM moved),
594 	 * QUERY_ADAPTER (which gives additional miscellaneous
595 	 * information), and INIT/QUERY_HCA (which serves the purpose of
596 	 * recording what configuration information was passed to the firmware
597 	 * when the HCA was initialized).
598 	 */
599 	struct hermon_hw_queryfw_s	hs_fw;
600 	struct hermon_hw_querydevlim_s	hs_devlim;
601 	struct hermon_hw_query_port_s	hs_queryport;
602 	struct hermon_hw_set_port_s 	*hs_initport;
603 	struct hermon_hw_queryadapter_s	hs_adapter;
604 	struct hermon_hw_initqueryhca_s	hs_hcaparams;
605 
606 	/*
607 	 * The following are used for managing special QP resources.
608 	 * Specifically, we have a lock, a set of flags (in "hs_spec_qpflags")
609 	 * used to track the special QP resources, and two Hermon resource
610 	 * handle pointers.  Each resource handle actually corresponds to two
611 	 * consecutive QP contexts (one per port) for each special QP type.
612 	 */
613 	kmutex_t		hs_spec_qplock;
614 	uint_t			hs_spec_qpflags;
615 	hermon_rsrc_t		*hs_spec_qp0;
616 	hermon_rsrc_t		*hs_spec_qp1;
617 	/*
618 	 * For Hermon, you have to alloc 8 qp's total, but the last 4 are
619 	 * unused/reserved.  The following represents the handle for those
620 	 * last 4 qp's
621 	 */
622 	hermon_rsrc_t		*hs_spec_qp_unused;
623 
624 	/*
625 	 * Related in some ways to the special QP handling above are these
626 	 * resources which are used specifically for implementing the Hermon
627 	 * agents (SMA, PMA, and BMA).  Although, each of these agents does
628 	 * little more that intercept the appropriate incoming MAD and forward
629 	 * it along to the firmware (see hermon_agents.c for more details), we
630 	 * do still use a task queue to queue them up.  We can also configure
631 	 * the driver to force firmware handling for certain classes of MAD,
632 	 * and, therefore, we require the agent list and number of agents
633 	 * in order to know what needs to be torn down at detach() time.
634 	 */
635 	hermon_agent_list_t	*hs_agents;
636 	ddi_taskq_t		*hs_taskq_agents;
637 	uint_t			hs_num_agents;
638 
639 	/*
640 	 * Multicast group lists.  These are used to track the "shadow" MCG
641 	 * lists that speed up the processing of attach and detach multicast
642 	 * group operations.  See hermon_misc.h for more details.  Note: we
643 	 * need the pointer to the "temporary" MCG entry here primarily
644 	 * because the size of a given MCG entry is configurable.  Therefore,
645 	 * it is impossible to put this variable on the stack.  And rather
646 	 * than allocate and deallocate the entry multiple times, we choose
647 	 * instead to preallocate it once and reuse it over and over again.
648 	 */
649 	kmutex_t		hs_mcglock;
650 	hermon_mcghdl_t		hs_mcghdl;
651 	hermon_hw_mcg_t		*hs_mcgtmp;
652 
653 	/*
654 	 * Cache of the pkey table, sgid (guid-only) tables, and
655 	 * sgid (subnet) prefix.  These arrays are set
656 	 * during port_query, and mainly used for generating MLX GSI wqes.
657 	 */
658 	ib_pkey_t		*hs_pkey[HERMON_MAX_PORTS];
659 	ib_sn_prefix_t		hs_sn_prefix[HERMON_MAX_PORTS];
660 	ib_guid_t		*hs_guid[HERMON_MAX_PORTS];
661 
662 	/*
663 	 * Used for tracking Hermon kstat information
664 	 */
665 	hermon_ks_info_t	*hs_ks_info;
666 
667 	/*
668 	 * Used for Hermon info ioctl used by VTS
669 	 */
670 	kmutex_t		hs_info_lock;
671 
672 	/*
673 	 * Used for Hermon FW flash burning.  They are used exclusively
674 	 * within the ioctl calls for use when accessing the hermon
675 	 * flash device.
676 	 */
677 	kmutex_t		hs_fw_flashlock;
678 	int			hs_fw_flashstarted;
679 	dev_t			hs_fw_flashdev;
680 	uint32_t		hs_fw_log_sector_sz;
681 	uint32_t		hs_fw_device_sz;
682 	uint32_t		hs_fw_flashbank;
683 	uint32_t		*hs_fw_sector;
684 	uint32_t		hs_fw_gpio[4];
685 	int			hs_fw_cmdset;
686 
687 	/*
688 	 * Used for Hermon FM. They are basically used to manage
689 	 * the toggle switch to enable/disable Hermon FM.
690 	 * Please see the comment in hermon_fm.c.
691 	 */
692 	int			hs_fm_capabilities; /* FM capabilities */
693 	int			hs_fm_disable;	/* Hermon FM disable flag */
694 	int			hs_fm_state;	/* Hermon FM state */
695 	boolean_t		hs_fm_async_fatal; /* async internal error */
696 	uint32_t		hs_fm_async_errcnt; /* async error count */
697 	boolean_t		hs_fm_poll_suspend; /* poll thread suspend */
698 	kmutex_t		hs_fm_lock;	/* mutex for state */
699 	hermon_hca_fm_t		*hs_fm_hca_fm;	/* HCA FM pointer */
700 	ddi_acc_handle_t	hs_fm_cmdhdl;	/* fm-protected CMD hdl */
701 	ddi_acc_handle_t	hs_fm_uarhdl;	/* fm-protected UAR hdl */
702 	ddi_device_acc_attr_t	hs_fm_accattr;	/* fm-protected acc attr */
703 	ddi_periodic_t		hs_fm_poll_thread; /* fma poll thread */
704 	int32_t			hs_fm_degraded_reason;	/* degradation cause */
705 #ifdef FMA_TEST
706 	mod_hash_t		*hs_fm_test_hash; /* testset */
707 	mod_hash_t		*hs_fm_id_hash;	/* testid */
708 #endif
709 	/*
710 	 * Hermon fastreboot support. To sw-reset Hermon HCA, the driver
711 	 * needs to save/restore MSI-X tables and PBA. Those members are
712 	 * used for the purpose.
713 	 */
714 	/* Access handle for PCI config space */
715 	ddi_acc_handle_t	hs_reg_pcihdl;		/* PCI cfg handle */
716 	ddi_acc_handle_t	hs_fm_pcihdl;		/* 	fm handle */
717 	ushort_t		hs_caps_ptr;		/* MSI-X caps */
718 	ushort_t		hs_msix_ctrl;		/* MSI-X ctrl */
719 
720 	/* members to handle MSI-X tables */
721 	ddi_acc_handle_t	hs_reg_msix_tblhdl;	/* MSI-X table handle */
722 	ddi_acc_handle_t	hs_fm_msix_tblhdl;	/* 	fm handle */
723 	char 			*hs_msix_tbl_addr;	/* MSI-X table addr */
724 	char 			*hs_msix_tbl_entries;	/* MSI-X table entry */
725 	size_t			hs_msix_tbl_size;	/* MSI-X table size */
726 	uint32_t		hs_msix_tbl_offset;	/* MSI-X table offset */
727 	uint32_t		hs_msix_tbl_rnumber;	/* MSI-X table reg# */
728 
729 	/* members to handle MSI-X PBA */
730 	ddi_acc_handle_t	hs_reg_msix_pbahdl;	/* MSI-X PBA handle */
731 	ddi_acc_handle_t	hs_fm_msix_pbahdl;	/* 	fm handle */
732 	char 			*hs_msix_pba_addr;	/* MSI-X PBA addr */
733 	char 			*hs_msix_pba_entries;	/* MSI-X PBA entry */
734 	size_t			hs_msix_pba_size;	/* MSI-X PBA size */
735 	uint32_t		hs_msix_pba_offset;	/* MSI-X PBA offset */
736 	uint32_t		hs_msix_pba_rnumber;	/* MSI-X PBA reg# */
737 
738 	boolean_t		hs_quiescing;		/* in fastreboot */
739 };
740 _NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_fw_flashlock,
741     hermon_state_s::hs_fw_flashstarted
742     hermon_state_s::hs_fw_flashdev
743     hermon_state_s::hs_fw_log_sector_sz
744     hermon_state_s::hs_fw_device_sz))
745 _NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_spec_qplock,
746     hermon_state_s::hs_spec_qpflags
747     hermon_state_s::hs_spec_qp0
748     hermon_state_s::hs_spec_qp1))
749 _NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_mcglock,
750     hermon_state_s::hs_mcghdl
751     hermon_state_s::hs_mcgtmp))
752 _NOTE(DATA_READABLE_WITHOUT_LOCK(hermon_state_s::hs_in_evcallb
753     hermon_state_s::hs_fw_log_sector_sz
754     hermon_state_s::hs_fw_device_sz
755     hermon_state_s::hs_spec_qpflags
756     hermon_state_s::hs_spec_qp0
757     hermon_state_s::hs_spec_qp1))
758 _NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_qpn_avl_lock,
759     hermon_state_s::hs_qpn_avl))
760 _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
761     hermon_state_s::hs_fm_async_fatal
762     hermon_state_s::hs_fw_sector))
763 
764 /*
765  * HERMON_IN_FASTREBOOT() shows if Hermon driver is at fastreboot.
766  * This macro should be used to check if the mutex lock can be used
767  * since the lock cannot be used if the driver is in the quiesce mode.
768  */
769 #define	HERMON_IN_FASTREBOOT(state)	(state->hs_quiescing == B_TRUE)
770 
771 /*
772  * Bit positions in the "hs_spec_qpflags" field above.  The flags are (from
773  * least significant to most): (QP0,Port1), (QP0,Port2), (QP1,Port1), and
774  * (QP1,Port2).  The masks are there to help with some specific allocation
775  * and freeing operations
776  */
777 #define	HERMON_SPECIAL_QP0_RSRC		0
778 #define	HERMON_SPECIAL_QP0_RSRC_MASK	0x3
779 #define	HERMON_SPECIAL_QP1_RSRC		2
780 #define	HERMON_SPECIAL_QP1_RSRC_MASK	0xC
781 
782 
783 /*
784  * These flags specifies additional behaviors on database access.
785  * HERMON_UMAP_DB_REMOVE, for example, specifies that (if found) the database
786  * entry should be removed from the database.  HERMON_UMAP_DB_IGNORE_INSTANCE
787  * specifies that a particular database query should ignore value in the
788  * "tdb_instance" field as a criterion for the search.
789  */
790 #define	HERMON_UMAP_DB_REMOVE		(1 << 0)
791 #define	HERMON_UMAP_DB_IGNORE_INSTANCE	(1 << 1)
792 
793 /*
794  * The hermon_umap_db_t structure contains what is referred to throughout the
795  * driver code as the "userland resources database".  This structure contains
796  * all the necessary information to track resources that have been prepared
797  * for direct-from-userland access.  There is an AVL tree ("hdl_umapdb_avl")
798  * which consists of the "hermon_umap_db_entry_t" (below) and a lock to ensure
799  * atomic access when adding or removing entries from the database.
800  */
801 typedef struct hermon_umap_db_s {
802 	kmutex_t		hdl_umapdb_lock;
803 	avl_tree_t		hdl_umapdb_avl;
804 } hermon_umap_db_t;
805 
806 /*
807  * The hermon_umap_db_priv_t structure currently contains information necessary
808  * to provide the "on close" callback to the firmware flash interfaces.  It
809  * is intended that this structure could be extended to enable other "on
810  * close" callbacks as well.
811  */
812 typedef struct hermon_umap_db_priv_s {
813 	int		(*hdp_cb)(void *);
814 	void		*hdp_arg;
815 } hermon_umap_db_priv_t;
816 
817 /*
818  * The hermon_umap_db_common_t structure contains fields which are common
819  * between the database entries ("hermon_umap_db_entry_t") and the structure
820  * used to contain the search criteria ("hermon_umap_db_query_t").  This
821  * structure contains a key, a resource type (described above), an instance
822  * (corresponding to the driver instance which inserted the database entry),
823  * and a "value" field.  Typically, "hdb_value" is a pointer to a Hermon
824  * resource object.  Although for memory regions, the value field corresponds
825  * to the ddi_umem_cookie_t for the pinned userland memory.
826  * The structure also includes a placeholder for private data ("hdb_priv").
827  * Currently this data is being used for holding "on close" callback
828  * information to allow certain kinds of cleanup even if a userland process
829  * prematurely exits.
830  */
831 typedef struct hermon_umap_db_common_s {
832 	uint64_t		hdb_key;
833 	uint64_t		hdb_value;
834 	uint_t			hdb_type;
835 	uint_t			hdb_instance;
836 	void			*hdb_priv;
837 } hermon_umap_db_common_t;
838 
839 /*
840  * The hermon_umap_db_entry_t structure is the entry in "userland resources
841  * database".  As required by the AVL framework, each entry contains an
842  * "avl_node_t".  Then, as required to implement the database, each entry
843  * contains a "hermon_umap_db_common_t" structure used to contain all of the
844  * relevant entries.
845  */
846 typedef struct hermon_umap_db_entry_s {
847 	avl_node_t		hdbe_avlnode;
848 	hermon_umap_db_common_t	hdbe_common;
849 } hermon_umap_db_entry_t;
850 
851 /*
852  * The hermon_umap_db_query_t structure is used in queries to the "userland
853  * resources database".  In addition to the "hermon_umap_db_common_t" structure
854  * used to contain the various search criteria, this structure also contains
855  * a flags field "hqdb_flags" which can be used to specify additional behaviors
856  * (as described above).  Specifically, the flags field can be used to specify
857  * that an entry should be removed from the database, if found, and to
858  * specify whether the database lookup should consider "tdb_instance" in the
859  * search.
860  */
861 typedef struct hermon_umap_db_query_s {
862 	uint_t			hqdb_flags;
863 	hermon_umap_db_common_t	hqdb_common;
864 } hermon_umap_db_query_t;
865 _NOTE(MUTEX_PROTECTS_DATA(hermon_umap_db_s::hdl_umapdb_lock,
866     hermon_umap_db_entry_s::hdbe_avlnode
867     hermon_umap_db_entry_s::hdbe_common.hdb_key
868     hermon_umap_db_entry_s::hdbe_common.hdb_value
869     hermon_umap_db_entry_s::hdbe_common.hdb_type
870     hermon_umap_db_entry_s::hdbe_common.hdb_instance))
871 
872 /*
873  * The hermon_devmap_track_t structure contains all the necessary information
874  * to track resources that have been mapped through devmap.  There is a
875  * back-pointer to the Hermon softstate, the logical offset corresponding with
876  * the mapped resource, the size of the mapped resource (zero indicates an
877  * "invalid mapping"), and a reference count and lock used to determine when
878  * to free the structure (specifically, this is necessary to handle partial
879  * unmappings).
880  */
881 typedef struct hermon_devmap_track_s {
882 	hermon_state_t	*hdt_state;
883 	uint64_t	hdt_offset;
884 	uint_t		hdt_size;
885 	int		hdt_refcnt;
886 	kmutex_t	hdt_lock;
887 } hermon_devmap_track_t;
888 
889 #define	HERMON_ICM_SPLIT	64
890 #define	HERMON_ICM_SPAN		4096
891 
892 #define	hermon_bitmap(bitmap, dma_info, icm_table, split_index)	\
893 	bitmap = (icm_table)->icm_bitmap[split_index];		\
894 	if (bitmap == NULL) {					\
895 		_NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*(icm_table))) \
896 		int num_spans = (icm_table)->num_spans;		\
897 		bitmap =					\
898 		(icm_table)->icm_bitmap[split_index] =		\
899 		    kmem_zalloc((num_spans + 7) / 8, KM_SLEEP);	\
900 		ASSERT((icm_table)->icm_dma[split_index] == NULL); \
901 		(icm_table)->icm_dma[split_index] =		\
902 		    kmem_zalloc(num_spans * sizeof (hermon_dma_info_t), \
903 		    KM_SLEEP);					\
904 	}							\
905 	dma_info = (icm_table)->icm_dma[split_index]
906 
907 /*
908  * The hermon_icm_table_t encodes data pertaining to a given ICM table, and
909  * holds an array of hermon_dma_info_t's related to its backing memory. Each
910  * ICM table is sized during initialization, but real memory is allocated
911  * and mapped into and out of ICM in the device throughout the life of the
912  * instance. We use a bitmap to determine whether or not a given ICM object
913  * has memory backing it or not, and an array of hermon_dma_info_t's to house
914  * the actual allocations. Memory is allocated in chunks of span_size, stored
915  * in the icm_dma array, and can later be looked up by using the bitmap index.
916  * The total number of ICM spans is equal to table_size / span_size. We also
917  * keep track of the ICM characteristics, such as ICM object size and the
918  * number of entries in the ICM area.
919  */
920 struct hermon_icm_table_s {
921 	kmutex_t		icm_table_lock;
922 	kcondvar_t		icm_table_cv;
923 	uint8_t			icm_busy;
924 	hermon_rsrc_type_t	icm_type;
925 	uint64_t		icm_baseaddr;
926 	uint64_t		table_size;
927 	uint64_t		num_entries;	/* maximum #entries */
928 	uint32_t		object_size;
929 	uint32_t		span;		/* #rsrc's per span */
930 	uint32_t		num_spans;	/* #dmainfos in icm_dma */
931 	uint32_t		split_shift;
932 	uint32_t		span_mask;
933 	uint32_t		span_shift;
934 	uint32_t		rsrc_mask;
935 	uint16_t		log_num_entries;
936 	uint16_t		log_object_size;
937 	/* two arrays of pointers, each pointer points to arrays */
938 	uint8_t			*icm_bitmap[HERMON_ICM_SPLIT];
939 	hermon_dma_info_t	*icm_dma[HERMON_ICM_SPLIT];
940 };
941 /*
942  * Split the rsrc index into three pieces:
943  *
944  *      index1 - icm_bitmap[HERMON_ICM_SPLIT], icm_dma[HERMON_ICM_SPLIT]
945  *      index2 - bitmap[], dma[]
946  *      offset - rsrc within the icm mapping
947  */
948 #define	hermon_index(index1, index2, rindx, table, offset)		\
949 	index1 = (rindx) >> table->split_shift;				\
950 	index2 = ((rindx) & table->span_mask) >> table->span_shift;	\
951 	offset = (rindx) & table->rsrc_mask
952 
953 /* Defined in hermon.c */
954 int hermon_dma_alloc(hermon_state_t *state, hermon_dma_info_t *dma_info,
955     uint16_t opcode);
956 void hermon_dma_attr_init(hermon_state_t *state, ddi_dma_attr_t *dma_attr);
957 void hermon_dma_free(hermon_dma_info_t *info);
958 int hermon_icm_alloc(hermon_state_t *state, hermon_rsrc_type_t type,
959     uint32_t icm_index1, uint32_t icm_index2);
960 void hermon_icm_free(hermon_state_t *state, hermon_rsrc_type_t type,
961     uint32_t icm_index1, uint32_t icm_index2);
962 int hermon_device_mode(hermon_state_t *state);
963 
964 /* Defined in hermon_umap.c */
965 int hermon_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
966     size_t *maplen, uint_t model);
967 ibt_status_t hermon_umap_ci_data_in(hermon_state_t *state,
968     ibt_ci_data_flags_t flags, ibt_object_type_t object, void *hdl,
969     void *data_p, size_t data_sz);
970 ibt_status_t hermon_umap_ci_data_out(hermon_state_t *state,
971     ibt_ci_data_flags_t flags, ibt_object_type_t object, void *hdl,
972     void *data_p, size_t data_sz);
973 void hermon_umap_db_init(void);
974 void hermon_umap_db_fini(void);
975 hermon_umap_db_entry_t *hermon_umap_db_alloc(uint_t instance, uint64_t key,
976     uint_t type, uint64_t value);
977 void hermon_umap_db_free(hermon_umap_db_entry_t *umapdb);
978 void hermon_umap_db_add(hermon_umap_db_entry_t *umapdb);
979 void hermon_umap_db_add_nolock(hermon_umap_db_entry_t *umapdb);
980 int hermon_umap_db_find(uint_t instance, uint64_t key, uint_t type,
981     uint64_t *value, uint_t flags, hermon_umap_db_entry_t **umapdb);
982 int hermon_umap_db_find_nolock(uint_t instance, uint64_t key, uint_t type,
983     uint64_t *value, uint_t flags, hermon_umap_db_entry_t **umapdb);
984 void hermon_umap_umemlock_cb(ddi_umem_cookie_t *umem_cookie);
985 int hermon_umap_db_set_onclose_cb(dev_t dev, uint64_t flag,
986     int (*callback)(void *), void *arg);
987 int hermon_umap_db_clear_onclose_cb(dev_t dev, uint64_t flag);
988 int hermon_umap_db_handle_onclose_cb(hermon_umap_db_priv_t *priv);
989 int hermon_rsrc_hw_entries_init(hermon_state_t *state,
990     hermon_rsrc_hw_entry_info_t *info);
991 void hermon_rsrc_hw_entries_fini(hermon_state_t *state,
992     hermon_rsrc_hw_entry_info_t *info);
993 
994 #ifdef __cplusplus
995 }
996 #endif
997 
998 #endif	/* _SYS_IB_ADAPTERS_HERMON_H */
999