9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
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 *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or http://www.opensolaris.org/os/licensing.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
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 *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifndef _SYS_IB_ADAPTERS_TAVOR_RSRC_H
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define _SYS_IB_ADAPTERS_TAVOR_RSRC_H
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_rsrc.h
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains all of the prototypes, #defines, and structures necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for the Tavor 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 */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/types.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/conf.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/ddi.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/sunddi.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#include <sys/disp.h>
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifdef __cplusplus
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorextern "C" {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
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 * TAVOR_NOSLEEP (indicating that it is not appropriate to sleep in the current
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * context. In all other cases, this macro will return TAVOR_SLEEP.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor *
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The TAVOR_CMD_SLEEP_NOSPIN and TAVOR_CMD_NOSLEEP_SPIN #defines from
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_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 * TAVOR_SLEEPFLAG_FOR_CONTEXT() macro will work in all cases.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SLEEP 0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_NOSLEEP 1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SLEEPFLAG_FOR_CONTEXT() \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((servicing_interrupt() || ddi_in_panic()) ? TAVOR_NOSLEEP : \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_SLEEP)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
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 Tavor drivers are present,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the TAVOR_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 TAVOR_RSRC_NAME_MAXLEN.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_RSRC_CACHE "tavor_rsrc_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_PDHDL_CACHE "tavor_pdhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_MRHDL_CACHE "tavor_mrhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_EQHDL_CACHE "tavor_eqhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CQHDL_CACHE "tavor_cqhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SRQHDL_CACHE "tavor_srqhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_AHHDL_CACHE "tavor_ahhdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_QPHDL_CACHE "tavor_qphdl_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_REFCNT_CACHE "tavor_refcnt_cache"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_VMEM "tavor_ddr_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_INMBOX_VMEM "tavor_ddr_inmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_OUTMBOX_VMEM "tavor_ddr_outmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_INTR_INMBOX_VMEM "tavor_ddr_intr_inmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_INTR_OUTMBOX_VMEM "tavor_ddr_intr_outmbox_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_QPC_VMEM "tavor_ddr_qpc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_CQC_VMEM "tavor_ddr_cqc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_SRQC_VMEM "tavor_ddr_srqc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_EQC_VMEM "tavor_ddr_eqc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_EQPC_VMEM "tavor_ddr_eqpc_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_RDB_VMEM "tavor_ddr_rdb_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_MCG_VMEM "tavor_ddr_mcg_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_MPT_VMEM "tavor_ddr_mpt_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_MTT_VMEM "tavor_ddr_mtt_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_UARSCR_VMEM "tavor_ddr_uarscr_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_DDR_UDAV_VMEM "tavor_ddr_udav_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_UAR_VMEM "tavor_uar_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_PDHDL_VMEM "tavor_pd_vmem"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* Macro provided for building unique naming for multiple instance */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_RSRC_NAME(rsrc_name, string) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (void) sprintf((rsrc_name), string"%08X", \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor state->ts_instance)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_RSRC_NAME_MAXLEN 0x80
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type is used to capture all the various types
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of Tavor resources. Note: The TAVOR_NUM_RESOURCES type is used as a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * marker for the end of the resource types. No additional resources should
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be added after TAVOR_NUM_RESOURCES. Any addition resources should be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * added before it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_QPC,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_CQC,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_SRQC,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_EQC,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_EQPC,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RDB,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_MCG,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_MPT,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_MTT,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_UAR_SCR,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_UDAV,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_IN_MBOX,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_OUT_MBOX,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_PDHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_MRHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_EQHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_CQHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_SRQHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_AHHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_QPHDL,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_REFCNT,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_UARPG,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_INTR_IN_MBOX,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_INTR_OUT_MBOX,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* No more resources types below this point! */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_NUM_RESOURCES
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_type_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following enumerated type and structures are used during resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * initialization. Note: The TAVOR_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 * TAVOR_RSRC_CLEANUP_ALL. Any addition steps should be added before it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef enum {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL0,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL1,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL2,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL3,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_PHASE1_COMPLETE,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL5,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL6,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL7,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL8,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL9,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL10,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL11,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL12,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL13,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL14,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL15,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL16,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL17,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL18,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL19,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL20,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL21,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL22,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL23,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL24,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL25,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL26,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL27,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL28,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL29,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_LEVEL30,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* No more cleanup steps below this point! */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_RSRC_CLEANUP_ALL
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_cleanup_level_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_rsrc_mbox_info_t structure is used when initializing the two
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor mailbox types ("In" and "Out"). This structure contains the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * requested number and size of the mailboxes, the resource pool from which
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the other relevant properties will come, and the name of the resource
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef struct tavor_rsrc_mbox_info_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t mbi_num;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t mbi_size;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_pool_info_t *mbi_rsrcpool;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor char *mbi_rsrcname;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_mbox_info_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_rsrc_hw_entry_info_t structure is used when initializing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor 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 Tavor QUERY_DEV_LIM command).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * In addition is contains a number of requested entries to be "pre-allocated"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (this is generally because the Tavor hardware requires a certain number
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for its own purposes). Lastly the resource pool and resource name
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef struct tavor_rsrc_hw_entry_info_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t hwi_num;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t hwi_max;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t hwi_prealloc;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_pool_info_t *hwi_rsrcpool;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor char *hwi_rsrcname;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_hw_entry_info_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_rsrc_sw_hdl_info_t structure is used when initializing the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor 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 TAVOR_SWHDL_KMEMCACHE_INIT flag indicates that the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * given resource should have a kmem_cache setup for it, and the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * TAVOR_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 */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef struct tavor_rsrc_sw_hdl_info_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t swi_num;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t swi_max;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t swi_prealloc_sz;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_pool_info_t *swi_rsrcpool;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor int (*swi_constructor)(void *, void *, int);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void (*swi_destructor)(void *, void *);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor char *swi_rsrcname;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t swi_flags;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *swi_table_ptr;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_sw_hdl_info_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SWHDL_NOFLAGS 0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SWHDL_KMEMCACHE_INIT (1 << 0)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_SWHDL_TABLE_INIT (1 << 1)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
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 Tavor DDR memory,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in system memory, or in Tavor UAR memory.
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 Tavor driver instance with which it is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * associated.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstruct tavor_rsrc_pool_info_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_type_t rsrc_type;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t rsrc_loc;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t rsrc_pool_size;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint64_t rsrc_align;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t rsrc_shift;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t rsrc_quantum;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *rsrc_start;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *rsrc_ddr_offset;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor vmem_t *rsrc_vmp;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_state_t *rsrc_state;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *rsrc_private;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor};
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_IN_DDR 0x0
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_IN_SYSMEM 0x1
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_IN_UAR 0x2
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_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 */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortypedef struct tavor_rsrc_priv_mbox_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dev_info_t *pmb_dip;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_dma_attr_t pmb_dmaattr;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t pmb_acchdl;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_device_acc_attr_t pmb_devaccattr;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t pmb_xfer_mode;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor} tavor_rsrc_priv_mbox_t;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_rsrc_t structure is the structure returned by the Tavor 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 */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstruct tavor_rsrc_s {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_type_t rsrc_type;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor void *tr_addr;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t tr_len;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint32_t tr_indx;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_acc_handle_t tr_acchdl;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_dma_handle_t tr_dmahdl;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor};
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/*
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following are the Tavor Resource Management routines that accessible
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * externally (i.e. throughout the rest of the Tavor driver software).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These include the alloc/free routines, the initialization routines, which
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * are broken into two phases (see tavor_rsrc.c for further explanation),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and the Tavor resource cleanup routines (which are used at driver detach()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * time.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_rsrc_alloc(tavor_state_t *state, tavor_rsrc_type_t rsrc,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t num, uint_t sleepflag, tavor_rsrc_t **hdl);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_rsrc_free(tavor_state_t *state, tavor_rsrc_t **hdl);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_rsrc_init_phase1(tavor_state_t *state);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorint tavor_rsrc_init_phase2(tavor_state_t *state);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_rsrc_fini(tavor_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor tavor_rsrc_cleanup_level_t clean);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#ifdef __cplusplus
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor}
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_TAVOR_RSRC_H */