2 * This module provides common API for accessing firmware configuration pages
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
5 * Copyright (C) 2012-2014 LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
21 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
24 * solely responsible for determining the appropriateness of using and
25 * distributing the Program and assumes all risks associated with its
26 * exercise of rights under this Agreement, including but not limited to
27 * the risks and costs of program errors, damage to or loss of data,
28 * programs or equipment, and unavailability or interruption of operations.
30 * DISCLAIMER OF LIABILITY
31 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
32 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
45 #include <linux/module.h>
46 #include <linux/kernel.h>
47 #include <linux/init.h>
48 #include <linux/errno.h>
49 #include <linux/blkdev.h>
50 #include <linux/sched.h>
51 #include <linux/workqueue.h>
52 #include <linux/delay.h>
53 #include <linux/pci.h>
55 #include "mpt3sas_base.h"
57 /* local definitions */
59 /* Timeout for config page request (in seconds) */
60 #define MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT 15
62 /* Common sgl flags for READING a config page. */
63 #define MPT3_CONFIG_COMMON_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
64 MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
65 | MPI2_SGE_FLAGS_END_OF_LIST) << MPI2_SGE_FLAGS_SHIFT)
67 /* Common sgl flags for WRITING a config page. */
68 #define MPT3_CONFIG_COMMON_WRITE_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
69 MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
70 | MPI2_SGE_FLAGS_END_OF_LIST | MPI2_SGE_FLAGS_HOST_TO_IOC) \
71 << MPI2_SGE_FLAGS_SHIFT)
74 * struct config_request - obtain dma memory via routine
77 * @page_dma: phys pointer
80 struct config_request
{
87 * _config_display_some_debug - debug routine
88 * @ioc: per adapter object
89 * @smid: system request message index
90 * @calling_function_name: string pass from calling function
91 * @mpi_reply: reply message frame
94 * Function for displaying debug info helpful when debugging issues
98 _config_display_some_debug(struct MPT3SAS_ADAPTER
*ioc
, u16 smid
,
99 char *calling_function_name
, MPI2DefaultReply_t
*mpi_reply
)
101 Mpi2ConfigRequest_t
*mpi_request
;
104 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
107 mpi_request
= mpt3sas_base_get_msg_frame(ioc
, smid
);
108 switch (mpi_request
->Header
.PageType
& MPI2_CONFIG_PAGETYPE_MASK
) {
109 case MPI2_CONFIG_PAGETYPE_IO_UNIT
:
112 case MPI2_CONFIG_PAGETYPE_IOC
:
115 case MPI2_CONFIG_PAGETYPE_BIOS
:
118 case MPI2_CONFIG_PAGETYPE_RAID_VOLUME
:
119 desc
= "raid_volume";
121 case MPI2_CONFIG_PAGETYPE_MANUFACTURING
:
122 desc
= "manufacturing";
124 case MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK
:
127 case MPI2_CONFIG_PAGETYPE_EXTENDED
:
128 switch (mpi_request
->ExtPageType
) {
129 case MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
:
130 desc
= "sas_io_unit";
132 case MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
:
133 desc
= "sas_expander";
135 case MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
:
138 case MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
:
141 case MPI2_CONFIG_EXTPAGETYPE_LOG
:
144 case MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE
:
147 case MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG
:
148 desc
= "raid_config";
150 case MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING
:
151 desc
= "driver_mapping";
153 case MPI2_CONFIG_EXTPAGETYPE_SAS_PORT
:
156 case MPI2_CONFIG_EXTPAGETYPE_EXT_MANUFACTURING
:
157 desc
= "ext_manufacturing";
159 case MPI2_CONFIG_EXTPAGETYPE_PCIE_IO_UNIT
:
160 desc
= "pcie_io_unit";
162 case MPI2_CONFIG_EXTPAGETYPE_PCIE_SWITCH
:
163 desc
= "pcie_switch";
165 case MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
:
166 desc
= "pcie_device";
168 case MPI2_CONFIG_EXTPAGETYPE_PCIE_LINK
:
178 ioc_info(ioc
, "%s: %s(%d), action(%d), form(0x%08x), smid(%d)\n",
179 calling_function_name
, desc
,
180 mpi_request
->Header
.PageNumber
, mpi_request
->Action
,
181 le32_to_cpu(mpi_request
->PageAddress
), smid
);
186 if (mpi_reply
->IOCStatus
|| mpi_reply
->IOCLogInfo
)
187 ioc_info(ioc
, "\tiocstatus(0x%04x), loginfo(0x%08x)\n",
188 le16_to_cpu(mpi_reply
->IOCStatus
),
189 le32_to_cpu(mpi_reply
->IOCLogInfo
));
193 * _config_alloc_config_dma_memory - obtain physical memory
194 * @ioc: per adapter object
195 * @mem: struct config_request
197 * A wrapper for obtaining dma-able memory for config page request.
199 * Return: 0 for success, non-zero for failure.
202 _config_alloc_config_dma_memory(struct MPT3SAS_ADAPTER
*ioc
,
203 struct config_request
*mem
)
207 if (mem
->sz
> ioc
->config_page_sz
) {
208 mem
->page
= dma_alloc_coherent(&ioc
->pdev
->dev
, mem
->sz
,
209 &mem
->page_dma
, GFP_KERNEL
);
211 ioc_err(ioc
, "%s: dma_alloc_coherent failed asking for (%d) bytes!!\n",
215 } else { /* use tmp buffer if less than 512 bytes */
216 mem
->page
= ioc
->config_page
;
217 mem
->page_dma
= ioc
->config_page_dma
;
219 ioc
->config_vaddr
= mem
->page
;
224 * _config_free_config_dma_memory - wrapper to free the memory
225 * @ioc: per adapter object
226 * @mem: struct config_request
228 * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory.
230 * Return: 0 for success, non-zero for failure.
233 _config_free_config_dma_memory(struct MPT3SAS_ADAPTER
*ioc
,
234 struct config_request
*mem
)
236 if (mem
->sz
> ioc
->config_page_sz
)
237 dma_free_coherent(&ioc
->pdev
->dev
, mem
->sz
, mem
->page
,
242 * mpt3sas_config_done - config page completion routine
243 * @ioc: per adapter object
244 * @smid: system request message index
245 * @msix_index: MSIX table index supplied by the OS
246 * @reply: reply message frame(lower 32bit addr)
249 * The callback handler when using _config_request.
251 * Return: 1 meaning mf should be freed from _base_interrupt
252 * 0 means the mf is freed from this function.
255 mpt3sas_config_done(struct MPT3SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
258 MPI2DefaultReply_t
*mpi_reply
;
260 if (ioc
->config_cmds
.status
== MPT3_CMD_NOT_USED
)
262 if (ioc
->config_cmds
.smid
!= smid
)
264 ioc
->config_cmds
.status
|= MPT3_CMD_COMPLETE
;
265 mpi_reply
= mpt3sas_base_get_reply_virt_addr(ioc
, reply
);
267 ioc
->config_cmds
.status
|= MPT3_CMD_REPLY_VALID
;
268 memcpy(ioc
->config_cmds
.reply
, mpi_reply
,
269 mpi_reply
->MsgLength
*4);
271 ioc
->config_cmds
.status
&= ~MPT3_CMD_PENDING
;
272 _config_display_some_debug(ioc
, smid
, "config_done", mpi_reply
);
273 ioc
->config_cmds
.smid
= USHRT_MAX
;
274 complete(&ioc
->config_cmds
.done
);
279 * _config_request - main routine for sending config page requests
280 * @ioc: per adapter object
281 * @mpi_request: request message frame
282 * @mpi_reply: reply mf payload returned from firmware
283 * @timeout: timeout in seconds
284 * @config_page: contents of the config page
285 * @config_page_sz: size of config page
288 * A generic API for config page requests to firmware.
290 * The ioc->config_cmds.status flag should be MPT3_CMD_NOT_USED before calling
293 * The callback index is set inside `ioc->config_cb_idx.
295 * Return: 0 for success, non-zero for failure.
298 _config_request(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigRequest_t
299 *mpi_request
, Mpi2ConfigReply_t
*mpi_reply
, int timeout
,
300 void *config_page
, u16 config_page_sz
)
303 Mpi2ConfigRequest_t
*config_request
;
305 u8 retry_count
, issue_host_reset
= 0;
306 struct config_request mem
;
307 u32 ioc_status
= UINT_MAX
;
309 mutex_lock(&ioc
->config_cmds
.mutex
);
310 if (ioc
->config_cmds
.status
!= MPT3_CMD_NOT_USED
) {
311 ioc_err(ioc
, "%s: config_cmd in use\n", __func__
);
312 mutex_unlock(&ioc
->config_cmds
.mutex
);
317 memset(&mem
, 0, sizeof(struct config_request
));
319 mpi_request
->VF_ID
= 0; /* TODO */
320 mpi_request
->VP_ID
= 0;
323 mpi_request
->Header
.PageVersion
= mpi_reply
->Header
.PageVersion
;
324 mpi_request
->Header
.PageNumber
= mpi_reply
->Header
.PageNumber
;
325 mpi_request
->Header
.PageType
= mpi_reply
->Header
.PageType
;
326 mpi_request
->Header
.PageLength
= mpi_reply
->Header
.PageLength
;
327 mpi_request
->ExtPageLength
= mpi_reply
->ExtPageLength
;
328 mpi_request
->ExtPageType
= mpi_reply
->ExtPageType
;
329 if (mpi_request
->Header
.PageLength
)
330 mem
.sz
= mpi_request
->Header
.PageLength
* 4;
332 mem
.sz
= le16_to_cpu(mpi_reply
->ExtPageLength
) * 4;
333 r
= _config_alloc_config_dma_memory(ioc
, &mem
);
336 if (mpi_request
->Action
==
337 MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
||
338 mpi_request
->Action
==
339 MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
) {
340 ioc
->base_add_sg_single(&mpi_request
->PageBufferSGE
,
341 MPT3_CONFIG_COMMON_WRITE_SGLFLAGS
| mem
.sz
,
343 memcpy(mem
.page
, config_page
, min_t(u16
, mem
.sz
,
346 memset(config_page
, 0, config_page_sz
);
347 ioc
->base_add_sg_single(&mpi_request
->PageBufferSGE
,
348 MPT3_CONFIG_COMMON_SGLFLAGS
| mem
.sz
, mem
.page_dma
);
349 memset(mem
.page
, 0, min_t(u16
, mem
.sz
, config_page_sz
));
355 if (retry_count
> 2) { /* attempt only 2 retries */
359 ioc_info(ioc
, "%s: attempting retry (%d)\n",
360 __func__
, retry_count
);
363 r
= mpt3sas_wait_for_ioc(ioc
, MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
);
367 smid
= mpt3sas_base_get_smid(ioc
, ioc
->config_cb_idx
);
369 ioc_err(ioc
, "%s: failed obtaining a smid\n", __func__
);
370 ioc
->config_cmds
.status
= MPT3_CMD_NOT_USED
;
376 memset(mpi_reply
, 0, sizeof(Mpi2ConfigReply_t
));
377 ioc
->config_cmds
.status
= MPT3_CMD_PENDING
;
378 config_request
= mpt3sas_base_get_msg_frame(ioc
, smid
);
379 ioc
->config_cmds
.smid
= smid
;
380 memcpy(config_request
, mpi_request
, sizeof(Mpi2ConfigRequest_t
));
381 _config_display_some_debug(ioc
, smid
, "config_request", NULL
);
382 init_completion(&ioc
->config_cmds
.done
);
383 ioc
->put_smid_default(ioc
, smid
);
384 wait_for_completion_timeout(&ioc
->config_cmds
.done
, timeout
*HZ
);
385 if (!(ioc
->config_cmds
.status
& MPT3_CMD_COMPLETE
)) {
386 mpt3sas_base_check_cmd_timeout(ioc
,
387 ioc
->config_cmds
.status
, mpi_request
,
388 sizeof(Mpi2ConfigRequest_t
)/4);
390 if (ioc
->config_cmds
.smid
== smid
)
391 mpt3sas_base_free_smid(ioc
, smid
);
392 if ((ioc
->shost_recovery
) || (ioc
->config_cmds
.status
&
393 MPT3_CMD_RESET
) || ioc
->pci_error_recovery
)
395 issue_host_reset
= 1;
400 if (ioc
->config_cmds
.status
& MPT3_CMD_REPLY_VALID
) {
401 memcpy(mpi_reply
, ioc
->config_cmds
.reply
,
402 sizeof(Mpi2ConfigReply_t
));
404 /* Reply Frame Sanity Checks to workaround FW issues */
405 if ((mpi_request
->Header
.PageType
& 0xF) !=
406 (mpi_reply
->Header
.PageType
& 0xF)) {
407 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
408 _debug_dump_reply(mpi_reply
, ioc
->request_sz
/4);
409 panic("%s: %s: Firmware BUG: mpi_reply mismatch: Requested PageType(0x%02x) Reply PageType(0x%02x)\n",
411 mpi_request
->Header
.PageType
& 0xF,
412 mpi_reply
->Header
.PageType
& 0xF);
415 if (((mpi_request
->Header
.PageType
& 0xF) ==
416 MPI2_CONFIG_PAGETYPE_EXTENDED
) &&
417 mpi_request
->ExtPageType
!= mpi_reply
->ExtPageType
) {
418 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
419 _debug_dump_reply(mpi_reply
, ioc
->request_sz
/4);
420 panic("%s: %s: Firmware BUG: mpi_reply mismatch: Requested ExtPageType(0x%02x) Reply ExtPageType(0x%02x)\n",
422 mpi_request
->ExtPageType
,
423 mpi_reply
->ExtPageType
);
425 ioc_status
= le16_to_cpu(mpi_reply
->IOCStatus
)
426 & MPI2_IOCSTATUS_MASK
;
430 ioc_info(ioc
, "%s: retry (%d) completed!!\n",
431 __func__
, retry_count
);
433 if ((ioc_status
== MPI2_IOCSTATUS_SUCCESS
) &&
434 config_page
&& mpi_request
->Action
==
435 MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
) {
436 u8
*p
= (u8
*)mem
.page
;
438 /* Config Page Sanity Checks to workaround FW issues */
440 if ((mpi_request
->Header
.PageType
& 0xF) !=
442 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
443 _debug_dump_reply(mpi_reply
, ioc
->request_sz
/4);
444 _debug_dump_config(p
, min_t(u16
, mem
.sz
,
446 panic("%s: %s: Firmware BUG: config page mismatch: Requested PageType(0x%02x) Reply PageType(0x%02x)\n",
448 mpi_request
->Header
.PageType
& 0xF,
452 if (((mpi_request
->Header
.PageType
& 0xF) ==
453 MPI2_CONFIG_PAGETYPE_EXTENDED
) &&
454 (mpi_request
->ExtPageType
!= p
[6])) {
455 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
456 _debug_dump_reply(mpi_reply
, ioc
->request_sz
/4);
457 _debug_dump_config(p
, min_t(u16
, mem
.sz
,
459 panic("%s: %s: Firmware BUG: config page mismatch: Requested ExtPageType(0x%02x) Reply ExtPageType(0x%02x)\n",
461 mpi_request
->ExtPageType
, p
[6]);
464 memcpy(config_page
, mem
.page
, min_t(u16
, mem
.sz
,
470 _config_free_config_dma_memory(ioc
, &mem
);
472 ioc
->config_cmds
.status
= MPT3_CMD_NOT_USED
;
473 mutex_unlock(&ioc
->config_cmds
.mutex
);
475 if (issue_host_reset
)
476 mpt3sas_base_hard_reset_handler(ioc
, FORCE_BIG_HAMMER
);
481 * mpt3sas_config_get_manufacturing_pg0 - obtain manufacturing page 0
482 * @ioc: per adapter object
483 * @mpi_reply: reply mf payload returned from firmware
484 * @config_page: contents of the config page
487 * Return: 0 for success, non-zero for failure.
490 mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER
*ioc
,
491 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage0_t
*config_page
)
493 Mpi2ConfigRequest_t mpi_request
;
496 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
497 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
498 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
499 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
500 mpi_request
.Header
.PageNumber
= 0;
501 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
502 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
503 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
504 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
508 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
509 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
510 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
511 sizeof(*config_page
));
517 * mpt3sas_config_get_manufacturing_pg7 - obtain manufacturing page 7
518 * @ioc: per adapter object
519 * @mpi_reply: reply mf payload returned from firmware
520 * @config_page: contents of the config page
521 * @sz: size of buffer passed in config_page
524 * Return: 0 for success, non-zero for failure.
527 mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER
*ioc
,
528 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage7_t
*config_page
,
531 Mpi2ConfigRequest_t mpi_request
;
534 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
535 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
536 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
537 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
538 mpi_request
.Header
.PageNumber
= 7;
539 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING7_PAGEVERSION
;
540 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
541 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
542 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
546 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
547 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
548 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
555 * mpt3sas_config_get_manufacturing_pg10 - obtain manufacturing page 10
556 * @ioc: per adapter object
557 * @mpi_reply: reply mf payload returned from firmware
558 * @config_page: contents of the config page
561 * Return: 0 for success, non-zero for failure.
564 mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER
*ioc
,
565 Mpi2ConfigReply_t
*mpi_reply
,
566 struct Mpi2ManufacturingPage10_t
*config_page
)
568 Mpi2ConfigRequest_t mpi_request
;
571 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
572 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
573 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
574 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
575 mpi_request
.Header
.PageNumber
= 10;
576 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
577 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
578 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
579 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
583 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
584 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
585 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
586 sizeof(*config_page
));
592 * mpt3sas_config_get_manufacturing_pg11 - obtain manufacturing page 11
593 * @ioc: per adapter object
594 * @mpi_reply: reply mf payload returned from firmware
595 * @config_page: contents of the config page
598 * Return: 0 for success, non-zero for failure.
601 mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER
*ioc
,
602 Mpi2ConfigReply_t
*mpi_reply
,
603 struct Mpi2ManufacturingPage11_t
*config_page
)
605 Mpi2ConfigRequest_t mpi_request
;
608 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
609 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
610 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
611 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
612 mpi_request
.Header
.PageNumber
= 11;
613 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
614 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
615 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
616 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
620 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
621 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
622 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
623 sizeof(*config_page
));
629 * mpt3sas_config_set_manufacturing_pg11 - set manufacturing page 11
630 * @ioc: per adapter object
631 * @mpi_reply: reply mf payload returned from firmware
632 * @config_page: contents of the config page
635 * Return: 0 for success, non-zero for failure.
638 mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER
*ioc
,
639 Mpi2ConfigReply_t
*mpi_reply
,
640 struct Mpi2ManufacturingPage11_t
*config_page
)
642 Mpi2ConfigRequest_t mpi_request
;
645 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
646 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
647 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
648 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
649 mpi_request
.Header
.PageNumber
= 11;
650 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
651 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
652 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
653 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
657 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
658 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
659 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
660 sizeof(*config_page
));
666 * mpt3sas_config_get_bios_pg2 - obtain bios page 2
667 * @ioc: per adapter object
668 * @mpi_reply: reply mf payload returned from firmware
669 * @config_page: contents of the config page
672 * Return: 0 for success, non-zero for failure.
675 mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER
*ioc
,
676 Mpi2ConfigReply_t
*mpi_reply
, Mpi2BiosPage2_t
*config_page
)
678 Mpi2ConfigRequest_t mpi_request
;
681 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
682 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
683 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
684 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_BIOS
;
685 mpi_request
.Header
.PageNumber
= 2;
686 mpi_request
.Header
.PageVersion
= MPI2_BIOSPAGE2_PAGEVERSION
;
687 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
688 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
689 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
693 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
694 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
695 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
696 sizeof(*config_page
));
702 * mpt3sas_config_get_bios_pg3 - obtain bios page 3
703 * @ioc: per adapter object
704 * @mpi_reply: reply mf payload returned from firmware
705 * @config_page: contents of the config page
708 * Return: 0 for success, non-zero for failure.
711 mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
712 *mpi_reply
, Mpi2BiosPage3_t
*config_page
)
714 Mpi2ConfigRequest_t mpi_request
;
717 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
718 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
719 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
720 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_BIOS
;
721 mpi_request
.Header
.PageNumber
= 3;
722 mpi_request
.Header
.PageVersion
= MPI2_BIOSPAGE3_PAGEVERSION
;
723 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
724 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
725 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
729 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
730 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
731 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
732 sizeof(*config_page
));
738 * mpt3sas_config_get_iounit_pg0 - obtain iounit page 0
739 * @ioc: per adapter object
740 * @mpi_reply: reply mf payload returned from firmware
741 * @config_page: contents of the config page
744 * Return: 0 for success, non-zero for failure.
747 mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER
*ioc
,
748 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage0_t
*config_page
)
750 Mpi2ConfigRequest_t mpi_request
;
753 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
754 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
755 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
756 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
757 mpi_request
.Header
.PageNumber
= 0;
758 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE0_PAGEVERSION
;
759 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
760 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
761 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
765 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
766 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
767 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
768 sizeof(*config_page
));
774 * mpt3sas_config_get_iounit_pg1 - obtain iounit page 1
775 * @ioc: per adapter object
776 * @mpi_reply: reply mf payload returned from firmware
777 * @config_page: contents of the config page
780 * Return: 0 for success, non-zero for failure.
783 mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
784 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage1_t
*config_page
)
786 Mpi2ConfigRequest_t mpi_request
;
789 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
790 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
791 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
792 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
793 mpi_request
.Header
.PageNumber
= 1;
794 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE1_PAGEVERSION
;
795 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
796 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
797 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
801 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
802 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
803 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
804 sizeof(*config_page
));
810 * mpt3sas_config_set_iounit_pg1 - set iounit page 1
811 * @ioc: per adapter object
812 * @mpi_reply: reply mf payload returned from firmware
813 * @config_page: contents of the config page
816 * Return: 0 for success, non-zero for failure.
819 mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
820 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage1_t
*config_page
)
822 Mpi2ConfigRequest_t mpi_request
;
825 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
826 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
827 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
828 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
829 mpi_request
.Header
.PageNumber
= 1;
830 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE1_PAGEVERSION
;
831 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
832 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
833 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
837 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
838 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
839 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
840 sizeof(*config_page
));
846 * mpt3sas_config_get_iounit_pg3 - obtain iounit page 3
847 * @ioc: per adapter object
848 * @mpi_reply: reply mf payload returned from firmware
849 * @config_page: contents of the config page
850 * @sz: size of buffer passed in config_page
853 * Return: 0 for success, non-zero for failure.
856 mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER
*ioc
,
857 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage3_t
*config_page
, u16 sz
)
859 Mpi2ConfigRequest_t mpi_request
;
862 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
863 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
864 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
865 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
866 mpi_request
.Header
.PageNumber
= 3;
867 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE3_PAGEVERSION
;
868 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
869 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
870 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
874 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
875 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
876 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
882 * mpt3sas_config_get_iounit_pg8 - obtain iounit page 8
883 * @ioc: per adapter object
884 * @mpi_reply: reply mf payload returned from firmware
885 * @config_page: contents of the config page
888 * Return: 0 for success, non-zero for failure.
891 mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER
*ioc
,
892 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage8_t
*config_page
)
894 Mpi2ConfigRequest_t mpi_request
;
897 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
898 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
899 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
900 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
901 mpi_request
.Header
.PageNumber
= 8;
902 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE8_PAGEVERSION
;
903 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
904 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
905 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
909 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
910 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
911 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
912 sizeof(*config_page
));
918 * mpt3sas_config_get_ioc_pg8 - obtain ioc page 8
919 * @ioc: per adapter object
920 * @mpi_reply: reply mf payload returned from firmware
921 * @config_page: contents of the config page
924 * Return: 0 for success, non-zero for failure.
927 mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER
*ioc
,
928 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage8_t
*config_page
)
930 Mpi2ConfigRequest_t mpi_request
;
933 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
934 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
935 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
936 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
937 mpi_request
.Header
.PageNumber
= 8;
938 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
939 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
940 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
941 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
945 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
946 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
947 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
948 sizeof(*config_page
));
953 * mpt3sas_config_get_ioc_pg1 - obtain ioc page 1
954 * @ioc: per adapter object
955 * @mpi_reply: reply mf payload returned from firmware
956 * @config_page: contents of the config page
959 * Return: 0 for success, non-zero for failure.
962 mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER
*ioc
,
963 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage1_t
*config_page
)
965 Mpi2ConfigRequest_t mpi_request
;
968 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
969 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
970 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
971 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
972 mpi_request
.Header
.PageNumber
= 1;
973 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
974 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
975 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
976 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
980 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
981 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
982 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
983 sizeof(*config_page
));
989 * mpt3sas_config_set_ioc_pg1 - modify ioc page 1
990 * @ioc: per adapter object
991 * @mpi_reply: reply mf payload returned from firmware
992 * @config_page: contents of the config page
995 * Return: 0 for success, non-zero for failure.
998 mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER
*ioc
,
999 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage1_t
*config_page
)
1001 Mpi2ConfigRequest_t mpi_request
;
1004 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1005 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1006 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1007 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
1008 mpi_request
.Header
.PageNumber
= 1;
1009 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
1010 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1011 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1012 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1016 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1017 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1018 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1019 sizeof(*config_page
));
1025 * mpt3sas_config_get_sas_device_pg0 - obtain sas device page 0
1026 * @ioc: per adapter object
1027 * @mpi_reply: reply mf payload returned from firmware
1028 * @config_page: contents of the config page
1029 * @form: GET_NEXT_HANDLE or HANDLE
1030 * @handle: device handle
1033 * Return: 0 for success, non-zero for failure.
1036 mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1037 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasDevicePage0_t
*config_page
,
1038 u32 form
, u32 handle
)
1040 Mpi2ConfigRequest_t mpi_request
;
1043 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1044 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1045 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1046 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1047 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
;
1048 mpi_request
.Header
.PageVersion
= MPI2_SASDEVICE0_PAGEVERSION
;
1049 mpi_request
.Header
.PageNumber
= 0;
1050 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1051 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1052 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1056 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1057 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1058 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1059 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1060 sizeof(*config_page
));
1066 * mpt3sas_config_get_sas_device_pg1 - obtain sas device page 1
1067 * @ioc: per adapter object
1068 * @mpi_reply: reply mf payload returned from firmware
1069 * @config_page: contents of the config page
1070 * @form: GET_NEXT_HANDLE or HANDLE
1071 * @handle: device handle
1074 * Return: 0 for success, non-zero for failure.
1077 mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1078 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasDevicePage1_t
*config_page
,
1079 u32 form
, u32 handle
)
1081 Mpi2ConfigRequest_t mpi_request
;
1084 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1085 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1086 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1087 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1088 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
;
1089 mpi_request
.Header
.PageVersion
= MPI2_SASDEVICE1_PAGEVERSION
;
1090 mpi_request
.Header
.PageNumber
= 1;
1091 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1092 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1093 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1097 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1098 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1099 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1100 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1101 sizeof(*config_page
));
1107 * mpt3sas_config_get_pcie_device_pg0 - obtain pcie device page 0
1108 * @ioc: per adapter object
1109 * @mpi_reply: reply mf payload returned from firmware
1110 * @config_page: contents of the config page
1111 * @form: GET_NEXT_HANDLE or HANDLE
1112 * @handle: device handle
1115 * Return: 0 for success, non-zero for failure.
1118 mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1119 Mpi2ConfigReply_t
*mpi_reply
, Mpi26PCIeDevicePage0_t
*config_page
,
1120 u32 form
, u32 handle
)
1122 Mpi2ConfigRequest_t mpi_request
;
1125 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1126 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1127 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1128 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1129 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
;
1130 mpi_request
.Header
.PageVersion
= MPI26_PCIEDEVICE0_PAGEVERSION
;
1131 mpi_request
.Header
.PageNumber
= 0;
1132 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1133 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1134 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1138 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1139 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1140 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1141 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1142 sizeof(*config_page
));
1148 * mpt3sas_config_get_pcie_device_pg2 - obtain pcie device page 2
1149 * @ioc: per adapter object
1150 * @mpi_reply: reply mf payload returned from firmware
1151 * @config_page: contents of the config page
1152 * @form: GET_NEXT_HANDLE or HANDLE
1153 * @handle: device handle
1156 * Return: 0 for success, non-zero for failure.
1159 mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER
*ioc
,
1160 Mpi2ConfigReply_t
*mpi_reply
, Mpi26PCIeDevicePage2_t
*config_page
,
1161 u32 form
, u32 handle
)
1163 Mpi2ConfigRequest_t mpi_request
;
1166 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1167 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1168 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1169 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1170 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
;
1171 mpi_request
.Header
.PageVersion
= MPI26_PCIEDEVICE2_PAGEVERSION
;
1172 mpi_request
.Header
.PageNumber
= 2;
1173 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1174 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1175 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1179 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1180 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1181 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1182 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1183 sizeof(*config_page
));
1189 * mpt3sas_config_get_number_hba_phys - obtain number of phys on the host
1190 * @ioc: per adapter object
1191 * @num_phys: pointer returned with the number of phys
1194 * Return: 0 for success, non-zero for failure.
1197 mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER
*ioc
, u8
*num_phys
)
1199 Mpi2ConfigRequest_t mpi_request
;
1202 Mpi2ConfigReply_t mpi_reply
;
1203 Mpi2SasIOUnitPage0_t config_page
;
1206 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1207 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1208 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1209 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1210 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1211 mpi_request
.Header
.PageNumber
= 0;
1212 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE0_PAGEVERSION
;
1213 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1214 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1215 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1219 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1220 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1221 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, &config_page
,
1222 sizeof(Mpi2SasIOUnitPage0_t
));
1224 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1225 MPI2_IOCSTATUS_MASK
;
1226 if (ioc_status
== MPI2_IOCSTATUS_SUCCESS
)
1227 *num_phys
= config_page
.NumPhys
;
1234 * mpt3sas_config_get_sas_iounit_pg0 - obtain sas iounit page 0
1235 * @ioc: per adapter object
1236 * @mpi_reply: reply mf payload returned from firmware
1237 * @config_page: contents of the config page
1238 * @sz: size of buffer passed in config_page
1241 * Calling function should call config_get_number_hba_phys prior to
1242 * this function, so enough memory is allocated for config_page.
1244 * Return: 0 for success, non-zero for failure.
1247 mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1248 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage0_t
*config_page
,
1251 Mpi2ConfigRequest_t mpi_request
;
1254 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1255 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1256 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1257 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1258 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1259 mpi_request
.Header
.PageNumber
= 0;
1260 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE0_PAGEVERSION
;
1261 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1262 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1263 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1267 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1268 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1269 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1275 * mpt3sas_config_get_sas_iounit_pg1 - obtain sas iounit page 1
1276 * @ioc: per adapter object
1277 * @mpi_reply: reply mf payload returned from firmware
1278 * @config_page: contents of the config page
1279 * @sz: size of buffer passed in config_page
1282 * Calling function should call config_get_number_hba_phys prior to
1283 * this function, so enough memory is allocated for config_page.
1285 * Return: 0 for success, non-zero for failure.
1288 mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1289 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
,
1292 Mpi2ConfigRequest_t mpi_request
;
1295 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1296 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1297 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1298 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1299 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1300 mpi_request
.Header
.PageNumber
= 1;
1301 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE1_PAGEVERSION
;
1302 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1303 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1304 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1308 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1309 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1310 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1316 * mpt3sas_config_set_sas_iounit_pg1 - send sas iounit page 1
1317 * @ioc: per adapter object
1318 * @mpi_reply: reply mf payload returned from firmware
1319 * @config_page: contents of the config page
1320 * @sz: size of buffer passed in config_page
1323 * Calling function should call config_get_number_hba_phys prior to
1324 * this function, so enough memory is allocated for config_page.
1326 * Return: 0 for success, non-zero for failure.
1329 mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1330 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
,
1333 Mpi2ConfigRequest_t mpi_request
;
1336 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1337 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1338 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1339 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1340 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1341 mpi_request
.Header
.PageNumber
= 1;
1342 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE1_PAGEVERSION
;
1343 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1344 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1345 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1349 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1350 _config_request(ioc
, &mpi_request
, mpi_reply
,
1351 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1352 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
1353 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1354 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1360 * mpt3sas_config_get_expander_pg0 - obtain expander page 0
1361 * @ioc: per adapter object
1362 * @mpi_reply: reply mf payload returned from firmware
1363 * @config_page: contents of the config page
1364 * @form: GET_NEXT_HANDLE or HANDLE
1365 * @handle: expander handle
1368 * Return: 0 for success, non-zero for failure.
1371 mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1372 *mpi_reply
, Mpi2ExpanderPage0_t
*config_page
, u32 form
, u32 handle
)
1374 Mpi2ConfigRequest_t mpi_request
;
1377 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1378 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1379 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1380 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1381 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
;
1382 mpi_request
.Header
.PageNumber
= 0;
1383 mpi_request
.Header
.PageVersion
= MPI2_SASEXPANDER0_PAGEVERSION
;
1384 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1385 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1386 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1390 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1391 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1392 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1393 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1394 sizeof(*config_page
));
1400 * mpt3sas_config_get_expander_pg1 - obtain expander page 1
1401 * @ioc: per adapter object
1402 * @mpi_reply: reply mf payload returned from firmware
1403 * @config_page: contents of the config page
1404 * @phy_number: phy number
1405 * @handle: expander handle
1408 * Return: 0 for success, non-zero for failure.
1411 mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1412 *mpi_reply
, Mpi2ExpanderPage1_t
*config_page
, u32 phy_number
,
1415 Mpi2ConfigRequest_t mpi_request
;
1418 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1419 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1420 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1421 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1422 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
;
1423 mpi_request
.Header
.PageNumber
= 1;
1424 mpi_request
.Header
.PageVersion
= MPI2_SASEXPANDER1_PAGEVERSION
;
1425 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1426 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1427 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1431 mpi_request
.PageAddress
=
1432 cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM
|
1433 (phy_number
<< MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT
) | handle
);
1434 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1435 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1436 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1437 sizeof(*config_page
));
1443 * mpt3sas_config_get_enclosure_pg0 - obtain enclosure page 0
1444 * @ioc: per adapter object
1445 * @mpi_reply: reply mf payload returned from firmware
1446 * @config_page: contents of the config page
1447 * @form: GET_NEXT_HANDLE or HANDLE
1448 * @handle: expander handle
1451 * Return: 0 for success, non-zero for failure.
1454 mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1455 *mpi_reply
, Mpi2SasEnclosurePage0_t
*config_page
, u32 form
, u32 handle
)
1457 Mpi2ConfigRequest_t mpi_request
;
1460 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1461 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1462 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1463 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1464 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE
;
1465 mpi_request
.Header
.PageNumber
= 0;
1466 mpi_request
.Header
.PageVersion
= MPI2_SASENCLOSURE0_PAGEVERSION
;
1467 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1468 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1469 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1473 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1474 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1475 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1476 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1477 sizeof(*config_page
));
1483 * mpt3sas_config_get_phy_pg0 - obtain phy page 0
1484 * @ioc: per adapter object
1485 * @mpi_reply: reply mf payload returned from firmware
1486 * @config_page: contents of the config page
1487 * @phy_number: phy number
1490 * Return: 0 for success, non-zero for failure.
1493 mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1494 *mpi_reply
, Mpi2SasPhyPage0_t
*config_page
, u32 phy_number
)
1496 Mpi2ConfigRequest_t mpi_request
;
1499 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1500 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1501 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1502 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1503 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
;
1504 mpi_request
.Header
.PageNumber
= 0;
1505 mpi_request
.Header
.PageVersion
= MPI2_SASPHY0_PAGEVERSION
;
1506 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1507 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1508 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1512 mpi_request
.PageAddress
=
1513 cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER
| phy_number
);
1514 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1515 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1516 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1517 sizeof(*config_page
));
1523 * mpt3sas_config_get_phy_pg1 - obtain phy page 1
1524 * @ioc: per adapter object
1525 * @mpi_reply: reply mf payload returned from firmware
1526 * @config_page: contents of the config page
1527 * @phy_number: phy number
1530 * Return: 0 for success, non-zero for failure.
1533 mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1534 *mpi_reply
, Mpi2SasPhyPage1_t
*config_page
, u32 phy_number
)
1536 Mpi2ConfigRequest_t mpi_request
;
1539 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1540 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1541 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1542 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1543 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
;
1544 mpi_request
.Header
.PageNumber
= 1;
1545 mpi_request
.Header
.PageVersion
= MPI2_SASPHY1_PAGEVERSION
;
1546 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1547 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1548 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1552 mpi_request
.PageAddress
=
1553 cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER
| phy_number
);
1554 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1555 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1556 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1557 sizeof(*config_page
));
1563 * mpt3sas_config_get_raid_volume_pg1 - obtain raid volume page 1
1564 * @ioc: per adapter object
1565 * @mpi_reply: reply mf payload returned from firmware
1566 * @config_page: contents of the config page
1567 * @form: GET_NEXT_HANDLE or HANDLE
1568 * @handle: volume handle
1571 * Return: 0 for success, non-zero for failure.
1574 mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1575 Mpi2ConfigReply_t
*mpi_reply
, Mpi2RaidVolPage1_t
*config_page
, u32 form
,
1578 Mpi2ConfigRequest_t mpi_request
;
1581 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1582 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1583 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1584 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1585 mpi_request
.Header
.PageNumber
= 1;
1586 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE1_PAGEVERSION
;
1587 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1588 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1589 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1593 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1594 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1595 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1596 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1597 sizeof(*config_page
));
1603 * mpt3sas_config_get_number_pds - obtain number of phys disk assigned to volume
1604 * @ioc: per adapter object
1605 * @handle: volume handle
1606 * @num_pds: returns pds count
1609 * Return: 0 for success, non-zero for failure.
1612 mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER
*ioc
, u16 handle
,
1615 Mpi2ConfigRequest_t mpi_request
;
1616 Mpi2RaidVolPage0_t config_page
;
1617 Mpi2ConfigReply_t mpi_reply
;
1621 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1623 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1624 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1625 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1626 mpi_request
.Header
.PageNumber
= 0;
1627 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE0_PAGEVERSION
;
1628 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1629 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1630 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1634 mpi_request
.PageAddress
=
1635 cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE
| handle
);
1636 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1637 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1638 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, &config_page
,
1639 sizeof(Mpi2RaidVolPage0_t
));
1641 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1642 MPI2_IOCSTATUS_MASK
;
1643 if (ioc_status
== MPI2_IOCSTATUS_SUCCESS
)
1644 *num_pds
= config_page
.NumPhysDisks
;
1652 * mpt3sas_config_get_raid_volume_pg0 - obtain raid volume page 0
1653 * @ioc: per adapter object
1654 * @mpi_reply: reply mf payload returned from firmware
1655 * @config_page: contents of the config page
1656 * @form: GET_NEXT_HANDLE or HANDLE
1657 * @handle: volume handle
1658 * @sz: size of buffer passed in config_page
1661 * Return: 0 for success, non-zero for failure.
1664 mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1665 Mpi2ConfigReply_t
*mpi_reply
, Mpi2RaidVolPage0_t
*config_page
, u32 form
,
1668 Mpi2ConfigRequest_t mpi_request
;
1671 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1672 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1673 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1674 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1675 mpi_request
.Header
.PageNumber
= 0;
1676 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE0_PAGEVERSION
;
1677 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1678 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1679 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1683 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1684 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1685 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1686 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1692 * mpt3sas_config_get_phys_disk_pg0 - obtain phys disk page 0
1693 * @ioc: per adapter object
1694 * @mpi_reply: reply mf payload returned from firmware
1695 * @config_page: contents of the config page
1696 * @form: GET_NEXT_PHYSDISKNUM, PHYSDISKNUM, DEVHANDLE
1697 * @form_specific: specific to the form
1700 * Return: 0 for success, non-zero for failure.
1703 mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1704 *mpi_reply
, Mpi2RaidPhysDiskPage0_t
*config_page
, u32 form
,
1707 Mpi2ConfigRequest_t mpi_request
;
1710 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1711 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1712 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1713 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK
;
1714 mpi_request
.Header
.PageNumber
= 0;
1715 mpi_request
.Header
.PageVersion
= MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION
;
1716 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1717 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1718 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1722 mpi_request
.PageAddress
= cpu_to_le32(form
| form_specific
);
1723 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1724 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1725 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1726 sizeof(*config_page
));
1732 * mpt3sas_config_get_volume_handle - returns volume handle for give hidden
1734 * @ioc: per adapter object
1735 * @pd_handle: phys disk handle
1736 * @volume_handle: volume handle
1739 * Return: 0 for success, non-zero for failure.
1742 mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER
*ioc
, u16 pd_handle
,
1745 Mpi2RaidConfigurationPage0_t
*config_page
= NULL
;
1746 Mpi2ConfigRequest_t mpi_request
;
1747 Mpi2ConfigReply_t mpi_reply
;
1748 int r
, i
, config_page_sz
;
1752 u16 phys_disk_dev_handle
;
1755 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1756 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1757 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1758 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1759 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG
;
1760 mpi_request
.Header
.PageVersion
= MPI2_RAIDCONFIG0_PAGEVERSION
;
1761 mpi_request
.Header
.PageNumber
= 0;
1762 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1763 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1764 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1768 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1769 config_page_sz
= (le16_to_cpu(mpi_reply
.ExtPageLength
) * 4);
1770 config_page
= kmalloc(config_page_sz
, GFP_KERNEL
);
1778 mpi_request
.PageAddress
= cpu_to_le32(config_num
+
1779 MPI2_RAID_PGAD_FORM_GET_NEXT_CONFIGNUM
);
1780 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1781 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1786 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1787 MPI2_IOCSTATUS_MASK
;
1788 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
)
1790 for (i
= 0; i
< config_page
->NumElements
; i
++) {
1791 element_type
= le16_to_cpu(config_page
->
1792 ConfigElement
[i
].ElementFlags
) &
1793 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE
;
1795 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT
||
1797 MPI2_RAIDCONFIG0_EFLAGS_OCE_ELEMENT
) {
1798 phys_disk_dev_handle
=
1799 le16_to_cpu(config_page
->ConfigElement
[i
].
1801 if (phys_disk_dev_handle
== pd_handle
) {
1803 le16_to_cpu(config_page
->
1804 ConfigElement
[i
].VolDevHandle
);
1808 } else if (element_type
==
1809 MPI2_RAIDCONFIG0_EFLAGS_HOT_SPARE_ELEMENT
) {
1815 config_num
= config_page
->ConfigNum
;
1823 * mpt3sas_config_get_volume_wwid - returns wwid given the volume handle
1824 * @ioc: per adapter object
1825 * @volume_handle: volume handle
1826 * @wwid: volume wwid
1829 * Return: 0 for success, non-zero for failure.
1832 mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER
*ioc
, u16 volume_handle
,
1835 Mpi2ConfigReply_t mpi_reply
;
1836 Mpi2RaidVolPage1_t raid_vol_pg1
;
1839 if (!(mpt3sas_config_get_raid_volume_pg1(ioc
, &mpi_reply
,
1840 &raid_vol_pg1
, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE
,
1842 *wwid
= le64_to_cpu(raid_vol_pg1
.WWID
);