9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
13cc0a0b8d667c14344b4ff49cc47350cd9ef182Bill Taylor * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains the #defines and typedefs necessary for the Hermon softstate
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structure and for proper attach() and detach() processing. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * includes all the other Hermon header files (and so is the only header
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file that is directly included by the Hermon source files).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Lastly, this file includes everything necessary for implementing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * devmap interface and for maintaining the "mapped resource database".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * First include all the Hermon typedefs, then include all the other Hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific headers (many of which depend on the typedefs having already
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * been defined).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/ib/adapters/hermon/hermon_typedef.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/ib/adapters/hermon/hermon_agents.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Number of initial states to setup. Used in call to ddi_soft_state_init()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Macro and defines used to calculate device instance number from minor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number (and vice versa).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_DEV_INSTANCE(dev) (getminor((dev)) & \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Locations for the various Hermon hardware CMD,UAR & MSIx PCIe BARs
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_CMD_BAR 1 /* device config space */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor#define HERMON_MSIX_MAX 256 /* max # of interrupt vectors */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * VPD header size - or more rightfully, the area of interest for fwflash
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * There's more, but we don't need it for our use so we don't read it
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_VPD_HDR_DWSIZE 0x10 /* 16 Dwords */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Offsets to be used w/ reset to save/restore PCI capability stuff
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Some defines for the software reset. These define the value that should
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be written to begin the reset (HERMON_SW_RESET_START), the delay before
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * beginning to poll for completion (HERMON_SW_RESET_DELAY), the in-between
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * polling delay (HERMON_SW_RESET_POLL_DELAY), and the value that indicates
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that the reset has not completed (HERMON_SW_RESET_NOTDONE).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_SW_RESET_DELAY 1000000 /* 1000 ms, per 0.36 PRM */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_SW_RESET_POLL_DELAY 100 /* 100 us */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These defines are used in the Hermon software reset operation. They define
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the total number PCI registers to read/restore during the reset. And they
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * also specify two config registers which should not be read or restored.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_SW_RESET_REG22_RSVD 0x16 /* 22 dec */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_SW_RESET_REG23_RSVD 0x17 /* 23 dec */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Macro used to output HCA warning messages. Note: HCA warning messages
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are only generated when an unexpected condition has been detected. This
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * can be the result of a software bug or some other problem. Previously
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * this was used for hardware errors, but those now use HERMON_FMANOTE
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * instead, indicating that the driver state is more likely in an
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * unpredictable state, and that shutdown/restart is suggested.
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * HERMON_WARNING messages are not considered important enough to print
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * to the console, just to the message log.
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor cmn_err(CE_CONT, "!hermon%d: %s\n", (state)->hs_instance, string)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Macro used to set attach failure messages. Also, the attach message buf
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * size is set here.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_ATTACH_MSG(attach_buf, attach_msg) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (void) snprintf((attach_buf), HERMON_ATTACH_MSGSIZE, (attach_msg));
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Macros used for controlling whether or not event callbacks will be forwarded
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to the IBTF. This is necessary because there are certain race conditions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that can occur (e.g. calling IBTF with an asynch event before the IBTF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * registration has successfully completed or handling an event after we've
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * detached from the IBTF.)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_ENABLE_IBTF_CALLB() initializes the "hs_ibtfpriv" field in the Hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * softstate. When "hs_ibtfpriv" is non-NULL, it is OK to forward asynch
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and CQ events to the IBTF.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_DO_IBTF_ASYNC_CALLB() and HERMON_DO_IBTF_CQ_CALLB() both set and clear
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "hs_in_evcallb" flag, as necessary, to indicate that an IBTF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * callback is currently in progress. This is necessary so that we can
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * block on this condition in hermon_detach().
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_QUIESCE_IBTF_CALLB() is used in hermon_detach() to set the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "hs_ibtfpriv" to NULL (thereby disabling any further IBTF callbacks)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and to poll on the "hs_in_evcallb" flag. When this flag is zero, all
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * IBTF callbacks have quiesced and it is safe to continue with detach
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (i.e. continue detaching from IBTF).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_ENABLE_IBTF_CALLB(state, tmp_ibtfpriv) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_DO_IBTF_ASYNC_CALLB(state, type, event) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS((state)->hs_in_evcallb)) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibc_async_handler((state)->hs_ibtfpriv, (type), (event)); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS((state)->hs_in_evcallb)) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibc_cq_handler((state)->hs_ibtfpriv, (cq)->cq_hdlrarg); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (count++ < HERMON_QUIESCE_IBTF_CALLB_POLL_MAX)) { \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor drv_usecwait(HERMON_QUIESCE_IBTF_CALLB_POLL_DELAY); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Defines used by the HERMON_QUIESCE_IBTF_CALLB() macro to determine the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * duration and number of times (at maximum) to poll while waiting for IBTF
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * callbacks to quiesce.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_QUIESCE_IBTF_CALLB_POLL_MAX 1000000
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Macros to retrieve PCI id's of the device
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_GET_VENDOR_ID(dip) HERMON_DDI_PROP_GET(dip, "vendor-id")
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_GET_DEVICE_ID(dip) HERMON_DDI_PROP_GET(dip, "device-id")
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_GET_REVISION_ID(dip) HERMON_DDI_PROP_GET(dip, "revision-id")
13cc0a0b8d667c14344b4ff49cc47350cd9ef182Bill Taylor * Defines used to record the device mode to which Hermon driver has been
13cc0a0b8d667c14344b4ff49cc47350cd9ef182Bill Taylor * attached. HERMON_MAINTENANCE_MODE is used when the device has
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * come up in the "maintenance mode". In this mode, no InfiniBand interfaces
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are enabled, but the device's firmware can be updated/flashed (and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * test/debug interfaces should be useable).
13cc0a0b8d667c14344b4ff49cc47350cd9ef182Bill Taylor * HERMON_HCA_MODE isused when the device has come up in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * normal HCA mode. In this mode, all necessary InfiniBand interfaces are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * enabled (and, if necessary, HERMON firmware can be updated/flashed).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used to determine if the device is operational, or not in maintenance mode.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This means either the driver has attached successfully against an hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * device in hermon compatibility mode, or against a hermon device in full HCA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following define is used (in hermon_umap_db_set_onclose_cb()) to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * indicate that a cleanup callback is needed to undo initialization done
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * by the firmware flash burn code.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type and structures are used during driver
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * initialization. Note: The HERMON_DRV_CLEANUP_ALL type is used as a marker
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for end of the cleanup steps. No cleanup steps should be added after
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_DRV_CLEANUP_ALL. Any addition steps should be added before it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* No more driver cleanup steps below this point! */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_dma_info_t structure is used to store information related to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the various ICM resources' DMA allocations. The related ICM table and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * virtual address are stored here. The DMA and Access handles are stored
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * here. Also, the allocation length and virtual (host) address.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_cmd_reg_t structure is used to hold the address of the each of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the most frequently accessed hardware registers. Specifically, it holds
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the HCA Command Registers (HCR, used to pass command and mailbox
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information back and forth to Hermon firmware) and the lock used to guarantee
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * mutually exclusive access to the registers.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Related to this, is the "clr_int" register which is used to clear the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * interrupt once all EQs have been serviced.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Finally, there is the software reset register which is used to reinitialize
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the Hermon device and to put it into a known state at driver startup time.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Below we also have the offsets (into the CMD register space) for each of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the various registers.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_cmd_reg_t::hcr_lock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* SOME TEMPORARY PRINTING THINGS */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* END PRINTING THINGS */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_state_t structure is the HCA software state structure. It
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * contains all the pointers and placeholder for everything that the HCA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * driver needs to properly operate. One of these structures exists for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * every instance of the HCA driver.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* PCI device, vendor, and revision IDs */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DMA information for the InfiniHost Context Memory (ICM),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ICM Auxiliary allocation and the firmware. Also, record
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of ICM and ICMA sizes, in bytes.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Hermon interrupt/MSI information */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_intr_handle_t hs_intrmsi_hdl[HERMON_MSIX_MAX];
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* Do not use reserved EQs */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* cq_sched data */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* hermon HCA name and HCA part number */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Hermon device operational mode */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Attach buffer saved per state to store detailed attach errors */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Hermon NodeGUID, SystemImageGUID, and NodeDescription */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Info passed to IBTF during registration */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon register mapping. Holds the device access attributes,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * kernel mapped addresses, and DDI access handles for both
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon's CMD and UAR BARs.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor caddr_t hs_reg_cmd_baseaddr; /* Hermon CMD BAR */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor caddr_t hs_reg_uar_baseaddr; /* Hermon UAR BAR */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor caddr_t hs_reg_msi_baseaddr; /* Hermon MSIx BAR */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Some additional things for UAR Pages
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t hs_kernel_uar_index; /* kernel UAR index */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Bar to Blueflame */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor caddr_t hs_reg_bf_baseaddr; /* blueflame base */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_reg_bfhdl; /* blueflame handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon PCI config space registers. This array is used to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * save and restore the PCI config registers before and after a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * software reset.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* for reset per Linux driver */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon UAR page resources. Holds the resource pointers for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * UAR page #0 (reserved) and for UAR page #1 (used for kernel
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * driver doorbells). In addition, we save a pointer to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * UAR page #1 doorbells which will be used throughout the driver
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * whenever it is necessary to ring one of them. And, in case we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are unable to do 64-bit writes to the page (because of system
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * architecture), we include a lock (to ensure atomic 64-bit access).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used during a call to open() if we are in maintenance mode, this
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * field serves as a semi-unique rolling count index value, used only
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the setup of umap_db entries. This is primarily needed to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * firmware device access ioctl operations can still be guaranteed to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * close in the event of an unplanned process exit, even in maintenance
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon command registers. This structure contains the addresses
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for each of the most frequently accessed CMD registers. Since
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * almost all accesses to the Hermon hardware are through the Hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * command interface (i.e. the HCR), we save away the pointer to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the HCR, as well as pointers to the ECR and INT registers (as
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * well as their corresponding "clear" registers) for interrupt
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * processing. And we also save away a pointer to the software
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * reset register (see above).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon resource pointers. The following are pointers to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * kmem cache (from which the Hermon resource handles are allocated),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and the array of "resource pools" (which store all the pertinent
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information necessary to manage each of the various types of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resources that are used by the driver. See hermon_rsrc.h for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * more detail.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon mailbox lists. These hold the information necessary to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * manage the pools of pre-allocated Hermon mailboxes (both "In" and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Out" type). See hermon_cmd.h for more detail.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon interrupt mailbox lists. We allocate both an "In" mailbox
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and an "Out" type mailbox for the interrupt context. This is in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * order to guarantee that a mailbox entry will always be available in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the interrupt context, and we can NOSLEEP without having to worry
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * about possible failure allocating the mbox. We create this as an
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * mboxlist so that we have the potential for having multiple mboxes
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * available based on the number of interrupts we can receive at once.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon outstanding command list. Used to hold all the information
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * necessary to manage the Hermon "outstanding command list". See
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_cmd.h for more detail.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This structure contains the Hermon driver's "configuration profile".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This is the collected set of configuration information, such as
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number of QPs, CQs, mailboxes and other resources, sizes of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * individual resources, other system level configuration information,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * etc. See hermon_cfg.h for more detail.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This flag contains the profile setting, selecting which profile the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * driver would use. This is needed in the case where we have to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fallback to a smaller profile based on some DDR conditions. If we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * don't fallback, then it is set to the size of DDR in the system.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following are a collection of resource handles used by the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon driver (internally). First is the protection domain (PD)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handle that is used when mapping all kernel memory (work queues,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * completion queues, etc). Next is an array of EQ handles. This
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * array is indexed by EQ number and allows the Hermon driver to quickly
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * convert an EQ number into the software structure associated with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * given EQ. Likewise, we have three arrays for CQ, QP and SRQ
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handles. These arrays are also indexed by CQ, QP or SRQ number and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allow the driver to quickly find the corresponding CQ, QP or SRQ
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * software structure. Note: while the EQ table is of fixed size
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (because there are a maximum of 64 EQs), each of the CQ, QP and SRQ
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handle lists must be allocated at driver startup.
dd9e16da4243358c2e9251a4ca5d50f56e0adc68agiri /* linked list of kernel dbr resources */
dd9e16da4243358c2e9251a4ca5d50f56e0adc68agiri /* linked list of non-kernel dbr resources */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The AVL tree is used to store information regarding QP number
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allocations. The lock protects access to the AVL tree.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This field is used to indicate whether or not the Hermon driver is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * currently in an IBTF event callback elsewhere in the system. Note:
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * It is "volatile" because we intend to poll on this value - in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_detach() - until we are assured that no further IBTF callbacks
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are currently being processed.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following structures are used to store the results of several
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * device query commands passed to the Hermon hardware at startup.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically, we have hung onto the results of QUERY_DDR (which
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * gives information about how much DDR memory is present and where
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * it is located), QUERY_FW (which gives information about firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * version numbers and the location and extent of firmware's footprint
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in DDR, QUERY_DEVLIM (which gives the device limitations/resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * maximums) and QUERY_PORT (where some of the specs from DEVLIM moved),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * QUERY_ADAPTER (which gives additional miscellaneous
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information), and INIT/QUERY_HCA (which serves the purpose of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * recording what configuration information was passed to the firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * when the HCA was initialized).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following are used for managing special QP resources.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically, we have a lock, a set of flags (in "hs_spec_qpflags")
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * used to track the special QP resources, and two Hermon resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handle pointers. Each resource handle actually corresponds to two
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * consecutive QP contexts (one per port) for each special QP type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * For Hermon, you have to alloc 8 qp's total, but the last 4 are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * unused/reserved. The following represents the handle for those
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * last 4 qp's
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Related in some ways to the special QP handling above are these
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resources which are used specifically for implementing the Hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * agents (SMA, PMA, and BMA). Although, each of these agents does
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * little more that intercept the appropriate incoming MAD and forward
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * it along to the firmware (see hermon_agents.c for more details), we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * do still use a task queue to queue them up. We can also configure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the driver to force firmware handling for certain classes of MAD,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and, therefore, we require the agent list and number of agents
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in order to know what needs to be torn down at detach() time.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Multicast group lists. These are used to track the "shadow" MCG
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * lists that speed up the processing of attach and detach multicast
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * group operations. See hermon_misc.h for more details. Note: we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * need the pointer to the "temporary" MCG entry here primarily
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * because the size of a given MCG entry is configurable. Therefore,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * it is impossible to put this variable on the stack. And rather
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * than allocate and deallocate the entry multiple times, we choose
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * instead to preallocate it once and reuse it over and over again.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Cache of the pkey table, sgid (guid-only) tables, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * sgid (subnet) prefix. These arrays are set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * during port_query, and mainly used for generating MLX GSI wqes.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used for tracking Hermon kstat information
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used for Hermon info ioctl used by VTS
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used for Hermon FW flash burning. They are used exclusively
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * within the ioctl calls for use when accessing the hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * flash device.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Used for Hermon FM. They are basically used to manage
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the toggle switch to enable/disable Hermon FM.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Please see the comment in hermon_fm.c.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor boolean_t hs_fm_async_fatal; /* async internal error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t hs_fm_async_errcnt; /* async error count */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor boolean_t hs_fm_poll_suspend; /* poll thread suspend */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_hca_fm_t *hs_fm_hca_fm; /* HCA FM pointer */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_fm_cmdhdl; /* fm-protected CMD hdl */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_fm_uarhdl; /* fm-protected UAR hdl */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_device_acc_attr_t hs_fm_accattr; /* fm-protected acc attr */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_periodic_t hs_fm_poll_thread; /* fma poll thread */
32c5adfd7396fc0a0807a6f8cbb3a257e4c27af2Eiji Ota int32_t hs_fm_degraded_reason; /* degradation cause */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* FCoIB data */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor boolean_t hs_fcoib_may_be_running; /* cq_poll test */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon fastreboot support. To sw-reset Hermon HCA, the driver
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * needs to save/restore MSI-X tables and PBA. Those members are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * used for the purpose.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Access handle for PCI config space */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_reg_pcihdl; /* PCI cfg handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* members to handle MSI-X tables */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_reg_msix_tblhdl; /* MSI-X table handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_fm_msix_tblhdl; /* fm handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor char *hs_msix_tbl_entries; /* MSI-X table entry */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t hs_msix_tbl_offset; /* MSI-X table offset */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t hs_msix_tbl_rnumber; /* MSI-X table reg# */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* members to handle MSI-X PBA */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_reg_msix_pbahdl; /* MSI-X PBA handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t hs_fm_msix_pbahdl; /* fm handle */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor char *hs_msix_pba_entries; /* MSI-X PBA entry */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t hs_msix_pba_offset; /* MSI-X PBA offset */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t hs_msix_pba_rnumber; /* MSI-X PBA reg# */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_fw_flashlock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_spec_qplock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_mcglock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(DATA_READABLE_WITHOUT_LOCK(hermon_state_s::hs_in_evcallb
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_state_s::hs_qpn_avl_lock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_IN_FASTREBOOT() shows if Hermon driver is at fastreboot.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This macro should be used to check if the mutex lock can be used
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * since the lock cannot be used if the driver is in the quiesce mode.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_IN_FASTREBOOT(state) (state->hs_quiescing == B_TRUE)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Bit positions in the "hs_spec_qpflags" field above. The flags are (from
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * least significant to most): (QP0,Port1), (QP0,Port2), (QP1,Port1), and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (QP1,Port2). The masks are there to help with some specific allocation
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and freeing operations
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These flags specifies additional behaviors on database access.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_UMAP_DB_REMOVE, for example, specifies that (if found) the database
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * entry should be removed from the database. HERMON_UMAP_DB_IGNORE_INSTANCE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specifies that a particular database query should ignore value in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "tdb_instance" field as a criterion for the search.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_umap_db_t structure contains what is referred to throughout the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * driver code as the "userland resources database". This structure contains
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * all the necessary information to track resources that have been prepared
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for direct-from-userland access. There is an AVL tree ("hdl_umapdb_avl")
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * which consists of the "hermon_umap_db_entry_t" (below) and a lock to ensure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * atomic access when adding or removing entries from the database.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_umap_db_priv_t structure currently contains information necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to provide the "on close" callback to the firmware flash interfaces. It
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is intended that this structure could be extended to enable other "on
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * close" callbacks as well.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_umap_db_common_t structure contains fields which are common
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * between the database entries ("hermon_umap_db_entry_t") and the structure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * used to contain the search criteria ("hermon_umap_db_query_t"). This
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structure contains a key, a resource type (described above), an instance
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (corresponding to the driver instance which inserted the database entry),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and a "value" field. Typically, "hdb_value" is a pointer to a Hermon
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resource object. Although for memory regions, the value field corresponds
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to the ddi_umem_cookie_t for the pinned userland memory.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The structure also includes a placeholder for private data ("hdb_priv").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Currently this data is being used for holding "on close" callback
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information to allow certain kinds of cleanup even if a userland process
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * prematurely exits.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_umap_db_entry_t structure is the entry in "userland resources
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * database". As required by the AVL framework, each entry contains an
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "avl_node_t". Then, as required to implement the database, each entry
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * contains a "hermon_umap_db_common_t" structure used to contain all of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * relevant entries.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_umap_db_query_t structure is used in queries to the "userland
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resources database". In addition to the "hermon_umap_db_common_t" structure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * used to contain the various search criteria, this structure also contains
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * a flags field "hqdb_flags" which can be used to specify additional behaviors
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (as described above). Specifically, the flags field can be used to specify
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that an entry should be removed from the database, if found, and to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specify whether the database lookup should consider "tdb_instance" in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor_NOTE(MUTEX_PROTECTS_DATA(hermon_umap_db_s::hdl_umapdb_lock,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_umap_db_entry_s::hdbe_common.hdb_instance))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_devmap_track_t structure contains all the necessary information
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to track resources that have been mapped through devmap. There is a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * back-pointer to the Hermon softstate, the logical offset corresponding with
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the mapped resource, the size of the mapped resource (zero indicates an
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "invalid mapping"), and a reference count and lock used to determine when
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to free the structure (specifically, this is necessary to handle partial
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * unmappings).
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor#define hermon_bitmap(bitmap, dma_info, icm_table, split_index, num_to_hdl) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor bitmap = (icm_table)->icm_bitmap[split_index]; \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*(icm_table))) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ASSERT((icm_table)->icm_dma[split_index] == NULL); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor kmem_zalloc(num_spans * sizeof (hermon_dma_info_t), \
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor ASSERT((icm_table)->num_to_hdl[split_index] == NULL); \
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor sizeof (void **), KM_SLEEP); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_icm_table_t encodes data pertaining to a given ICM table, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * holds an array of hermon_dma_info_t's related to its backing memory. Each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ICM table is sized during initialization, but real memory is allocated
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and mapped into and out of ICM in the device throughout the life of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * instance. We use a bitmap to determine whether or not a given ICM object
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * has memory backing it or not, and an array of hermon_dma_info_t's to house
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the actual allocations. Memory is allocated in chunks of span_size, stored
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the icm_dma array, and can later be looked up by using the bitmap index.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The total number of ICM spans is equal to table_size / span_size. We also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * keep track of the ICM characteristics, such as ICM object size and the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number of entries in the ICM area.
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* three arrays of pointers, each pointer points to arrays */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor void ***num_to_hdl[HERMON_ICM_SPLIT]; /* qp/cq/srq */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Split the rsrc index into three pieces:
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * index1 - icm_bitmap[HERMON_ICM_SPLIT], icm_dma[HERMON_ICM_SPLIT]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * index2 - bitmap[], dma[]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * offset - rsrc within the icm mapping
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define hermon_index(index1, index2, rindx, table, offset) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor index2 = ((rindx) & table->span_mask) >> table->span_shift; \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Defined in hermon.c */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_dma_alloc(hermon_state_t *state, hermon_dma_info_t *dma_info,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_dma_attr_init(hermon_state_t *state, ddi_dma_attr_t *dma_attr);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_icm_alloc(hermon_state_t *state, hermon_rsrc_type_t type,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_icm_free(hermon_state_t *state, hermon_rsrc_type_t type,
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylorvoid *hermon_icm_num_to_hdl(hermon_state_t *state, hermon_rsrc_type_t type,
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylorvoid hermon_icm_set_num_to_hdl(hermon_state_t *state, hermon_rsrc_type_t type,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Defined in hermon_umap.c */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Tayloribt_status_t hermon_umap_ci_data_in(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_ci_data_flags_t flags, ibt_object_type_t object, void *hdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Tayloribt_status_t hermon_umap_ci_data_out(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_ci_data_flags_t flags, ibt_object_type_t object, void *hdl,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_umap_db_entry_t *hermon_umap_db_alloc(uint_t instance, uint64_t key,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_umap_db_free(hermon_umap_db_entry_t *umapdb);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_umap_db_add(hermon_umap_db_entry_t *umapdb);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_umap_db_add_nolock(hermon_umap_db_entry_t *umapdb);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_umap_db_find(uint_t instance, uint64_t key, uint_t type,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t *value, uint_t flags, hermon_umap_db_entry_t **umapdb);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_umap_db_find_nolock(uint_t instance, uint64_t key, uint_t type,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t *value, uint_t flags, hermon_umap_db_entry_t **umapdb);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_umap_umemlock_cb(ddi_umem_cookie_t *umem_cookie);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_umap_db_set_onclose_cb(dev_t dev, uint64_t flag,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_umap_db_clear_onclose_cb(dev_t dev, uint64_t flag);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_umap_db_handle_onclose_cb(hermon_umap_db_priv_t *priv);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_rsrc_hw_entries_init(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_rsrc_hw_entries_fini(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_HERMON_H */