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