hermon_rsrc.h revision 17a2b317610f531d565bf4e940433aab2d9e6985
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
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains all of the prototypes, #defines, and structures necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for the Hermon Resource Management routines.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically it contains the resource names, resource types, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structures used for enabling both init/fini and alloc/free operations.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The above extern and the following #defines and macro are used to determine
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the current context for purposes of setting the sleepflag. If the calling
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * thread is running in the interrupt context, then macro will return
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_NOSLEEP (indicating that it is not appropriate to sleep in the current
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * context. In all other cases, this macro will return HERMON_SLEEP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The HERMON_CMD_SLEEP_NOSPIN and HERMON_CMD_NOSLEEP_SPIN #defines from
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_cmd.h are set to use and be compatible with the following SLEEP
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * variables. It is important that these remain in sync so that the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_SLEEPFLAG_FOR_CONTEXT() macro will work in all cases.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((servicing_interrupt() || ddi_in_panic()) ? HERMON_NOSLEEP : \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following #defines are used as the names for various resource pools.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * They represent the kmem_cache and vmem_arena names, respectively. In
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * order to provide for unique naming when multiple Hermon drivers are present,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the HERMON_RSRC_NAME macro below is used to append the driver's instance
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number to the provided string. Note: resource names should not be longer
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * than HERMON_RSRC_NAME_MAXLEN.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_SRQHDL_CACHE "hermon_srqhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_REFCNT_CACHE "hermon_refcnt_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_OUTMBOX_VMEM "hermon_outmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_INTR_INMBOX_VMEM "hermon_intr_inmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_INTR_OUTMBOX_VMEM "hermon_intr_outmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* ICM based vmem */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_CMPT_QPC_VMEM "hermon_cmpt_qpc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_CMPT_SRQ_VMEM "hermon_cmpt_srq_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_CMPT_CQC_VMEM "hermon_cmpt_cqc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_CMPT_EQC_VMEM "hermon_cmpt_eqc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Add'd vmem arenas */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_UAR_PAGE_VMEM_ATTCH "hermon_uar_pg_vmem:a"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_UAR_PAGE_VMEM_RUNTM "hermon_uar_pg_vmem:r"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define HERMON_BLUEFLAME_VMEM "hermon_blueflame_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Macro provided for building unique naming for multiple instance */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* various cMPT types - need to concatenate w/ index to find it in ICM */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type is used to capture all the various types
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of Hermon resources. Note the HERMON_NUM_RESOURCES type is used as a marker
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for the end of the resource types. No additional resources should be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * added after this. Note also that HERMON_NUM_ICM_RESOURCES is used similarly,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * indicating the number of ICM resource types. If additional ICM types are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * added, they should be added before MERMON_NUM_ICM_RESOURCES.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_CMPT, /* for sizing ICM space for control MPTs */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_ALTC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_AUXC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_RDB, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_CMPT_QPC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_CMPT_SRQC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_CMPT_CQC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_CMPT_EQC, /* for allocation of ICM backing memory */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* all types above are in ICM, all below are in non-ICM */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type and structures are used during resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * initialization. Note: The HERMON_RSRC_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_RSRC_CLEANUP_ALL. Any addition steps should be added before it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* No more cleanup steps below this point! */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_rsrc_mbox_info_t structure is used when initializing the two
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon mailbox types ("In" and "Out"). This structure contains the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * requested number and size of the mailboxes, and the resource pool from
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * which the other relevant properties will come.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_rsrc_hw_entry_info_t structure is used when initializing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon HW entry types. This structure contains the requested number of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * entries for the resource. That value is compared against the maximum
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number (usually determined as a result of the Hermon QUERY_DEV_CAP command).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * In addition it contains a number of requested entries to be "pre-allocated"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (this is generally because the Hermon hardware requires a certain number
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for its own purposes). Lastly the resource pool and resource name
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_rsrc_sw_hdl_info_t structure is used when initializing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon software handle types. This structure also contains the requested
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * number of handles for the resource. That value is compared against a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * maximum number passed in. Because many of the software handle resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * types are managed through the use of kmem_cache, fields are provided for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specifying cache constructor and destructor methods. Just like above,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * there is space for resource pool and resource name information. And,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * somewhat like above, there is space to provide information (size, type,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * pointer to table, etc). about any "pre-allocated" resources that need to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be set aside.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note specifically that the "swi_flags" field may contain any of the flags
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * #define'd below. The HERMON_SWHDL_KMEMCACHE_INIT flag indicates that the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * given resource should have a kmem_cache setup for it, and the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HERMON_SWHDL_TABLE_INIT flag indicates that some preallocation (as defined
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * by the "swi_num" and "swi_prealloc_sz" fields) should be done, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resulting table pointer passed back in "swi_table_ptr".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor int (*swi_constructor)(void *, void *, int);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void (*swi_destructor)(void *, void *);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following structure is used to specify (at init time) and to track
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (during allocation and freeing) all the useful information regarding a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * particular resource type. An array of these resources (indexed by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * resource type) is allocated at driver startup time. It is available
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * through the driver's soft state structure.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Each resource has an indication of its type and its location. Resources
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * may be located in one of three possible places - in the Hermon ICM memory
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (device virtual, backed by system memory),in system memory, or in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon UAR memory (residing behind BAR2).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Each resource pool also has properties associated with it and the object
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that make up the pool. These include the pool's size, the size of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * individual objects (rsrc_quantum), any alignment restrictions placed on
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the pool of objects, and the shift size (log2) of each object.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * In addition (depending on object type) the "rsrc_ddr_offset" field may
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * indicate where in DDR memory a given resource pool is located (e.g. a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * QP context table). It may have a pointer to a vmem_arena for that table
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and/or it may point to some other private information (rsrc_private)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to the given object type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Always, though, the resource pool pointer provides a pointer back to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * soft state structure of the Hermon driver instance with which it is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * associated.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t rsrc_pool_size; /* table size (num x size) */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *rsrc_start; /* phys start addr of table */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_rsrc_priv_mbox_t structure is used to pass along additional
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information about the mailbox types. Specifically, by containing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DMA attributes, access handle, dev access handle, etc., it provides enough
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information that each mailbox can be later by bound/unbound/etc. for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DMA access by the hardware. Note: we can also specify (using the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "pmb_xfer_mode" field), whether a given mailbox type should be bound for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * DDI_DMA_STREAMING or DDI_DMA_CONSISTENT operations.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* JBDB what is this handle for? */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The hermon_rsrc_t structure is the structure returned by the Hermon resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allocation routines. It contains all the necessary information about the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allocated object. Specifically, it provides an address where the object
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * can be accessed. It also provides the length and index (specifically, for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * those resources that are accessed from tables). In addition it can provide
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * an access handles and DMA handle to be used when accessing or setting DMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to a specific object. Note: not all of this information is valid for all
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * object types. See the consumers of each object for more explanation of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * which fields are used (and for what purpose).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following are the Hermon Resource Management routines that accessible
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * externally (i.e. throughout the rest of the Hermon driver software).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These include the alloc/free routines, the initialization routines, which
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are broken into two phases (see hermon_rsrc.c for further explanation),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and the Hermon resource cleanup routines (which are used at driver detach()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_rsrc_alloc(hermon_state_t *state, hermon_rsrc_type_t rsrc,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t num, uint_t sleepflag, hermon_rsrc_t **hdl);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid hermon_rsrc_free(hermon_state_t *state, hermon_rsrc_t **hdl);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_rsrc_init_phase1(hermon_state_t *state);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint hermon_rsrc_init_phase2(hermon_state_t *state);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor/* Exporting resource reservation capabilitity to FCoIB */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylorint hermon_rsrc_reserve(hermon_state_t *state, hermon_rsrc_type_t rsrc,
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor uint_t num, uint_t sleepflag, hermon_rsrc_t **hdl);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_HERMON_RSRC_H */