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 mpi_request
= mpt3sas_base_get_msg_frame(ioc
, smid
);
105 switch (mpi_request
->Header
.PageType
& MPI2_CONFIG_PAGETYPE_MASK
) {
106 case MPI2_CONFIG_PAGETYPE_IO_UNIT
:
109 case MPI2_CONFIG_PAGETYPE_IOC
:
112 case MPI2_CONFIG_PAGETYPE_BIOS
:
115 case MPI2_CONFIG_PAGETYPE_RAID_VOLUME
:
116 desc
= "raid_volume";
118 case MPI2_CONFIG_PAGETYPE_MANUFACTURING
:
119 desc
= "manufacturing";
121 case MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK
:
124 case MPI2_CONFIG_PAGETYPE_EXTENDED
:
125 switch (mpi_request
->ExtPageType
) {
126 case MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
:
127 desc
= "sas_io_unit";
129 case MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
:
130 desc
= "sas_expander";
132 case MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
:
135 case MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
:
138 case MPI2_CONFIG_EXTPAGETYPE_LOG
:
141 case MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE
:
144 case MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG
:
145 desc
= "raid_config";
147 case MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING
:
148 desc
= "driver_mapping";
150 case MPI2_CONFIG_EXTPAGETYPE_SAS_PORT
:
153 case MPI2_CONFIG_EXTPAGETYPE_EXT_MANUFACTURING
:
154 desc
= "ext_manufacturing";
156 case MPI2_CONFIG_EXTPAGETYPE_PCIE_IO_UNIT
:
157 desc
= "pcie_io_unit";
159 case MPI2_CONFIG_EXTPAGETYPE_PCIE_SWITCH
:
160 desc
= "pcie_switch";
162 case MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
:
163 desc
= "pcie_device";
165 case MPI2_CONFIG_EXTPAGETYPE_PCIE_LINK
:
175 ioc_info(ioc
, "%s: %s(%d), action(%d), form(0x%08x), smid(%d)\n",
176 calling_function_name
, desc
,
177 mpi_request
->Header
.PageNumber
, mpi_request
->Action
,
178 le32_to_cpu(mpi_request
->PageAddress
), smid
);
183 if (mpi_reply
->IOCStatus
|| mpi_reply
->IOCLogInfo
)
184 ioc_info(ioc
, "\tiocstatus(0x%04x), loginfo(0x%08x)\n",
185 le16_to_cpu(mpi_reply
->IOCStatus
),
186 le32_to_cpu(mpi_reply
->IOCLogInfo
));
190 * _config_alloc_config_dma_memory - obtain physical memory
191 * @ioc: per adapter object
192 * @mem: struct config_request
194 * A wrapper for obtaining dma-able memory for config page request.
196 * Return: 0 for success, non-zero for failure.
199 _config_alloc_config_dma_memory(struct MPT3SAS_ADAPTER
*ioc
,
200 struct config_request
*mem
)
204 if (mem
->sz
> ioc
->config_page_sz
) {
205 mem
->page
= dma_alloc_coherent(&ioc
->pdev
->dev
, mem
->sz
,
206 &mem
->page_dma
, GFP_KERNEL
);
208 ioc_err(ioc
, "%s: dma_alloc_coherent failed asking for (%d) bytes!!\n",
212 } else { /* use tmp buffer if less than 512 bytes */
213 mem
->page
= ioc
->config_page
;
214 mem
->page_dma
= ioc
->config_page_dma
;
216 ioc
->config_vaddr
= mem
->page
;
221 * _config_free_config_dma_memory - wrapper to free the memory
222 * @ioc: per adapter object
223 * @mem: struct config_request
225 * A wrapper to free dma-able memory when using _config_alloc_config_dma_memory.
227 * Return: 0 for success, non-zero for failure.
230 _config_free_config_dma_memory(struct MPT3SAS_ADAPTER
*ioc
,
231 struct config_request
*mem
)
233 if (mem
->sz
> ioc
->config_page_sz
)
234 dma_free_coherent(&ioc
->pdev
->dev
, mem
->sz
, mem
->page
,
239 * mpt3sas_config_done - config page completion routine
240 * @ioc: per adapter object
241 * @smid: system request message index
242 * @msix_index: MSIX table index supplied by the OS
243 * @reply: reply message frame(lower 32bit addr)
246 * The callback handler when using _config_request.
248 * Return: 1 meaning mf should be freed from _base_interrupt
249 * 0 means the mf is freed from this function.
252 mpt3sas_config_done(struct MPT3SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
255 MPI2DefaultReply_t
*mpi_reply
;
257 if (ioc
->config_cmds
.status
== MPT3_CMD_NOT_USED
)
259 if (ioc
->config_cmds
.smid
!= smid
)
261 ioc
->config_cmds
.status
|= MPT3_CMD_COMPLETE
;
262 mpi_reply
= mpt3sas_base_get_reply_virt_addr(ioc
, reply
);
264 ioc
->config_cmds
.status
|= MPT3_CMD_REPLY_VALID
;
265 memcpy(ioc
->config_cmds
.reply
, mpi_reply
,
266 mpi_reply
->MsgLength
*4);
268 ioc
->config_cmds
.status
&= ~MPT3_CMD_PENDING
;
269 if (ioc
->logging_level
& MPT_DEBUG_CONFIG
)
270 _config_display_some_debug(ioc
, smid
, "config_done", mpi_reply
);
271 ioc
->config_cmds
.smid
= USHRT_MAX
;
272 complete(&ioc
->config_cmds
.done
);
277 * _config_request - main routine for sending config page requests
278 * @ioc: per adapter object
279 * @mpi_request: request message frame
280 * @mpi_reply: reply mf payload returned from firmware
281 * @timeout: timeout in seconds
282 * @config_page: contents of the config page
283 * @config_page_sz: size of config page
286 * A generic API for config page requests to firmware.
288 * The ioc->config_cmds.status flag should be MPT3_CMD_NOT_USED before calling
291 * The callback index is set inside `ioc->config_cb_idx.
293 * Return: 0 for success, non-zero for failure.
296 _config_request(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigRequest_t
297 *mpi_request
, Mpi2ConfigReply_t
*mpi_reply
, int timeout
,
298 void *config_page
, u16 config_page_sz
)
301 Mpi2ConfigRequest_t
*config_request
;
303 u8 retry_count
, issue_host_reset
= 0;
304 struct config_request mem
;
305 u32 ioc_status
= UINT_MAX
;
307 mutex_lock(&ioc
->config_cmds
.mutex
);
308 if (ioc
->config_cmds
.status
!= MPT3_CMD_NOT_USED
) {
309 ioc_err(ioc
, "%s: config_cmd in use\n", __func__
);
310 mutex_unlock(&ioc
->config_cmds
.mutex
);
315 memset(&mem
, 0, sizeof(struct config_request
));
317 mpi_request
->VF_ID
= 0; /* TODO */
318 mpi_request
->VP_ID
= 0;
321 mpi_request
->Header
.PageVersion
= mpi_reply
->Header
.PageVersion
;
322 mpi_request
->Header
.PageNumber
= mpi_reply
->Header
.PageNumber
;
323 mpi_request
->Header
.PageType
= mpi_reply
->Header
.PageType
;
324 mpi_request
->Header
.PageLength
= mpi_reply
->Header
.PageLength
;
325 mpi_request
->ExtPageLength
= mpi_reply
->ExtPageLength
;
326 mpi_request
->ExtPageType
= mpi_reply
->ExtPageType
;
327 if (mpi_request
->Header
.PageLength
)
328 mem
.sz
= mpi_request
->Header
.PageLength
* 4;
330 mem
.sz
= le16_to_cpu(mpi_reply
->ExtPageLength
) * 4;
331 r
= _config_alloc_config_dma_memory(ioc
, &mem
);
334 if (mpi_request
->Action
==
335 MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
||
336 mpi_request
->Action
==
337 MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
) {
338 ioc
->base_add_sg_single(&mpi_request
->PageBufferSGE
,
339 MPT3_CONFIG_COMMON_WRITE_SGLFLAGS
| mem
.sz
,
341 memcpy(mem
.page
, config_page
, min_t(u16
, mem
.sz
,
344 memset(config_page
, 0, config_page_sz
);
345 ioc
->base_add_sg_single(&mpi_request
->PageBufferSGE
,
346 MPT3_CONFIG_COMMON_SGLFLAGS
| mem
.sz
, mem
.page_dma
);
347 memset(mem
.page
, 0, min_t(u16
, mem
.sz
, config_page_sz
));
353 if (retry_count
> 2) { /* attempt only 2 retries */
357 ioc_info(ioc
, "%s: attempting retry (%d)\n",
358 __func__
, retry_count
);
361 r
= mpt3sas_wait_for_ioc(ioc
, MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
);
365 smid
= mpt3sas_base_get_smid(ioc
, ioc
->config_cb_idx
);
367 ioc_err(ioc
, "%s: failed obtaining a smid\n", __func__
);
368 ioc
->config_cmds
.status
= MPT3_CMD_NOT_USED
;
374 memset(ioc
->config_cmds
.reply
, 0, sizeof(Mpi2ConfigReply_t
));
375 ioc
->config_cmds
.status
= MPT3_CMD_PENDING
;
376 config_request
= mpt3sas_base_get_msg_frame(ioc
, smid
);
377 ioc
->config_cmds
.smid
= smid
;
378 memcpy(config_request
, mpi_request
, sizeof(Mpi2ConfigRequest_t
));
379 if (ioc
->logging_level
& MPT_DEBUG_CONFIG
)
380 _config_display_some_debug(ioc
, smid
, "config_request", NULL
);
381 init_completion(&ioc
->config_cmds
.done
);
382 ioc
->put_smid_default(ioc
, smid
);
383 wait_for_completion_timeout(&ioc
->config_cmds
.done
, timeout
*HZ
);
384 if (!(ioc
->config_cmds
.status
& MPT3_CMD_COMPLETE
)) {
385 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
386 _config_display_some_debug(ioc
,
387 smid
, "config_request", NULL
);
388 ioc_err(ioc
, "%s: command timeout\n", __func__
);
389 mpt3sas_base_check_cmd_timeout(ioc
, ioc
->config_cmds
.status
,
390 mpi_request
, sizeof(Mpi2ConfigRequest_t
) / 4);
392 if (ioc
->config_cmds
.smid
== smid
)
393 mpt3sas_base_free_smid(ioc
, smid
);
394 if ((ioc
->shost_recovery
) || (ioc
->config_cmds
.status
&
395 MPT3_CMD_RESET
) || ioc
->pci_error_recovery
)
397 issue_host_reset
= 1;
402 if (ioc
->config_cmds
.status
& MPT3_CMD_REPLY_VALID
) {
403 memcpy(mpi_reply
, ioc
->config_cmds
.reply
,
404 sizeof(Mpi2ConfigReply_t
));
406 /* Reply Frame Sanity Checks to workaround FW issues */
407 if ((mpi_request
->Header
.PageType
& 0xF) !=
408 (mpi_reply
->Header
.PageType
& 0xF)) {
409 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
410 _config_display_some_debug(ioc
,
411 smid
, "config_request", NULL
);
412 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
413 _debug_dump_reply(mpi_reply
, ioc
->reply_sz
/4);
414 panic("%s: %s: Firmware BUG: mpi_reply mismatch: Requested PageType(0x%02x) Reply PageType(0x%02x)\n",
416 mpi_request
->Header
.PageType
& 0xF,
417 mpi_reply
->Header
.PageType
& 0xF);
420 if (((mpi_request
->Header
.PageType
& 0xF) ==
421 MPI2_CONFIG_PAGETYPE_EXTENDED
) &&
422 mpi_request
->ExtPageType
!= mpi_reply
->ExtPageType
) {
423 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
424 _config_display_some_debug(ioc
,
425 smid
, "config_request", NULL
);
426 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
427 _debug_dump_reply(mpi_reply
, ioc
->reply_sz
/4);
428 panic("%s: %s: Firmware BUG: mpi_reply mismatch: Requested ExtPageType(0x%02x) Reply ExtPageType(0x%02x)\n",
430 mpi_request
->ExtPageType
,
431 mpi_reply
->ExtPageType
);
433 ioc_status
= le16_to_cpu(mpi_reply
->IOCStatus
)
434 & MPI2_IOCSTATUS_MASK
;
438 ioc_info(ioc
, "%s: retry (%d) completed!!\n",
439 __func__
, retry_count
);
441 if ((ioc_status
== MPI2_IOCSTATUS_SUCCESS
) &&
442 config_page
&& mpi_request
->Action
==
443 MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
) {
444 u8
*p
= (u8
*)mem
.page
;
446 /* Config Page Sanity Checks to workaround FW issues */
448 if ((mpi_request
->Header
.PageType
& 0xF) !=
450 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
451 _config_display_some_debug(ioc
,
452 smid
, "config_request", NULL
);
453 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
454 _debug_dump_reply(mpi_reply
, ioc
->reply_sz
/4);
455 _debug_dump_config(p
, min_t(u16
, mem
.sz
,
457 panic("%s: %s: Firmware BUG: config page mismatch: Requested PageType(0x%02x) Reply PageType(0x%02x)\n",
459 mpi_request
->Header
.PageType
& 0xF,
463 if (((mpi_request
->Header
.PageType
& 0xF) ==
464 MPI2_CONFIG_PAGETYPE_EXTENDED
) &&
465 (mpi_request
->ExtPageType
!= p
[6])) {
466 if (!(ioc
->logging_level
& MPT_DEBUG_CONFIG
))
467 _config_display_some_debug(ioc
,
468 smid
, "config_request", NULL
);
469 _debug_dump_mf(mpi_request
, ioc
->request_sz
/4);
470 _debug_dump_reply(mpi_reply
, ioc
->reply_sz
/4);
471 _debug_dump_config(p
, min_t(u16
, mem
.sz
,
473 panic("%s: %s: Firmware BUG: config page mismatch: Requested ExtPageType(0x%02x) Reply ExtPageType(0x%02x)\n",
475 mpi_request
->ExtPageType
, p
[6]);
478 memcpy(config_page
, mem
.page
, min_t(u16
, mem
.sz
,
484 _config_free_config_dma_memory(ioc
, &mem
);
486 ioc
->config_cmds
.status
= MPT3_CMD_NOT_USED
;
487 mutex_unlock(&ioc
->config_cmds
.mutex
);
489 if (issue_host_reset
)
490 mpt3sas_base_hard_reset_handler(ioc
, FORCE_BIG_HAMMER
);
495 * mpt3sas_config_get_manufacturing_pg0 - obtain manufacturing page 0
496 * @ioc: per adapter object
497 * @mpi_reply: reply mf payload returned from firmware
498 * @config_page: contents of the config page
501 * Return: 0 for success, non-zero for failure.
504 mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER
*ioc
,
505 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage0_t
*config_page
)
507 Mpi2ConfigRequest_t mpi_request
;
510 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
511 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
512 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
513 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
514 mpi_request
.Header
.PageNumber
= 0;
515 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
516 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
517 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
518 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
522 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
523 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
524 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
525 sizeof(*config_page
));
531 * mpt3sas_config_get_manufacturing_pg7 - obtain manufacturing page 7
532 * @ioc: per adapter object
533 * @mpi_reply: reply mf payload returned from firmware
534 * @config_page: contents of the config page
535 * @sz: size of buffer passed in config_page
538 * Return: 0 for success, non-zero for failure.
541 mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER
*ioc
,
542 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage7_t
*config_page
,
545 Mpi2ConfigRequest_t mpi_request
;
548 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
549 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
550 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
551 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
552 mpi_request
.Header
.PageNumber
= 7;
553 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING7_PAGEVERSION
;
554 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
555 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
556 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
560 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
561 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
562 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
569 * mpt3sas_config_get_manufacturing_pg10 - obtain manufacturing page 10
570 * @ioc: per adapter object
571 * @mpi_reply: reply mf payload returned from firmware
572 * @config_page: contents of the config page
575 * Return: 0 for success, non-zero for failure.
578 mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER
*ioc
,
579 Mpi2ConfigReply_t
*mpi_reply
,
580 struct Mpi2ManufacturingPage10_t
*config_page
)
582 Mpi2ConfigRequest_t mpi_request
;
585 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
586 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
587 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
588 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
589 mpi_request
.Header
.PageNumber
= 10;
590 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
591 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
592 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
593 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
597 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
598 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
599 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
600 sizeof(*config_page
));
606 * mpt3sas_config_get_manufacturing_pg11 - obtain manufacturing page 11
607 * @ioc: per adapter object
608 * @mpi_reply: reply mf payload returned from firmware
609 * @config_page: contents of the config page
612 * Return: 0 for success, non-zero for failure.
615 mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER
*ioc
,
616 Mpi2ConfigReply_t
*mpi_reply
,
617 struct Mpi2ManufacturingPage11_t
*config_page
)
619 Mpi2ConfigRequest_t mpi_request
;
622 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
623 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
624 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
625 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
626 mpi_request
.Header
.PageNumber
= 11;
627 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
628 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
629 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
630 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
634 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
635 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
636 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
637 sizeof(*config_page
));
643 * mpt3sas_config_set_manufacturing_pg11 - set manufacturing page 11
644 * @ioc: per adapter object
645 * @mpi_reply: reply mf payload returned from firmware
646 * @config_page: contents of the config page
649 * Return: 0 for success, non-zero for failure.
652 mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER
*ioc
,
653 Mpi2ConfigReply_t
*mpi_reply
,
654 struct Mpi2ManufacturingPage11_t
*config_page
)
656 Mpi2ConfigRequest_t mpi_request
;
659 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
660 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
661 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
662 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_MANUFACTURING
;
663 mpi_request
.Header
.PageNumber
= 11;
664 mpi_request
.Header
.PageVersion
= MPI2_MANUFACTURING0_PAGEVERSION
;
665 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
666 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
667 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
671 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
672 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
673 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
674 sizeof(*config_page
));
680 * mpt3sas_config_get_bios_pg2 - obtain bios page 2
681 * @ioc: per adapter object
682 * @mpi_reply: reply mf payload returned from firmware
683 * @config_page: contents of the config page
686 * Return: 0 for success, non-zero for failure.
689 mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER
*ioc
,
690 Mpi2ConfigReply_t
*mpi_reply
, Mpi2BiosPage2_t
*config_page
)
692 Mpi2ConfigRequest_t mpi_request
;
695 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
696 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
697 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
698 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_BIOS
;
699 mpi_request
.Header
.PageNumber
= 2;
700 mpi_request
.Header
.PageVersion
= MPI2_BIOSPAGE2_PAGEVERSION
;
701 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
702 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
703 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
707 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
708 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
709 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
710 sizeof(*config_page
));
716 * mpt3sas_config_get_bios_pg3 - obtain bios page 3
717 * @ioc: per adapter object
718 * @mpi_reply: reply mf payload returned from firmware
719 * @config_page: contents of the config page
722 * Return: 0 for success, non-zero for failure.
725 mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
726 *mpi_reply
, Mpi2BiosPage3_t
*config_page
)
728 Mpi2ConfigRequest_t mpi_request
;
731 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
732 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
733 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
734 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_BIOS
;
735 mpi_request
.Header
.PageNumber
= 3;
736 mpi_request
.Header
.PageVersion
= MPI2_BIOSPAGE3_PAGEVERSION
;
737 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
738 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
739 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
743 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
744 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
745 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
746 sizeof(*config_page
));
752 * mpt3sas_config_get_iounit_pg0 - obtain iounit page 0
753 * @ioc: per adapter object
754 * @mpi_reply: reply mf payload returned from firmware
755 * @config_page: contents of the config page
758 * Return: 0 for success, non-zero for failure.
761 mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER
*ioc
,
762 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage0_t
*config_page
)
764 Mpi2ConfigRequest_t mpi_request
;
767 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
768 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
769 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
770 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
771 mpi_request
.Header
.PageNumber
= 0;
772 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE0_PAGEVERSION
;
773 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
774 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
775 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
779 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
780 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
781 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
782 sizeof(*config_page
));
788 * mpt3sas_config_get_iounit_pg1 - obtain iounit page 1
789 * @ioc: per adapter object
790 * @mpi_reply: reply mf payload returned from firmware
791 * @config_page: contents of the config page
794 * Return: 0 for success, non-zero for failure.
797 mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
798 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage1_t
*config_page
)
800 Mpi2ConfigRequest_t mpi_request
;
803 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
804 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
805 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
806 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
807 mpi_request
.Header
.PageNumber
= 1;
808 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE1_PAGEVERSION
;
809 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
810 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
811 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
815 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
816 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
817 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
818 sizeof(*config_page
));
824 * mpt3sas_config_set_iounit_pg1 - set iounit page 1
825 * @ioc: per adapter object
826 * @mpi_reply: reply mf payload returned from firmware
827 * @config_page: contents of the config page
830 * Return: 0 for success, non-zero for failure.
833 mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
834 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage1_t
*config_page
)
836 Mpi2ConfigRequest_t mpi_request
;
839 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
840 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
841 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
842 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
843 mpi_request
.Header
.PageNumber
= 1;
844 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE1_PAGEVERSION
;
845 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
846 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
847 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
851 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
852 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
853 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
854 sizeof(*config_page
));
860 * mpt3sas_config_get_iounit_pg3 - obtain iounit page 3
861 * @ioc: per adapter object
862 * @mpi_reply: reply mf payload returned from firmware
863 * @config_page: contents of the config page
864 * @sz: size of buffer passed in config_page
867 * Return: 0 for success, non-zero for failure.
870 mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER
*ioc
,
871 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage3_t
*config_page
, u16 sz
)
873 Mpi2ConfigRequest_t mpi_request
;
876 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
877 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
878 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
879 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
880 mpi_request
.Header
.PageNumber
= 3;
881 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE3_PAGEVERSION
;
882 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
883 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
884 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
888 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
889 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
890 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
896 * mpt3sas_config_get_iounit_pg8 - obtain iounit page 8
897 * @ioc: per adapter object
898 * @mpi_reply: reply mf payload returned from firmware
899 * @config_page: contents of the config page
902 * Return: 0 for success, non-zero for failure.
905 mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER
*ioc
,
906 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOUnitPage8_t
*config_page
)
908 Mpi2ConfigRequest_t mpi_request
;
911 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
912 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
913 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
914 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IO_UNIT
;
915 mpi_request
.Header
.PageNumber
= 8;
916 mpi_request
.Header
.PageVersion
= MPI2_IOUNITPAGE8_PAGEVERSION
;
917 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
918 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
919 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
923 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
924 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
925 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
926 sizeof(*config_page
));
932 * mpt3sas_config_get_ioc_pg8 - obtain ioc page 8
933 * @ioc: per adapter object
934 * @mpi_reply: reply mf payload returned from firmware
935 * @config_page: contents of the config page
938 * Return: 0 for success, non-zero for failure.
941 mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER
*ioc
,
942 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage8_t
*config_page
)
944 Mpi2ConfigRequest_t mpi_request
;
947 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
948 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
949 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
950 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
951 mpi_request
.Header
.PageNumber
= 8;
952 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
953 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
954 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
955 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
959 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
960 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
961 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
962 sizeof(*config_page
));
967 * mpt3sas_config_get_ioc_pg1 - obtain ioc page 1
968 * @ioc: per adapter object
969 * @mpi_reply: reply mf payload returned from firmware
970 * @config_page: contents of the config page
973 * Return: 0 for success, non-zero for failure.
976 mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER
*ioc
,
977 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage1_t
*config_page
)
979 Mpi2ConfigRequest_t mpi_request
;
982 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
983 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
984 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
985 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
986 mpi_request
.Header
.PageNumber
= 1;
987 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
988 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
989 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
990 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
994 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
995 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
996 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
997 sizeof(*config_page
));
1003 * mpt3sas_config_set_ioc_pg1 - modify ioc page 1
1004 * @ioc: per adapter object
1005 * @mpi_reply: reply mf payload returned from firmware
1006 * @config_page: contents of the config page
1009 * Return: 0 for success, non-zero for failure.
1012 mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1013 Mpi2ConfigReply_t
*mpi_reply
, Mpi2IOCPage1_t
*config_page
)
1015 Mpi2ConfigRequest_t mpi_request
;
1018 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1019 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1020 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1021 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_IOC
;
1022 mpi_request
.Header
.PageNumber
= 1;
1023 mpi_request
.Header
.PageVersion
= MPI2_IOCPAGE8_PAGEVERSION
;
1024 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1025 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1026 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1030 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1031 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1032 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1033 sizeof(*config_page
));
1039 * mpt3sas_config_get_sas_device_pg0 - obtain sas device page 0
1040 * @ioc: per adapter object
1041 * @mpi_reply: reply mf payload returned from firmware
1042 * @config_page: contents of the config page
1043 * @form: GET_NEXT_HANDLE or HANDLE
1044 * @handle: device handle
1047 * Return: 0 for success, non-zero for failure.
1050 mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1051 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasDevicePage0_t
*config_page
,
1052 u32 form
, u32 handle
)
1054 Mpi2ConfigRequest_t mpi_request
;
1057 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1058 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1059 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1060 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1061 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
;
1062 mpi_request
.Header
.PageVersion
= MPI2_SASDEVICE0_PAGEVERSION
;
1063 mpi_request
.Header
.PageNumber
= 0;
1064 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1065 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1066 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1070 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1071 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1072 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1073 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1074 sizeof(*config_page
));
1080 * mpt3sas_config_get_sas_device_pg1 - obtain sas device page 1
1081 * @ioc: per adapter object
1082 * @mpi_reply: reply mf payload returned from firmware
1083 * @config_page: contents of the config page
1084 * @form: GET_NEXT_HANDLE or HANDLE
1085 * @handle: device handle
1088 * Return: 0 for success, non-zero for failure.
1091 mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1092 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasDevicePage1_t
*config_page
,
1093 u32 form
, u32 handle
)
1095 Mpi2ConfigRequest_t mpi_request
;
1098 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1099 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1100 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1101 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1102 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE
;
1103 mpi_request
.Header
.PageVersion
= MPI2_SASDEVICE1_PAGEVERSION
;
1104 mpi_request
.Header
.PageNumber
= 1;
1105 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1106 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1107 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1111 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1112 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1113 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1114 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1115 sizeof(*config_page
));
1121 * mpt3sas_config_get_pcie_device_pg0 - obtain pcie device page 0
1122 * @ioc: per adapter object
1123 * @mpi_reply: reply mf payload returned from firmware
1124 * @config_page: contents of the config page
1125 * @form: GET_NEXT_HANDLE or HANDLE
1126 * @handle: device handle
1129 * Return: 0 for success, non-zero for failure.
1132 mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1133 Mpi2ConfigReply_t
*mpi_reply
, Mpi26PCIeDevicePage0_t
*config_page
,
1134 u32 form
, u32 handle
)
1136 Mpi2ConfigRequest_t mpi_request
;
1139 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1140 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1141 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1142 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1143 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
;
1144 mpi_request
.Header
.PageVersion
= MPI26_PCIEDEVICE0_PAGEVERSION
;
1145 mpi_request
.Header
.PageNumber
= 0;
1146 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1147 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1148 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1152 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1153 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1154 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1155 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1156 sizeof(*config_page
));
1162 * mpt3sas_config_get_pcie_device_pg2 - obtain pcie device page 2
1163 * @ioc: per adapter object
1164 * @mpi_reply: reply mf payload returned from firmware
1165 * @config_page: contents of the config page
1166 * @form: GET_NEXT_HANDLE or HANDLE
1167 * @handle: device handle
1170 * Return: 0 for success, non-zero for failure.
1173 mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER
*ioc
,
1174 Mpi2ConfigReply_t
*mpi_reply
, Mpi26PCIeDevicePage2_t
*config_page
,
1175 u32 form
, u32 handle
)
1177 Mpi2ConfigRequest_t mpi_request
;
1180 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1181 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1182 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1183 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1184 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE
;
1185 mpi_request
.Header
.PageVersion
= MPI26_PCIEDEVICE2_PAGEVERSION
;
1186 mpi_request
.Header
.PageNumber
= 2;
1187 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1188 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1189 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1193 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1194 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1195 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1196 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1197 sizeof(*config_page
));
1203 * mpt3sas_config_get_number_hba_phys - obtain number of phys on the host
1204 * @ioc: per adapter object
1205 * @num_phys: pointer returned with the number of phys
1208 * Return: 0 for success, non-zero for failure.
1211 mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER
*ioc
, u8
*num_phys
)
1213 Mpi2ConfigRequest_t mpi_request
;
1216 Mpi2ConfigReply_t mpi_reply
;
1217 Mpi2SasIOUnitPage0_t config_page
;
1220 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1221 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1222 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1223 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1224 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1225 mpi_request
.Header
.PageNumber
= 0;
1226 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE0_PAGEVERSION
;
1227 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1228 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1229 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1233 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1234 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1235 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, &config_page
,
1236 sizeof(Mpi2SasIOUnitPage0_t
));
1238 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1239 MPI2_IOCSTATUS_MASK
;
1240 if (ioc_status
== MPI2_IOCSTATUS_SUCCESS
)
1241 *num_phys
= config_page
.NumPhys
;
1248 * mpt3sas_config_get_sas_iounit_pg0 - obtain sas iounit page 0
1249 * @ioc: per adapter object
1250 * @mpi_reply: reply mf payload returned from firmware
1251 * @config_page: contents of the config page
1252 * @sz: size of buffer passed in config_page
1255 * Calling function should call config_get_number_hba_phys prior to
1256 * this function, so enough memory is allocated for config_page.
1258 * Return: 0 for success, non-zero for failure.
1261 mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1262 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage0_t
*config_page
,
1265 Mpi2ConfigRequest_t mpi_request
;
1268 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1269 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1270 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1271 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1272 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1273 mpi_request
.Header
.PageNumber
= 0;
1274 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE0_PAGEVERSION
;
1275 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1276 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1277 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1281 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1282 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1283 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1289 * mpt3sas_config_get_sas_iounit_pg1 - obtain sas iounit page 1
1290 * @ioc: per adapter object
1291 * @mpi_reply: reply mf payload returned from firmware
1292 * @config_page: contents of the config page
1293 * @sz: size of buffer passed in config_page
1296 * Calling function should call config_get_number_hba_phys prior to
1297 * this function, so enough memory is allocated for config_page.
1299 * Return: 0 for success, non-zero for failure.
1302 mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1303 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
,
1306 Mpi2ConfigRequest_t mpi_request
;
1309 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1310 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1311 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1312 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1313 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1314 mpi_request
.Header
.PageNumber
= 1;
1315 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE1_PAGEVERSION
;
1316 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1317 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1318 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1322 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1323 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1324 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1330 * mpt3sas_config_set_sas_iounit_pg1 - send sas iounit page 1
1331 * @ioc: per adapter object
1332 * @mpi_reply: reply mf payload returned from firmware
1333 * @config_page: contents of the config page
1334 * @sz: size of buffer passed in config_page
1337 * Calling function should call config_get_number_hba_phys prior to
1338 * this function, so enough memory is allocated for config_page.
1340 * Return: 0 for success, non-zero for failure.
1343 mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1344 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
,
1347 Mpi2ConfigRequest_t mpi_request
;
1350 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1351 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1352 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1353 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1354 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT
;
1355 mpi_request
.Header
.PageNumber
= 1;
1356 mpi_request
.Header
.PageVersion
= MPI2_SASIOUNITPAGE1_PAGEVERSION
;
1357 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1358 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1359 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1363 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1364 _config_request(ioc
, &mpi_request
, mpi_reply
,
1365 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1366 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
1367 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1368 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1374 * mpt3sas_config_get_expander_pg0 - obtain expander page 0
1375 * @ioc: per adapter object
1376 * @mpi_reply: reply mf payload returned from firmware
1377 * @config_page: contents of the config page
1378 * @form: GET_NEXT_HANDLE or HANDLE
1379 * @handle: expander handle
1382 * Return: 0 for success, non-zero for failure.
1385 mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1386 *mpi_reply
, Mpi2ExpanderPage0_t
*config_page
, u32 form
, u32 handle
)
1388 Mpi2ConfigRequest_t mpi_request
;
1391 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1392 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1393 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1394 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1395 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
;
1396 mpi_request
.Header
.PageNumber
= 0;
1397 mpi_request
.Header
.PageVersion
= MPI2_SASEXPANDER0_PAGEVERSION
;
1398 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1399 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1400 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1404 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1405 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1406 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1407 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1408 sizeof(*config_page
));
1414 * mpt3sas_config_get_expander_pg1 - obtain expander page 1
1415 * @ioc: per adapter object
1416 * @mpi_reply: reply mf payload returned from firmware
1417 * @config_page: contents of the config page
1418 * @phy_number: phy number
1419 * @handle: expander handle
1422 * Return: 0 for success, non-zero for failure.
1425 mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1426 *mpi_reply
, Mpi2ExpanderPage1_t
*config_page
, u32 phy_number
,
1429 Mpi2ConfigRequest_t mpi_request
;
1432 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1433 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1434 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1435 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1436 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER
;
1437 mpi_request
.Header
.PageNumber
= 1;
1438 mpi_request
.Header
.PageVersion
= MPI2_SASEXPANDER1_PAGEVERSION
;
1439 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1440 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1441 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1445 mpi_request
.PageAddress
=
1446 cpu_to_le32(MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM
|
1447 (phy_number
<< MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT
) | handle
);
1448 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1449 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1450 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1451 sizeof(*config_page
));
1457 * mpt3sas_config_get_enclosure_pg0 - obtain enclosure page 0
1458 * @ioc: per adapter object
1459 * @mpi_reply: reply mf payload returned from firmware
1460 * @config_page: contents of the config page
1461 * @form: GET_NEXT_HANDLE or HANDLE
1462 * @handle: expander handle
1465 * Return: 0 for success, non-zero for failure.
1468 mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1469 *mpi_reply
, Mpi2SasEnclosurePage0_t
*config_page
, u32 form
, u32 handle
)
1471 Mpi2ConfigRequest_t mpi_request
;
1474 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1475 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1476 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1477 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1478 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE
;
1479 mpi_request
.Header
.PageNumber
= 0;
1480 mpi_request
.Header
.PageVersion
= MPI2_SASENCLOSURE0_PAGEVERSION
;
1481 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1482 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1483 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1487 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1488 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1489 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1490 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1491 sizeof(*config_page
));
1497 * mpt3sas_config_get_phy_pg0 - obtain phy page 0
1498 * @ioc: per adapter object
1499 * @mpi_reply: reply mf payload returned from firmware
1500 * @config_page: contents of the config page
1501 * @phy_number: phy number
1504 * Return: 0 for success, non-zero for failure.
1507 mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1508 *mpi_reply
, Mpi2SasPhyPage0_t
*config_page
, u32 phy_number
)
1510 Mpi2ConfigRequest_t mpi_request
;
1513 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1514 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1515 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1516 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1517 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
;
1518 mpi_request
.Header
.PageNumber
= 0;
1519 mpi_request
.Header
.PageVersion
= MPI2_SASPHY0_PAGEVERSION
;
1520 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1521 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1522 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1526 mpi_request
.PageAddress
=
1527 cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER
| phy_number
);
1528 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1529 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1530 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1531 sizeof(*config_page
));
1537 * mpt3sas_config_get_phy_pg1 - obtain phy page 1
1538 * @ioc: per adapter object
1539 * @mpi_reply: reply mf payload returned from firmware
1540 * @config_page: contents of the config page
1541 * @phy_number: phy number
1544 * Return: 0 for success, non-zero for failure.
1547 mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1548 *mpi_reply
, Mpi2SasPhyPage1_t
*config_page
, u32 phy_number
)
1550 Mpi2ConfigRequest_t mpi_request
;
1553 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1554 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1555 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1556 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1557 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_SAS_PHY
;
1558 mpi_request
.Header
.PageNumber
= 1;
1559 mpi_request
.Header
.PageVersion
= MPI2_SASPHY1_PAGEVERSION
;
1560 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1561 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1562 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1566 mpi_request
.PageAddress
=
1567 cpu_to_le32(MPI2_SAS_PHY_PGAD_FORM_PHY_NUMBER
| phy_number
);
1568 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1569 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1570 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1571 sizeof(*config_page
));
1577 * mpt3sas_config_get_raid_volume_pg1 - obtain raid volume page 1
1578 * @ioc: per adapter object
1579 * @mpi_reply: reply mf payload returned from firmware
1580 * @config_page: contents of the config page
1581 * @form: GET_NEXT_HANDLE or HANDLE
1582 * @handle: volume handle
1585 * Return: 0 for success, non-zero for failure.
1588 mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1589 Mpi2ConfigReply_t
*mpi_reply
, Mpi2RaidVolPage1_t
*config_page
, u32 form
,
1592 Mpi2ConfigRequest_t mpi_request
;
1595 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1596 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1597 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1598 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1599 mpi_request
.Header
.PageNumber
= 1;
1600 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE1_PAGEVERSION
;
1601 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1602 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1603 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1607 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1608 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1609 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1610 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1611 sizeof(*config_page
));
1617 * mpt3sas_config_get_number_pds - obtain number of phys disk assigned to volume
1618 * @ioc: per adapter object
1619 * @handle: volume handle
1620 * @num_pds: returns pds count
1623 * Return: 0 for success, non-zero for failure.
1626 mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER
*ioc
, u16 handle
,
1629 Mpi2ConfigRequest_t mpi_request
;
1630 Mpi2RaidVolPage0_t config_page
;
1631 Mpi2ConfigReply_t mpi_reply
;
1635 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1637 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1638 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1639 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1640 mpi_request
.Header
.PageNumber
= 0;
1641 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE0_PAGEVERSION
;
1642 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1643 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1644 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1648 mpi_request
.PageAddress
=
1649 cpu_to_le32(MPI2_RAID_VOLUME_PGAD_FORM_HANDLE
| handle
);
1650 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1651 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
1652 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, &config_page
,
1653 sizeof(Mpi2RaidVolPage0_t
));
1655 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1656 MPI2_IOCSTATUS_MASK
;
1657 if (ioc_status
== MPI2_IOCSTATUS_SUCCESS
)
1658 *num_pds
= config_page
.NumPhysDisks
;
1666 * mpt3sas_config_get_raid_volume_pg0 - obtain raid volume page 0
1667 * @ioc: per adapter object
1668 * @mpi_reply: reply mf payload returned from firmware
1669 * @config_page: contents of the config page
1670 * @form: GET_NEXT_HANDLE or HANDLE
1671 * @handle: volume handle
1672 * @sz: size of buffer passed in config_page
1675 * Return: 0 for success, non-zero for failure.
1678 mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1679 Mpi2ConfigReply_t
*mpi_reply
, Mpi2RaidVolPage0_t
*config_page
, u32 form
,
1682 Mpi2ConfigRequest_t mpi_request
;
1685 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1686 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1687 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1688 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_VOLUME
;
1689 mpi_request
.Header
.PageNumber
= 0;
1690 mpi_request
.Header
.PageVersion
= MPI2_RAIDVOLPAGE0_PAGEVERSION
;
1691 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1692 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1693 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1697 mpi_request
.PageAddress
= cpu_to_le32(form
| handle
);
1698 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1699 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1700 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
, sz
);
1706 * mpt3sas_config_get_phys_disk_pg0 - obtain phys disk page 0
1707 * @ioc: per adapter object
1708 * @mpi_reply: reply mf payload returned from firmware
1709 * @config_page: contents of the config page
1710 * @form: GET_NEXT_PHYSDISKNUM, PHYSDISKNUM, DEVHANDLE
1711 * @form_specific: specific to the form
1714 * Return: 0 for success, non-zero for failure.
1717 mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
1718 *mpi_reply
, Mpi2RaidPhysDiskPage0_t
*config_page
, u32 form
,
1721 Mpi2ConfigRequest_t mpi_request
;
1724 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1725 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1726 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1727 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_RAID_PHYSDISK
;
1728 mpi_request
.Header
.PageNumber
= 0;
1729 mpi_request
.Header
.PageVersion
= MPI2_RAIDPHYSDISKPAGE0_PAGEVERSION
;
1730 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1731 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1732 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1736 mpi_request
.PageAddress
= cpu_to_le32(form
| form_specific
);
1737 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1738 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1739 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1740 sizeof(*config_page
));
1746 * mpt3sas_config_get_driver_trigger_pg0 - obtain driver trigger page 0
1747 * @ioc: per adapter object
1748 * @mpi_reply: reply mf payload returned from firmware
1749 * @config_page: contents of the config page
1752 * Returns 0 for success, non-zero for failure.
1755 mpt3sas_config_get_driver_trigger_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1756 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage0_t
*config_page
)
1758 Mpi2ConfigRequest_t mpi_request
;
1761 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1762 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1763 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1764 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1765 mpi_request
.ExtPageType
=
1766 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
1767 mpi_request
.Header
.PageNumber
= 0;
1768 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE0_PAGEVERSION
;
1769 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1770 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1771 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1775 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1776 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1777 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1778 sizeof(*config_page
));
1784 * mpt3sas_config_set_driver_trigger_pg0 - write driver trigger page 0
1785 * @ioc: per adapter object
1786 * @mpi_reply: reply mf payload returned from firmware
1787 * @config_page: contents of the config page
1790 * Returns 0 for success, non-zero for failure.
1793 _config_set_driver_trigger_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1794 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage0_t
*config_page
)
1796 Mpi2ConfigRequest_t mpi_request
;
1799 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1800 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1801 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1802 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1803 mpi_request
.ExtPageType
=
1804 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
1805 mpi_request
.Header
.PageNumber
= 0;
1806 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE0_PAGEVERSION
;
1807 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1808 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1809 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1813 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1814 _config_request(ioc
, &mpi_request
, mpi_reply
,
1815 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1816 sizeof(*config_page
));
1817 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
1818 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1819 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1820 sizeof(*config_page
));
1826 * mpt3sas_config_update_driver_trigger_pg0 - update driver trigger page 0
1827 * @ioc: per adapter object
1828 * @trigger_flag: trigger type bit map
1829 * @set: set ot clear trigger values
1832 * Returns 0 for success, non-zero for failure.
1835 mpt3sas_config_update_driver_trigger_pg0(struct MPT3SAS_ADAPTER
*ioc
,
1836 u16 trigger_flag
, bool set
)
1838 Mpi26DriverTriggerPage0_t tg_pg0
;
1839 Mpi2ConfigReply_t mpi_reply
;
1841 u16 flags
, ioc_status
;
1843 rc
= mpt3sas_config_get_driver_trigger_pg0(ioc
, &mpi_reply
, &tg_pg0
);
1846 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1847 MPI2_IOCSTATUS_MASK
;
1848 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
1851 "%s: Failed to get trigger pg0, ioc_status(0x%04x)\n",
1852 __func__
, ioc_status
));
1857 flags
= le16_to_cpu(tg_pg0
.TriggerFlags
) | trigger_flag
;
1859 flags
= le16_to_cpu(tg_pg0
.TriggerFlags
) & ~trigger_flag
;
1861 tg_pg0
.TriggerFlags
= cpu_to_le16(flags
);
1863 rc
= _config_set_driver_trigger_pg0(ioc
, &mpi_reply
, &tg_pg0
);
1866 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1867 MPI2_IOCSTATUS_MASK
;
1868 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
1871 "%s: Failed to update trigger pg0, ioc_status(0x%04x)\n",
1872 __func__
, ioc_status
));
1880 * mpt3sas_config_get_driver_trigger_pg1 - obtain driver trigger page 1
1881 * @ioc: per adapter object
1882 * @mpi_reply: reply mf payload returned from firmware
1883 * @config_page: contents of the config page
1886 * Returns 0 for success, non-zero for failure.
1889 mpt3sas_config_get_driver_trigger_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1890 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage1_t
*config_page
)
1892 Mpi2ConfigRequest_t mpi_request
;
1895 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1896 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1897 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1898 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1899 mpi_request
.ExtPageType
=
1900 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
1901 mpi_request
.Header
.PageNumber
= 1;
1902 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE1_PAGEVERSION
;
1903 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1904 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1905 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1909 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
1910 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1911 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1912 sizeof(*config_page
));
1918 * mpt3sas_config_set_driver_trigger_pg1 - write driver trigger page 1
1919 * @ioc: per adapter object
1920 * @mpi_reply: reply mf payload returned from firmware
1921 * @config_page: contents of the config page
1924 * Returns 0 for success, non-zero for failure.
1927 _config_set_driver_trigger_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1928 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage1_t
*config_page
)
1930 Mpi2ConfigRequest_t mpi_request
;
1933 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
1934 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
1935 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
1936 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
1937 mpi_request
.ExtPageType
=
1938 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
1939 mpi_request
.Header
.PageNumber
= 1;
1940 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE1_PAGEVERSION
;
1941 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
1942 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1943 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
1947 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
1948 _config_request(ioc
, &mpi_request
, mpi_reply
,
1949 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1950 sizeof(*config_page
));
1951 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
1952 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
1953 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
1954 sizeof(*config_page
));
1960 * mpt3sas_config_update_driver_trigger_pg1 - update driver trigger page 1
1961 * @ioc: per adapter object
1962 * @master_tg: Master trigger bit map
1963 * @set: set ot clear trigger values
1966 * Returns 0 for success, non-zero for failure.
1969 mpt3sas_config_update_driver_trigger_pg1(struct MPT3SAS_ADAPTER
*ioc
,
1970 struct SL_WH_MASTER_TRIGGER_T
*master_tg
, bool set
)
1972 Mpi26DriverTriggerPage1_t tg_pg1
;
1973 Mpi2ConfigReply_t mpi_reply
;
1977 rc
= mpt3sas_config_update_driver_trigger_pg0(ioc
,
1978 MPI26_DRIVER_TRIGGER0_FLAG_MASTER_TRIGGER_VALID
, set
);
1982 rc
= mpt3sas_config_get_driver_trigger_pg1(ioc
, &mpi_reply
, &tg_pg1
);
1986 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
1987 MPI2_IOCSTATUS_MASK
;
1988 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
1991 "%s: Failed to get trigger pg1, ioc_status(0x%04x)\n",
1992 __func__
, ioc_status
));
1998 tg_pg1
.NumMasterTrigger
= cpu_to_le16(1);
1999 tg_pg1
.MasterTriggers
[0].MasterTriggerFlags
= cpu_to_le32(
2000 master_tg
->MasterData
);
2002 tg_pg1
.NumMasterTrigger
= 0;
2003 tg_pg1
.MasterTriggers
[0].MasterTriggerFlags
= 0;
2006 rc
= _config_set_driver_trigger_pg1(ioc
, &mpi_reply
, &tg_pg1
);
2010 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2011 MPI2_IOCSTATUS_MASK
;
2012 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2015 "%s: Failed to get trigger pg1, ioc_status(0x%04x)\n",
2016 __func__
, ioc_status
));
2024 mpt3sas_config_update_driver_trigger_pg0(ioc
,
2025 MPI26_DRIVER_TRIGGER0_FLAG_MASTER_TRIGGER_VALID
, !set
);
2031 * mpt3sas_config_get_driver_trigger_pg2 - obtain driver trigger page 2
2032 * @ioc: per adapter object
2033 * @mpi_reply: reply mf payload returned from firmware
2034 * @config_page: contents of the config page
2037 * Returns 0 for success, non-zero for failure.
2040 mpt3sas_config_get_driver_trigger_pg2(struct MPT3SAS_ADAPTER
*ioc
,
2041 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage2_t
*config_page
)
2043 Mpi2ConfigRequest_t mpi_request
;
2046 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2047 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2048 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2049 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2050 mpi_request
.ExtPageType
=
2051 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2052 mpi_request
.Header
.PageNumber
= 2;
2053 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE2_PAGEVERSION
;
2054 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2055 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2056 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2060 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
2061 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2062 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2063 sizeof(*config_page
));
2069 * mpt3sas_config_set_driver_trigger_pg2 - write driver trigger page 2
2070 * @ioc: per adapter object
2071 * @mpi_reply: reply mf payload returned from firmware
2072 * @config_page: contents of the config page
2075 * Returns 0 for success, non-zero for failure.
2078 _config_set_driver_trigger_pg2(struct MPT3SAS_ADAPTER
*ioc
,
2079 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage2_t
*config_page
)
2081 Mpi2ConfigRequest_t mpi_request
;
2084 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2085 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2086 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2087 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2088 mpi_request
.ExtPageType
=
2089 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2090 mpi_request
.Header
.PageNumber
= 2;
2091 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE2_PAGEVERSION
;
2092 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2093 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2094 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2098 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
2099 _config_request(ioc
, &mpi_request
, mpi_reply
,
2100 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2101 sizeof(*config_page
));
2102 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
2103 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2104 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2105 sizeof(*config_page
));
2111 * mpt3sas_config_update_driver_trigger_pg2 - update driver trigger page 2
2112 * @ioc: per adapter object
2113 * @event_tg: list of Event Triggers
2114 * @set: set ot clear trigger values
2117 * Returns 0 for success, non-zero for failure.
2120 mpt3sas_config_update_driver_trigger_pg2(struct MPT3SAS_ADAPTER
*ioc
,
2121 struct SL_WH_EVENT_TRIGGERS_T
*event_tg
, bool set
)
2123 Mpi26DriverTriggerPage2_t tg_pg2
;
2124 Mpi2ConfigReply_t mpi_reply
;
2128 rc
= mpt3sas_config_update_driver_trigger_pg0(ioc
,
2129 MPI26_DRIVER_TRIGGER0_FLAG_MPI_EVENT_TRIGGER_VALID
, set
);
2133 rc
= mpt3sas_config_get_driver_trigger_pg2(ioc
, &mpi_reply
, &tg_pg2
);
2137 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2138 MPI2_IOCSTATUS_MASK
;
2139 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2142 "%s: Failed to get trigger pg2, ioc_status(0x%04x)\n",
2143 __func__
, ioc_status
));
2149 count
= event_tg
->ValidEntries
;
2150 tg_pg2
.NumMPIEventTrigger
= cpu_to_le16(count
);
2151 for (i
= 0; i
< count
; i
++) {
2152 tg_pg2
.MPIEventTriggers
[i
].MPIEventCode
=
2154 event_tg
->EventTriggerEntry
[i
].EventValue
);
2155 tg_pg2
.MPIEventTriggers
[i
].MPIEventCodeSpecific
=
2157 event_tg
->EventTriggerEntry
[i
].LogEntryQualifier
);
2160 tg_pg2
.NumMPIEventTrigger
= 0;
2161 memset(&tg_pg2
.MPIEventTriggers
[0], 0,
2162 NUM_VALID_ENTRIES
* sizeof(
2163 MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY
));
2166 rc
= _config_set_driver_trigger_pg2(ioc
, &mpi_reply
, &tg_pg2
);
2170 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2171 MPI2_IOCSTATUS_MASK
;
2172 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2175 "%s: Failed to get trigger pg2, ioc_status(0x%04x)\n",
2176 __func__
, ioc_status
));
2184 mpt3sas_config_update_driver_trigger_pg0(ioc
,
2185 MPI26_DRIVER_TRIGGER0_FLAG_MPI_EVENT_TRIGGER_VALID
, !set
);
2191 * mpt3sas_config_get_driver_trigger_pg3 - obtain driver trigger page 3
2192 * @ioc: per adapter object
2193 * @mpi_reply: reply mf payload returned from firmware
2194 * @config_page: contents of the config page
2197 * Returns 0 for success, non-zero for failure.
2200 mpt3sas_config_get_driver_trigger_pg3(struct MPT3SAS_ADAPTER
*ioc
,
2201 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage3_t
*config_page
)
2203 Mpi2ConfigRequest_t mpi_request
;
2206 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2207 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2208 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2209 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2210 mpi_request
.ExtPageType
=
2211 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2212 mpi_request
.Header
.PageNumber
= 3;
2213 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE3_PAGEVERSION
;
2214 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2215 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2216 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2220 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
2221 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2222 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2223 sizeof(*config_page
));
2229 * mpt3sas_config_set_driver_trigger_pg3 - write driver trigger page 3
2230 * @ioc: per adapter object
2231 * @mpi_reply: reply mf payload returned from firmware
2232 * @config_page: contents of the config page
2235 * Returns 0 for success, non-zero for failure.
2238 _config_set_driver_trigger_pg3(struct MPT3SAS_ADAPTER
*ioc
,
2239 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage3_t
*config_page
)
2241 Mpi2ConfigRequest_t mpi_request
;
2244 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2245 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2246 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2247 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2248 mpi_request
.ExtPageType
=
2249 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2250 mpi_request
.Header
.PageNumber
= 3;
2251 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE3_PAGEVERSION
;
2252 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2253 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2254 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2258 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
2259 _config_request(ioc
, &mpi_request
, mpi_reply
,
2260 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2261 sizeof(*config_page
));
2262 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
2263 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2264 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2265 sizeof(*config_page
));
2271 * mpt3sas_config_update_driver_trigger_pg3 - update driver trigger page 3
2272 * @ioc: per adapter object
2273 * @scsi_tg: scsi trigger list
2274 * @set: set ot clear trigger values
2277 * Returns 0 for success, non-zero for failure.
2280 mpt3sas_config_update_driver_trigger_pg3(struct MPT3SAS_ADAPTER
*ioc
,
2281 struct SL_WH_SCSI_TRIGGERS_T
*scsi_tg
, bool set
)
2283 Mpi26DriverTriggerPage3_t tg_pg3
;
2284 Mpi2ConfigReply_t mpi_reply
;
2288 rc
= mpt3sas_config_update_driver_trigger_pg0(ioc
,
2289 MPI26_DRIVER_TRIGGER0_FLAG_SCSI_SENSE_TRIGGER_VALID
, set
);
2293 rc
= mpt3sas_config_get_driver_trigger_pg3(ioc
, &mpi_reply
, &tg_pg3
);
2297 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2298 MPI2_IOCSTATUS_MASK
;
2299 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2302 "%s: Failed to get trigger pg3, ioc_status(0x%04x)\n",
2303 __func__
, ioc_status
));
2308 count
= scsi_tg
->ValidEntries
;
2309 tg_pg3
.NumSCSISenseTrigger
= cpu_to_le16(count
);
2310 for (i
= 0; i
< count
; i
++) {
2311 tg_pg3
.SCSISenseTriggers
[i
].ASCQ
=
2312 scsi_tg
->SCSITriggerEntry
[i
].ASCQ
;
2313 tg_pg3
.SCSISenseTriggers
[i
].ASC
=
2314 scsi_tg
->SCSITriggerEntry
[i
].ASC
;
2315 tg_pg3
.SCSISenseTriggers
[i
].SenseKey
=
2316 scsi_tg
->SCSITriggerEntry
[i
].SenseKey
;
2319 tg_pg3
.NumSCSISenseTrigger
= 0;
2320 memset(&tg_pg3
.SCSISenseTriggers
[0], 0,
2321 NUM_VALID_ENTRIES
* sizeof(
2322 MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY
));
2325 rc
= _config_set_driver_trigger_pg3(ioc
, &mpi_reply
, &tg_pg3
);
2329 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2330 MPI2_IOCSTATUS_MASK
;
2331 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2334 "%s: Failed to get trigger pg3, ioc_status(0x%04x)\n",
2335 __func__
, ioc_status
));
2341 mpt3sas_config_update_driver_trigger_pg0(ioc
,
2342 MPI26_DRIVER_TRIGGER0_FLAG_SCSI_SENSE_TRIGGER_VALID
, !set
);
2348 * mpt3sas_config_get_driver_trigger_pg4 - obtain driver trigger page 4
2349 * @ioc: per adapter object
2350 * @mpi_reply: reply mf payload returned from firmware
2351 * @config_page: contents of the config page
2354 * Returns 0 for success, non-zero for failure.
2357 mpt3sas_config_get_driver_trigger_pg4(struct MPT3SAS_ADAPTER
*ioc
,
2358 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage4_t
*config_page
)
2360 Mpi2ConfigRequest_t mpi_request
;
2363 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2364 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2365 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2366 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2367 mpi_request
.ExtPageType
=
2368 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2369 mpi_request
.Header
.PageNumber
= 4;
2370 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE4_PAGEVERSION
;
2371 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2372 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2373 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2377 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
2378 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2379 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2380 sizeof(*config_page
));
2386 * mpt3sas_config_set_driver_trigger_pg4 - write driver trigger page 4
2387 * @ioc: per adapter object
2388 * @mpi_reply: reply mf payload returned from firmware
2389 * @config_page: contents of the config page
2392 * Returns 0 for success, non-zero for failure.
2395 _config_set_driver_trigger_pg4(struct MPT3SAS_ADAPTER
*ioc
,
2396 Mpi2ConfigReply_t
*mpi_reply
, Mpi26DriverTriggerPage4_t
*config_page
)
2398 Mpi2ConfigRequest_t mpi_request
;
2401 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2402 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2403 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2404 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2405 mpi_request
.ExtPageType
=
2406 MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER
;
2407 mpi_request
.Header
.PageNumber
= 4;
2408 mpi_request
.Header
.PageVersion
= MPI26_DRIVER_TRIGGER_PAGE4_PAGEVERSION
;
2409 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2410 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2411 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2415 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_CURRENT
;
2416 _config_request(ioc
, &mpi_request
, mpi_reply
,
2417 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2418 sizeof(*config_page
));
2419 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM
;
2420 r
= _config_request(ioc
, &mpi_request
, mpi_reply
,
2421 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2422 sizeof(*config_page
));
2428 * mpt3sas_config_update_driver_trigger_pg4 - update driver trigger page 4
2429 * @ioc: per adapter object
2430 * @mpi_tg: mpi trigger list
2431 * @set: set ot clear trigger values
2434 * Returns 0 for success, non-zero for failure.
2437 mpt3sas_config_update_driver_trigger_pg4(struct MPT3SAS_ADAPTER
*ioc
,
2438 struct SL_WH_MPI_TRIGGERS_T
*mpi_tg
, bool set
)
2440 Mpi26DriverTriggerPage4_t tg_pg4
;
2441 Mpi2ConfigReply_t mpi_reply
;
2445 rc
= mpt3sas_config_update_driver_trigger_pg0(ioc
,
2446 MPI26_DRIVER_TRIGGER0_FLAG_LOGINFO_TRIGGER_VALID
, set
);
2450 rc
= mpt3sas_config_get_driver_trigger_pg4(ioc
, &mpi_reply
, &tg_pg4
);
2454 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2455 MPI2_IOCSTATUS_MASK
;
2456 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2459 "%s: Failed to get trigger pg4, ioc_status(0x%04x)\n",
2460 __func__
, ioc_status
));
2466 count
= mpi_tg
->ValidEntries
;
2467 tg_pg4
.NumIOCStatusLogInfoTrigger
= cpu_to_le16(count
);
2468 for (i
= 0; i
< count
; i
++) {
2469 tg_pg4
.IOCStatusLoginfoTriggers
[i
].IOCStatus
=
2470 cpu_to_le16(mpi_tg
->MPITriggerEntry
[i
].IOCStatus
);
2471 tg_pg4
.IOCStatusLoginfoTriggers
[i
].LogInfo
=
2472 cpu_to_le32(mpi_tg
->MPITriggerEntry
[i
].IocLogInfo
);
2475 tg_pg4
.NumIOCStatusLogInfoTrigger
= 0;
2476 memset(&tg_pg4
.IOCStatusLoginfoTriggers
[0], 0,
2477 NUM_VALID_ENTRIES
* sizeof(
2478 MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY
));
2481 rc
= _config_set_driver_trigger_pg4(ioc
, &mpi_reply
, &tg_pg4
);
2485 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2486 MPI2_IOCSTATUS_MASK
;
2487 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
) {
2490 "%s: Failed to get trigger pg4, ioc_status(0x%04x)\n",
2491 __func__
, ioc_status
));
2499 mpt3sas_config_update_driver_trigger_pg0(ioc
,
2500 MPI26_DRIVER_TRIGGER0_FLAG_LOGINFO_TRIGGER_VALID
, !set
);
2506 * mpt3sas_config_get_volume_handle - returns volume handle for give hidden
2508 * @ioc: per adapter object
2509 * @pd_handle: phys disk handle
2510 * @volume_handle: volume handle
2513 * Return: 0 for success, non-zero for failure.
2516 mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER
*ioc
, u16 pd_handle
,
2519 Mpi2RaidConfigurationPage0_t
*config_page
= NULL
;
2520 Mpi2ConfigRequest_t mpi_request
;
2521 Mpi2ConfigReply_t mpi_reply
;
2522 int r
, i
, config_page_sz
;
2526 u16 phys_disk_dev_handle
;
2529 memset(&mpi_request
, 0, sizeof(Mpi2ConfigRequest_t
));
2530 mpi_request
.Function
= MPI2_FUNCTION_CONFIG
;
2531 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_HEADER
;
2532 mpi_request
.Header
.PageType
= MPI2_CONFIG_PAGETYPE_EXTENDED
;
2533 mpi_request
.ExtPageType
= MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG
;
2534 mpi_request
.Header
.PageVersion
= MPI2_RAIDCONFIG0_PAGEVERSION
;
2535 mpi_request
.Header
.PageNumber
= 0;
2536 ioc
->build_zero_len_sge_mpi(ioc
, &mpi_request
.PageBufferSGE
);
2537 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
2538 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, NULL
, 0);
2542 mpi_request
.Action
= MPI2_CONFIG_ACTION_PAGE_READ_CURRENT
;
2543 config_page_sz
= (le16_to_cpu(mpi_reply
.ExtPageLength
) * 4);
2544 config_page
= kmalloc(config_page_sz
, GFP_KERNEL
);
2552 mpi_request
.PageAddress
= cpu_to_le32(config_num
+
2553 MPI2_RAID_PGAD_FORM_GET_NEXT_CONFIGNUM
);
2554 r
= _config_request(ioc
, &mpi_request
, &mpi_reply
,
2555 MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT
, config_page
,
2560 ioc_status
= le16_to_cpu(mpi_reply
.IOCStatus
) &
2561 MPI2_IOCSTATUS_MASK
;
2562 if (ioc_status
!= MPI2_IOCSTATUS_SUCCESS
)
2564 for (i
= 0; i
< config_page
->NumElements
; i
++) {
2565 element_type
= le16_to_cpu(config_page
->
2566 ConfigElement
[i
].ElementFlags
) &
2567 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE
;
2569 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT
||
2571 MPI2_RAIDCONFIG0_EFLAGS_OCE_ELEMENT
) {
2572 phys_disk_dev_handle
=
2573 le16_to_cpu(config_page
->ConfigElement
[i
].
2575 if (phys_disk_dev_handle
== pd_handle
) {
2577 le16_to_cpu(config_page
->
2578 ConfigElement
[i
].VolDevHandle
);
2582 } else if (element_type
==
2583 MPI2_RAIDCONFIG0_EFLAGS_HOT_SPARE_ELEMENT
) {
2589 config_num
= config_page
->ConfigNum
;
2597 * mpt3sas_config_get_volume_wwid - returns wwid given the volume handle
2598 * @ioc: per adapter object
2599 * @volume_handle: volume handle
2600 * @wwid: volume wwid
2603 * Return: 0 for success, non-zero for failure.
2606 mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER
*ioc
, u16 volume_handle
,
2609 Mpi2ConfigReply_t mpi_reply
;
2610 Mpi2RaidVolPage1_t raid_vol_pg1
;
2613 if (!(mpt3sas_config_get_raid_volume_pg1(ioc
, &mpi_reply
,
2614 &raid_vol_pg1
, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE
,
2616 *wwid
= le64_to_cpu(raid_vol_pg1
.WWID
);