70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * CDDL HEADER START
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * The contents of this file are subject to the terms of the
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Common Development and Distribution License (the "License").
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * You may not use this file except in compliance with the License.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * See the License for the specific language governing permissions
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * and limitations under the License.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * When distributing Covered Code, include this CDDL HEADER in each
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * If applicable, add the following below this CDDL HEADER, with the
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * fields enclosed by brackets "[]" replaced with your own identifying
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * information: Portions Copyright [yyyy] [name of copyright owner]
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * CDDL HEADER END
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Use is subject to license terms.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat#pragma ident "%Z%%M% %I% %E% SMI"
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatstatic void dump_flags(unsigned long long flags, char **strings);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatstatic void dump_state_str(char *name, uintptr_t addr, char **strings);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatstatic int mpxio_walk_cb(uintptr_t addr, const void *data, void *cbdata);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_INIT",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_ONLINE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_STANDBY",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_FAULT",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_OFFLINE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_USER_DISABLE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_DRV_DISABLE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_OFFLINE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_SUSPEND",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_POWER_DOWN",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_DETACH",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_USER_DISABLE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_D_DISABLE",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_D_DISABLE_TRANS",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "MDI_PHCI_FLAGS_POWER_TRANSITION",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatstatic char mdipathinfo_cb_str[] = "::print struct mdi_pathinfo";
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatstatic char mdiphci_cb_str[] = "::print struct mdi_phci";
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a path, dump mdi_pathinfo struct and detailed pi_prop list.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGSUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdipi(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(&value, sizeof (struct mdi_pathinfo), addr) !=
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat sizeof (struct mdi_pathinfo)) {
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("------------- mdi_pathinfo @ %#lr ----------\n", addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_string((uintptr_t)value.pi_addr, "PWWN,LUN (pi_addr)");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_client: %25l#r::print struct mdi_client\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_phci: %27l#r::print struct mdi_phci\n", value.pi_phci);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_pprivate: %23l#r\n", value.pi_pprivate);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_client_link: %20l#r::print struct mdi_pathinfo\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_phci_link: %22l#r::print struct mdi_pathinfo\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_prop: %27l#r::print struct nv_list\n", value.pi_prop);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Need to shift right 20 bits to match mdi_pathinfo_ext_states
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_flags((unsigned long long)MDI_PI_EXT_STATE(&value) >> 20,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Need to shift right 20 bits to match mdi_pathinfo_ext_states
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_flags((unsigned long long)MDI_PI_OLD_EXT_STATE(&value)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_mutex(value.pi_mutex, "per-path mutex (pi_mutex):");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_condvar(value.pi_state_cv, "Path state (pi_state_cv)");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_kstats: %25l#r::print struct mdi_pi_kstats\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("pi_cprivate UNUSED: %16l#r \n", value.pi_cprivate);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdiprops()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a pi_prop, dump the pi_prop list.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGSUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdiprops(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdiphci()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a phci, dump mdi_phci struct.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGSUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdiphci(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(&value, sizeof (struct mdi_phci), addr) !=
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat sizeof (struct mdi_phci)) {
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("---------------- mdi_phci @ %#lr ----------\n", addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_next: %27l#r::print struct mdi_phci\n", value.ph_next);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_prev: %27l#r::print struct mdi_phci\n", value.ph_prev);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_vhci: %27l#r::print struct mdi_vhci\n", value.ph_vhci);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_dip: %28l#r::print struct dev_info\n", value.ph_dip);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("\nph_path_head: %22l#r::print struct mdi_pathinfo\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_path_tail: %22l#r::print struct mdi_pathinfo\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("ph_path_count: %21d\n", value.ph_path_count);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_pwalk("mdipi_phci_list", (mdb_walk_cb_t)mpxio_walk_cb,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_flags((unsigned long long)value.ph_flags, mdi_phci_flags);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_mutex(value.ph_mutex, "per-pHCI mutex (ph_mutex):");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat "Paths in transient state (ph_unstable_cv)");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdivhci()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a vhci, dump mdi_vhci struct and list all phcis.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGSUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdivhci(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(&value, sizeof (struct mdi_vhci), addr) !=
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat sizeof (struct mdi_vhci)) {
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("----------------- mdi_vhci @ %#lr ----------\n", addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_string((uintptr_t)value.vh_class, "Class name (vh_class)");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_dip: %28l#r::print struct dev_info\n", value.vh_dip);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_next: %27l#r::print struct mdi_vhci\n", value.vh_next);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_prev: %27l#r::print struct mdi_vhci\n", value.vh_prev);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_state_str("Load Balance (vh_lb)", value.vh_lb, client_lb_str);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_ops: %28l#r::print struct mdi_vhci_ops\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_mutex(value.vh_phci_mutex, "phci mutex (vh_phci_mutex):");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_phci_count: %21d\n", value.vh_phci_count);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("\nvh_phci_head: %22l#r::print struct mdi_phci\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_phci_tail: %22l#r::print struct mdi_phci\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat dump_mutex(value.vh_phci_mutex, "client mutex (vh_client_mutex):");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_client_count: %19d\n", value.vh_client_count);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("vh_client_table: %19l#r::print struct client_hash\n",
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_pwalk("mdiphci_list", (mdb_walk_cb_t)mpxio_walk_cb,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* mdi_pathinfo client walker */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat wsp->walk_data = mdb_alloc(sizeof (struct mdi_pathinfo), UM_SLEEP);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(wsp->walk_data, sizeof (struct mdi_pathinfo),
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_warn("failed to read mdi_pathinfo at %p", wsp->walk_addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat (((struct mdi_pathinfo *)wsp->walk_data)->pi_client_link);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_free(wsp->walk_data, sizeof (struct mdi_pathinfo));
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdiclient_paths()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a path, walk through mdi_pathinfo client links.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdiclient_paths(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_pwalk_dcmd("mdipi_client_list", "mdipi", argc, argv, addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* mdi_pathinfo phci walker */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat wsp->walk_data = mdb_alloc(sizeof (struct mdi_pathinfo), UM_SLEEP);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(wsp->walk_data, sizeof (struct mdi_pathinfo),
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_warn("failed to read mdi_pathinfo at %p", wsp->walk_addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat (((struct mdi_pathinfo *)wsp->walk_data)->pi_phci_link);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_free(wsp->walk_data, sizeof (struct mdi_pathinfo));
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdiphci_paths()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a path, walk through mdi_pathinfo phci links.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdiphci_paths(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_pwalk_dcmd("mdipi_phci_list", "mdipi", argc, argv, addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* mdi_phci walker */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat wsp->walk_data = mdb_alloc(sizeof (struct mdi_phci), UM_SLEEP);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_vread(wsp->walk_data, sizeof (struct mdi_phci), wsp->walk_addr)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_warn("failed to read mdi_phci at %p", wsp->walk_addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * mdiphcis()
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Given a phci, walk through mdi_phci ph_next links.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmdiphcis(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_pwalk_dcmd("mdiphci_list", "mdiphci", argc, argv, addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat * Print the flag name by comparing flags to the mask variable.
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat for (i = 0; i < 64; i++) {
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat /* make output pretty */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("%s is%s held\n", name, FT(m, uint64_t) == 0 ? " not" : "");
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("Threads sleeping on %s = %d\n", name, (int)FT(c, ushort_t));
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat if (mdb_readstr(string_val, MAXNAMELEN, addr) == -1) {
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat return (1);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat return (0);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("%s: %s (%l#r)\n", name, string_val, addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatdump_state_str(char *name, uintptr_t addr, char **strings)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat mdb_printf("%s: %s (%l#r)\n", name, strings[(unsigned long)addr], addr);
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat/* ARGSUSED */
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramatmpxio_walk_cb(uintptr_t addr, const void *data, void *cbdata)
70ab954a5d6c4d36858fd6e7e3dd4498d06d2c40ramat return (0);