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
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Contains all of the prototypes, #defines, and structures necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for the Interrupt and Event Processing routines
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically it contains the various event types, event flags,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structures used for managing Tavor event queues, and prototypes for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * many of the functions consumed by other parts of the Tavor driver.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor UAR Doorbell Write Macro
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If on a 32-bit system, we must hold a lock around the ddi_put64() to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ensure that the 64-bit write is an atomic operation. This is a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * requirement of the Tavor hardware and is to protect from the race
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * condition present when more than one kernel thread attempts to do each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of their two 32-bit accesses (for 64-bit doorbell) simultaneously.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are on a 64-bit system then the ddi_put64() is completed as one
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * 64-bit instruction, and the lock is not needed.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This is done as a preprocessor #if to speed up execution at run-time
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * since doorbell ringing is a "fast-path" operation.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_UAR_DOORBELL(state, ts_uar, doorbell) { \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_put64(state->ts_reg_uarhdl, ts_uar, doorbell); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_UAR_DOORBELL(state, ts_uar, doorbell) { \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ddi_put64(state->ts_reg_uarhdl, ts_uar, doorbell); \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the default number of Event Queues (EQ) and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * their default size. By default the size of each EQ is set to 4K entries,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * but this value is controllable through the "log_default_eq_sz"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * configuration variable. We also specify the number of EQs which the Tavor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * driver currently uses (TAVOR_NUM_EQ_USED). Note: this value should be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * less than or equal to TAVOR_NUM_EQ. Because there are only so many classes
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of events today, it is unnecessary to allocate all 64 EQs only to leave
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * several of them unused.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following macro determines whether the contents of EQ memory (EQEs)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * need to be sync'd (with ddi_dma_sync()). This decision is based on whether
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the EQ memory is in DDR memory (no sync) or system memory (sync required).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: It doesn't make much sense to put EQEs in DDR memory (since they are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * primarily written by HW and read by the CPU), but the driver does support
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * that possibility. And it also supports the possibility that if a CQ in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * system memory is mapped DDI_DMA_CONSISTENT, it can be configured to not be
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * sync'd because of the "sync override" parameter in the config profile.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((((((state)->ts_cfg_profile->cp_streaming_consistent) && \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((state)->ts_cfg_profile->cp_consistent_syncoverride))) || \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((eqinfo).qa_location == TAVOR_QUEUE_LOCATION_INDDR)) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following defines specify the size of the individual Event Queue
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context (EQC) entries
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_EQC_SIZE (1 << TAVOR_EQC_SIZE_SHIFT)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * These are the defines for the Tavor event types. They are specified by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the Tavor register specification. Below are the "event type masks" in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * which each event type corresponds to one of the 64-bits in the mask.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_EVT_LOCAL_EEC_CAT_ERROR 0x06 /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor (1 << TAVOR_EVT_LOCAL_EEC_CAT_ERROR) /* unsupported: RD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The last defines are used by tavor_eqe_sync() to indicate whether or not
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to force a DMA sync. The case for forcing a DMA sync on a EQE comes from
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the possibility that we could receive an interrupt, read of the ECR, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * have each of these operations complete successfully _before_ the hardware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * has finished its DMA to the event queue.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Catastrophic error values. In case of a catastrophic error, the following
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * errors are reported in a special buffer space. The buffer location is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * returned from a QUERY_FW command. We check that buffer against these error
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * values to determine what kind of error occurred.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define TAVOR_CATASTROPHIC_INTERNAL_PARITY_ERROR 0x5
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This define is the 'enable' flag used when programming the MSI number
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * into event queues. It is or'd with the MSI number and the result is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * written into the EX context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The tavor_sw_eq_s structure is also referred to using the "tavor_eqhdl_t"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * typedef (see tavor_typedef.h). It encodes all the information necessary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to track the various resources needed to allocate, initialize, poll, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (later) free an event queue (EQ).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Specifically, it has a consumer index and a lock to ensure single threaded
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * access to it. It has pointers to the various resources allocated for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * event queue, i.e. an EQC resource and the memory for the event queue
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * itself. It has flags to indicate whether the EQ requires ddi_dma_sync()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ("eq_sync") or to indicate which type of event class(es) the EQ has been
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * mapped to (eq_evttypemask).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * It also has a pointer to the associated MR handle (for the mapped queue
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * memory) and a function pointer that points to the handler that should
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be called when the corresponding EQ has fired. Note: the "eq_func"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handler takes a Tavor softstate pointer, a pointer to the EQ handle, and a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * pointer to a generic tavor_hw_eqe_t structure. It is up to the "eq_func"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * handler function to determine what specific type of event is being passed.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Lastly, we have the always necessary backpointer to the resource for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * EQ handle structure itself.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor int (*eq_func)(tavor_state_t *state, tavor_eqhdl_t eq,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_eq_doorbell(tavor_state_t *state, uint32_t eq_cmd, uint32_t eqn,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorvoid tavor_eq_overflow_handler(tavor_state_t *state, tavor_eqhdl_t eq,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* _SYS_IB_ADAPTERS_TAVOR_EVENT_H */