mpt_sas.c revision 5b5046010dc014958659914f953b1197da4054ac
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <limits.h>
#include <sys/mdb_modapi.h>
#pragma pack(1)
#pragma pack()
struct {
int value;
char *text;
} devinfo_array[] = {
{ MPI2_SAS_DEVICE_INFO_SEP, "SEP" },
{ MPI2_SAS_DEVICE_INFO_ATAPI_DEVICE, "ATAPI device" },
{ MPI2_SAS_DEVICE_INFO_LSI_DEVICE, "LSI device" },
{ MPI2_SAS_DEVICE_INFO_DIRECT_ATTACH, "direct attach" },
{ MPI2_SAS_DEVICE_INFO_SSP_TARGET, "SSP tgt" },
{ MPI2_SAS_DEVICE_INFO_STP_TARGET, "STP tgt" },
{ MPI2_SAS_DEVICE_INFO_SMP_TARGET, "SMP tgt" },
{ MPI2_SAS_DEVICE_INFO_SATA_DEVICE, "SATA dev" },
{ MPI2_SAS_DEVICE_INFO_SSP_INITIATOR, "SSP init" },
{ MPI2_SAS_DEVICE_INFO_STP_INITIATOR, "STP init" },
{ MPI2_SAS_DEVICE_INFO_SMP_INITIATOR, "SMP init" },
{ MPI2_SAS_DEVICE_INFO_SATA_HOST, "SATA host" }
};
static int
atoi(const char *p)
{
int n;
int c = *p++;
for (n = 0; c >= '0' && c <= '9'; c = *p++) {
n *= 10; /* two steps to avoid unnecessary overflow */
n += '0' - c; /* accum neg to avoid surprises at MAX */
}
return (-n);
}
int
{
struct dev_info d;
mdb_warn("couldn't read dev_info");
return (DCMD_ERR);
}
if (d.devi_parent) {
(uintptr_t)d.devi_node_name);
}
return (DCMD_OK);
}
/* ARGSUSED */
int
{
struct mdi_pathinfo pi;
struct mdi_client c;
int mdi_target = 0, mdi_lun = 0;
mdb_warn("couldn't read mdi_pathinfo");
return (DCMD_ERR);
}
if (target != mdi_target)
return (0);
mdb_warn("couldn't read mdi_client");
return (-1);
}
case MDI_PATHINFO_STATE_INIT:
mdb_printf(" initializing");
break;
mdb_printf(" online");
break;
mdb_printf(" standby");
break;
case MDI_PATHINFO_STATE_FAULT:
mdb_printf(" fault");
break;
mdb_printf(" offline");
break;
default:
mdb_printf(" invalid state");
break;
}
mdb_printf("\n");
return (0);
}
void
{
struct dev_info d;
struct mdi_phci p;
mdb_warn("couldn't read m_dip");
return;
}
if (MDI_PHCI(&d)) {
== -1) {
mdb_warn("couldn't read m_dip.devi_mdi_xhci");
return;
}
if (p.ph_path_head)
return;
}
}
void
{
int j;
mdb_warn("couldn't read cmd_pkt");
return;
}
/*
* We use cmd_cdblen here because 5.10 doesn't
* have the cdb length in the pkt
*/
mdb_warn("couldn't read pkt_cdbp");
return;
}
mdb_printf("%3d,%-3d [ ",
for (j = 0; j < m->cmd_cdblen; j++)
mdb_printf("]\n");
}
void
display_ports(struct mptsas m)
{
int i;
mdb_printf("\n");
mdb_printf("phy number and port mapping table\n");
for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
if (m.m_phy_info[i].attached_devhdl) {
mdb_printf("phy %x --> port %x, phymask %x,"
m.m_phy_info[i].phy_mask,
m.m_phy_info[i].attached_devhdl);
}
}
mdb_printf("\n");
}
static void *
{
if (pos == MPTSAS_HASH_FIRST) {
} else {
return (NULL);
} else {
}
}
/* the traverse reaches the end */
return (NULL);
} else {
}
}
mdb_warn("couldn't read hashtab");
return (NULL);
}
mdb_warn("couldn't read hashdata");
return (NULL);
}
return (ret);
}
void
display_targets(struct mptsas_slots *s)
{
mdb_printf("\n");
mdb_printf("The SCSI target information\n");
MPTSAS_HASH_FIRST, sizeof (mptsas_target_t));
mdb_printf("\n");
mdb_printf("throttle %x, dr_flag %x, m_t_ncmds %x\n",
}
mdb_printf("\n");
mdb_printf("The smp child information\n");
MPTSAS_HASH_FIRST, sizeof (mptsas_smp_t));
mdb_printf("\n");
}
mdb_printf("\n");
#if 0
mdb_printf("targ wwn ncmds throttle "
"dr_flag timeout dups\n");
mdb_printf("-------------------------------"
"--------------------------------\n");
for (i = 0; i < MPTSAS_MAX_TARGETS; i++) {
mdb_printf("%4d ", i);
switch (s->m_target[i].m_t_throttle) {
case QFULL_THROTTLE:
mdb_printf(" QFULL ");
break;
case DRAIN_THROTTLE:
mdb_printf(" DRAIN ");
break;
case HOLD_THROTTLE:
mdb_printf(" HOLD ");
break;
case MAX_THROTTLE:
mdb_printf(" MAX ");
break;
case CHOKE_THROTTLE:
mdb_printf(" CHOKE ");
break;
default:
mdb_printf("%8d ",
s->m_target[i].m_t_throttle);
}
case MPTSAS_DR_INACTIVE:
mdb_printf(" INACTIVE ");
break;
mdb_printf(" TIMEOUT ");
break;
mdb_printf("TIMEOUT_NC ");
break;
mdb_printf(" OFFLINING ");
break;
mdb_printf(" ONLINING ");
break;
default:
mdb_printf(" UNKNOWN ");
break;
}
mdb_printf("%3d/%-3d %d/%d\n",
s->m_target[i].m_dr_online_dups,
s->m_target[i].m_dr_offline_dups);
if (verbose) {
mdb_inc_indent(5);
if ((s->m_target[i].m_deviceinfo &
mdb_printf("Fanout expander: ");
if ((s->m_target[i].m_deviceinfo &
mdb_printf("Edge expander: ");
if ((s->m_target[i].m_deviceinfo &
mdb_printf("End device: ");
if ((s->m_target[i].m_deviceinfo &
mdb_printf("No device ");
loop < (sizeof (devinfo_array) /
sizeof (devinfo_array[0])); loop++) {
if (s->m_target[i].m_deviceinfo &
mdb_printf("%s%s",
comma++;
}
}
mdb_printf("\n");
*target_path = 0;
if (construct_path((uintptr_t)
== DCMD_OK)
}
mdi_info(m, i);
mdb_dec_indent(5);
}
}
}
#endif
}
int
{
#if 0
int i, nslots;
struct mptsas_cmd c, *q, *slots;
int header_output = 0;
int slots_in_use = 0;
int tcmds = 0;
int mismatch = 0;
int ncmds = 0;
for (i = 0; i < nslots; i++)
if (s->m_slot[i]) {
slots_in_use++;
mdb_warn("couldn't read slot");
}
tcmds++;
mismatch++;
}
mdb_warn("couldn't follow m_waitq");
goto exit;
}
mdb_warn("couldn't follow m_doneq");
goto exit;
}
for (i = 0; i < MPTSAS_MAX_TARGETS; i++)
mdb_printf("\n");
mdb_printf(" mpt. slot mptsas_slots slot");
mdb_printf("\n");
mdb_printf("m_ncmds total"
" targ throttle m_t_ncmds targ_tot wq dq");
mdb_printf("\n");
mdb_printf("----------------------------------------------------");
mdb_printf("\n");
saved_indent = mdb_dec_indent(0);
for (i = 0; i < s->m_n_slots; i++)
if (s->m_slot[i]) {
if (!header_output) {
mdb_printf("\n");
mdb_printf("mptsas_cmd slot cmd_slot "
"cmd_flags cmd_pkt_flags scsi_pkt "
" targ,lun [ pkt_cdbp ...\n");
mdb_printf("-------------------------------"
"--------------------------------------"
"--------------------------------------"
"------\n");
header_output = 1;
}
mdb_printf("%16p %4d %s %4d %8x %8x %16p ",
s->m_slot[i], i,
slots[i].cmd_pkt_flags,
}
/* print the wait queue */
if (q == m.m_waitq)
mdb_printf("\n");
== -1) {
mdb_warn("couldn't follow m_waitq");
goto exit;
}
mdb_printf("%16p wait n/a %4d %8x %8x %16p ",
c.cmd_pkt);
print_cdb(&c);
}
/* print the done queue */
if (q == m.m_doneq)
mdb_printf("\n");
== -1) {
mdb_warn("couldn't follow m_doneq");
goto exit;
}
mdb_printf("%16p done n/a %4d %8x %8x %16p ",
c.cmd_pkt);
print_cdb(&c);
}
if (m.m_ncmds != slots_in_use)
mdb_printf("WARNING: mpt.m_ncmds does not match the number of "
"slots in use\n");
mdb_printf("WARNING: the total of m_target[].m_t_ncmds does "
"not match the slots in use\n");
if (mismatch)
mdb_printf("WARNING: corruption in slot table, "
"m_slot[].cmd_slot incorrect\n");
/* now check for corruptions */
for (i = 0; i < nslots; i++)
if (s->m_slot[i] == q)
mdb_printf("WARNING: m_waitq entry"
"(mptsas_cmd_t) %p is in m_slot[%i]\n",
q, i);
mdb_warn("couldn't follow m_waitq");
goto exit;
}
}
for (i = 0; i < nslots; i++)
if (s->m_slot[i] == q)
mdb_printf("WARNING: m_doneq entry "
"(mptsas_cmd_t) %p is in m_slot[%i]\n", q, i);
mdb_warn("couldn't follow m_doneq");
goto exit;
}
if ((c.cmd_flags & CFLAG_FINISHED) == 0)
mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
"should have CFLAG_FINISHED set\n", q);
if (c.cmd_flags & CFLAG_IN_TRANSPORT)
mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
"should not have CFLAG_IN_TRANSPORT set\n", q);
if (c.cmd_flags & CFLAG_CMDARQ)
mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
"should not have CFLAG_CMDARQ set\n", q);
if (c.cmd_flags & CFLAG_COMPLETED)
mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
"should not have CFLAG_COMPLETED set\n", q);
}
exit:
return (rv);
#endif
mdb_printf("\n");
mdb_printf("The slot information is not implemented yet\n");
return (0);
}
void
display_deviceinfo(struct mptsas m)
{
char device_path[PATH_MAX];
*device_path = 0;
}
mdb_printf("\n");
#if 0
mdb_printf("base_wwid phys "
"mptid prodid devid revid ssid\n");
mdb_printf("-----------------------------"
"----------------------------------\n");
m.m_productid, m.m_devid);
switch (m.m_devid) {
case MPTSAS_909:
mdb_printf("(909) ");
break;
case MPTSAS_929:
mdb_printf("(929) ");
break;
case MPTSAS_919:
mdb_printf("(919) ");
break;
case MPTSAS_1030:
mdb_printf("(1030) ");
break;
case MPTSAS_1064:
mdb_printf("(1064) ");
break;
case MPTSAS_1068:
mdb_printf("(1068) ");
break;
case MPTSAS_1064E:
mdb_printf("(1064E) ");
break;
case MPTSAS_1068E:
mdb_printf("(1068E) ");
break;
default:
mdb_printf("(?????) ");
break;
}
for (i = 0; i < MAX_MPI2_PORTS; i++) {
if (i%4 == 0)
mdb_printf("\n");
mdb_printf("%d:", i);
switch (m.m_port_type[i]) {
mdb_printf("inactive ",
m.m_protocol_flags[i]);
break;
mdb_printf("SCSI (0x%1x) ",
m.m_protocol_flags[i]);
break;
mdb_printf("FC (0x%1x) ",
m.m_protocol_flags[i]);
break;
mdb_printf("iSCSI (0x%1x) ",
m.m_protocol_flags[i]);
break;
mdb_printf("SAS (0x%1x) ",
m.m_protocol_flags[i]);
break;
default:
mdb_printf("unknown ");
}
}
#endif
mdb_printf("\n");
}
static int
{
struct mptsas m;
struct mptsas_slots *s;
int nslots;
int slot_size = 0;
void *mptsas_state;
if (!(flags & DCMD_ADDRSPEC)) {
mptsas_state = NULL;
mdb_warn("can't read mptsas_state");
return (DCMD_ERR);
}
mdb_warn("mdb_pwalk_dcmd failed");
return (DCMD_ERR);
}
return (DCMD_OK);
}
return (DCMD_USAGE);
return (DCMD_ERR);
}
if (mdb_vread(s, sizeof (mptsas_slots_t),
mdb_warn("couldn't read small mptsas_slots_t at 0x%p",
m.m_active);
mdb_free(s, sizeof (mptsas_slots_t));
return (DCMD_ERR);
}
mdb_free(s, sizeof (mptsas_slots_t));
slot_size = sizeof (mptsas_slots_t) +
mdb_warn("couldn't read large mptsas_slots_t at 0x%p",
m.m_active);
return (DCMD_ERR);
}
/* processing completed */
target_info) {
mdb_printf("\n");
mdb_printf(" mptsas_t inst ncmds suspend power");
mdb_printf("\n");
mdb_printf("========================================="
"=======================================");
mdb_printf("\n");
}
switch (m.m_power_level) {
case PM_LEVEL_D0:
mdb_printf(" ON=D0 ");
break;
case PM_LEVEL_D1:
mdb_printf(" D1 ");
break;
case PM_LEVEL_D2:
mdb_printf(" D2 ");
break;
case PM_LEVEL_D3:
mdb_printf("OFF=D3 ");
break;
default:
mdb_printf("INVALD ");
}
mdb_printf("\n");
mdb_inc_indent(17);
if (target_info)
display_targets(s);
if (port_info)
display_ports(m);
if (device_info)
if (slot_info)
mdb_dec_indent(17);
return (rv);
}
/*
* Only -t is implemented now, will add more later when the driver is stable
*/
void
{
mdb_printf("Prints summary information about each mpt_sas instance, "
"including warning\nmessages when slot usage doesn't match "
"summary information.\n"
"Without the address of a \"struct mptsas\", prints every "
"instance.\n\n"
"Switches:\n"
" -t includes information about targets\n"
" -p includes information about port\n"
" -d includes information about the hardware\n");
}
static const mdb_dcmd_t dcmds[] = {
mptsas_help}, { NULL }
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}