2009-03-09 15:21:12 +08:00
|
|
|
/*
|
|
|
|
* This module provides common API for accessing firmware configuration pages
|
|
|
|
*
|
|
|
|
* This code is based on drivers/scsi/mpt2sas/mpt2_base.c
|
2010-03-17 18:58:04 +08:00
|
|
|
* Copyright (C) 2007-2010 LSI Corporation
|
2009-03-09 15:21:12 +08:00
|
|
|
* (mailto:DL-MPTFusionLinux@lsi.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
|
|
|
|
* LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
|
|
|
|
* solely responsible for determining the appropriateness of using and
|
|
|
|
* distributing the Program and assumes all risks associated with its
|
|
|
|
* exercise of rights under this Agreement, including but not limited to
|
|
|
|
* the risks and costs of program errors, damage to or loss of data,
|
|
|
|
* programs or equipment, and unavailability or interruption of operations.
|
|
|
|
|
|
|
|
* DISCLAIMER OF LIABILITY
|
|
|
|
* NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
|
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
|
|
* USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
|
|
|
* HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pci.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-03-09 15:21:12 +08:00
|
|
|
|
|
|
|
#include "mpt2sas_base.h"
|
|
|
|
|
|
|
|
/* local definitions */
|
|
|
|
|
|
|
|
/* Timeout for config page request (in seconds) */
|
|
|
|
#define MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT 15
|
|
|
|
|
|
|
|
/* Common sgl flags for READING a config page. */
|
|
|
|
#define MPT2_CONFIG_COMMON_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
|
|
|
|
MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
|
|
|
|
| MPI2_SGE_FLAGS_END_OF_LIST) << MPI2_SGE_FLAGS_SHIFT)
|
|
|
|
|
|
|
|
/* Common sgl flags for WRITING a config page. */
|
|
|
|
#define MPT2_CONFIG_COMMON_WRITE_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
|
|
|
|
MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
|
|
|
|
| MPI2_SGE_FLAGS_END_OF_LIST | MPI2_SGE_FLAGS_HOST_TO_IOC) \
|
|
|
|
<< MPI2_SGE_FLAGS_SHIFT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct config_request - obtain dma memory via routine
|
2009-08-20 15:54:31 +08:00
|
|
|
* @sz: size
|
|
|
|
* @page: virt pointer
|
|
|
|
* @page_dma: phys pointer
|
2009-03-09 15:21:12 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct config_request{
|
2009-08-20 15:54:31 +08:00
|
|
|
u16 sz;
|
|
|
|
void *page;
|
|
|
|
dma_addr_t page_dma;
|
2009-03-09 15:21:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
|
|
|
|
/**
|
|
|
|
* _config_display_some_debug - debug routine
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @smid: system request message index
|
|
|
|
* @calling_function_name: string pass from calling function
|
|
|
|
* @mpi_reply: reply message frame
|
|
|
|
* Context: none.
|
|
|
|
*
|
|
|
|
* Function for displaying debug info helpfull when debugging issues
|
|
|
|
* in this module.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_config_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid,
|
|
|
|
char *calling_function_name, MPI2DefaultReply_t *mpi_reply)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t *mpi_request;
|
|
|
|
char *desc = NULL;
|
|
|
|
|
|
|
|
if (!(ioc->logging_level & MPT_DEBUG_CONFIG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
|
|
|
|
switch (mpi_request->Header.PageType & MPI2_CONFIG_PAGETYPE_MASK) {
|
|
|
|
case MPI2_CONFIG_PAGETYPE_IO_UNIT:
|
|
|
|
desc = "io_unit";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_IOC:
|
|
|
|
desc = "ioc";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_BIOS:
|
|
|
|
desc = "bios";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_RAID_VOLUME:
|
|
|
|
desc = "raid_volume";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_MANUFACTURING:
|
|
|
|
desc = "manufaucturing";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK:
|
|
|
|
desc = "physdisk";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_PAGETYPE_EXTENDED:
|
|
|
|
switch (mpi_request->ExtPageType) {
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT:
|
|
|
|
desc = "sas_io_unit";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER:
|
|
|
|
desc = "sas_expander";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE:
|
|
|
|
desc = "sas_device";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_SAS_PHY:
|
|
|
|
desc = "sas_phy";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_LOG:
|
|
|
|
desc = "log";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE:
|
|
|
|
desc = "enclosure";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG:
|
|
|
|
desc = "raid_config";
|
|
|
|
break;
|
|
|
|
case MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING:
|
|
|
|
desc = "driver_mappping";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printk(MPT2SAS_DEBUG_FMT "%s: %s(%d), action(%d), form(0x%08x), "
|
|
|
|
"smid(%d)\n", ioc->name, calling_function_name, desc,
|
|
|
|
mpi_request->Header.PageNumber, mpi_request->Action,
|
|
|
|
le32_to_cpu(mpi_request->PageAddress), smid);
|
|
|
|
|
|
|
|
if (!mpi_reply)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (mpi_reply->IOCStatus || mpi_reply->IOCLogInfo)
|
|
|
|
printk(MPT2SAS_DEBUG_FMT
|
|
|
|
"\tiocstatus(0x%04x), loginfo(0x%08x)\n",
|
|
|
|
ioc->name, le16_to_cpu(mpi_reply->IOCStatus),
|
|
|
|
le32_to_cpu(mpi_reply->IOCLogInfo));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-08-20 15:54:31 +08:00
|
|
|
/**
|
|
|
|
* _config_alloc_config_dma_memory - obtain physical memory
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mem: struct config_request
|
|
|
|
*
|
|
|
|
* A wrapper for obtaining dma-able memory for config page request.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
_config_alloc_config_dma_memory(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
struct config_request *mem)
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if (mem->sz > ioc->config_page_sz) {
|
|
|
|
mem->page = dma_alloc_coherent(&ioc->pdev->dev, mem->sz,
|
|
|
|
&mem->page_dma, GFP_KERNEL);
|
|
|
|
if (!mem->page) {
|
|
|
|
printk(MPT2SAS_ERR_FMT "%s: dma_alloc_coherent"
|
|
|
|
" failed asking for (%d) bytes!!\n",
|
|
|
|
ioc->name, __func__, mem->sz);
|
|
|
|
r = -ENOMEM;
|
|
|
|
}
|
|
|
|
} else { /* use tmp buffer if less than 512 bytes */
|
|
|
|
mem->page = ioc->config_page;
|
|
|
|
mem->page_dma = ioc->config_page_dma;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _config_free_config_dma_memory - wrapper to free the memory
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mem: struct config_request
|
|
|
|
*
|
|
|
|
* A wrapper to free dma-able memory when using _config_alloc_config_dma_memory.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
struct config_request *mem)
|
|
|
|
{
|
|
|
|
if (mem->sz > ioc->config_page_sz)
|
|
|
|
dma_free_coherent(&ioc->pdev->dev, mem->sz, mem->page,
|
|
|
|
mem->page_dma);
|
|
|
|
}
|
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
/**
|
|
|
|
* mpt2sas_config_done - config page completion routine
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @smid: system request message index
|
2009-09-25 14:14:41 +08:00
|
|
|
* @msix_index: MSIX table index supplied by the OS
|
2009-03-09 15:21:12 +08:00
|
|
|
* @reply: reply message frame(lower 32bit addr)
|
|
|
|
* Context: none.
|
|
|
|
*
|
|
|
|
* The callback handler when using _config_request.
|
|
|
|
*
|
2009-09-14 13:34:23 +08:00
|
|
|
* Return 1 meaning mf should be freed from _base_interrupt
|
|
|
|
* 0 means the mf is freed from this function.
|
2009-03-09 15:21:12 +08:00
|
|
|
*/
|
2009-09-14 13:34:23 +08:00
|
|
|
u8
|
2009-09-25 14:14:41 +08:00
|
|
|
mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
|
|
|
|
u32 reply)
|
2009-03-09 15:21:12 +08:00
|
|
|
{
|
|
|
|
MPI2DefaultReply_t *mpi_reply;
|
|
|
|
|
|
|
|
if (ioc->config_cmds.status == MPT2_CMD_NOT_USED)
|
2009-09-14 13:34:23 +08:00
|
|
|
return 1;
|
2009-03-09 15:21:12 +08:00
|
|
|
if (ioc->config_cmds.smid != smid)
|
2009-09-14 13:34:23 +08:00
|
|
|
return 1;
|
2009-03-09 15:21:12 +08:00
|
|
|
ioc->config_cmds.status |= MPT2_CMD_COMPLETE;
|
|
|
|
mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
|
|
|
|
if (mpi_reply) {
|
|
|
|
ioc->config_cmds.status |= MPT2_CMD_REPLY_VALID;
|
|
|
|
memcpy(ioc->config_cmds.reply, mpi_reply,
|
|
|
|
mpi_reply->MsgLength*4);
|
|
|
|
}
|
|
|
|
ioc->config_cmds.status &= ~MPT2_CMD_PENDING;
|
|
|
|
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
|
|
|
|
_config_display_some_debug(ioc, smid, "config_done", mpi_reply);
|
|
|
|
#endif
|
2010-05-25 05:33:03 +08:00
|
|
|
ioc->config_cmds.smid = USHRT_MAX;
|
2009-03-09 15:21:12 +08:00
|
|
|
complete(&ioc->config_cmds.done);
|
2009-09-14 13:34:23 +08:00
|
|
|
return 1;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _config_request - main routine for sending config page requests
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_request: request message frame
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @timeout: timeout in seconds
|
2009-08-20 15:54:31 +08:00
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @config_page_sz: size of config page
|
|
|
|
* Context: sleep
|
2009-03-09 15:21:12 +08:00
|
|
|
*
|
|
|
|
* A generic API for config page requests to firmware.
|
|
|
|
*
|
|
|
|
* The ioc->config_cmds.status flag should be MPT2_CMD_NOT_USED before calling
|
|
|
|
* this API.
|
|
|
|
*
|
|
|
|
* The callback index is set inside `ioc->config_cb_idx.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
_config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
|
2009-08-20 15:54:31 +08:00
|
|
|
*mpi_request, Mpi2ConfigReply_t *mpi_reply, int timeout,
|
|
|
|
void *config_page, u16 config_page_sz)
|
2009-03-09 15:21:12 +08:00
|
|
|
{
|
|
|
|
u16 smid;
|
|
|
|
u32 ioc_state;
|
|
|
|
unsigned long timeleft;
|
|
|
|
Mpi2ConfigRequest_t *config_request;
|
|
|
|
int r;
|
2009-08-20 15:54:31 +08:00
|
|
|
u8 retry_count, issue_host_reset = 0;
|
2009-03-09 15:21:12 +08:00
|
|
|
u16 wait_state_count;
|
2009-08-20 15:54:31 +08:00
|
|
|
struct config_request mem;
|
2009-03-09 15:21:12 +08:00
|
|
|
|
2009-08-14 17:31:35 +08:00
|
|
|
mutex_lock(&ioc->config_cmds.mutex);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) {
|
|
|
|
printk(MPT2SAS_ERR_FMT "%s: config_cmd in use\n",
|
|
|
|
ioc->name, __func__);
|
2009-08-14 17:31:35 +08:00
|
|
|
mutex_unlock(&ioc->config_cmds.mutex);
|
2009-03-09 15:21:12 +08:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
2009-08-20 15:54:31 +08:00
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
retry_count = 0;
|
2009-08-20 15:54:31 +08:00
|
|
|
memset(&mem, 0, sizeof(struct config_request));
|
|
|
|
|
2009-09-25 14:14:41 +08:00
|
|
|
mpi_request->VF_ID = 0; /* TODO */
|
|
|
|
mpi_request->VP_ID = 0;
|
|
|
|
|
2009-08-20 15:54:31 +08:00
|
|
|
if (config_page) {
|
|
|
|
mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion;
|
|
|
|
mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber;
|
|
|
|
mpi_request->Header.PageType = mpi_reply->Header.PageType;
|
|
|
|
mpi_request->Header.PageLength = mpi_reply->Header.PageLength;
|
|
|
|
mpi_request->ExtPageLength = mpi_reply->ExtPageLength;
|
|
|
|
mpi_request->ExtPageType = mpi_reply->ExtPageType;
|
|
|
|
if (mpi_request->Header.PageLength)
|
|
|
|
mem.sz = mpi_request->Header.PageLength * 4;
|
|
|
|
else
|
|
|
|
mem.sz = le16_to_cpu(mpi_reply->ExtPageLength) * 4;
|
|
|
|
r = _config_alloc_config_dma_memory(ioc, &mem);
|
|
|
|
if (r != 0)
|
|
|
|
goto out;
|
|
|
|
if (mpi_request->Action ==
|
2009-12-16 21:25:26 +08:00
|
|
|
MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT ||
|
|
|
|
mpi_request->Action ==
|
|
|
|
MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM) {
|
2009-08-20 15:54:31 +08:00
|
|
|
ioc->base_add_sg_single(&mpi_request->PageBufferSGE,
|
|
|
|
MPT2_CONFIG_COMMON_WRITE_SGLFLAGS | mem.sz,
|
|
|
|
mem.page_dma);
|
|
|
|
memcpy(mem.page, config_page, min_t(u16, mem.sz,
|
|
|
|
config_page_sz));
|
|
|
|
} else {
|
|
|
|
memset(config_page, 0, config_page_sz);
|
|
|
|
ioc->base_add_sg_single(&mpi_request->PageBufferSGE,
|
|
|
|
MPT2_CONFIG_COMMON_SGLFLAGS | mem.sz, mem.page_dma);
|
|
|
|
}
|
|
|
|
}
|
2009-03-09 15:21:12 +08:00
|
|
|
|
|
|
|
retry_config:
|
2009-08-07 22:07:14 +08:00
|
|
|
if (retry_count) {
|
2009-08-20 15:54:31 +08:00
|
|
|
if (retry_count > 2) { /* attempt only 2 retries */
|
|
|
|
r = -EFAULT;
|
|
|
|
goto free_mem;
|
|
|
|
}
|
2009-08-07 22:07:14 +08:00
|
|
|
printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n",
|
|
|
|
ioc->name, __func__, retry_count);
|
|
|
|
}
|
2009-03-09 15:21:12 +08:00
|
|
|
wait_state_count = 0;
|
|
|
|
ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
|
|
|
|
while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
|
|
|
|
if (wait_state_count++ == MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT) {
|
|
|
|
printk(MPT2SAS_ERR_FMT
|
|
|
|
"%s: failed due to ioc not operational\n",
|
|
|
|
ioc->name, __func__);
|
2009-08-20 15:54:31 +08:00
|
|
|
ioc->config_cmds.status = MPT2_CMD_NOT_USED;
|
2009-08-14 17:31:35 +08:00
|
|
|
r = -EFAULT;
|
2009-08-20 15:54:31 +08:00
|
|
|
goto free_mem;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
ssleep(1);
|
|
|
|
ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
|
|
|
|
printk(MPT2SAS_INFO_FMT "%s: waiting for "
|
|
|
|
"operational state(count=%d)\n", ioc->name,
|
|
|
|
__func__, wait_state_count);
|
|
|
|
}
|
|
|
|
if (wait_state_count)
|
|
|
|
printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n",
|
|
|
|
ioc->name, __func__);
|
|
|
|
|
|
|
|
smid = mpt2sas_base_get_smid(ioc, ioc->config_cb_idx);
|
|
|
|
if (!smid) {
|
|
|
|
printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
|
|
|
|
ioc->name, __func__);
|
2009-08-20 15:54:31 +08:00
|
|
|
ioc->config_cmds.status = MPT2_CMD_NOT_USED;
|
2009-08-14 17:31:35 +08:00
|
|
|
r = -EAGAIN;
|
2009-08-20 15:54:31 +08:00
|
|
|
goto free_mem;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
r = 0;
|
|
|
|
memset(mpi_reply, 0, sizeof(Mpi2ConfigReply_t));
|
|
|
|
ioc->config_cmds.status = MPT2_CMD_PENDING;
|
|
|
|
config_request = mpt2sas_base_get_msg_frame(ioc, smid);
|
|
|
|
ioc->config_cmds.smid = smid;
|
|
|
|
memcpy(config_request, mpi_request, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
|
|
|
|
_config_display_some_debug(ioc, smid, "config_request", NULL);
|
|
|
|
#endif
|
2009-08-20 15:54:31 +08:00
|
|
|
init_completion(&ioc->config_cmds.done);
|
2009-09-25 14:14:41 +08:00
|
|
|
mpt2sas_base_put_smid_default(ioc, smid);
|
2009-03-09 15:21:12 +08:00
|
|
|
timeleft = wait_for_completion_timeout(&ioc->config_cmds.done,
|
|
|
|
timeout*HZ);
|
|
|
|
if (!(ioc->config_cmds.status & MPT2_CMD_COMPLETE)) {
|
|
|
|
printk(MPT2SAS_ERR_FMT "%s: timeout\n",
|
|
|
|
ioc->name, __func__);
|
|
|
|
_debug_dump_mf(mpi_request,
|
|
|
|
sizeof(Mpi2ConfigRequest_t)/4);
|
2009-08-14 17:31:35 +08:00
|
|
|
retry_count++;
|
|
|
|
if (ioc->config_cmds.smid == smid)
|
|
|
|
mpt2sas_base_free_smid(ioc, smid);
|
2009-08-20 15:54:31 +08:00
|
|
|
if ((ioc->shost_recovery) || (ioc->config_cmds.status &
|
|
|
|
MPT2_CMD_RESET))
|
2009-08-14 17:31:35 +08:00
|
|
|
goto retry_config;
|
|
|
|
issue_host_reset = 1;
|
|
|
|
r = -EFAULT;
|
2009-08-20 15:54:31 +08:00
|
|
|
goto free_mem;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
2009-08-20 15:54:31 +08:00
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID)
|
|
|
|
memcpy(mpi_reply, ioc->config_cmds.reply,
|
|
|
|
sizeof(Mpi2ConfigReply_t));
|
|
|
|
if (retry_count)
|
2009-08-20 15:54:31 +08:00
|
|
|
printk(MPT2SAS_INFO_FMT "%s: retry (%d) completed!!\n",
|
|
|
|
ioc->name, __func__, retry_count);
|
|
|
|
if (config_page && mpi_request->Action ==
|
|
|
|
MPI2_CONFIG_ACTION_PAGE_READ_CURRENT)
|
|
|
|
memcpy(config_page, mem.page, min_t(u16, mem.sz,
|
|
|
|
config_page_sz));
|
|
|
|
free_mem:
|
|
|
|
if (config_page)
|
|
|
|
_config_free_config_dma_memory(ioc, &mem);
|
|
|
|
out:
|
2009-03-09 15:21:12 +08:00
|
|
|
ioc->config_cmds.status = MPT2_CMD_NOT_USED;
|
2009-08-14 17:31:35 +08:00
|
|
|
mutex_unlock(&ioc->config_cmds.mutex);
|
2009-08-20 15:54:31 +08:00
|
|
|
|
2009-08-14 17:31:35 +08:00
|
|
|
if (issue_host_reset)
|
2009-03-09 15:21:12 +08:00
|
|
|
mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
|
|
|
|
FORCE_BIG_HAMMER);
|
2009-08-14 17:31:35 +08:00
|
|
|
return r;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_manufacturing_pg0 - obtain manufacturing page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_MANUFACTURING;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-08-20 15:53:49 +08:00
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_manufacturing_pg10 - obtain manufacturing page 10
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_MANUFACTURING;
|
|
|
|
mpi_request.Header.PageNumber = 10;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_MANUFACTURING0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-08-20 15:53:49 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-08-20 15:53:49 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_bios_pg2 - obtain bios page 2
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2BiosPage2_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_BIOS;
|
|
|
|
mpi_request.Header.PageNumber = 2;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_BIOSPAGE2_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_bios_pg3 - obtain bios page 3
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2BiosPage3_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_BIOS;
|
|
|
|
mpi_request.Header.PageNumber = 3;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_iounit_pg0 - obtain iounit page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage0_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_iounit_pg1 - obtain iounit page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_set_iounit_pg1 - set iounit page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
|
2009-08-20 15:54:31 +08:00
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage1_t *config_page)
|
2009-03-09 15:21:12 +08:00
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_IOUNITPAGE1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_ioc_pg8 - obtain ioc page 8
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2IOCPage8_t *config_page)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_IOC;
|
|
|
|
mpi_request.Header.PageNumber = 8;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_sas_device_pg0 - obtain sas device page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: device handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASDEVICE0_PAGEVERSION;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_sas_device_pg1 - obtain sas device page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: device handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASDEVICE1_PAGEVERSION;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_number_hba_phys - obtain number of phys on the host
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @num_phys: pointer returned with the number of phys
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
u16 ioc_status;
|
|
|
|
Mpi2ConfigReply_t mpi_reply;
|
|
|
|
Mpi2SasIOUnitPage0_t config_page;
|
|
|
|
|
2009-08-20 15:54:31 +08:00
|
|
|
*num_phys = 0;
|
2009-03-09 15:21:12 +08:00
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page,
|
|
|
|
sizeof(Mpi2SasIOUnitPage0_t));
|
2009-03-09 15:21:12 +08:00
|
|
|
if (!r) {
|
|
|
|
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
|
|
|
|
MPI2_IOCSTATUS_MASK;
|
2009-08-20 15:54:31 +08:00
|
|
|
if (ioc_status == MPI2_IOCSTATUS_SUCCESS)
|
2009-03-09 15:21:12 +08:00
|
|
|
*num_phys = config_page.NumPhys;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_sas_iounit_pg0 - obtain sas iounit page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @sz: size of buffer passed in config_page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Calling function should call config_get_number_hba_phys prior to
|
|
|
|
* this function, so enough memory is allocated for config_page.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
2009-08-20 15:54:31 +08:00
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-16 21:25:26 +08:00
|
|
|
* mpt2sas_config_get_sas_iounit_pg1 - obtain sas iounit page 1
|
2009-03-09 15:21:12 +08:00
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @sz: size of buffer passed in config_page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Calling function should call config_get_number_hba_phys prior to
|
|
|
|
* this function, so enough memory is allocated for config_page.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
2009-12-16 21:25:26 +08:00
|
|
|
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE1_PAGEVERSION;
|
2009-03-09 15:21:12 +08:00
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-12-16 21:25:26 +08:00
|
|
|
/**
|
|
|
|
* mpt2sas_config_set_sas_iounit_pg1 - send sas iounit page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @sz: size of buffer passed in config_page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Calling function should call config_get_number_hba_phys prior to
|
|
|
|
* this function, so enough memory is allocated for config_page.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT;
|
|
|
|
_config_request(ioc, &mpi_request, mpi_reply,
|
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
|
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-03-09 15:21:12 +08:00
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_expander_pg0 - obtain expander page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: expander handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASEXPANDER0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_expander_pg1 - obtain expander page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @phy_number: phy number
|
|
|
|
* @handle: expander handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number,
|
|
|
|
u16 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASEXPANDER1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress =
|
|
|
|
cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM |
|
|
|
|
(phy_number << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_enclosure_pg0 - obtain enclosure page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: expander handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASENCLOSURE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_phy_pg0 - obtain phy page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @phy_number: phy number
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_PHY;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASPHY0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress =
|
|
|
|
cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_phy_pg1 - obtain phy page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @phy_number: phy number
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_PHY;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_SASPHY1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress =
|
|
|
|
cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER | phy_number);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_raid_volume_pg1 - obtain raid volume page 1
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: volume handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
|
|
|
|
u32 handle)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME;
|
|
|
|
mpi_request.Header.PageNumber = 1;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_number_pds - obtain number of phys disk assigned to volume
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @handle: volume handle
|
|
|
|
* @num_pds: returns pds count
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle,
|
|
|
|
u8 *num_pds)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
2009-08-20 15:54:31 +08:00
|
|
|
Mpi2RaidVolPage0_t config_page;
|
2009-03-09 15:21:12 +08:00
|
|
|
Mpi2ConfigReply_t mpi_reply;
|
|
|
|
int r;
|
|
|
|
u16 ioc_status;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
*num_pds = 0;
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress =
|
|
|
|
cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page,
|
|
|
|
sizeof(Mpi2RaidVolPage0_t));
|
2009-03-09 15:21:12 +08:00
|
|
|
if (!r) {
|
|
|
|
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
|
|
|
|
MPI2_IOCSTATUS_MASK;
|
2009-08-20 15:54:31 +08:00
|
|
|
if (ioc_status == MPI2_IOCSTATUS_SUCCESS)
|
|
|
|
*num_pds = config_page.NumPhysDisks;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_raid_volume_pg0 - obtain raid volume page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_HANDLE or HANDLE
|
|
|
|
* @handle: volume handle
|
|
|
|
* @sz: size of buffer passed in config_page
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc,
|
|
|
|
Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
|
|
|
|
u32 handle, u16 sz)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_VOLUME;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_RAIDVOLPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | handle);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_phys_disk_pg0 - obtain phys disk page 0
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @mpi_reply: reply mf payload returned from firmware
|
|
|
|
* @config_page: contents of the config page
|
|
|
|
* @form: GET_NEXT_PHYSDISKNUM, PHYSDISKNUM, DEVHANDLE
|
|
|
|
* @form_specific: specific to the form
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
|
|
|
|
*mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
|
|
|
|
u32 form_specific)
|
|
|
|
{
|
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress = cpu_to_le32(form | form_specific);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
|
|
|
r = _config_request(ioc, &mpi_request, mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
sizeof(*config_page));
|
2009-03-09 15:21:12 +08:00
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_volume_handle - returns volume handle for give hidden raid components
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @pd_handle: phys disk handle
|
|
|
|
* @volume_handle: volume handle
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
|
|
|
|
u16 *volume_handle)
|
|
|
|
{
|
2009-08-20 15:54:31 +08:00
|
|
|
Mpi2RaidConfigurationPage0_t *config_page = NULL;
|
2009-03-09 15:21:12 +08:00
|
|
|
Mpi2ConfigRequest_t mpi_request;
|
|
|
|
Mpi2ConfigReply_t mpi_reply;
|
2009-08-20 15:54:31 +08:00
|
|
|
int r, i, config_page_sz;
|
2009-03-09 15:21:12 +08:00
|
|
|
u16 ioc_status;
|
|
|
|
|
|
|
|
*volume_handle = 0;
|
|
|
|
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
|
|
|
|
mpi_request.Function = MPI2_FUNCTION_CONFIG;
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
|
|
|
|
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
|
|
|
|
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG;
|
|
|
|
mpi_request.Header.PageVersion = MPI2_RAIDCONFIG0_PAGEVERSION;
|
|
|
|
mpi_request.Header.PageNumber = 0;
|
|
|
|
mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
|
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mpi_request.PageAddress =
|
|
|
|
cpu_to_le32(MPI2_RAID_PGAD_FORM_ACTIVE_CONFIG);
|
|
|
|
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
|
2009-08-20 15:54:31 +08:00
|
|
|
config_page_sz = (le16_to_cpu(mpi_reply.ExtPageLength) * 4);
|
|
|
|
config_page = kmalloc(config_page_sz, GFP_KERNEL);
|
|
|
|
if (!config_page)
|
|
|
|
goto out;
|
2009-03-09 15:21:12 +08:00
|
|
|
r = _config_request(ioc, &mpi_request, &mpi_reply,
|
2009-08-20 15:54:31 +08:00
|
|
|
MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
|
|
|
|
config_page_sz);
|
2009-03-09 15:21:12 +08:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
r = -1;
|
|
|
|
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
|
|
|
|
if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
|
2009-08-20 15:54:31 +08:00
|
|
|
goto out;
|
2009-03-09 15:21:12 +08:00
|
|
|
for (i = 0; i < config_page->NumElements; i++) {
|
2010-03-17 18:54:52 +08:00
|
|
|
if ((le16_to_cpu(config_page->ConfigElement[i].ElementFlags) &
|
2009-03-09 15:21:12 +08:00
|
|
|
MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) !=
|
|
|
|
MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT)
|
|
|
|
continue;
|
2010-03-17 18:54:52 +08:00
|
|
|
if (le16_to_cpu(config_page->ConfigElement[i].
|
|
|
|
PhysDiskDevHandle) == pd_handle) {
|
2009-03-09 15:21:12 +08:00
|
|
|
*volume_handle = le16_to_cpu(config_page->
|
|
|
|
ConfigElement[i].VolDevHandle);
|
|
|
|
r = 0;
|
2009-08-20 15:54:31 +08:00
|
|
|
goto out;
|
2009-03-09 15:21:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
2009-08-20 15:54:31 +08:00
|
|
|
kfree(config_page);
|
2009-03-09 15:21:12 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpt2sas_config_get_volume_wwid - returns wwid given the volume handle
|
|
|
|
* @ioc: per adapter object
|
|
|
|
* @volume_handle: volume handle
|
|
|
|
* @wwid: volume wwid
|
|
|
|
* Context: sleep.
|
|
|
|
*
|
|
|
|
* Returns 0 for success, non-zero for failure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
|
|
|
|
u64 *wwid)
|
|
|
|
{
|
|
|
|
Mpi2ConfigReply_t mpi_reply;
|
|
|
|
Mpi2RaidVolPage1_t raid_vol_pg1;
|
|
|
|
|
|
|
|
*wwid = 0;
|
|
|
|
if (!(mpt2sas_config_get_raid_volume_pg1(ioc, &mpi_reply,
|
|
|
|
&raid_vol_pg1, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE,
|
|
|
|
volume_handle))) {
|
|
|
|
*wwid = le64_to_cpu(raid_vol_pg1.WWID);
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
}
|