2 * Copyright (c) 2015 Netflix, Inc.
3 * Written by: Scott Long <scottl@freebsd.org>
5 * Copyright (c) 2008 Yahoo!, Inc.
7 * Written by: John Baldwin <jhb@FreeBSD.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the author nor the names of any co-contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/param.h>
35 #include <sys/errno.h>
36 #include <sys/endian.h>
44 static char * get_device_speed(uint8_t rate);
45 static char * get_device_type(uint32_t di);
46 static int show_all(int ac, char **av);
47 static int show_devices(int ac, char **av);
48 static int show_enclosures(int ac, char **av);
49 static int show_expanders(int ac, char **av);
53 #define STANDALONE_STATE "ONLINE"
56 show_adapter(int ac, char **av)
58 const char* pcie_speed[] = { "2.5", "5.0", "8.0", "16.0", "32.0" };
59 const char* temp_units[] = { "", "F", "C" };
60 const char* ioc_speeds[] = { "", "Full", "Half", "Quarter", "Eighth" };
62 MPI2_CONFIG_PAGE_SASIOUNIT_0 *sas0;
63 MPI2_CONFIG_PAGE_SASIOUNIT_1 *sas1;
64 MPI2_SAS_IO_UNIT0_PHY_DATA *phy0;
65 MPI2_SAS_IO_UNIT1_PHY_DATA *phy1;
66 MPI2_CONFIG_PAGE_MAN_0 *man0;
67 MPI2_CONFIG_PAGE_BIOS_3 *bios3;
68 MPI2_CONFIG_PAGE_IO_UNIT_1 *iounit1;
69 MPI2_CONFIG_PAGE_IO_UNIT_7 *iounit7;
70 MPI2_IOC_FACTS_REPLY *facts;
72 char *speed, *minspeed, *maxspeed, *isdisabled, *type;
73 char devhandle[8], ctrlhandle[8];
77 warnx("show adapter: extra arguments");
81 fd = mps_open(mps_unit);
88 man0 = mps_read_man_page(fd, 0, NULL);
91 warn("Failed to get controller info");
94 if (man0->Header.PageLength < sizeof(*man0) / 4) {
95 warnx("Invalid controller info");
98 printf("mp%s%d Adapter:\n", is_mps ? "s": "r", mps_unit);
99 printf(" Board Name: %.16s\n", man0->BoardName);
100 printf(" Board Assembly: %.16s\n", man0->BoardAssembly);
101 printf(" Chip Name: %.16s\n", man0->ChipName);
102 printf(" Chip Revision: %.16s\n", man0->ChipRevision);
105 bios3 = mps_read_config_page(fd, MPI2_CONFIG_PAGETYPE_BIOS, 3, 0, NULL);
108 warn("Failed to get BIOS page 3 info");
111 v = le32toh(bios3->BiosVersion);
112 printf(" BIOS Revision: %d.%02d.%02d.%02d\n",
113 ((v & 0xff000000) >> 24), ((v &0xff0000) >> 16),
114 ((v & 0xff00) >> 8), (v & 0xff));
117 if ((facts = mps_get_iocfacts(fd)) == NULL) {
118 printf("could not get controller IOCFacts\n");
122 v = facts->FWVersion.Word;
123 printf("Firmware Revision: %d.%02d.%02d.%02d\n",
124 ((v & 0xff000000) >> 24), ((v &0xff0000) >> 16),
125 ((v & 0xff00) >> 8), (v & 0xff));
126 printf(" Integrated RAID: %s\n",
127 (facts->IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID)
131 iounit1 = mps_read_config_page(fd, MPI2_CONFIG_PAGETYPE_IO_UNIT, 1, 0, NULL);
132 if (iounit1 == NULL) {
134 warn("Failed to get IOUNIT page 1 info");
137 printf(" SATA NCQ: %s\n",
138 ((iounit1->Flags & MPI2_IOUNITPAGE1_NATIVE_COMMAND_Q_DISABLE) == 0) ?
139 "ENABLED" : "DISABLED");
142 iounit7 = mps_read_config_page(fd, MPI2_CONFIG_PAGETYPE_IO_UNIT, 7, 0, NULL);
143 if (iounit7 == NULL) {
145 warn("Failed to get IOUNIT page 7 info");
148 printf(" PCIe Width/Speed: x%d (%s GB/sec)\n", iounit7->PCIeWidth,
149 pcie_speed[iounit7->PCIeSpeed]);
150 printf(" IOC Speed: %s\n", ioc_speeds[iounit7->IOCSpeed]);
151 printf(" Temperature: ");
152 if (iounit7->IOCTemperatureUnits == MPI2_IOUNITPAGE7_IOC_TEMP_NOT_PRESENT)
153 printf("Unknown/Unsupported\n");
155 printf("%d %s\n", iounit7->IOCTemperature,
156 temp_units[iounit7->IOCTemperatureUnits]);
159 fd = mps_open(mps_unit);
166 sas0 = mps_read_extended_config_page(fd,
167 MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT,
168 MPI2_SASIOUNITPAGE0_PAGEVERSION, 0, 0, &IOCStatus);
171 warn("Error retrieving SAS IO Unit page %d", IOCStatus);
177 sas1 = mps_read_extended_config_page(fd,
178 MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT,
179 MPI2_SASIOUNITPAGE1_PAGEVERSION, 1, 0, &IOCStatus);
182 warn("Error retrieving SAS IO Unit page %d", IOCStatus);
189 printf("%-8s%-12s%-11s%-10s%-8s%-7s%-7s%s\n", "PhyNum", "CtlrHandle",
190 "DevHandle", "Disabled", "Speed", "Min", "Max", "Device");
191 for (i = 0; i < sas0->NumPhys; i++) {
192 phy0 = &sas0->PhyData[i];
193 phy1 = &sas1->PhyData[i];
194 if (phy0->PortFlags &
195 MPI2_SASIOUNIT0_PORTFLAGS_DISCOVERY_IN_PROGRESS) {
196 printf("Discovery still in progress\n");
199 if (phy0->PhyFlags & MPI2_SASIOUNIT0_PHYFLAGS_PHY_DISABLED)
204 minspeed = get_device_speed(phy1->MaxMinLinkRate);
205 maxspeed = get_device_speed(phy1->MaxMinLinkRate >> 4);
206 type = get_device_type(le32toh(phy0->ControllerPhyDeviceInfo));
208 if (le16toh(phy0->AttachedDevHandle) != 0) {
209 snprintf(devhandle, sizeof(devhandle), "%04x",
210 le16toh(phy0->AttachedDevHandle));
211 snprintf(ctrlhandle, sizeof(ctrlhandle), "%04x",
212 le16toh(phy0->ControllerDevHandle));
213 speed = get_device_speed(phy0->NegotiatedLinkRate);
215 snprintf(devhandle, sizeof(devhandle), " ");
216 snprintf(ctrlhandle, sizeof(ctrlhandle), " ");
219 printf("%-8d%-12s%-11s%-10s%-8s%-7s%-7s%s\n",
220 i, ctrlhandle, devhandle, isdisabled, speed, minspeed,
230 MPS_COMMAND(show, adapter, show_adapter, "", "display controller information")
233 show_iocfacts(int ac, char **av)
235 MPI2_IOC_FACTS_REPLY *facts;
240 fd = mps_open(mps_unit);
247 if ((facts = mps_get_iocfacts(fd)) == NULL) {
248 printf("could not get controller IOCFacts\n");
253 fb = (uint8_t *)facts;
255 #define IOCCAP "\3ScsiTaskFull" "\4DiagTrace" "\5SnapBuf" "\6ExtBuf" \
256 "\7EEDP" "\10BiDirTarg" "\11Multicast" "\14TransRetry" "\15IR" \
257 "\16EventReplay" "\17RaidAccel" "\20MSIXIndex" "\21HostDisc" \
258 "\22FastPath" "\23RDPQArray" "\24AtomicReqDesc" "\25PCIeSRIOV"
260 bzero(tmpbuf, sizeof(tmpbuf));
261 mps_parse_flags(facts->IOCCapabilities, IOCCAP, tmpbuf, sizeof(tmpbuf));
263 printf(" MsgVersion: %d.%d\n",
264 facts->MsgVersion >> 8, facts->MsgVersion & 0xff);
265 printf(" MsgLength: %d\n", facts->MsgLength);
266 printf(" Function: 0x%x\n", facts->Function);
267 printf(" HeaderVersion: %02d,%02d\n",
268 facts->HeaderVersion >> 8, facts->HeaderVersion & 0xff);
269 printf(" IOCNumber: %d\n", facts->IOCNumber);
270 printf(" MsgFlags: 0x%x\n", facts->MsgFlags);
271 printf(" VP_ID: %d\n", facts->VP_ID);
272 printf(" VF_ID: %d\n", facts->VF_ID);
273 printf(" IOCExceptions: %d\n", facts->IOCExceptions);
274 printf(" IOCStatus: %d\n", facts->IOCStatus);
275 printf(" IOCLogInfo: 0x%x\n", facts->IOCLogInfo);
276 printf(" MaxChainDepth: %d\n", facts->MaxChainDepth);
277 printf(" WhoInit: 0x%x\n", facts->WhoInit);
278 printf(" NumberOfPorts: %d\n", facts->NumberOfPorts);
279 printf(" MaxMSIxVectors: %d\n", facts->MaxMSIxVectors);
280 printf(" RequestCredit: %d\n", facts->RequestCredit);
281 printf(" ProductID: 0x%x\n", facts->ProductID);
282 printf(" IOCCapabilities: 0x%x %s\n", facts->IOCCapabilities,
284 printf(" FWVersion: %02d.%02d.%02d.%02d\n",
285 facts->FWVersion.Struct.Major, facts->FWVersion.Struct.Minor,
286 facts->FWVersion.Struct.Unit, facts->FWVersion.Struct.Dev);
287 printf(" IOCRequestFrameSize: %d\n", facts->IOCRequestFrameSize);
289 printf(" MaxChainSegmentSize: %d\n", (uint16_t)(fb[0x26]));
290 printf(" MaxInitiators: %d\n", facts->MaxInitiators);
291 printf(" MaxTargets: %d\n", facts->MaxTargets);
292 printf(" MaxSasExpanders: %d\n", facts->MaxSasExpanders);
293 printf(" MaxEnclosures: %d\n", facts->MaxEnclosures);
295 bzero(tmpbuf, sizeof(tmpbuf));
296 mps_parse_flags(facts->ProtocolFlags,
297 "\4NvmeDevices\2ScsiTarget\1ScsiInitiator", tmpbuf, sizeof(tmpbuf));
298 printf(" ProtocolFlags: 0x%x %s\n", facts->ProtocolFlags, tmpbuf);
299 printf(" HighPriorityCredit: %d\n", facts->HighPriorityCredit);
300 printf("MaxRepDescPostQDepth: %d\n",
301 facts->MaxReplyDescriptorPostQueueDepth);
302 printf(" ReplyFrameSize: %d\n", facts->ReplyFrameSize);
303 printf(" MaxVolumes: %d\n", facts->MaxVolumes);
304 printf(" MaxDevHandle: %d\n", facts->MaxDevHandle);
305 printf("MaxPersistentEntries: %d\n", facts->MaxPersistentEntries);
306 printf(" MinDevHandle: %d\n", facts->MinDevHandle);
308 printf(" CurrentHostPageSize: %d\n", (uint8_t)(fb[0x3e]));
314 MPS_COMMAND(show, iocfacts, show_iocfacts, "", "Show IOC Facts Message");
317 show_adapters(int ac, char **av)
319 MPI2_CONFIG_PAGE_MAN_0 *man0;
320 MPI2_IOC_FACTS_REPLY *facts;
323 printf("Device Name\t Chip Name Board Name Firmware\n");
324 for (unit = 0; unit < MPS_MAX_UNIT; unit++) {
328 facts = mps_get_iocfacts(fd);
331 warn("Faled to get controller iocfacts");
335 man0 = mps_read_man_page(fd, 0, NULL);
338 warn("Failed to get controller info");
343 if (man0->Header.PageLength < sizeof(*man0) / 4) {
344 warnx("Invalid controller info");
350 printf("/dev/mp%s%d\t%16s %16s %08x\n",
351 is_mps ? "s": "r", unit,
352 man0->ChipName, man0->BoardName, facts->FWVersion.Word);
359 MPS_COMMAND(show, adapters, show_adapters, "", "Show a summary of all adapters");
362 get_device_type(uint32_t di)
366 return ("SEP Target ");
368 return ("ATAPI Target ");
370 return ("SAS Target ");
372 return ("STP Target ");
374 return ("SMP Target ");
376 return ("SATA Target ");
378 return ("SAS Initiator ");
380 return ("SATA Initiator");
382 return ("No Device ");
383 return ("Unknown Device");
387 get_enc_type(uint32_t flags, int *issep)
392 switch (flags & 0xf) {
394 type = "Direct Attached SES-2";
398 type = "Direct Attached SGPIO";
401 type = "Expander SGPIO";
404 type = "External SES-2";
408 type = "Direct Attached GPIO";
419 mps_device_speed[] = {
435 get_device_speed(uint8_t rate)
440 if (rate >= sizeof(mps_device_speed))
443 if ((speed = mps_device_speed[rate]) == NULL)
460 "RAID Physical Disk",
472 "RAID Configuration",
473 "Driver Persistent Mapping",
476 "Extended Manufacturing"
480 get_page_name(u_int page)
484 if (page >= sizeof(mps_page_name))
486 if ((name = mps_page_name[page]) == NULL)
492 show_all(int ac, char **av)
496 printf("Adapter:\n");
497 error = show_adapter(ac, av);
498 printf("Devices:\n");
499 error = show_devices(ac, av);
500 printf("Enclosures:\n");
501 error = show_enclosures(ac, av);
502 printf("Expanders:\n");
503 error = show_expanders(ac, av);
506 MPS_COMMAND(show, all, show_all, "", "Show all devices");
509 show_devices(int ac, char **av)
511 MPI2_CONFIG_PAGE_SASIOUNIT_0 *sas0;
512 MPI2_SAS_IO_UNIT0_PHY_DATA *phydata;
513 MPI2_CONFIG_PAGE_SAS_DEV_0 *device;
514 MPI2_CONFIG_PAGE_EXPANDER_1 *exp1;
515 uint16_t IOCStatus, handle, bus, target;
516 char *type, *speed, enchandle[8], slot[8], bt[16];
518 int fd, error, nphys;
520 fd = mps_open(mps_unit);
527 sas0 = mps_read_extended_config_page(fd,
528 MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT,
529 MPI2_SASIOUNITPAGE0_PAGEVERSION, 0, 0, &IOCStatus);
532 warn("Error retrieving SAS IO Unit page %d", IOCStatus);
535 nphys = sas0->NumPhys;
537 printf("B____%-5s%-17s%-8s%-10s%-14s%-6s%-5s%-6s%s\n",
538 "T", "SAS Address", "Handle", "Parent", "Device", "Speed",
539 "Enc", "Slot", "Wdt");
542 device = mps_read_extended_config_page(fd,
543 MPI2_CONFIG_EXTPAGETYPE_SAS_DEVICE,
544 MPI2_SASDEVICE0_PAGEVERSION, 0,
545 MPI2_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE | handle,
547 if (device == NULL) {
548 if (IOCStatus == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
551 warn("Error retrieving device page");
555 handle = le16toh(device->DevHandle);
557 if (device->ParentDevHandle == 0x0) {
564 error = mps_map_btdh(fd, &handle, &bus, &target);
569 if ((bus == 0xffff) || (target == 0xffff))
570 snprintf(bt, sizeof(bt), " ");
572 snprintf(bt, sizeof(bt), "%02d %02d", bus, target);
574 type = get_device_type(le32toh(device->DeviceInfo));
576 if (device->DeviceInfo & 0x800) { /* Direct Attached */
577 if (device->PhyNum < nphys) {
578 phydata = &sas0->PhyData[device->PhyNum];
579 speed = get_device_speed(phydata->NegotiatedLinkRate);
582 } else if (device->ParentDevHandle > 0) {
583 exp1 = mps_read_extended_config_page(fd,
584 MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER,
585 MPI2_SASEXPANDER1_PAGEVERSION, 1,
586 MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM |
588 MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) |
589 le16toh(device->ParentDevHandle), &IOCStatus);
591 if (IOCStatus != MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) {
593 warn("Error retrieving expander page 1: 0x%x",
601 speed = get_device_speed(exp1->NegotiatedLinkRate);
607 if (device->EnclosureHandle != 0) {
608 snprintf(enchandle, sizeof(enchandle), "%04x", le16toh(device->EnclosureHandle));
609 snprintf(slot, sizeof(slot), "%02d", le16toh(device->Slot));
611 snprintf(enchandle, sizeof(enchandle), " ");
612 snprintf(slot, sizeof(slot), " ");
615 snprintf(buf, sizeof(buf), "%08x%08x", le32toh(device->SASAddress.High),
616 le32toh(device->SASAddress.Low));
617 printf("%-17s", buf);
618 snprintf(buf, sizeof(buf), "%04x", le16toh(device->DevHandle));
620 snprintf(buf, sizeof(buf), "%04x", le16toh(device->ParentDevHandle));
621 printf("%-10s", buf);
622 printf("%-14s%-6s%-5s%-6s%d\n", type, speed,
623 enchandle, slot, device->MaxPortConnections);
631 MPS_COMMAND(show, devices, show_devices, "", "Show attached devices");
634 show_enclosures(int ac, char **av)
636 MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0 *enc;
637 char *type, sepstr[8];
638 uint16_t IOCStatus, handle;
639 int fd, error, issep;
641 fd = mps_open(mps_unit);
648 printf("Slots Logical ID SEPHandle EncHandle Type\n");
651 enc = mps_read_extended_config_page(fd,
652 MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE,
653 MPI2_SASENCLOSURE0_PAGEVERSION, 0,
654 MPI2_SAS_ENCLOS_PGAD_FORM_GET_NEXT_HANDLE | handle,
657 if (IOCStatus == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
660 warn("Error retrieving enclosure page");
664 type = get_enc_type(le16toh(enc->Flags), &issep);
666 snprintf(sepstr, sizeof(sepstr), " ");
668 snprintf(sepstr, sizeof(sepstr), "%04x", le16toh(enc->SEPDevHandle));
669 printf(" %.2d %08x%08x %s %04x %s\n",
670 le16toh(enc->NumSlots), le32toh(enc->EnclosureLogicalID.High),
671 le32toh(enc->EnclosureLogicalID.Low), sepstr, le16toh(enc->EnclosureHandle),
673 handle = le16toh(enc->EnclosureHandle);
680 MPS_COMMAND(show, enclosures, show_enclosures, "", "Show attached enclosures");
683 show_expanders(int ac, char **av)
685 MPI2_CONFIG_PAGE_EXPANDER_0 *exp0;
686 MPI2_CONFIG_PAGE_EXPANDER_1 *exp1;
687 uint16_t IOCStatus, handle;
688 char enchandle[8], parent[8], rphy[4], rhandle[8];
689 char *speed, *min, *max, *type;
690 int fd, error, nphys, i;
692 fd = mps_open(mps_unit);
699 printf("NumPhys SAS Address DevHandle Parent EncHandle SAS Level\n");
702 exp0 = mps_read_extended_config_page(fd,
703 MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER,
704 MPI2_SASEXPANDER0_PAGEVERSION, 0,
705 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL | handle,
708 if (IOCStatus == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
711 warn("Error retrieving expander page 0");
716 nphys = exp0->NumPhys;
717 handle = le16toh(exp0->DevHandle);
719 if (exp0->EnclosureHandle == 0x00)
720 snprintf(enchandle, sizeof(enchandle), " ");
722 snprintf(enchandle, sizeof(enchandle), "%04d", le16toh(exp0->EnclosureHandle));
723 if (exp0->ParentDevHandle == 0x0)
724 snprintf(parent, sizeof(parent), " ");
726 snprintf(parent, sizeof(parent), "%04x", le16toh(exp0->ParentDevHandle));
727 printf(" %02d %08x%08x %04x %s %s %d\n",
728 exp0->NumPhys, le32toh(exp0->SASAddress.High), le32toh(exp0->SASAddress.Low),
729 le16toh(exp0->DevHandle), parent, enchandle, exp0->SASLevel);
732 printf(" Phy RemotePhy DevHandle Speed Min Max Device\n");
733 for (i = 0; i < nphys; i++) {
734 exp1 = mps_read_extended_config_page(fd,
735 MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER,
736 MPI2_SASEXPANDER1_PAGEVERSION, 1,
737 MPI2_SAS_EXPAND_PGAD_FORM_HNDL_PHY_NUM |
738 (i << MPI2_SAS_EXPAND_PGAD_PHYNUM_SHIFT) |
739 exp0->DevHandle, &IOCStatus);
742 MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
743 warn("Error retrieving expander pg 1");
746 type = get_device_type(le32toh(exp1->AttachedDeviceInfo));
747 if ((le32toh(exp1->AttachedDeviceInfo) &0x7) == 0) {
749 snprintf(rphy, sizeof(rphy), " ");
750 snprintf(rhandle, sizeof(rhandle), " ");
752 speed = get_device_speed(
753 exp1->NegotiatedLinkRate);
754 snprintf(rphy, sizeof(rphy), "%02d",
755 exp1->AttachedPhyIdentifier);
756 snprintf(rhandle, sizeof(rhandle), "%04x",
757 le16toh(exp1->AttachedDevHandle));
759 min = get_device_speed(exp1->HwLinkRate);
760 max = get_device_speed(exp1->HwLinkRate >> 4);
761 printf(" %02d %s %s %s %s %s %s\n", exp1->Phy, rphy, rhandle, speed, min, max, type);
773 MPS_COMMAND(show, expanders, show_expanders, "", "Show attached expanders");
776 show_cfgpage(int ac, char **av)
778 MPI2_CONFIG_PAGE_HEADER *hdr;
779 MPI2_CONFIG_EXTENDED_PAGE_HEADER *ehdr;
784 int fd, error, len, attrs;
785 char *pgname, *pgattr;
787 fd = mps_open(mps_unit);
800 addr = htole32((uint32_t)strtoul(av[3], NULL, 0));
802 num = (uint8_t)strtoul(av[2], NULL, 0);
804 page = (uint8_t)strtoul(av[1], NULL, 0);
808 warn("cfgpage: not enough arguments");
813 data = mps_read_extended_config_page(fd, page, 0, num, addr,
816 data = mps_read_config_page(fd, page, num, addr, &IOCStatus);
820 warn("Error retrieving cfg page: %s\n",
821 mps_ioc_status(IOCStatus));
827 len = le16toh(ehdr->ExtPageLength) * 4;
828 page = ehdr->ExtPageType;
829 attrs = ehdr->PageType >> 4;
832 len = hdr->PageLength * 4;
833 page = hdr->PageType & 0xf;
834 attrs = hdr->PageType >> 4;
837 pgname = get_page_name(page);
839 pgattr = "Read-only";
841 pgattr = "Read-Write";
843 pgattr = "Read-Write Persistent";
845 pgattr = "Unknown Page Attribute";
847 printf("Page 0x%x: %s %d, %s\n", page, pgname, num, pgattr);
848 hexdump(data, len, NULL, HD_REVERSED | 4);
854 MPS_COMMAND(show, cfgpage, show_cfgpage, "page [num] [addr]", "Display config page");