1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
88f23e9faSHans Rosenfeld  * You can obtain a copy of the license at
98f23e9faSHans Rosenfeld  * http://www.opensource.org/licenses/cddl1.txt.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte 
22fcf3ce44SJohn Forte /*
238f23e9faSHans Rosenfeld  * Copyright (c) 2004-2012 Emulex. All rights reserved.
2482527734SSukumar Swaminathan  * Use is subject to license terms.
25*a3170057SPaul Winder  * Copyright 2020 RackTop Systems, Inc.
26fcf3ce44SJohn Forte  */
27fcf3ce44SJohn Forte 
28291a2b48SSukumar Swaminathan #include <emlxs.h>
29fcf3ce44SJohn Forte 
3082527734SSukumar Swaminathan /* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
3182527734SSukumar Swaminathan EMLXS_MSG_DEF(EMLXS_MBOX_C);
3282527734SSukumar Swaminathan 
3382527734SSukumar Swaminathan 
348f23e9faSHans Rosenfeld emlxs_table_t emlxs_mb_status_table[] = {
358f23e9faSHans Rosenfeld 	{MBX_SUCCESS, "SUCCESS"},
368f23e9faSHans Rosenfeld 	{MBX_FAILURE, "FAILURE"},
378f23e9faSHans Rosenfeld 	{MBXERR_NUM_IOCBS, "NUM_IOCBS"},
388f23e9faSHans Rosenfeld 	{MBXERR_IOCBS_EXCEEDED, "IOCBS_EXCEEDED"},
398f23e9faSHans Rosenfeld 	{MBXERR_BAD_RING_NUMBER, "BAD_RING_NUMBER"},
408f23e9faSHans Rosenfeld 	{MBXERR_MASK_ENTRIES_RANGE, "MASK_ENTRIES_RANGE"},
418f23e9faSHans Rosenfeld 	{MBXERR_MASKS_EXCEEDED, "MASKS_EXCEEDED"},
428f23e9faSHans Rosenfeld 	{MBXERR_BAD_PROFILE, "BAD_PROFILE"},
438f23e9faSHans Rosenfeld 	{MBXERR_BAD_DEF_CLASS, "BAD_DEF_CLASS"},
448f23e9faSHans Rosenfeld 	{MBXERR_BAD_MAX_RESPONDER, "BAD_MAX_RESPONDER"},
458f23e9faSHans Rosenfeld 	{MBXERR_BAD_MAX_ORIGINATOR, "BAD_MAX_ORIGINATOR"},
468f23e9faSHans Rosenfeld 	{MBXERR_RPI_REGISTERED, "RPI_REGISTERED"},
478f23e9faSHans Rosenfeld 	{MBXERR_RPI_FULL, "RPI_FULL"},
488f23e9faSHans Rosenfeld 	{MBXERR_NO_RESOURCES, "NO_RESOURCES"},
498f23e9faSHans Rosenfeld 	{MBXERR_BAD_RCV_LENGTH, "BAD_RCV_LENGTH"},
508f23e9faSHans Rosenfeld 	{MBXERR_DMA_ERROR, "DMA_ERROR"},
518f23e9faSHans Rosenfeld 	{MBXERR_NOT_SUPPORTED, "NOT_SUPPORTED"},
528f23e9faSHans Rosenfeld 	{MBXERR_UNSUPPORTED_FEATURE, "UNSUPPORTED_FEATURE"},
538f23e9faSHans Rosenfeld 	{MBXERR_UNKNOWN_COMMAND, "UNKNOWN_COMMAND"},
548f23e9faSHans Rosenfeld 	{MBXERR_BAD_IP_BIT, "BAD_IP_BIT"},
558f23e9faSHans Rosenfeld 	{MBXERR_BAD_PCB_ALIGN, "BAD_PCB_ALIGN"},
568f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_ID, "BAD_HBQ_ID"},
578f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_STATE, "BAD_HBQ_STATE"},
588f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_MASK_NUM, "BAD_HBQ_MASK_NUM"},
598f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_MASK_SUBSET, "BAD_HBQ_MASK_SUBSET"},
608f23e9faSHans Rosenfeld 	{MBXERR_HBQ_CREATE_FAIL, "HBQ_CREATE_FAIL"},
618f23e9faSHans Rosenfeld 	{MBXERR_HBQ_EXISTING, "HBQ_EXISTING"},
628f23e9faSHans Rosenfeld 	{MBXERR_HBQ_RSPRING_FULL, "HBQ_RSPRING_FULL"},
638f23e9faSHans Rosenfeld 	{MBXERR_HBQ_DUP_MASK, "HBQ_DUP_MASK"},
648f23e9faSHans Rosenfeld 	{MBXERR_HBQ_INVAL_GET_PTR, "HBQ_INVAL_GET_PTR"},
658f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_SIZE, "BAD_HBQ_SIZE"},
668f23e9faSHans Rosenfeld 	{MBXERR_BAD_HBQ_ORDER, "BAD_HBQ_ORDER"},
678f23e9faSHans Rosenfeld 	{MBXERR_INVALID_ID, "INVALID_ID"},
688f23e9faSHans Rosenfeld 	{MBXERR_INVALID_VFI, "INVALID_VFI"},
698f23e9faSHans Rosenfeld 	{MBXERR_FLASH_WRITE_FAILED, "FLASH_WRITE_FAILED"},
708f23e9faSHans Rosenfeld 	{MBXERR_INVALID_LINKSPEED, "INVALID_LINKSPEED"},
718f23e9faSHans Rosenfeld 	{MBXERR_BAD_REDIRECT, "BAD_REDIRECT"},
728f23e9faSHans Rosenfeld 	{MBXERR_RING_ALREADY_CONFIG, "RING_ALREADY_CONFIG"},
738f23e9faSHans Rosenfeld 	{MBXERR_RING_INACTIVE, "RING_INACTIVE"},
748f23e9faSHans Rosenfeld 	{MBXERR_RPI_INACTIVE, "RPI_INACTIVE"},
758f23e9faSHans Rosenfeld 	{MBXERR_NO_ACTIVE_XRI, "NO_ACTIVE_XRI"},
768f23e9faSHans Rosenfeld 	{MBXERR_XRI_NOT_ACTIVE, "XRI_NOT_ACTIVE"},
778f23e9faSHans Rosenfeld 	{MBXERR_RPI_INUSE, "RPI_INUSE"},
788f23e9faSHans Rosenfeld 	{MBXERR_NO_LINK_ATTENTION, "NO_LINK_ATTENTION"},
798f23e9faSHans Rosenfeld 	{MBXERR_INVALID_SLI_MODE, "INVALID_SLI_MODE"},
808f23e9faSHans Rosenfeld 	{MBXERR_INVALID_HOST_PTR, "INVALID_HOST_PTR"},
818f23e9faSHans Rosenfeld 	{MBXERR_CANT_CFG_SLI_MODE, "CANT_CFG_SLI_MODE"},
828f23e9faSHans Rosenfeld 	{MBXERR_BAD_OVERLAY, "BAD_OVERLAY"},
838f23e9faSHans Rosenfeld 	{MBXERR_INVALID_FEAT_REQ, "INVALID_FEAT_REQ"},
848f23e9faSHans Rosenfeld 	{MBXERR_CONFIG_CANT_COMPLETE, "CONFIG_CANT_COMPLETE"},
858f23e9faSHans Rosenfeld 	{MBXERR_DID_ALREADY_REGISTERED, "DID_ALREADY_REGISTERED"},
868f23e9faSHans Rosenfeld 	{MBXERR_DID_INCONSISTENT, "DID_INCONSISTENT"},
878f23e9faSHans Rosenfeld 	{MBXERR_VPI_TOO_LARGE, "VPI_TOO_LARGE"},
888f23e9faSHans Rosenfeld 	{MBXERR_STILL_ASSOCIATED, "STILL_ASSOCIATED"},
898f23e9faSHans Rosenfeld 	{MBXERR_INVALID_VF_STATE, "INVALID_VF_STATE"},
908f23e9faSHans Rosenfeld 	{MBXERR_VFI_ALREADY_REGISTERED, "VFI_ALREADY_REGISTERED"},
918f23e9faSHans Rosenfeld 	{MBXERR_VFI_TOO_LARGE, "VFI_TOO_LARGE"},
928f23e9faSHans Rosenfeld 	{MBXERR_LOAD_FW_FAILED, "LOAD_FW_FAILED"},
938f23e9faSHans Rosenfeld 	{MBXERR_FIND_FW_FAILED, "FIND_FW_FAILED"},
948f23e9faSHans Rosenfeld };
9582527734SSukumar Swaminathan 
9682527734SSukumar Swaminathan emlxs_table_t emlxs_mb_cmd_table[] = {
9782527734SSukumar Swaminathan 	{MBX_SHUTDOWN, "SHUTDOWN"},
9882527734SSukumar Swaminathan 	{MBX_LOAD_SM, "LOAD_SM"},
9982527734SSukumar Swaminathan 	{MBX_READ_NV, "READ_NV"},
10082527734SSukumar Swaminathan 	{MBX_WRITE_NV, "WRITE_NV"},
10182527734SSukumar Swaminathan 	{MBX_RUN_BIU_DIAG, "RUN_BIU_DIAG"},
10282527734SSukumar Swaminathan 	{MBX_INIT_LINK, "INIT_LINK"},
10382527734SSukumar Swaminathan 	{MBX_DOWN_LINK, "DOWN_LINK"},
10482527734SSukumar Swaminathan 	{MBX_CONFIG_LINK, "CONFIG_LINK"},
10582527734SSukumar Swaminathan 	{MBX_PART_SLIM, "PART_SLIM"},
10682527734SSukumar Swaminathan 	{MBX_CONFIG_RING, "CONFIG_RING"},
10782527734SSukumar Swaminathan 	{MBX_RESET_RING, "RESET_RING"},
10882527734SSukumar Swaminathan 	{MBX_READ_CONFIG, "READ_CONFIG"},
10982527734SSukumar Swaminathan 	{MBX_READ_RCONFIG, "READ_RCONFIG"},
11082527734SSukumar Swaminathan 	{MBX_READ_SPARM, "READ_SPARM"},
11182527734SSukumar Swaminathan 	{MBX_READ_STATUS, "READ_STATUS"},
11282527734SSukumar Swaminathan 	{MBX_READ_RPI, "READ_RPI"},
11382527734SSukumar Swaminathan 	{MBX_READ_XRI, "READ_XRI"},
11482527734SSukumar Swaminathan 	{MBX_READ_REV, "READ_REV"},
11582527734SSukumar Swaminathan 	{MBX_READ_LNK_STAT, "READ_LNK_STAT"},
11682527734SSukumar Swaminathan 	{MBX_REG_LOGIN, "REG_LOGIN"},
117a9800bebSGarrett D'Amore 	{MBX_UNREG_LOGIN, "UNREG_RPI"},
11882527734SSukumar Swaminathan 	{MBX_READ_LA, "READ_LA"},
11982527734SSukumar Swaminathan 	{MBX_CLEAR_LA, "CLEAR_LA"},
12082527734SSukumar Swaminathan 	{MBX_DUMP_MEMORY, "DUMP_MEMORY"},
12182527734SSukumar Swaminathan 	{MBX_DUMP_CONTEXT, "DUMP_CONTEXT"},
12282527734SSukumar Swaminathan 	{MBX_RUN_DIAGS, "RUN_DIAGS"},
12382527734SSukumar Swaminathan 	{MBX_RESTART, "RESTART"},
12482527734SSukumar Swaminathan 	{MBX_UPDATE_CFG, "UPDATE_CFG"},
12582527734SSukumar Swaminathan 	{MBX_DOWN_LOAD, "DOWN_LOAD"},
12682527734SSukumar Swaminathan 	{MBX_DEL_LD_ENTRY, "DEL_LD_ENTRY"},
12782527734SSukumar Swaminathan 	{MBX_RUN_PROGRAM, "RUN_PROGRAM"},
12882527734SSukumar Swaminathan 	{MBX_SET_MASK, "SET_MASK"},
12982527734SSukumar Swaminathan 	{MBX_SET_VARIABLE, "SET_VARIABLE"},
13082527734SSukumar Swaminathan 	{MBX_UNREG_D_ID, "UNREG_D_ID"},
13182527734SSukumar Swaminathan 	{MBX_KILL_BOARD, "KILL_BOARD"},
13282527734SSukumar Swaminathan 	{MBX_CONFIG_FARP, "CONFIG_FARP"},
13382527734SSukumar Swaminathan 	{MBX_LOAD_AREA, "LOAD_AREA"},
13482527734SSukumar Swaminathan 	{MBX_RUN_BIU_DIAG64, "RUN_BIU_DIAG64"},
13582527734SSukumar Swaminathan 	{MBX_CONFIG_PORT, "CONFIG_PORT"},
13682527734SSukumar Swaminathan 	{MBX_READ_SPARM64, "READ_SPARM64"},
13782527734SSukumar Swaminathan 	{MBX_READ_RPI64, "READ_RPI64"},
13882527734SSukumar Swaminathan 	{MBX_CONFIG_MSI, "CONFIG_MSI"},
13982527734SSukumar Swaminathan 	{MBX_CONFIG_MSIX, "CONFIG_MSIX"},
140a9800bebSGarrett D'Amore 	{MBX_REG_LOGIN64, "REG_RPI"},
14182527734SSukumar Swaminathan 	{MBX_READ_LA64, "READ_LA64"},
14282527734SSukumar Swaminathan 	{MBX_FLASH_WR_ULA, "FLASH_WR_ULA"},
14382527734SSukumar Swaminathan 	{MBX_SET_DEBUG, "SET_DEBUG"},
14482527734SSukumar Swaminathan 	{MBX_GET_DEBUG, "GET_DEBUG"},
14582527734SSukumar Swaminathan 	{MBX_LOAD_EXP_ROM, "LOAD_EXP_ROM"},
14682527734SSukumar Swaminathan 	{MBX_BEACON, "BEACON"},
14782527734SSukumar Swaminathan 	{MBX_CONFIG_HBQ, "CONFIG_HBQ"},	/* SLI3 */
14882527734SSukumar Swaminathan 	{MBX_REG_VPI, "REG_VPI"},	/* NPIV */
14982527734SSukumar Swaminathan 	{MBX_UNREG_VPI, "UNREG_VPI"},	/* NPIV */
15082527734SSukumar Swaminathan 	{MBX_ASYNC_EVENT, "ASYNC_EVENT"},
15182527734SSukumar Swaminathan 	{MBX_HEARTBEAT, "HEARTBEAT"},
15282527734SSukumar Swaminathan 	{MBX_READ_EVENT_LOG_STATUS, "READ_EVENT_LOG_STATUS"},
15382527734SSukumar Swaminathan 	{MBX_READ_EVENT_LOG, "READ_EVENT_LOG"},
15482527734SSukumar Swaminathan 	{MBX_WRITE_EVENT_LOG, "WRITE_EVENT_LOG"},
15582527734SSukumar Swaminathan 	{MBX_NV_LOG, "NV_LOG"},
15682527734SSukumar Swaminathan 	{MBX_PORT_CAPABILITIES, "PORT_CAPABILITIES"},
15782527734SSukumar Swaminathan 	{MBX_IOV_CONTROL, "IOV_CONTROL"},
15882527734SSukumar Swaminathan 	{MBX_IOV_MBX, "IOV_MBX"},
15982527734SSukumar Swaminathan 	{MBX_SLI_CONFIG, "SLI_CONFIG"},
16082527734SSukumar Swaminathan 	{MBX_REQUEST_FEATURES, "REQUEST_FEATURES"},
16182527734SSukumar Swaminathan 	{MBX_RESUME_RPI, "RESUME_RPI"},
16282527734SSukumar Swaminathan 	{MBX_REG_VFI, "REG_VFI"},
16382527734SSukumar Swaminathan 	{MBX_REG_FCFI, "REG_FCFI"},
16482527734SSukumar Swaminathan 	{MBX_UNREG_VFI, "UNREG_VFI"},
16582527734SSukumar Swaminathan 	{MBX_UNREG_FCFI, "UNREG_FCFI"},
16682527734SSukumar Swaminathan 	{MBX_INIT_VFI, "INIT_VFI"},
1678f23e9faSHans Rosenfeld 	{MBX_INIT_VPI, "INIT_VPI"},
1688f23e9faSHans Rosenfeld 	{MBX_WRITE_VPARMS, "WRITE_VPARMS"},
1698f23e9faSHans Rosenfeld 	{MBX_ACCESS_VDATA, "ACCESS_VDATA"}
17082527734SSukumar Swaminathan };	/* emlxs_mb_cmd_table */
17182527734SSukumar Swaminathan 
17282527734SSukumar Swaminathan 
1738f23e9faSHans Rosenfeld emlxs_table_t emlxs_request_feature_table[] = {
1748f23e9faSHans Rosenfeld 	{SLI4_FEATURE_INHIBIT_AUTO_ABTS, "IAA "},	/* Bit 0 */
1758f23e9faSHans Rosenfeld 	{SLI4_FEATURE_NPIV, "NPIV "},			/* Bit 1 */
1768f23e9faSHans Rosenfeld 	{SLI4_FEATURE_DIF, "DIF "},			/* Bit 2 */
1778f23e9faSHans Rosenfeld 	{SLI4_FEATURE_VIRTUAL_FABRICS, "VF "},		/* Bit 3 */
1788f23e9faSHans Rosenfeld 	{SLI4_FEATURE_FCP_INITIATOR, "FCPI "},		/* Bit 4 */
1798f23e9faSHans Rosenfeld 	{SLI4_FEATURE_FCP_TARGET, "FCPT "},		/* Bit 5 */
1808f23e9faSHans Rosenfeld 	{SLI4_FEATURE_FCP_COMBO, "FCPC "},		/* Bit 6 */
1818f23e9faSHans Rosenfeld 	{SLI4_FEATURE_RSVD1, "RSVD1 "},			/* Bit 7 */
1828f23e9faSHans Rosenfeld 	{SLI4_FEATURE_RQD, "RQD "},			/* Bit 8 */
1838f23e9faSHans Rosenfeld 	{SLI4_FEATURE_INHIBIT_AUTO_ABTS_R, "IAAR "},	/* Bit 9 */
1848f23e9faSHans Rosenfeld 	{SLI4_FEATURE_HIGH_LOGIN_MODE, "HLM "},		/* Bit 10 */
1858f23e9faSHans Rosenfeld 	{SLI4_FEATURE_PERF_HINT, "PERFH "}		/* Bit 11 */
1868f23e9faSHans Rosenfeld };	/* emlxs_request_feature_table */
1878f23e9faSHans Rosenfeld 
1888f23e9faSHans Rosenfeld 
1898f23e9faSHans Rosenfeld extern char *
emlxs_mb_xlate_status(uint32_t status)1908f23e9faSHans Rosenfeld emlxs_mb_xlate_status(uint32_t status)
1918f23e9faSHans Rosenfeld {
1928f23e9faSHans Rosenfeld 	static char	buffer[32];
1938f23e9faSHans Rosenfeld 	uint32_t	i;
1948f23e9faSHans Rosenfeld 	uint32_t	count;
1958f23e9faSHans Rosenfeld 
1968f23e9faSHans Rosenfeld 	count = sizeof (emlxs_mb_status_table) / sizeof (emlxs_table_t);
1978f23e9faSHans Rosenfeld 	for (i = 0; i < count; i++) {
1988f23e9faSHans Rosenfeld 		if (status == emlxs_mb_status_table[i].code) {
1998f23e9faSHans Rosenfeld 			return (emlxs_mb_status_table[i].string);
2008f23e9faSHans Rosenfeld 		}
2018f23e9faSHans Rosenfeld 	}
2028f23e9faSHans Rosenfeld 
2038f23e9faSHans Rosenfeld 	(void) snprintf(buffer, sizeof (buffer), "status=%x", status);
2048f23e9faSHans Rosenfeld 	return (buffer);
2058f23e9faSHans Rosenfeld 
2068f23e9faSHans Rosenfeld } /* emlxs_mb_xlate_status() */
2078f23e9faSHans Rosenfeld 
2088f23e9faSHans Rosenfeld 
209a9800bebSGarrett D'Amore /* SLI4 */
21082527734SSukumar Swaminathan /*ARGSUSED*/
21182527734SSukumar Swaminathan extern void
emlxs_mb_resetport(emlxs_hba_t * hba,MAILBOXQ * mbq)21282527734SSukumar Swaminathan emlxs_mb_resetport(emlxs_hba_t *hba, MAILBOXQ *mbq)
21382527734SSukumar Swaminathan {
214a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
21582527734SSukumar Swaminathan 
216a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
21782527734SSukumar Swaminathan 	mbq->nonembed = NULL;
21882527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
219a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
22082527734SSukumar Swaminathan 
22182527734SSukumar Swaminathan 	/*
22282527734SSukumar Swaminathan 	 * Signifies an embedded command
22382527734SSukumar Swaminathan 	 */
224a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.embedded = 1;
22582527734SSukumar Swaminathan 
226a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_SLI_CONFIG;
227a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
228a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.payload_length = IOCTL_HEADER_SZ;
229a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.subsystem =
23082527734SSukumar Swaminathan 	    IOCTL_SUBSYSTEM_COMMON;
231a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.opcode = COMMON_OPCODE_RESET;
232a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.timeout = 0;
233a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.req_length = 0;
23482527734SSukumar Swaminathan 
23582527734SSukumar Swaminathan 	return;
23682527734SSukumar Swaminathan 
23782527734SSukumar Swaminathan } /* emlxs_mb_resetport() */
23882527734SSukumar Swaminathan 
23982527734SSukumar Swaminathan 
240a9800bebSGarrett D'Amore /* SLI4 */
24182527734SSukumar Swaminathan /*ARGSUSED*/
24282527734SSukumar Swaminathan extern void
emlxs_mb_request_features(emlxs_hba_t * hba,MAILBOXQ * mbq,uint32_t mask)2438f23e9faSHans Rosenfeld emlxs_mb_request_features(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t mask)
24482527734SSukumar Swaminathan {
245a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
24682527734SSukumar Swaminathan 
24782527734SSukumar Swaminathan 	hba->flag &= ~FC_NPIV_ENABLED;
2488f23e9faSHans Rosenfeld 	hba->sli.sli4.flag &= ~(EMLXS_SLI4_PHON | EMLXS_SLI4_PHWQ);
24982527734SSukumar Swaminathan 
250a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
25182527734SSukumar Swaminathan 	mbq->nonembed = NULL;
25282527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
253a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
25482527734SSukumar Swaminathan 
255a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_REQUEST_FEATURES;
256a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
25782527734SSukumar Swaminathan 
2588f23e9faSHans Rosenfeld 	mb4->un.varReqFeatures.featuresRequested = mask;
2598f23e9faSHans Rosenfeld 	return;
26082527734SSukumar Swaminathan 
26182527734SSukumar Swaminathan } /* emlxs_mb_request_features() */
26282527734SSukumar Swaminathan 
26382527734SSukumar Swaminathan 
264a9800bebSGarrett D'Amore /* SLI4 */
26582527734SSukumar Swaminathan /*ARGSUSED*/
26682527734SSukumar Swaminathan extern void
emlxs_mb_noop(emlxs_hba_t * hba,MAILBOXQ * mbq)26782527734SSukumar Swaminathan emlxs_mb_noop(emlxs_hba_t *hba, MAILBOXQ *mbq)
26882527734SSukumar Swaminathan {
269a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
27082527734SSukumar Swaminathan 	IOCTL_COMMON_NOP *nop;
27182527734SSukumar Swaminathan 
272a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
27382527734SSukumar Swaminathan 	mbq->nonembed = NULL;
27482527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
275a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
27682527734SSukumar Swaminathan 
27782527734SSukumar Swaminathan 	/*
27882527734SSukumar Swaminathan 	 * Signifies an embedded command
27982527734SSukumar Swaminathan 	 */
280a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.embedded = 1;
28182527734SSukumar Swaminathan 
282a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_SLI_CONFIG;
283a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
284a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.payload_length = sizeof (IOCTL_COMMON_NOP) +
28582527734SSukumar Swaminathan 	    IOCTL_HEADER_SZ;
286a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.subsystem =
28782527734SSukumar Swaminathan 	    IOCTL_SUBSYSTEM_COMMON;
288a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.opcode = COMMON_OPCODE_NOP;
289a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.timeout = 0;
290a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.req_length =
29182527734SSukumar Swaminathan 	    sizeof (IOCTL_COMMON_NOP);
292a9800bebSGarrett D'Amore 	nop = (IOCTL_COMMON_NOP *)&mb4->un.varSLIConfig.payload;
29382527734SSukumar Swaminathan 	nop->params.request.context = -1;
29482527734SSukumar Swaminathan 
29582527734SSukumar Swaminathan 	return;
29682527734SSukumar Swaminathan 
29782527734SSukumar Swaminathan } /* emlxs_mb_noop() */
29882527734SSukumar Swaminathan 
29982527734SSukumar Swaminathan 
300a9800bebSGarrett D'Amore /* SLI4 */
30182527734SSukumar Swaminathan /*ARGSUSED*/
30282527734SSukumar Swaminathan extern int
emlxs_mbext_noop(emlxs_hba_t * hba,MAILBOXQ * mbq)30382527734SSukumar Swaminathan emlxs_mbext_noop(emlxs_hba_t *hba, MAILBOXQ *mbq)
30482527734SSukumar Swaminathan {
305a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
30682527734SSukumar Swaminathan 	IOCTL_COMMON_NOP *nop;
30782527734SSukumar Swaminathan 	MATCHMAP *mp;
30882527734SSukumar Swaminathan 	mbox_req_hdr_t	*hdr_req;
30982527734SSukumar Swaminathan 
310a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
31182527734SSukumar Swaminathan 
3128f23e9faSHans Rosenfeld 	if ((mp = (MATCHMAP *)emlxs_mem_get(hba, MEM_BUF)) == 0) {
31382527734SSukumar Swaminathan 		return (1);
31482527734SSukumar Swaminathan 	}
31582527734SSukumar Swaminathan 	/*
31682527734SSukumar Swaminathan 	 * Save address for completion
31782527734SSukumar Swaminathan 	 * Signifies a non-embedded command
31882527734SSukumar Swaminathan 	 */
319a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.embedded = 0;
320a9800bebSGarrett D'Amore 	mbq->nonembed = (void *)mp;
32182527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
322a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
32382527734SSukumar Swaminathan 
324a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_SLI_CONFIG;
325a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
32682527734SSukumar Swaminathan 
32782527734SSukumar Swaminathan 	hdr_req = (mbox_req_hdr_t *)mp->virt;
32882527734SSukumar Swaminathan 	hdr_req->subsystem = IOCTL_SUBSYSTEM_COMMON;
32982527734SSukumar Swaminathan 	hdr_req->opcode = COMMON_OPCODE_NOP;
33082527734SSukumar Swaminathan 	hdr_req->timeout = 0;
33182527734SSukumar Swaminathan 	hdr_req->req_length = sizeof (IOCTL_COMMON_NOP);
33282527734SSukumar Swaminathan 	nop = (IOCTL_COMMON_NOP *)(hdr_req + 1);
33382527734SSukumar Swaminathan 	nop->params.request.context = -1;
33482527734SSukumar Swaminathan 
33582527734SSukumar Swaminathan 	return (0);
33682527734SSukumar Swaminathan 
33782527734SSukumar Swaminathan } /* emlxs_mbext_noop() */
33882527734SSukumar Swaminathan 
33982527734SSukumar Swaminathan 
340a9800bebSGarrett D'Amore /* SLI4 */
34182527734SSukumar Swaminathan /*ARGSUSED*/
34282527734SSukumar Swaminathan extern void
emlxs_mb_eq_create(emlxs_hba_t * hba,MAILBOXQ * mbq,uint32_t num)34382527734SSukumar Swaminathan emlxs_mb_eq_create(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t num)
34482527734SSukumar Swaminathan {
345a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
34682527734SSukumar Swaminathan 	IOCTL_COMMON_EQ_CREATE *qp;
34782527734SSukumar Swaminathan 	uint64_t	addr;
34882527734SSukumar Swaminathan 
349a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
35082527734SSukumar Swaminathan 	mbq->nonembed = NULL;
35182527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
352a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
35382527734SSukumar Swaminathan 
35482527734SSukumar Swaminathan 	/*
35582527734SSukumar Swaminathan 	 * Signifies an embedded command
35682527734SSukumar Swaminathan 	 */
357a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.embedded = 1;
35882527734SSukumar Swaminathan 
359a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_SLI_CONFIG;
360a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
361a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.payload_length =
36282527734SSukumar Swaminathan 	    sizeof (IOCTL_COMMON_EQ_CREATE) + IOCTL_HEADER_SZ;
363a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.subsystem =
36482527734SSukumar Swaminathan 	    IOCTL_SUBSYSTEM_COMMON;
365a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.opcode = COMMON_OPCODE_EQ_CREATE;
366a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.timeout = 0;
367a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.req_length =
36882527734SSukumar Swaminathan 	    sizeof (IOCTL_COMMON_EQ_CREATE);
3698f23e9faSHans Rosenfeld 	mb4->un.varSLIConfig.be.un_hdr.hdr_req.version = 0;
3708f23e9faSHans Rosenfeld 
371a9800bebSGarrett D'Amore 	qp = (IOCTL_COMMON_EQ_CREATE *)&mb4->un.varSLIConfig.payload;
37282527734SSukumar Swaminathan 
37382527734SSukumar Swaminathan 	/* 1024 * 4 bytes = 4K */
37482527734SSukumar Swaminathan 	qp->params.request.EQContext.Count = EQ_ELEMENT_COUNT_1024;
37582527734SSukumar Swaminathan 	qp->params.request.EQContext.Valid = 1;
37682527734SSukumar Swaminathan 	qp->params.request.EQContext.DelayMult = EQ_DELAY_MULT;
37782527734SSukumar Swaminathan 
37882527734SSukumar Swaminathan 	addr = hba->sli.sli4.eq[num].addr.phys;
37982527734SSukumar Swaminathan 	qp->params.request.NumPages = 1;
38082527734SSukumar Swaminathan 	qp->params.request.Pages[0].addrLow = PADDR_LO(addr);
38182527734SSukumar Swaminathan 	qp->params.request.Pages[0].addrHigh = PADDR_HI(addr);
38282527734SSukumar Swaminathan 
38382527734SSukumar Swaminathan 	return;
38482527734SSukumar Swaminathan 
38582527734SSukumar Swaminathan } /* emlxs_mb_eq_create() */
38682527734SSukumar Swaminathan 
38782527734SSukumar Swaminathan 
388a9800bebSGarrett D'Amore /* SLI4 */
38982527734SSukumar Swaminathan /*ARGSUSED*/
39082527734SSukumar Swaminathan extern void
emlxs_mb_cq_create(emlxs_hba_t * hba,MAILBOXQ * mbq,uint32_t num)39182527734SSukumar Swaminathan emlxs_mb_cq_create(emlxs_hba_t *hba, MAILBOXQ *mbq, uint32_t num)
39282527734SSukumar Swaminathan {
393a9800bebSGarrett D'Amore 	MAILBOX4 *mb4 = (MAILBOX4 *)mbq;
39482527734SSukumar Swaminathan 	IOCTL_COMMON_CQ_CREATE *qp;
3958f23e9faSHans Rosenfeld 	IOCTL_COMMON_CQ_CREATE_V2 *qp2;
39682527734SSukumar Swaminathan 	uint64_t	addr;
3978f23e9faSHans Rosenfeld 	uint32_t	i;
39882527734SSukumar Swaminathan 
399a9800bebSGarrett D'Amore 	bzero((void *) mb4, MAILBOX_CMD_SLI4_BSIZE);
40082527734SSukumar Swaminathan 	mbq->nonembed = NULL;
40182527734SSukumar Swaminathan 	mbq->mbox_cmpl = NULL; /* no cmpl needed */
402a9800bebSGarrett D'Amore 	mbq->port = (void *)&PPORT;
40382527734SSukumar Swaminathan 
40482527734SSukumar Swaminathan 	/*
40582527734SSukumar Swaminathan 	 * Signifies an embedded command
40682527734SSukumar Swaminathan 	 */
407a9800bebSGarrett D'Amore 	mb4->un.varSLIConfig.be.embedded = 1;
40882527734SSukumar Swaminathan 
409a9800bebSGarrett D'Amore 	mb4->mbxCommand = MBX_SLI_CONFIG;
410a9800bebSGarrett D'Amore 	mb4->mbxOwner = OWN_HOST;
4118f23e9faSHans Rosenfeld 
4128f23e9faSHans Rosenfeld 	switch (hba->sli.sli4.param.CQV) {
4138f23e9faSHans Rosenfeld 	case 0:
4148f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.payload_length =
4158f23e9faSHans Rosenfeld 		    sizeof (IOCTL_COMMON_CQ_CREATE) + IOCTL_HEADER_SZ;
4168f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.subsystem =
4178f23e9faSHans Rosenfeld 		    IOCTL_SUBSYSTEM_COMMON;
4188f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.opcode =
4198f23e9faSHans Rosenfeld 		    COMMON_OPCODE_CQ_CREATE;
4208f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.timeout = 0;
4218f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.req_length =
4228f23e9faSHans Rosenfeld 		    sizeof (IOCTL_COMMON_CQ_CREATE);
4238f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.version = 0;
4248f23e9faSHans Rosenfeld 
4258f23e9faSHans Rosenfeld 		qp = (IOCTL_COMMON_CQ_CREATE *)
4268f23e9faSHans Rosenfeld 		    &mb4->un.varSLIConfig.payload;
4278f23e9faSHans Rosenfeld 
4288f23e9faSHans Rosenfeld 		/* 256 * 16 bytes = 4K */
4298f23e9faSHans Rosenfeld 		qp->params.request.CQContext.Count = CQ_ELEMENT_COUNT_256;
4308f23e9faSHans Rosenfeld 		qp->params.request.CQContext.EQId =
4318f23e9faSHans Rosenfeld 		    (uint8_t)hba->sli.sli4.cq[num].eqid;
4328f23e9faSHans Rosenfeld 		qp->params.request.CQContext.Valid = 1;
4338f23e9faSHans Rosenfeld 		qp->params.request.CQContext.Eventable = 1;
4348f23e9faSHans Rosenfeld 		qp->params.request.CQContext.NoDelay = 0;
4358f23e9faSHans Rosenfeld 		qp->params.request.CQContext.CoalesceWM = 0;
4368f23e9faSHans Rosenfeld 
4378f23e9faSHans Rosenfeld 		addr = hba->sli.sli4.cq[num].addr.phys;
4388f23e9faSHans Rosenfeld 		qp->params.request.NumPages = 1;
4398f23e9faSHans Rosenfeld 		qp->params.request.Pages[0].addrLow = PADDR_LO(addr);
4408f23e9faSHans Rosenfeld 		qp->params.request.Pages[0].addrHigh = PADDR_HI(addr);
4418f23e9faSHans Rosenfeld 
4428f23e9faSHans Rosenfeld 		break;
4438f23e9faSHans Rosenfeld 
4448f23e9faSHans Rosenfeld 	case 2:
4458f23e9faSHans Rosenfeld 	default:
4468f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.payload_length =
4478f23e9faSHans Rosenfeld 		    sizeof (IOCTL_COMMON_CQ_CREATE_V2) + IOCTL_HEADER_SZ;
4488f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.subsystem =
4498f23e9faSHans Rosenfeld 		    IOCTL_SUBSYSTEM_COMMON;
4508f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.opcode =
4518f23e9faSHans Rosenfeld 		    COMMON_OPCODE_CQ_CREATE;
4528f23e9faSHans Rosenfeld 		mb4->un.varSLIConfig.be.un_hdr.hdr_req.timeout = 0;
453