19e39c5baSBill Taylor /*
29e39c5baSBill Taylor  * CDDL HEADER START
39e39c5baSBill Taylor  *
49e39c5baSBill Taylor  * The contents of this file are subject to the terms of the
59e39c5baSBill Taylor  * Common Development and Distribution License (the "License").
69e39c5baSBill Taylor  * You may not use this file except in compliance with the License.
79e39c5baSBill Taylor  *
89e39c5baSBill Taylor  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99e39c5baSBill Taylor  * or http://www.opensolaris.org/os/licensing.
109e39c5baSBill Taylor  * See the License for the specific language governing permissions
119e39c5baSBill Taylor  * and limitations under the License.
129e39c5baSBill Taylor  *
139e39c5baSBill Taylor  * When distributing Covered Code, include this CDDL HEADER in each
149e39c5baSBill Taylor  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159e39c5baSBill Taylor  * If applicable, add the following below this CDDL HEADER, with the
169e39c5baSBill Taylor  * fields enclosed by brackets "[]" replaced with your own identifying
179e39c5baSBill Taylor  * information: Portions Copyright [yyyy] [name of copyright owner]
189e39c5baSBill Taylor  *
199e39c5baSBill Taylor  * CDDL HEADER END
209e39c5baSBill Taylor  */
219e39c5baSBill Taylor 
229e39c5baSBill Taylor /*
23*17a2b317SBill Taylor  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249e39c5baSBill Taylor  */
259e39c5baSBill Taylor 
269e39c5baSBill Taylor #ifndef	_SYS_IB_ADAPTERS_HERMON_CMD_H
279e39c5baSBill Taylor #define	_SYS_IB_ADAPTERS_HERMON_CMD_H
289e39c5baSBill Taylor 
299e39c5baSBill Taylor /*
309e39c5baSBill Taylor  * hermon_cmd.h
319e39c5baSBill Taylor  *    Contains all of the prototypes, #defines, and structures necessary
329e39c5baSBill Taylor  *    for the Hermon Firmware Command routines.
339e39c5baSBill Taylor  *    Specifically it contains the command types, command statuses and flags,
349e39c5baSBill Taylor  *    structures used for managing Hermon mailboxes and outstanding commands,
359e39c5baSBill Taylor  *    and prototypes for most of the functions consumed by other parts of
369e39c5baSBill Taylor  *    the Hermon driver.
379e39c5baSBill Taylor  */
389e39c5baSBill Taylor 
399e39c5baSBill Taylor #include <sys/types.h>
409e39c5baSBill Taylor #include <sys/conf.h>
419e39c5baSBill Taylor #include <sys/ddi.h>
429e39c5baSBill Taylor #include <sys/sunddi.h>
439e39c5baSBill Taylor 
449e39c5baSBill Taylor #include <sys/ib/mgt/sm_attr.h>
459e39c5baSBill Taylor 
469e39c5baSBill Taylor #ifdef __cplusplus
479e39c5baSBill Taylor extern "C" {
489e39c5baSBill Taylor #endif
499e39c5baSBill Taylor 
509e39c5baSBill Taylor 
519e39c5baSBill Taylor /*
529e39c5baSBill Taylor  * Defines used hermon_write_hcr() to determine the duration and number of
539e39c5baSBill Taylor  * times (at maximum) to poll while waiting for a Hermon firmware command to
549e39c5baSBill Taylor  * release the HCR resource (i.e. waiting for the command to complete)
559e39c5baSBill Taylor  */
569e39c5baSBill Taylor #define	HERMON_CMD_POLL_DELAY		1
579e39c5baSBill Taylor #define	HERMON_CMD_POLL_MAX		3000000
589e39c5baSBill Taylor 
599e39c5baSBill Taylor /*
609e39c5baSBill Taylor  * The following defines specify the default number of mailboxes (log 2) of
619e39c5baSBill Taylor  * each type and their size and alignment restrictions.  By default the number
629e39c5baSBill Taylor  * of both "In" and "Out" mailboxes is set to 1024 (with each mailbox being
639e39c5baSBill Taylor  * 4KB in size), but both the number and sizes of each are controllable
649e39c5baSBill Taylor  * through the "hermon_log_num_inmbox", "hermon_log_num_outmbox",
659e39c5baSBill Taylor  * "hermon_log_inmbox_size" and "hermon_log_outmbox_size" configuration
669e39c5baSBill Taylor  * variables. Also, we have a define that is used to allocate interrupt
679e39c5baSBill Taylor  * mailboxes (1 in, 1 out).
689e39c5baSBill Taylor  */
699e39c5baSBill Taylor #define	HERMON_NUM_MAILBOXES_SHIFT	0xA
709e39c5baSBill Taylor #define	HERMON_NUM_INTR_MAILBOXES_SHIFT	0
719e39c5baSBill Taylor #define	HERMON_MBOX_SIZE_SHIFT		0xC
729e39c5baSBill Taylor #define	HERMON_MBOX_SIZE			(1 << HERMON_MBOX_SIZE_SHIFT)
739e39c5baSBill Taylor #define	HERMON_MBOX_ALIGN		HERMON_MBOX_SIZE
749e39c5baSBill Taylor 
759e39c5baSBill Taylor /*
769e39c5baSBill Taylor  * These are the defines for the Hermon command type (opcodes).  They are
779e39c5baSBill Taylor  * specified by the Hermon PRM
789e39c5baSBill Taylor  */
799e39c5baSBill Taylor 
809e39c5baSBill Taylor /* Init Commands */
819e39c5baSBill Taylor #define	QUERY_DEV_LIM			0x3
829e39c5baSBill Taylor #define	QUERY_DEV_CAP			0x3
839e39c5baSBill Taylor #define	QUERY_FW			0x4
849e39c5baSBill Taylor #define	QUERY_ADAPTER			0x6
859e39c5baSBill Taylor #define	INIT_HCA			0x7
869e39c5baSBill Taylor #define	CLOSE_HCA			0x8
879e39c5baSBill Taylor #define	INIT_IB				0x9
889e39c5baSBill Taylor #define	INIT_PORT			0x9
899e39c5baSBill Taylor #define	CLOSE_IB			0xA
909e39c5baSBill Taylor #define	CLOSE_PORT			0xA
919e39c5baSBill Taylor #define	QUERY_HCA			0xB
929e39c5baSBill Taylor #define	SET_IB				0xC
939e39c5baSBill Taylor #define	SET_PORT			0xC
949e39c5baSBill Taylor /* added late in tavor for SRQ support */
959e39c5baSBill Taylor #define	MOD_STAT_CFG			0x34
969e39c5baSBill Taylor /* added late in Hermon (PRM 0.35) */
979e39c5baSBill Taylor #define	QUERY_PORT			0x43
989e39c5baSBill Taylor 
999e39c5baSBill Taylor 
1009e39c5baSBill Taylor /* TPT Commands */
1019e39c5baSBill Taylor #define	SW2HW_MPT			0xD
1029e39c5baSBill Taylor #define	QUERY_MPT			0xE
1039e39c5baSBill Taylor #define	HW2SW_MPT			0xF
1049e39c5baSBill Taylor #define	READ_MTT			0x10
1059e39c5baSBill Taylor #define	WRITE_MTT			0x11
1069e39c5baSBill Taylor #define	SYNC_TPT			0x2F
1079e39c5baSBill Taylor #define	MODIFY_MPT			0x39
1089e39c5baSBill Taylor 
1099e39c5baSBill Taylor /* EQ Commands */
1109e39c5baSBill Taylor #define	MAP_EQ				0x12
1119e39c5baSBill Taylor #define	SW2HW_EQ			0x13
1129e39c5baSBill Taylor #define	HW2SW_EQ			0x14
1139e39c5baSBill Taylor #define	QUERY_EQ			0x15
1149e39c5baSBill Taylor 
1159e39c5baSBill Taylor /* CQ Commands */
1169e39c5baSBill Taylor #define	SW2HW_CQ			0x16
1179e39c5baSBill Taylor #define	HW2SW_CQ			0x17
1189e39c5baSBill Taylor #define	QUERY_CQ			0x18
1199e39c5baSBill Taylor #define	MODIFY_CQ			0x2C
1209e39c5baSBill Taylor 
1219e39c5baSBill Taylor /* Modify CQ Command - opcode modifiers */
1229e39c5baSBill Taylor #define	RESIZE_CQ			0x0
1239e39c5baSBill Taylor #define	MODIFY_MODERATION_CQ		0x1
1249e39c5baSBill Taylor #define	MODIFY_EQN			0x2
1259e39c5baSBill Taylor 
1269e39c5baSBill Taylor /* QP Commands */
1279e39c5baSBill Taylor #define	RST2INIT_QP			0x19
1289e39c5baSBill Taylor #define	INIT2INIT_QP			0x2D
1299e39c5baSBill Taylor #define	INIT2RTR_QP			0x1A
1309e39c5baSBill Taylor #define	RTR2RTS_QP			0x1B
1319e39c5baSBill Taylor #define	RTS2RTS_QP			0x1C
1329e39c5baSBill Taylor #define	SQERR2RTS_QP			0x1D
1339e39c5baSBill Taylor #define	TOERR_QP			0x1E
1349e39c5baSBill Taylor #define	RTS2SQD_QP			0x1F
1359e39c5baSBill Taylor #define	SQD2SQD_QP			0x38
1369e39c5baSBill Taylor #define	SQD2RTS_QP			0x20
1379e39c5baSBill Taylor #define	TORST_QP			0x21
1389e39c5baSBill Taylor #define	QUERY_QP			0x22
1399e39c5baSBill Taylor #define	SUSPEND_QP			0x32	/* new w/ hermon driver */
1409e39c5baSBill Taylor #define	UNSUSPEND_QP			0x33	/* new w/ hermon driver */
1419e39c5baSBill Taylor 
1429e39c5baSBill Taylor /* SPECIAL QPs Commands */
1439e39c5baSBill Taylor #define	CONF_SPECIAL_QP			0x23
1449e39c5baSBill Taylor #define	MAD_IFC				0x24
1459e39c5baSBill Taylor 
1469e39c5baSBill Taylor /* added late in tavor for SRQ support */
1479e39c5baSBill Taylor /* SRQ Commands */
1489e39c5baSBill Taylor #define	SW2HW_SRQ			0x35
1499e39c5baSBill Taylor #define	HW2SW_SRQ			0x36
1509e39c5baSBill Taylor #define	QUERY_SRQ			0x37
151*17a2b317SBill Taylor /* new in hermon, replaces part of modify MPT */
1529e39c5baSBill Taylor #define	RESIZE_SRQ			0X44
1539e39c5baSBill Taylor /* new in hermon, set limit water mark */
1549e39c5baSBill Taylor #define	ARM_RQ				0X40
155*17a2b317SBill Taylor /* new in hermon (PRM 0.36) configure interrupt moderation */
156*17a2b317SBill Taylor #define	CONFIG_INT_MOD			0X45
157*17a2b317SBill Taylor #define	HW_HEALTH_CHECK			0X50
1589e39c5baSBill Taylor 
1599e39c5baSBill Taylor /* Multicast Group Commands */
1609e39c5baSBill Taylor #define	READ_MGM			0x25
1619e39c5baSBill Taylor #define	READ_MCG			0x25
1629e39c5baSBill Taylor #define	WRITE_MGM			0x26
1639e39c5baSBill Taylor #define	WRITE_MCG			0x26
1649e39c5baSBill Taylor #define	MGID_HASH			0x27
1659e39c5baSBill Taylor 
1669e39c5baSBill Taylor /* Debug/Diagnostic Commands */
1679e39c5baSBill Taylor #define	QUERY_DEBUG_MSG			0x2A
1689e39c5baSBill Taylor #define	SET_DEBUG_MSG			0x2B
1699e39c5baSBill Taylor #define	DIAG_RPRT			0x30
1709e39c5baSBill Taylor #define	CMD_NOP				0x31
1719e39c5baSBill Taylor 
172*17a2b317SBill Taylor #define	SET_VLAN_FLTR			0x47
173*17a2b317SBill Taylor #define	SET_MCAST_FLTR			0x48
174*17a2b317SBill Taylor 
175*17a2b317SBill Taylor #define	CONFIG_FC			0x4A
176*17a2b317SBill Taylor #define	QUERY_FC			0x4B
177*17a2b317SBill Taylor #define	HEART_BEAT_RQ			0x4C
178*17a2b317SBill Taylor 
179*17a2b317SBill Taylor #define	SENSE_PORT			0x4D
1809e39c5baSBill Taylor 
1819e39c5baSBill Taylor /* ICM and related commands - w/out LAM commands from Arbel */
1829e39c5baSBill Taylor #define	RUN_FW				0xFF6
1839e39c5baSBill Taylor #define	UNMAP_ICM			0xFF9
1849e39c5baSBill Taylor #define	MAP_ICM				0xFFA
1859e39c5baSBill Taylor #define	UNMAP_ICM_AUX			0xFFB
1869e39c5baSBill Taylor #define	MAP_ICM_AUX			0xFFC
1879e39c5baSBill Taylor #define	SET_ICM_SIZE			0xFFD
1889e39c5baSBill Taylor #define	UNMAP_FA			0xFFE
1899e39c5baSBill Taylor #define	MAP_FA				0xFFF
1909e39c5baSBill Taylor 
1919e39c5baSBill Taylor /*
1929e39c5baSBill Taylor  * Commands mentioned but not defined in PRM v35
1939e39c5baSBill Taylor  *	REL_ICM_AUX
1949e39c5baSBill Taylor  *	INIT_VM
1959e39c5baSBill Taylor  */
1969e39c5baSBill Taylor 
1979e39c5baSBill Taylor /*
1989e39c5baSBill Taylor  * These are the defines for the Hermon command completion statuses.  They are
1999e39c5baSBill Taylor  * also specified (in part) by the Hermon PRM.  However,
2009e39c5baSBill Taylor  * the HERMON_CMD_INSUFF_RSRC, HERMON_CMD_TIMEOUT and HERMON_CMD_INVALID_STATUS
2019e39c5baSBill Taylor  * codes were added for this driver specifically to indicate the conditions
2029e39c5baSBill Taylor  * when insufficient resources are available for a command, when a command has
2039e39c5baSBill Taylor  * timed out (failure in the Hermon firmware) or when some other invalid result
2049e39c5baSBill Taylor  * was received.
2059e39c5baSBill Taylor  */
2069e39c5baSBill Taylor #define	HERMON_CMD_TIMEOUT_TOGGLE	0xFFFC 	/* -4 */
2079e39c5baSBill Taylor #define	HERMON_CMD_INSUFF_RSRC		0xFFFD	/* -3 */
2089e39c5baSBill Taylor #define	HERMON_CMD_TIMEOUT_GOBIT	0xFFFE 	/* -2 */
2099e39c5baSBill Taylor #define	HERMON_CMD_INVALID_STATUS	0xFFFF  /* -1 */
2109e39c5baSBill Taylor #define	HERMON_CMD_SUCCESS		0x00
2119e39c5baSBill Taylor #define	HERMON_CMD_INTERNAL_ERR		0x01
2129e39c5baSBill Taylor #define	HERMON_CMD_BAD_OP		0x02
2139e39c5baSBill Taylor #define	HERMON_CMD_BAD_PARAM		0x03
2149e39c5baSBill Taylor #define	HERMON_CMD_BAD_SYS_STATE		0x04
2159e39c5baSBill Taylor #define	HERMON_CMD_BAD_RESOURCE		0x05
2169e39c5baSBill Taylor #define	HERMON_CMD_RESOURCE_BUSY		0x06
2179e39c5baSBill Taylor #define	HERMON_CMD_EXCEED_LIM		0x08
2189e39c5baSBill Taylor #define	HERMON_CMD_BAD_RES_STATE		0x09
2199e39c5baSBill Taylor #define	HERMON_CMD_BAD_INDEX		0x0A
2209e39c5baSBill Taylor #define	HERMON_CMD_BAD_NVMEM		0x0B
2219e39c5baSBill Taylor #define	HERMON_CMD_ICM_ERROR		0x0C
2229e39c5baSBill Taylor #define	HERMON_CMD_BAD_QP_STATE		0x10
2239e39c5baSBill Taylor #define	HERMON_CMD_BAD_SEG_PARAM		0x20
2249e39c5baSBill Taylor #define	HERMON_CMD_REG_BOUND		0x21
2259e39c5baSBill Taylor #define	HERMON_CMD_BAD_PKT		0x30
2269e39c5baSBill Taylor #define	HERMON_CMD_BAD_SIZE		0x40
2279e39c5baSBill Taylor 
2289e39c5baSBill Taylor /*
2299e39c5baSBill Taylor  * These defines are used in the "special QP" allocation to indicate the type
2309e39c5baSBill Taylor  * of special QP (SMI, GSI, or one of the raw types).  These values are
2319e39c5baSBill Taylor  * specified by the Hermon PRM
2329e39c5baSBill Taylor  */
2339e39c5baSBill Taylor #define	HERMON_CMD_QP_SMI		0
2349e39c5baSBill Taylor #define	HERMON_CMD_QP_GSI		1
2359e39c5baSBill Taylor #define	HERMON_CMD_QP_RAW_IPV6		2
2369e39c5baSBill Taylor #define	HERMON_CMD_QP_RAW_ETH		3
2379e39c5baSBill Taylor 
2389e39c5baSBill Taylor #define	HERMON_CMD_SPEC_QP_OPMOD(smi, gsi) \
2399e39c5baSBill Taylor 	((smi & 0x01) | ((gsi & 0x01) << 1))
2409e39c5baSBill Taylor 
2419e39c5baSBill Taylor /*
2429e39c5baSBill Taylor  * For certain Hermon QP state transition commands some optional flags are
2439e39c5baSBill Taylor  * allowed.  These "opmask" flags are defined by the Hermon PRM
2449e39c5baSBill Taylor  * as a bitmask.
2459e39c5baSBill Taylor  */
2469e39c5baSBill Taylor 
2479e39c5baSBill Taylor #define	HERMON_CMD_OP_ALT_PATH		(1 << 0)
2489e39c5baSBill Taylor #define	HERMON_CMD_OP_RRE		(1 << 1)
2499e39c5baSBill Taylor #define	HERMON_CMD_OP_RAE		(1 << 2)
2509e39c5baSBill Taylor #define	HERMON_CMD_OP_RWE		(1 << 3)
2519e39c5baSBill Taylor #define	HERMON_CMD_OP_PKEYINDX		(1 << 4) /* primary path */
2529e39c5baSBill Taylor #define	HERMON_CMD_OP_QKEY		(1 << 5)
2539e39c5baSBill Taylor #define	HERMON_CMD_OP_MINRNRNAK		(1 << 6)
2549e39c5baSBill Taylor #define	HERMON_CMD_OP_PRIM_PATH		(1 << 7)
2559e39c5baSBill Taylor #define	HERMON_CMD_OP_SRA_SET		(1 << 8)
2569e39c5baSBill Taylor #define	HERMON_CMD_OP_RRA_SET		(1 << 9)
2579e39c5baSBill Taylor #define	HERMON_CMD_OP_PM_STATE		(1 << 10) /* migration */
2589e39c5baSBill Taylor /* HERMON_CMD_OP_PRIM_PORT is obsolete, instead use HERMON_CMD_OP_SCHEDQUEUE */
2599e39c5baSBill Taylor #define	HERMON_CMD_OP_PRIM_PORT		(1 << 11)
2609e39c5baSBill Taylor #define	HERMON_CMD_OP_RETRYCNT		(1 << 12) /* Global */
2619e39c5baSBill Taylor #define	HERMON_CMD_OP_ALT_RNRRETRY	(1 << 13)
2629e39c5baSBill Taylor #define	HERMON_CMD_OP_ACKTIMEOUT	(1 << 14) /* primary path */
2639e39c5baSBill Taylor #define	HERMON_CMD_OP_PRIM_RNRRETRY	(1 << 15) /* reserved in HERMON */
2649e39c5baSBill Taylor #define	HERMON_CMD_OP_SCHEDQUEUE	(1 << 16)
2659e39c5baSBill Taylor #define	HERMON_CMD_OP_RSSCONTEXT	(1 << 17)
2669e39c5baSBill Taylor #define	HERMON_CMD_OP_SRQN		(1 << 18) /* for rss balancing */
2679e39c5baSBill Taylor #define	HERMON_CMD_OP_CQN_RCV		(1 << 19) /* for rss balancing */
2689e39c5baSBill Taylor /* Bits 20 - 31 RESERVED - per PRM 0.35c */
2699e39c5baSBill Taylor 
2709e39c5baSBill Taylor 
2719e39c5baSBill Taylor 
2729e39c5baSBill Taylor /*
2739e39c5baSBill Taylor  * The Hermon RTS2SQD command can take the following flag as part of its
2749e39c5baSBill Taylor  * input modifier to request the Send Queue Drained event
2759e39c5baSBill Taylor  */
2769e39c5baSBill Taylor #define	HERMON_CMD_REQ_SQD_EVENT		0x80000000
2779e39c5baSBill Taylor 
2789e39c5baSBill Taylor /*
2799e39c5baSBill Taylor  * The Hermon TORST command can take the following flag (as part of a bitmask)
2809e39c5baSBill Taylor  * in its opcode modifier to request that the transition to reset should
2819e39c5baSBill Taylor  * not go through the Error state (and, hence, should not generate "flushed-
2829e39c5baSBill Taylor  * in-error" completions
2839e39c5baSBill Taylor  */
2849e39c5baSBill Taylor #define	HERMON_CMD_DIRECT_TO_RESET	(1 << 1)
2859e39c5baSBill Taylor 
2869e39c5baSBill Taylor /*
2879e39c5baSBill Taylor  * Some Hermon commands write an OUT mailbox entry, depending on the value of
2889e39c5baSBill Taylor  * the 'opmod' parameter.  These defines provide the correct opmod value to
2899e39c5baSBill Taylor  * write depending on whether to write an entry or not.
2909e39c5baSBill Taylor  */
2919e39c5baSBill Taylor #define	HERMON_CMD_DO_OUTMBOX		(0)
2929e39c5baSBill Taylor #define	HERMON_CMD_NO_OUTMBOX		(1 << 0)
2939e39c5baSBill Taylor 
2949e39c5baSBill Taylor 
2959e39c5baSBill Taylor /*
2969e39c5baSBill Taylor  * The Hermon MAP_EQ command can take the following flags (and use the
2979e39c5baSBill Taylor  * HERMON_CMD_UNMAP_EQ_MASK input modifier) to indicate whether the given
2989e39c5baSBill Taylor  * event queue should mapped to or unmapped from the given event type.
2999e39c5baSBill Taylor  */
3009e39c5baSBill Taylor 
3019e39c5baSBill Taylor 
3029e39c5baSBill Taylor #define	HERMON_CMD_MAP_EQ_EVT_MAP	0
3039e39c5baSBill Taylor #define	HERMON_CMD_MAP_EQ_EVT_UNMAP	1
3049e39c5baSBill Taylor #define	HERMON_CMD_UNMAP_EQ_MASK	0x80000000
3059e39c5baSBill Taylor 
3069e39c5baSBill Taylor /*
3079e39c5baSBill Taylor  * The following defines are used by the MAD_IFC command and the helper
3089e39c5baSBill Taylor  * routines that get PortInfo, NodeInfo, GUIDInfo, and PKeyTable entries.
3099e39c5baSBill Taylor  *
3109e39c5baSBill Taylor  * The first indicates whether of not MKey checking should be enforced.
3119e39c5baSBill Taylor  * This is passed in the opcode modifier field for MAD_IFC commands.
3129e39c5baSBill Taylor  *
3139e39c5baSBill Taylor  * The next set are used to define certain hardcoded management datagram (MAD)
3149e39c5baSBill Taylor  * sizes, offsets, and header formats for each of the helper operations.
3159e39c5baSBill Taylor  */
3169e39c5baSBill Taylor #define	HERMON_CMD_MKEY_CHECK		0
3179e39c5baSBill Taylor #define	HERMON_CMD_MKEY_DONTCHECK	1
31830e01c53SRamaswamy Tummala #define	HERMON_CMD_BKEY_DONTCHECK	2
3199e39c5baSBill Taylor 
3209e39c5baSBill Taylor #define	HERMON_CMD_MAD_IFC_SIZE		0x100
3219e39c5baSBill Taylor #define	HERMON_CMD_MADDATA_OFFSET	0x40
3229e39c5baSBill Taylor #define	HERMON_CMD_MADHDR0		0x01010101
3239e39c5baSBill Taylor #define	HERMON_CMD_MADHDR1		0x00000000
3249e39c5baSBill Taylor #define	HERMON_CMD_MADHDR2		0x00000000
3259e39c5baSBill Taylor #define	HERMON_CMD_MADHDR3		0x00000000
3269e39c5baSBill Taylor 
3279e39c5baSBill Taylor #define	HERMON_CMD_PORTINFO		0x00150000
3289e39c5baSBill Taylor #define	HERMON_CMD_NODEINFO		0x00110000
3299e39c5baSBill Taylor #define	HERMON_CMD_NODEDESC		0x00100000
3309e39c5baSBill Taylor #define	HERMON_CMD_GUIDINFO		0x00140000
3319e39c5baSBill Taylor #define	HERMON_CMD_PKEYTBLE		0x00160000
3329e39c5baSBill Taylor 
333d1a5c838SRamaswamy Tummala #define	HERMON_CMD_PERF_GET		0x01040101
334d1a5c838SRamaswamy Tummala #define	HERMON_CMD_PERF_SET		0x01040102
33530e01c53SRamaswamy Tummala #define	HERMON_CMD_CLASSPORTINFO	0x00010000
3369e39c5baSBill Taylor #define	HERMON_CMD_PERFCNTRS		0x00120000
33730e01c53SRamaswamy Tummala #define	HERMON_CMD_EXTPERFCNTRS		0x001D0000
3389e39c5baSBill Taylor #define	HERMON_CMD_PERFATTR		0x00000000
3399e39c5baSBill Taylor 
34030e01c53SRamaswamy Tummala #define	HERMON_IS_EXT_WIDTH_SUPPORTED		0x0000020000000000
34130e01c53SRamaswamy Tummala #define	HERMON_IS_EXT_WIDTH_SUPPORTED_NOIETF	0x0000040000000000
34230e01c53SRamaswamy Tummala 
3439e39c5baSBill Taylor 
3449e39c5baSBill Taylor /*
3459e39c5baSBill Taylor  * The next few defines are used to indicate the size of the "reserved" area
3469e39c5baSBill Taylor  * in the WRITE_MTT command, and the respective sizes of the SET_PORT and
3479e39c5baSBill Taylor  * MGID_HASH commands
3489e39c5baSBill Taylor  */
3499e39c5baSBill Taylor #define	HERMON_CMD_WRITEMTT_RSVD_SZ	0x10
3509e39c5baSBill Taylor #define	HERMON_CMD_SETPORT_SZ		0x8
3519e39c5baSBill Taylor #define	HERMON_CMD_MGIDHASH_SZ		0x10
3529e39c5baSBill Taylor 
3539e39c5baSBill Taylor /*
3549e39c5baSBill Taylor  * This last define is used by hermon_cmn_ownership_cmd_post() to keep track
3559e39c5baSBill Taylor  * of the direction (from hardware ownership to software, or vice versa) of
3569e39c5baSBill Taylor  * the requested operation
3579e39c5baSBill Taylor  */
3589e39c5baSBill Taylor #define	HERMON_CMD_RSRC_HW2SW		0
3599e39c5baSBill Taylor #define	HERMON_CMD_RSRC_SW2HW		1
3609e39c5baSBill Taylor 
3619e39c5baSBill Taylor /*
3629e39c5baSBill Taylor  * The following macros are used for handling any endianness related issues
3639e39c5baSBill Taylor  * that might arise from the Hermon driver's internal use of MADs.
3649e39c5baSBill Taylor  *
3659e39c5baSBill Taylor  *    HERMON_GETPORTINFO_SWAP	- All the necessary swapping to handle the
3669e39c5baSBill Taylor  *				    response to a GetPortInfo MAD
3679e39c5baSBill Taylor  *    HERMON_GETNODEINFO_SWAP	- All the necessary swapping to handle the
3689e39c5baSBill Taylor  *				    response to a GetNodeInfo MAD
3699e39c5baSBill Taylor  *    HERMON_GETGUIDINFO_SWAP	- All the necessary swapping to handle the
3709e39c5baSBill Taylor  *				    response to a GetGUIDInfo MAD
3719e39c5baSBill Taylor  *    HERMON_GETPKEYTABLE_SWAP	- All the necessary swapping to handle the
3729e39c5baSBill Taylor  *				    response to a GetPKeyTable MAD
3739e39c5baSBill Taylor  */
3749e39c5baSBill Taylor 
3759e39c5baSBill Taylor 
3769e39c5baSBill Taylor #ifdef	_LITTLE_ENDIAN
3779e39c5baSBill Taylor #define	HERMON_GETPORTINFO_SWAP(portinfo)				\
3789e39c5baSBill Taylor {									\
3799e39c5baSBill Taylor 	(portinfo)->M_Key = ddi_swap64((portinfo)->M_Key);		\
3809e39c5baSBill Taylor 	(portinfo)->GidPrefix = ddi_swap64((portinfo)->GidPrefix);	\
3819e39c5baSBill Taylor 	(portinfo)->LID = ddi_swap16((portinfo)->LID);			\
3829e39c5baSBill Taylor 	(portinfo)->MasterSMLID = ddi_swap16((portinfo)->MasterSMLID);	\
3839e39c5baSBill Taylor 	(portinfo)->CapabilityMask =					\
3849e39c5baSBill Taylor 	    ddi_swap32((portinfo)->CapabilityMask);			\
3859e39c5baSBill Taylor 	(portinfo)->DiagCode = ddi_swap16((portinfo)->DiagCode);	\
3869e39c5baSBill Taylor 	(portinfo)->M_KeyLeasePeriod =					\
3879e39c5baSBill Taylor 	    ddi_swap16((portinfo)->M_KeyLeasePeriod);			\
3889e39c5baSBill Taylor 	(portinfo)->M_KeyViolations =					\
3899e39c5baSBill Taylor 	    ddi_swap16((portinfo)->M_KeyViolations);			\
3909e39c5baSBill Taylor 	(portinfo)->P_KeyViolations =					\
3919e39c5baSBill Taylor 	    ddi_swap16((portinfo)->P_KeyViolations);			\
3929e39c5baSBill Taylor 	(portinfo)->Q_KeyViolations =					\
3939e39c5baSBill Taylor 	    ddi_swap16((portinfo)->Q_KeyViolations);			\
3949e39c5baSBill Taylor }
3959e39c5baSBill Taylor #else
3969e39c5baSBill Taylor #define	HERMON_GETPORTINFO_SWAP(portinfo)
3979e39c5baSBill Taylor #endif
3989e39c5baSBill Taylor 
3999e39c5baSBill Taylor #ifdef	_LITTLE_ENDIAN
4009e39c5baSBill Taylor #define	HERMON_GETNODEINFO_SWAP(nodeinfo)				\
4019e39c5baSBill Taylor {									\
4029e39c5baSBill Taylor 	uint32_t	tmp;						\
4039e39c5baSBill Taylor 									\
4049e39c5baSBill Taylor 	tmp = ddi_swap32(((uint32_t *)nodeinfo)[9]);			\
4059e39c5baSBill Taylor 	(nodeinfo)->VendorID	 = tmp & 0xFFFFFF;			\
4069e39c5baSBill Taylor 	(nodeinfo)->LocalPortNum = tmp >> 24;				\
4079e39c5baSBill Taylor 	(nodeinfo)->Revision	 =					\
4089e39c5baSBill Taylor 	    ddi_swap32(((uint32_t *)nodeinfo)[8]);			\
4099e39c5baSBill Taylor 	tmp = ddi_swap32(((uint32_t *)nodeinfo)[7]);			\
4109e39c5baSBill Taylor 	(nodeinfo)->PartitionCap = tmp >> 16;				\
4119e39c5baSBill Taylor 	(nodeinfo)->DeviceID	 = tmp & 0xFFFF;			\
4129e39c5baSBill Taylor 	(nodeinfo)->PortGUID = ddi_swap64((((uint64_t)			\
4139e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[6]) << 32) |			\
4149e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[5]));				\
4159e39c5baSBill Taylor 	(nodeinfo)->NodeGUID = ddi_swap64((((uint64_t)			\
4169e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[4]) << 32) |			\
4179e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[3]));				\
4189e39c5baSBill Taylor 	(nodeinfo)->SystemImageGUID = ddi_swap64((((uint64_t)		\
4199e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[2]) << 32) |			\
4209e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[1]));				\
4219e39c5baSBill Taylor }
4229e39c5baSBill Taylor #else
4239e39c5baSBill Taylor #define	HERMON_GETNODEINFO_SWAP(nodeinfo)				\
4249e39c5baSBill Taylor {									\
4259e39c5baSBill Taylor 	uint32_t	tmp;						\
4269e39c5baSBill Taylor 									\
4279e39c5baSBill Taylor 	tmp = ((uint32_t *)nodeinfo)[9];				\
4289e39c5baSBill Taylor 	(nodeinfo)->VendorID	 = tmp & 0xFFFFFF;			\
4299e39c5baSBill Taylor 	(nodeinfo)->LocalPortNum = tmp >> 24;				\
4309e39c5baSBill Taylor 	(nodeinfo)->Revision	 = ((uint32_t *)nodeinfo)[8];		\
4319e39c5baSBill Taylor 	tmp = ((uint32_t *)nodeinfo)[7];				\
4329e39c5baSBill Taylor 	(nodeinfo)->PartitionCap = tmp >> 16;				\
4339e39c5baSBill Taylor 	(nodeinfo)->DeviceID	 = tmp & 0xFFFF;			\
4349e39c5baSBill Taylor 	(nodeinfo)->PortGUID = (((uint64_t)				\
4359e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[5]) << 32) |			\
4369e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[6]);					\
4379e39c5baSBill Taylor 	(nodeinfo)->NodeGUID = (((uint64_t)				\
4389e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[3]) << 32) |			\
4399e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[4]);					\
4409e39c5baSBill Taylor 	(nodeinfo)->SystemImageGUID = (((uint64_t)			\
4419e39c5baSBill Taylor 	    (((uint32_t *)nodeinfo)[1]) << 32) |			\
4429e39c5baSBill Taylor 	    ((uint32_t *)nodeinfo)[2]);					\
4439e39c5baSBill Taylor }
4449e39c5baSBill Taylor #endif
4459e39c5baSBill Taylor 
4469e39c5baSBill Taylor #ifdef	_LITTLE_ENDIAN
4479e39c5baSBill Taylor #define	HERMON_GETGUIDINFO_SWAP(guidinfo)				\
4489e39c5baSBill Taylor {									\
4499e39c5baSBill Taylor 	int	i;							\
4509e39c5baSBill Taylor 									\
4519e39c5baSBill Taylor 	for (i = 0; i < 8; i++) {					\
4529e39c5baSBill Taylor 		(guidinfo)->GUIDBlocks[i] =				\
4539e39c5baSBill Taylor 		    ddi_swap64((guidinfo)->GUIDBlocks[i]);		\
4549e39c5baSBill Taylor 	}								\
4559e39c5baSBill Taylor }
4569e39c5baSBill Taylor #else
4579e39c5baSBill Taylor #define	HERMON_GETGUIDINFO_SWAP(guidinfo)
4589e39c5baSBill Taylor #endif
4599e39c5baSBill Taylor 
4609e39c5baSBill Taylor #ifdef	_LITTLE_ENDIAN
4619e39c5baSBill Taylor #define	HERMON_GETPKEYTABLE_SWAP(pkeytable)				\
4629e39c5baSBill Taylor {									\
4639e39c5baSBill Taylor 	int	i;							\
4649e39c5baSBill Taylor 									\
4659e39c5baSBill Taylor 	for (i = 0; i < 32; i++) {					\
4669e39c5baSBill Taylor 		(pkeytable)->P_KeyTableBlocks[i] =			\
4679e39c5baSBill Taylor 		    ddi_swap16((pkeytable)->P_KeyTableBlocks[i]);	\
4689e39c5baSBill Taylor 	}								\
4699e39c5baSBill Taylor }
4709e39c5baSBill Taylor #else
4719e39c5baSBill Taylor #define	HERMON_GETPKEYTABLE_SWAP(pkeytable)
4729e39c5baSBill Taylor #endif
4739e39c5baSBill Taylor 
4749e39c5baSBill Taylor /*
4759e39c5baSBill Taylor  * The Hermon MODIFY_MPT command can take the following opcode modifier
4769e39c5baSBill Taylor  * options to specify whether to modify for ResizeSRQ() or to swap the
4779e39c5baSBill Taylor  * full MPT entry.
4789e39c5baSBill Taylor  */
4799e39c5baSBill Taylor #define	HERMON_CMD_MODIFY_MPT_RESIZESRQ	3
4809e39c5baSBill Taylor #define	HERMON_CMD_MODIFY_MPT_SWAPFULL	5
4819e39c5baSBill Taylor 
4829e39c5baSBill Taylor /*
4839e39c5baSBill Taylor  * Hermon MOD_STAT_CFG Opcode Modifier
4849e39c5baSBill Taylor  */
4859e39c5baSBill Taylor #define	HERMON_MOD_STAT_CFG_PTR		0x0
4869e39c5baSBill Taylor #define	HERMON_MOD_STAT_CFG_INLINE	0x1
4879e39c5baSBill Taylor #define	HERMON_MOD_STAT_CFG_DEFAULTS	0xF
4889e39c5baSBill Taylor 
4899e39c5baSBill Taylor 
4909e39c5baSBill Taylor /*
4919e39c5baSBill Taylor  * The hermon_mbox_t structure is used internally by the Hermon driver to track
4929e39c5baSBill Taylor  * all the information necessary to manage mailboxes for the Hermon command
4939e39c5baSBill Taylor  * interface.  Specifically, by containing a pointer to the buffer, the
4949e39c5baSBill Taylor  * PCI mapped address, the access handle, and a back pointer to the
4959e39c5baSBill Taylor  * hermon_rsrc_t structure used to track this resource, it provides enough
4969e39c5baSBill Taylor  * information allocate, use, and free any type of mailbox.
4979e39c5baSBill Taylor  *
4989e39c5baSBill Taylor  * The mb_indx, mb_next, and mb_prev fields are used only by the mailbox
4999e39c5baSBill Taylor  * alloc/free routines (see hermon_impl_mbox_alloc/free() for more details)
5009e39c5baSBill Taylor  * and are not read or modified by any mailbox consumers.  They are used
5019e39c5baSBill Taylor  * to implement a fast allocation mechanism.
5029e39c5baSBill Taylor  */
5039e39c5baSBill Taylor typedef struct hermon_mbox_s {
5049e39c5baSBill Taylor 	void			*mb_addr;
5059e39c5baSBill Taylor 	uint64_t		mb_mapaddr;
5069e39c5baSBill Taylor 	ddi_acc_handle_t	mb_acchdl;
5079e39c5baSBill Taylor 	hermon_rsrc_t		*mb_rsrcptr;
5089e39c5baSBill Taylor 	uint_t			mb_indx;
5099e39c5baSBill Taylor 	uint_t			mb_next;
5109e39c5baSBill Taylor 	uint_t			mb_prev;
5119e39c5baSBill Taylor } hermon_mbox_t;
5129e39c5baSBill Taylor 
5139e39c5baSBill Taylor /*
5149e39c5baSBill Taylor  * The hermon_mboxlist_t structure is used to track all the information
5159e39c5baSBill Taylor  * relevant to the pools of Hermon mailboxes.  Specifically, it has a pointer
5169e39c5baSBill Taylor  * to an array of hermon_mbox_t structures, a lock and cv used for blocking
5179e39c5baSBill Taylor  * on alloc when mailboxes are not available, and a head, tail, and entries
5189e39c5baSBill Taylor  * free counter to keep track of which (if any) mailboxes are currently free.
5199e39c5baSBill Taylor  * This is used (along with the mb_indx, mb_next, and mb_prev fields in the
5209e39c5baSBill Taylor  * hermon_mbox_t) to implement the fast allocation mechanism.
5219e39c5baSBill Taylor  */
5229e39c5baSBill Taylor typedef struct hermon_mboxlist_s {
5239e39c5baSBill Taylor 	kmutex_t		mbl_lock;
5249e39c5baSBill Taylor 	kcondvar_t		mbl_cv;
5259e39c5baSBill Taylor 	hermon_mbox_t		*mbl_mbox;
5269e39c5baSBill Taylor 	uint_t			mbl_list_sz;
5279e39c5baSBill Taylor 	uint_t			mbl_num_alloc;
5289e39c5baSBill Taylor 	uint_t			mbl_head_indx;
5299e39c5baSBill Taylor 	uint_t			mbl_tail_indx;
5309e39c5baSBill Taylor 	uint_t			mbl_entries_free;
5319e39c5baSBill Taylor 	uint_t			mbl_waiters;
5329e39c5baSBill Taylor 	uint_t			mbl_pollers;
5339e39c5baSBill Taylor 	uint_t			mbl_signal;
5349e39c5baSBill Taylor } hermon_mboxlist_t;
5359e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(hermon_mboxlist_t::mbl_lock,
5369e39c5baSBill Taylor     hermon_mboxlist_t::mbl_mbox
5379e39c5baSBill Taylor     hermon_mboxlist_t::mbl_list_sz
5389e39c5baSBill Taylor     hermon_mboxlist_t::mbl_num_alloc
5399e39c5baSBill Taylor     hermon_mboxlist_t::mbl_cv
5409e39c5baSBill Taylor     hermon_mboxlist_t::mbl_head_indx
5419e39c5baSBill Taylor     hermon_mboxlist_t::mbl_tail_indx
5429e39c5baSBill Taylor     hermon_mboxlist_t::mbl_entries_free
5439e39c5baSBill Taylor     hermon_mboxlist_t::mbl_waiters
5449e39c5baSBill Taylor     hermon_mboxlist_t::mbl_pollers
5459e39c5baSBill Taylor     hermon_mboxlist_t::mbl_signal
5469e39c5baSBill Taylor     hermon_mbox_t::mb_next
5479e39c5baSBill Taylor     hermon_mbox_t::mb_prev))
5489e39c5baSBill Taylor 
5499e39c5baSBill Taylor /*
5509e39c5baSBill Taylor  * The hermon_mbox_info_t structure is used by mailbox allocators to specify
5519e39c5baSBill Taylor  * the type of mailbox(es) being requested.  On a call to hermon_mbox_alloc()
5529e39c5baSBill Taylor  * the mbi_alloc_flags may be set to HERMON_ALLOC_INMBOX, HERMON_ALLOC_OUTMBOX,
5539e39c5baSBill Taylor  * or both.  If it is able to allocate the request type(s) of mailboxes,
5549e39c5baSBill Taylor  * hermon_mbox_alloc() will fill in the "mbi_in" and/or "mbi_out" pointers
5559e39c5baSBill Taylor  * to point to valid hermon_mbox_t structures from the appropriate
5569e39c5baSBill Taylor  * hermon_mboxlist_t (see above).
5579e39c5baSBill Taylor  * This same structure is also passed to hermon_mbox_free().  It is the
5589e39c5baSBill Taylor  * responsibility of the caller to hermon_mbox_alloc() to return this exact
5599e39c5baSBill Taylor  * structure (unmodified) to hermon_mbox_free().
5609e39c5baSBill Taylor  *
5619e39c5baSBill Taylor  * Note: If both "In" and "Out" mailboxes are requested, it is assured that
5629e39c5baSBill Taylor  * no deadlock can result (from holding one mailbox while attempting to get
5639e39c5baSBill Taylor  * the other).  This is assured by the fact that the "In" mailbox will always
5649e39c5baSBill Taylor  * be allocated first before attempting to allocate the "Out"
5659e39c5baSBill Taylor  */
5669e39c5baSBill Taylor typedef struct hermon_mbox_info_s {
5679e39c5baSBill Taylor 	uint_t			mbi_alloc_flags;
5689e39c5baSBill Taylor 	uint_t			mbi_sleep_context;
5699e39c5baSBill Taylor 	hermon_mbox_t		*mbi_in;
5709e39c5baSBill Taylor 	hermon_mbox_t		*mbi_out;
5719e39c5baSBill Taylor } hermon_mbox_info_t;
5729e39c5baSBill Taylor #define	HERMON_ALLOC_INMBOX	(1 << 0)
5739e39c5baSBill Taylor #define	HERMON_ALLOC_OUTMBOX	(1 << 1)
5749e39c5baSBill Taylor 
5759e39c5baSBill Taylor 
5769e39c5baSBill Taylor /*
5779e39c5baSBill Taylor  * The hermon_cmd_t structure is used internally by the Hermon driver to track
5789e39c5baSBill Taylor  * all the information necessary to manage outstanding firmware commands on
5799e39c5baSBill Taylor  * the Hermon command interface.
5809e39c5baSBill Taylor  *
5819e39c5baSBill Taylor  * Each hermon_cmd_t structure contains a cv and lock which are used by the
5829e39c5baSBill Taylor  * posting thread to block for completion (with cmd_status being overloaded
5839e39c5baSBill Taylor  * to indicate the condition variable).  The cmd_outparam field is used to
5849e39c5baSBill Taylor  * return additional status from those Hermon commands that specifically
5859e39c5baSBill Taylor  * require it.
5869e39c5baSBill Taylor  *
5879e39c5baSBill Taylor  * The cmd_indx, cmd_next, and cmd_prev fields are used by the outstanding
5889e39c5baSBill Taylor  * command alloc/free routines (see hermon_outstanding_cmd_alloc/free() for
5899e39c5baSBill Taylor  * more details).  They are used (in much the same way as the mb_indx,
5909e39c5baSBill Taylor  * mb_next, and mb_prev fields in hermon_mbox_t above) to implement a fast
5919e39c5baSBill Taylor  * allocation mechanism.
5929e39c5baSBill Taylor  */
5939e39c5baSBill Taylor typedef struct hermon_cmd_s {
5949e39c5baSBill Taylor 	kmutex_t		cmd_comp_lock;
5959e39c5baSBill Taylor 	kcondvar_t		cmd_comp_cv;
5969e39c5baSBill Taylor 	uint64_t		cmd_outparm;
5979e39c5baSBill Taylor 	uint_t			cmd_status;
5989e39c5baSBill Taylor 	uint_t			cmd_indx;
5999e39c5baSBill Taylor 	uint_t			cmd_next;
6009e39c5baSBill Taylor 	uint_t			cmd_prev;
6019e39c5baSBill Taylor } hermon_cmd_t;
6029e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(hermon_cmd_t::cmd_comp_lock,
6039e39c5baSBill Taylor     hermon_cmd_t::cmd_comp_cv
6049e39c5baSBill Taylor     hermon_cmd_t::cmd_status))
6059e39c5baSBill Taylor 
6069e39c5baSBill Taylor /*
6079e39c5baSBill Taylor  * The hermon_cmdlist_t structure is used in almost exactly the same way as
6089e39c5baSBill Taylor  * the hermon_mboxlist_t above, but instead to track all the information
6099e39c5baSBill Taylor  * relevant to the pool of outstanding Hermon commands.  Specifically, it has
6109e39c5baSBill Taylor  * a pointer to an array of hermon_cmd_t structures, a lock and cv used for
6119e39c5baSBill Taylor  * blocking on alloc when outstanding command slots are not available, and a
6129e39c5baSBill Taylor  * head, tail, and entries free counter to keep track of which (if any)
6139e39c5baSBill Taylor  * command slots are currently free.  This is used (along with the cmd_indx,
6149e39c5baSBill Taylor  * cmd_next, and cmd_prev fields in the hermon_cmd_t) to implement the fast
6159e39c5baSBill Taylor  * allocation mechanism.
6169e39c5baSBill Taylor  */
6179e39c5baSBill Taylor typedef struct hermon_cmdlist_s {
6189e39c5baSBill Taylor 	kmutex_t		cml_lock;
6199e39c5baSBill Taylor 	kcondvar_t		cml_cv;
6209e39c5baSBill Taylor 	hermon_cmd_t		*cml_cmd;
6219e39c5baSBill Taylor 	uint_t			cml_list_sz;
6229e39c5baSBill Taylor 	uint_t			cml_num_alloc;
6239e39c5baSBill Taylor 	uint_t			cml_head_indx;
6249e39c5baSBill Taylor 	uint_t			cml_tail_indx;
6259e39c5baSBill Taylor 	uint_t			cml_entries_free;
6269e39c5baSBill Taylor 	uint_t			cml_waiters;
6279e39c5baSBill Taylor } hermon_cmdlist_t;
6289e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(hermon_cmdlist_t::cml_lock,
6299e39c5baSBill Taylor     hermon_cmdlist_t::cml_cv
6309e39c5baSBill Taylor     hermon_cmdlist_t::cml_cmd
6319e39c5baSBill Taylor     hermon_cmdlist_t::cml_list_sz
6329e39c5baSBill Taylor     hermon_cmdlist_t::cml_num_alloc
6339e39c5baSBill Taylor     hermon_cmdlist_t::cml_head_indx
6349e39c5baSBill Taylor     hermon_cmdlist_t::cml_tail_indx
6359e39c5baSBill Taylor     hermon_cmdlist_t::cml_entries_free
6369e39c5baSBill Taylor     hermon_cmdlist_t::cml_waiters
6379e39c5baSBill Taylor     hermon_cmd_t::cmd_next
6389e39c5baSBill Taylor     hermon_cmd_t::cmd_prev))
6399e39c5baSBill Taylor _NOTE(LOCK_ORDER(hermon_cmdlist_t::cml_lock
6409e39c5baSBill Taylor     hermon_cmd_t::cmd_comp_lock))
6419e39c5baSBill Taylor 
6429e39c5baSBill Taylor /*
6439e39c5baSBill Taylor  * The hermon_cmd_post_t structure is used by all the Hermon Firmware Command
6449e39c5baSBill Taylor  * routines to post to Hermon firmware.  The fields almost exactly mimic
6459e39c5baSBill Taylor  * the fields in the Hermon HCR registers.  The notable exception is the
6469e39c5baSBill Taylor  * addition of the "cp_flags" field (which can be set to HERMON_CMD_SPIN or
6479e39c5baSBill Taylor  * HERMON_CMD_NOSPIN).  This flag really controls the value of the "e" bit
6489e39c5baSBill Taylor  * in the HCR (i.e. the bit to indicate whether command should complete
6499e39c5baSBill Taylor  * "in place" - in the HCR - or whether they should have their completions
6509e39c5baSBill Taylor  * written to the command completion event queue.  HERMON_CMD_SPIN means
6519e39c5baSBill Taylor  * to allow commands to complete "in place" and to poll the "go" bit in
6529e39c5baSBill Taylor  * the HCR to determine completion.
6539e39c5baSBill Taylor  *
6549e39c5baSBill Taylor  * We use HERMON_SLEEP and HERMON_NOSLEEP for our HERMON_CMD_ #defines.  This is
6559e39c5baSBill Taylor  * to maintain consistency with the rest of the SLEEP flags.  Additionally,
6569e39c5baSBill Taylor  * because HERMON_SLEEPFLAG_FOR_CONTEXT() in hermon_rsrc.h returns HERMON_SLEEP
6579e39c5baSBill Taylor  * or NOSLEEP we must be compatible with this macro.
6589e39c5baSBill Taylor  */
6599e39c5baSBill Taylor typedef struct hermon_cmd_post_s {
6609e39c5baSBill Taylor 	uint64_t		cp_inparm;
6619e39c5baSBill Taylor 	uint64_t		cp_outparm;
6629e39c5baSBill Taylor 	uint32_t		cp_inmod;
6639e39c5baSBill Taylor 	uint16_t		cp_opcode;
6649e39c5baSBill Taylor 	uint16_t		cp_opmod;
6659e39c5baSBill Taylor 	uint32_t		cp_flags;
6669e39c5baSBill Taylor } hermon_cmd_post_t;
6679e39c5baSBill Taylor #define	HERMON_CMD_SLEEP_NOSPIN		HERMON_SLEEP
6689e39c5baSBill Taylor #define	HERMON_CMD_NOSLEEP_SPIN		HERMON_NOSLEEP
6699e39c5baSBill Taylor 
6709e39c5baSBill Taylor 
6719e39c5baSBill Taylor /*
6729e39c5baSBill Taylor  * The following are the Hermon Firmware Command routines that accessible
6739e39c5baSBill Taylor  * externally (i.e. throughout the rest of the Hermon driver software).
6749e39c5baSBill Taylor  * These include the all the alloc/free routines, some initialization
6759e39c5baSBill Taylor  * and cleanup routines, and the various specific Hermon firmware commands.
6769e39c5baSBill Taylor  */
6779e39c5baSBill Taylor int hermon_cmd_post(hermon_state_t *state, hermon_cmd_post_t *cmdpost);
6789e39c5baSBill Taylor int hermon_mbox_alloc(hermon_state_t *state, hermon_mbox_info_t *mbox_info,
6799e39c5baSBill Taylor     uint_t mbox_wait);
6809e39c5baSBill Taylor void hermon_mbox_free(hermon_state_t *state, hermon_mbox_info_t *mbox_info);
6819e39c5baSBill Taylor int hermon_cmd_complete_handler(hermon_state_t *state, hermon_eqhdl_t eq,
6829e39c5baSBill Taylor     hermon_hw_eqe_t *eqe);
6839e39c5baSBill Taylor int hermon_inmbox_list_init(hermon_state_t *state);
6849e39c5baSBill Taylor int hermon_intr_inmbox_list_init(hermon_state_t *state);
6859e39c5baSBill Taylor int hermon_outmbox_list_init(hermon_state_t *state);
6869e39c5baSBill Taylor int hermon_intr_outmbox_list_init(hermon_state_t *state);
6879e39c5baSBill Taylor void hermon_inmbox_list_fini(hermon_state_t *state);
6889e39c5baSBill Taylor void hermon_intr_inmbox_list_fini(hermon_state_t *state);
6899e39c5baSBill Taylor void hermon_outmbox_list_fini(hermon_state_t *state);
6909e39c5baSBill Taylor void hermon_intr_outmbox_list_fini(hermon_state_t *state);
6919e39c5baSBill Taylor int hermon_outstanding_cmdlist_init(hermon_state_t *state);
6929e39c5baSBill Taylor void hermon_outstanding_cmdlist_fini(hermon_state_t *state);
6939e39c5baSBill Taylor 
6949e39c5baSBill Taylor /* Added for MemFree */
6959e39c5baSBill Taylor int hermon_map_cmd_post(hermon_state_t *state, hermon_dma_info_t *dinfo,
6969e39c5baSBill Taylor     uint16_t opcode, ddi_dma_cookie_t cookie, uint_t ccount);
6979e39c5baSBill Taylor int hermon_map_fa_cmd_post(hermon_state_t *state);
6989e39c5baSBill Taylor int hermon_run_fw_cmd_post(hermon_state_t *state);
6999e39c5baSBill Taylor int hermon_set_icm_size_cmd_post(hermon_state_t *state);
7009e39c5baSBill Taylor int hermon_map_icm_aux_cmd_post(hermon_state_t *state);
7019e39c5baSBill Taylor int hermon_map_icm_cmd_post(hermon_state_t *state);
7029e39c5baSBill Taylor int hermon_disable_lam_cmd_post(hermon_state_t *state);
7039e39c5baSBill Taylor int hermon_unmap_icm_cmd_post(hermon_state_t *state,
7049e39c5baSBill Taylor     hermon_dma_info_t *dma_info);
7059e39c5baSBill Taylor int hermon_unmap_icm_aux_cmd_post(hermon_state_t *state);
7069e39c5baSBill Taylor int hermon_unmap_fa_cmd_post(hermon_state_t *state);
7079e39c5baSBill Taylor 
7089e39c5baSBill Taylor /*
7099e39c5baSBill Taylor  * INIT_HCA and CLOSE_HCA - used for initialization and teardown of Hermon
7109e39c5baSBill Taylor  * device configuration
7119e39c5baSBill Taylor  */
7129e39c5baSBill Taylor int hermon_init_hca_cmd_post(hermon_state_t *state,
7139e39c5baSBill Taylor     hermon_hw_initqueryhca_t *inithca, uint_t sleepflag);
7149e39c5baSBill Taylor int hermon_close_hca_cmd_post(hermon_state_t *state, uint_t sleepflag);
7159e39c5baSBill Taylor 
7169e39c5baSBill Taylor /*
7179e39c5baSBill Taylor  * INIT_PORT, CLOSE_PORT, and SET_PORT - used for bring Hermon ports up and
7189e39c5baSBill Taylor  * down, and to set properties of each port (e.g. PortInfo capability mask)
7199e39c5baSBill Taylor  * NOTE:  New names for the commands in Hermon (previously init_ close_ and
7209e39c5baSBill Taylor  * set_ib
7219e39c5baSBill Taylor  */
7229e39c5baSBill Taylor int hermon_set_port_cmd_post(hermon_state_t *state,
7239e39c5baSBill Taylor     hermon_hw_set_port_t *initport, uint_t port, uint_t sleepflag);
7249e39c5baSBill Taylor int hermon_init_port_cmd_post(hermon_state_t *state, uint_t port,
7259e39c5baSBill Taylor     uint_t sleepflag);
7269e39c5baSBill Taylor int hermon_close_port_cmd_post(hermon_state_t *state, uint_t port,
7279e39c5baSBill Taylor     uint_t sleepflag);
7289e39c5baSBill Taylor 
7299e39c5baSBill Taylor /*
7309e39c5baSBill Taylor  * This common function is used to post the following Hermon QP state
7319e39c5baSBill Taylor  * transition firmware commands:
7329e39c5baSBill Taylor  * RTS2SQD, TOERR, TORST, RST2INIT, INIT2INIT, INIT2RTR, RTR2RTS, RTS2RTS,
7339e39c5baSBill Taylor  * SQD2SQD, SQD2RTS, and SQERR2RTS.
7349e39c5baSBill Taylor  */
7359e39c5baSBill Taylor int hermon_cmn_qp_cmd_post(hermon_state_t *state, uint_t opcode,
7369e39c5baSBill Taylor     hermon_hw_qpc_t *qp, uint_t qpindx, uint32_t opmask, uint_t sleepflag);
7379e39c5baSBill Taylor 
7389e39c5baSBill Taylor /*
7399e39c5baSBill Taylor  * This common function is used to post the following Hermon query firmware
7409e39c5baSBill Taylor  * commands:
7419e39c5baSBill Taylor  * QUERY_DEV_LIM/CAP, QUERY_FW, QUERY_ADAPTER, QUERY_HCA, QUERY_MPT,
7429e39c5baSBill Taylor  * QUERY_EQ, QUERY_CQ, and QUERY_QP.
743*17a2b317SBill Taylor  * New with FCoIB, QUERY_FC
7449e39c5baSBill Taylor  */
7459e39c5baSBill Taylor int hermon_cmn_query_cmd_post(hermon_state_t *state, uint_t opcode,
7469e39c5baSBill Taylor     uint_t opmod, uint_t queryindx, void *query, uint_t size, uint_t sleepflag);
7479e39c5baSBill Taylor 
7489e39c5baSBill Taylor /*
7499e39c5baSBill Taylor  * This common function is used to post the following Hermon resource ownership
7509e39c5baSBill Taylor  * firmware commands:
7519e39c5baSBill Taylor  * HW2SW_MPT, HW2SW_EQ, HW2SW_CQ, SW2HW_MPT, SW2HW_EQ, and SW2HW_CQ
7529e39c5baSBill Taylor  */
7539e39c5baSBill Taylor int hermon_cmn_ownership_cmd_post(hermon_state_t *state, uint_t opcode,
7549e39c5baSBill Taylor     void *hwrsrc, uint_t size, uint_t hwrsrcindx, uint_t sleepflag);
7559e39c5baSBill Taylor 
7569e39c5baSBill Taylor /*
7579e39c5baSBill Taylor  * MAD_IFC and helper functions - used for posting IB MADs to Hermon firmware.
7589e39c5baSBill Taylor  * The helper functions are for the MADs most frequently used by the Hermon
7599e39c5baSBill Taylor  * driver (internally).
7609e39c5baSBill Taylor  */
7619e39c5baSBill Taylor int hermon_mad_ifc_cmd_post(hermon_state_t *state, uint_t port,
7629e39c5baSBill Taylor     uint_t sleepflag, uint32_t *mad, uint32_t *resp);
7639e39c5baSBill Taylor int hermon_getportinfo_cmd_post(hermon_state_t *state, uint_t port,
7649e39c5baSBill Taylor     uint_t sleepflag, sm_portinfo_t *portinfo);
7659e39c5baSBill Taylor int hermon_getnodeinfo_cmd_post(hermon_state_t *state, uint_t sleepflag,
7669e39c5baSBill Taylor     sm_nodeinfo_t *nodeinfo);
7679e39c5baSBill Taylor int hermon_getnodedesc_cmd_post(hermon_state_t *state, uint_t sleepflag,
7689e39c5baSBill Taylor     sm_nodedesc_t *nodedesc);
7699e39c5baSBill Taylor int hermon_getguidinfo_cmd_post(hermon_state_t *state, uint_t port,
7709e39c5baSBill Taylor     uint_t guidblock, uint_t sleepflag, sm_guidinfo_t *guidinfo);
7719e39c5baSBill Taylor int hermon_getpkeytable_cmd_post(hermon_state_t *state, uint_t port,
7729e39c5baSBill Taylor     uint_t pkeyblock, uint_t sleepflag, sm_pkey_table_t *pkeytable);
77330e01c53SRamaswamy Tummala int hermon_is_ext_port_counters_supported(hermon_state_t *state, uint_t port,
77430e01c53SRamaswamy Tummala     uint_t sleepflag, int *ext_width_supported);
77530e01c53SRamaswamy Tummala int hermon_getextperfcntr_cmd_post(hermon_state_t *state, uint_t port,
77630e01c53SRamaswamy Tummala     uint_t sleepflag, hermon_hw_sm_extperfcntr_t *perfinfo);
7779e39c5baSBill Taylor int hermon_getperfcntr_cmd_post(hermon_state_t *state, uint_t port,
778d1a5c838SRamaswamy Tummala     uint_t sleepflag, hermon_hw_sm_perfcntr_t *perfinfo, int reset);
7799e39c5baSBill Taylor /*
7809e39c5baSBill Taylor  * WRITE_MTT - used for write MTT entries to the Hermon MTT table
7819e39c5baSBill Taylor  */
7829e39c5baSBill Taylor int hermon_write_mtt_cmd_post(hermon_state_t *state, hermon_rsrc_t *mtt,
7839e39c5baSBill Taylor     uint64_t start_addr, uint_t nummtt, uint_t sleepflag);
7849e39c5baSBill Taylor 
7859e39c5baSBill Taylor /*
7869e39c5baSBill Taylor  * SYNC_TPT - used to sync Hermon TPT caches
7879e39c5baSBill Taylor  */
7889e39c5baSBill Taylor int hermon_sync_tpt_cmd_post(hermon_state_t *state, uint_t sleepflag);
7899e39c5baSBill Taylor 
7909e39c5baSBill Taylor /*
7919e39c5baSBill Taylor  * MAP_EQ - used for map classes of events to Hermon event queues (EQ)
7929e39c5baSBill Taylor  */
7939e39c5baSBill Taylor int hermon_map_eq_cmd_post(hermon_state_t *state, uint_t map,
7949e39c5baSBill Taylor     uint_t eqcindx, uint64_t eqmapmask, uint_t sleepflag);
7959e39c5baSBill Taylor 
7969e39c5baSBill Taylor /*
7979e39c5baSBill Taylor  * RESIZE_CQ - used for resize completion queue (CQ)
7989e39c5baSBill Taylor  *	opmod 0 is resize cq.  opmod 1 is modify interrupt moderation.
7999e39c5baSBill Taylor  */
8009e39c5baSBill Taylor int hermon_resize_cq_cmd_post(hermon_state_t *state, hermon_hw_cqc_t *cqc,
8019e39c5baSBill Taylor     uint_t cqcindx, uint32_t *prod_indx, uint_t sleepflag);
8029e39c5baSBill Taylor int hermon_modify_cq_cmd_post(hermon_state_t *state, hermon_hw_cqc_t *cqc,
8039e39c5baSBill Taylor     uint_t cqcindx, uint_t opmod, uint_t sleepflag);
8049e39c5baSBill Taylor 
8059e39c5baSBill Taylor /*
8069e39c5baSBill Taylor  * CONF_SPECIAL_QP - used to configure a pair of queue pairs for use as
8079e39c5baSBill Taylor  * special QP.  Necessary to enable full QP0 and/or QP1 operation.
8089e39c5baSBill Taylor  */
8099e39c5baSBill Taylor int hermon_conf_special_qp_cmd_post(hermon_state_t *state, uint_t qpindx,
8109e39c5baSBill Taylor     uint_t qptype, uint_t sleepflag, uint_t opmod);
8119e39c5baSBill Taylor 
812*17a2b317SBill Taylor /*
813*17a2b317SBill Taylor  * Get FEXCH HEART BEAT
814*17a2b317SBill Taylor  */
815*17a2b317SBill Taylor int hermon_get_heart_beat_rq_cmd_post(hermon_state_t *state, uint_t qpindx,
816*17a2b317SBill Taylor     uint64_t *outparm);
817*17a2b317SBill Taylor 
8189e39c5baSBill Taylor /*
8199e39c5baSBill Taylor  * MGID_HASH, READ_MGM, and WRITE_MGM - used for manipulation of the
8209e39c5baSBill Taylor  * hardware resource tables for multicast groups.
8219e39c5baSBill Taylor  *	NOTE: for intial implementation these functions retain their original
8229e39c5baSBill Taylor  *		names, though the proper hermon terminology is READ_MCG and
8239e39c5baSBill Taylor  *		WRITE_MCG - MGID_HASH retains its original name
8249e39c5baSBill Taylor  */
8259e39c5baSBill Taylor int hermon_mgid_hash_cmd_post(hermon_state_t *state, uint64_t mgid_h,
8269e39c5baSBill Taylor     uint64_t mgid_l, uint64_t *mgid_hash, uint_t sleepflag);
8279e39c5baSBill Taylor int hermon_read_mgm_cmd_post(hermon_state_t *state, hermon_hw_mcg_t *mcg,
8289e39c5baSBill Taylor     uint_t mcgindx, uint_t sleepflag);
8299e39c5baSBill Taylor int hermon_write_mgm_cmd_post(hermon_state_t *state, hermon_hw_mcg_t *mcg,
8309e39c5baSBill Taylor     uint_t mcgindx, uint_t sleepflag);
8319e39c5baSBill Taylor 
8329e39c5baSBill Taylor /*
8339e39c5baSBill Taylor  * MOD_STAT_CFG - used to configure (override) settings set in NVRAM before
8349e39c5baSBill Taylor  * a call to QUERY_DEV_LIM.  This is primarily used for SRQ settings in
8359e39c5baSBill Taylor  * the firmware.
8369e39c5baSBill Taylor  */
8379e39c5baSBill Taylor int hermon_mod_stat_cfg_cmd_post(hermon_state_t *state);
8389e39c5baSBill Taylor 
8399e39c5baSBill Taylor /*
8409e39c5baSBill Taylor  * MODIFY_MPT - used to change MPT attributes of a memory region.  This
8419e39c5baSBill Taylor  * was (Tavor/Arbel) primarily used for Resizing SRQs -- now may be used
8429e39c5baSBill Taylor  * to modify MPT paramters
8439e39c5baSBill Taylor  */
8449e39c5baSBill Taylor int hermon_modify_mpt_cmd_post(hermon_state_t *state, hermon_hw_dmpt_t *mpt,
8459e39c5baSBill Taylor     uint_t mptindx, uint_t flags, uint_t sleepflag);
8469e39c5baSBill Taylor 
8479e39c5baSBill Taylor /*
8489e39c5baSBill Taylor  * RESIZE_SRQ is new in hermon, replacing opcodes in modify_mpt.  It is used
8499e39c5baSBill Taylor  * to resize the SRQ, by passing the new information in the same format as
8509e39c5baSBill Taylor  * the original srqc, which the HCA will update appropriately
8519e39c5baSBill Taylor  */
8529e39c5baSBill Taylor int hermon_resize_srq_cmd_post(hermon_state_t *state, hermon_hw_srqc_t *srq,
8539e39c5baSBill Taylor     uint_t srqnum, uint_t sleepflag);
8549e39c5baSBill Taylor 
8559e39c5baSBill Taylor /*
8569e39c5baSBill Taylor  * CMD_NOP - used to test the interrupt/Event Queue mechanism.
8579e39c5baSBill Taylor  */
8589e39c5baSBill Taylor int hermon_nop_post(hermon_state_t *state, uint_t interval, uint_t sleep);
8599e39c5baSBill Taylor int hermon_setdebug_post(hermon_state_t *state);
860*17a2b317SBill Taylor 
8619e39c5baSBill Taylor /*
8629e39c5baSBill Taylor  * READ_MTT - used to read an mtt entry at address.
8639e39c5baSBill Taylor  */
8649e39c5baSBill Taylor int hermon_read_mtt_cmd_post(hermon_state_t *state, uint64_t mtt_addr,
8659e39c5baSBill Taylor     hermon_hw_mtt_t *mtt);
8669e39c5baSBill Taylor 
867*17a2b317SBill Taylor /*
868*17a2b317SBill Taylor  * SENSE_PORT - used to send protocol running on a port
869*17a2b317SBill Taylor  */
870*17a2b317SBill Taylor int hermon_sense_port_post(hermon_state_t *state, uint_t portnum,
871*17a2b317SBill Taylor     uint32_t *protocol);
872*17a2b317SBill Taylor 
873*17a2b317SBill Taylor /*
874*17a2b317SBill Taylor  * CONFIG_FC - used to do either a basic config passing in
875*17a2b317SBill Taylor  * 	*hermon_hw_config_fc_basic_s, or config the N_Port table.
876*17a2b317SBill Taylor  *	passing in pointer to an array of 32-bit id's
877*17a2b317SBill Taylor  *	Note that either one needs to be cast to void *
878*17a2b317SBill Taylor  */
879*17a2b317SBill Taylor int hermon_config_fc_cmd_post(hermon_state_t *state, void *cfginfo, int enable,
880*17a2b317SBill Taylor     int selector, int n_ports, int portnum, uint_t sleepflag);
881*17a2b317SBill Taylor 
882*17a2b317SBill Taylor /*
883*17a2b317SBill Taylor  * CONFIG_INT_MOD - used to configure INTERRUPT moderation
884*17a2b317SBill Taylor  */
885*17a2b317SBill Taylor int hermon_config_int_mod(hermon_state_t *state, uint_t min_delay,
886*17a2b317SBill Taylor     uint_t vector);
887*17a2b317SBill Taylor 
888*17a2b317SBill Taylor /*
889*17a2b317SBill Taylor  * HW_HEALTH_CHECK - tests state of the HCA
890*17a2b317SBill Taylor  *	if command fails, *health is invalid/undefined
891*17a2b317SBill Taylor  */
892*17a2b317SBill Taylor int hermon_hw_health_check(hermon_state_t *state, int *health);
893*17a2b317SBill Taylor 
8949e39c5baSBill Taylor #ifdef __cplusplus
8959e39c5baSBill Taylor }
8969e39c5baSBill Taylor #endif
8979e39c5baSBill Taylor 
8989e39c5baSBill Taylor #endif	/* _SYS_IB_ADAPTERS_HERMON_CMD_H */
899