mptsas_impl.c revision d3d50737e566cade9a08d73d2af95105ac7cd960
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * CDDL HEADER START
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * The contents of this file are subject to the terms of the
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Common Development and Distribution License (the "License").
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * You may not use this file except in compliance with the License.
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco * See the License for the specific language governing permissions
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco * and limitations under the License.
34ce5c2f0e9b0f6bf05895501c9f7171d4a5bab7Lubos Kosco * When distributing Covered Code, include this CDDL HEADER in each
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * If applicable, add the following below this CDDL HEADER, with the
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * fields enclosed by brackets "[]" replaced with your own identifying
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * information: Portions Copyright [yyyy] [name of copyright owner]
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * CDDL HEADER END
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Use is subject to license terms.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Copyright (c) 2000 to 2009, LSI Corporation.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * All rights reserved.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Redistribution and use in source and binary forms of all code within
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * this file that is exclusively owned by LSI, with or without
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * modification, is permitted provided that, in addition to the CDDL 1.0
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * License requirements, the following conditions are met:
34ce5c2f0e9b0f6bf05895501c9f7171d4a5bab7Lubos Kosco * Neither the name of the author nor the names of its contributors may be
fb96d0f1ab431db23ef75c52867d8261acda9b0aLubos Kosco * used to endorse or promote products derived from this software without
ad0b633ade6931f350b9ec745e5599d6afe6d6b3Lubos Kosco * specific prior written permission.
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * mptsas_impl - This file contains all the basic functions for communicating
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * to MPT based hardware.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * standard header files
2b809fbe98d3081cb2b097042e8d983c05d7ac19ralphmayr#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_type.h>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_cnfg.h>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_init.h>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_ioc.h>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_sas.h>
37187cd476e30232cba3afb116e079cb640f984eLubos Kosco * private header files.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco#include <sys/scsi/adapters/mpt_sas/mptsas_var.h>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * FMA header files.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * prototypes
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Koscostatic void mptsas_ioc_event_cmdq_add(mptsas_t *mpt, m_event_struct_t *cmd);
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Koscostatic void mptsas_ioc_event_cmdq_delete(mptsas_t *mpt, m_event_struct_t *cmd);
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Koscostatic m_event_struct_t *mptsas_ioc_event_find_by_cmd(mptsas_t *mpt,
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * add ioc evnet cmd into the queue
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Koscomptsas_ioc_event_cmdq_add(mptsas_t *mpt, m_event_struct_t *cmd)
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco if ((cmd->m_event_linkp = mpt->m_ioc_event_cmdq) == NULL) {
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * remove specified cmd from the ioc event queue
static m_event_struct_t *
return (ioc_cmd);
return (ioc_cmd);
length = 0;
DDI_SUCCESS) ||
DDI_SUCCESS)) {
goto page_done;
goto page_done;
if (iocstatus) {
iocloginfo));
goto page_done;
goto page_done;
goto page_done;
goto page_done;
goto page_done;
goto page_done;
goto page_done;
goto page_done;
goto page_done;
return (rval);
int send_numbytes;
int send_numbytes;
int polls = 0;
int polls = 0;
int polls = 0;
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
#ifdef SLM
int polls = 0;
return (MPTSAS_NO_RESET);
#ifdef SLM
goto hard_reset;
goto hard_reset;
return (MPTSAS_NO_RESET);
return (MPTSAS_RESET_FAIL);
return (MPTSAS_SUCCESS_HARDRESET);
return (DDI_FAILURE);
return (DDI_SUCCESS);
int lun)
return (FALSE);
return (rval);
int rvalue = 0;
return (rvalue);
for (i = 0; i < size; i++) {
rvalue = 0;
return (rvalue);
#ifndef __lock_lint
return (rval);
return (rval);
for (i = 0; i < SAS_WWN_BYTE_SIZE; i++) {
return (rval);
return (rval);
#ifndef __lock_lint
return (rval);
return (rval);
for (i = 0; i < SAS_WWN_BYTE_SIZE; i++) {
return (rval);
return (rval);
#ifndef __lock_lint
return (rval);
for (i = 0; i < SAS_WWN_BYTE_SIZE; i++) {
return (rval);
return (rval);
#ifndef __lock_lint
int i, num_phys;
return (rval);
for (i = 0; i < num_phys; i++) {
*retrypage0 = 0;
return (rval);
#ifndef __lock_lint
int i, num_phys;
return (rval);
for (i = 0; i < num_phys; i++) {
return (rval);
&retrypage0);
switch (state) {
case IOUC_READ_PAGE0:
if (readpage1 == 0) {
case IOUC_READ_PAGE1:
return (rval);
return (rval);
#ifndef __lock_lint
return (rval);
return (rval);
return (rval);
int recv_numbytes;
int recv_dmastate = 0;
int page_dmastate = 0;
int i, num_phys;
int page0_size =
sizeof (MPI2_CONFIG_PAGE_SASIOUNIT_0) +
int page1_size =
sizeof (MPI2_CONFIG_PAGE_SASIOUNIT_1) +
goto cleanup;
(sizeof (MPI2_CONFIG_REPLY)),
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
switch (state) {
case IOUC_READ_PAGE0:
page_number = 0;
case IOUC_READ_PAGE1:
0, page_number, 0, 0, 0, 0)) {
goto cleanup;
recv_accessp)) {
goto cleanup;
goto cleanup;
goto cleanup;
recv_accessp)) {
goto cleanup;
goto cleanup;
switch (state) {
case IOUC_READ_PAGE0:
goto cleanup;
for (i = 0; i < num_phys; i++) {
retrypage0++;
retrypage0 = 0;
if (readpage1 == 0) {
case IOUC_READ_PAGE1:
goto cleanup;
for (i = 0; i < num_phys; i++) {
goto cleanup;
goto cleanup;
return (rval);
int recv_numbytes;
int recv_dmastate = 0;
int page_dmastate = 0;
int page1_size =
sizeof (MPI2_CONFIG_PAGE_SASIOUNIT_1) +
return (rval);
if (reprogram == 0)
return (DDI_SUCCESS);
goto cleanup;
(sizeof (MPI2_CONFIG_REPLY)),
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
switch (state) {
case IOUC_READ_PAGE1:
case IOUC_WRITE_PAGE1:
0, page_number, 0, 0, 0, 0)) {
goto cleanup;
recv_accessp)) {
goto cleanup;
goto cleanup;
goto cleanup;
recv_accessp)) {
goto cleanup;
goto cleanup;
switch (state) {
case IOUC_READ_PAGE1:
goto cleanup;
port_flags |=
goto cleanup;
case IOUC_WRITE_PAGE1:
return (rval);
int recv_numbytes;
int recv_dmastate = 0;
int page_dmastate = 0;
goto done;
goto done;
(sizeof (MPI2_CONFIG_REPLY)),
goto done;
goto done;
recv_accessp)) {
goto done;
goto done;
goto done;
(sizeof (MPI2_CONFIG_PAGE_MAN_5)),
goto done;
goto done;
goto done;
recv_accessp)) {
goto done;
goto done;
goto done;
done:
return (rval);