stmf.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/dditypes.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mdb_modapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/modctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/lpif.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stmf.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/portif.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stmf_impl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <lun_map.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stmf_state.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fct.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fct_impl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "cmd_options.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilport_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_state state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmf_state") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)state.stmf_ilportlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (stmf_i_local_port_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilport_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status = WALK_NEXT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct stmf_i_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_local_port_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_callback)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((struct stmf_i_local_port *)wsp->walk_data)->ilport_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilport_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct stmf_i_local_port));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedump_ilport(struct stmf_i_local_port *ilportp, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ilportp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", ilportp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* here assume the alias is maximumly 1024 bytes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char alias[255];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_local_port lport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port ilport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilport, sizeof (ilport), (uintptr_t)ilportp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_local_port at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilportp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(alias, 0, sizeof (alias));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&lport, sizeof (lport),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)ilport.ilport_lport) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_local_port at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilport.ilport_lport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lport.lport_alias && mdb_vread(alias, sizeof (alias),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)lport.lport_alias) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read memory at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lport.lport_alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" lport: %p\n", ilport.ilport_lport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lport.lport_alias)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port alias: %s\n", alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port provider: %p\n", lport.lport_pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilports(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {NULL, };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stmf_ilport_walk_i(&ws) == WALK_ERR)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_ilport((stmf_i_local_port_t *)ws.walk_addr, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (stmf_ilport_walk_s(&ws) == WALK_NEXT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_ilport((stmf_i_local_port_t *)ws.walk_addr, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ilport_walk_f(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stmf_i_local_port *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext_stmf_port(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stmf_ilport_walk_i(wsp) == WALK_ERR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ilport_walk_f(wsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ilport_walk_f(wsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((struct stmf_i_local_port *)wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stmf_ilport_walk_s(wsp) == WALK_ERR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ilport_walk_f(wsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ilport_walk_f(wsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((struct stmf_i_local_port *)wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_iss(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_scsi_session *issp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_scsi_session iss;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("address of stmf_i_local_port should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be stmf_i_local_port_t.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (struct stmf_i_local_port), addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct stmf_i_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in stmf_i_local_port at %p\n", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte issp = iport.ilport_ss_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (issp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iss, sizeof (iss), (uintptr_t)issp) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_scsi_session_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte issp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", issp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" scsi session: %p\n", iss.iss_ss);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte issp = iss.iss_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilus(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_state state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_lu ilu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_lu *ilup;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilup = state.stmf_ilulist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ilup) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilu, sizeof (struct stmf_i_lu), (uintptr_t)ilup)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_lu_t at %p", ilup);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", ilup);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" lu: %p\n", ilu.ilu_lu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX lu_alias? what is its size? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilup = ilu.ilu_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_i_lu_providers(uintptr_t addr, uint_t flags, int argc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_state state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_lu_provider ilp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_lu_provider *ilpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilpp = state.stmf_ilplist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ilpp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilp, sizeof (stmf_i_lu_provider_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)ilpp) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_lu_provider_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", ilpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" lu provider: %p\n", ilp.ilp_lp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilpp = ilp.ilp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_i_port_providers(uintptr_t addr, uint_t flags, int argc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_state state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_port_provider ipp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_port_provider *ippp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ippp = state.stmf_ipplist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ippp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ipp, sizeof (stmf_i_port_provider_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)ippp) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_port_provider_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ippp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", ippp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port provider: %p\n", ipp.ipp_pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ippp = ipp.ipp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint string2wwn(const char *s, uint8_t wwn[8]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint16_t port_max_logins;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cervert stmf_i_local_port to fct_i_local_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct fct_i_local_port *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte__ilport2iport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_local_port lport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_local_port fport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("stmf_i_local_port address should be specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be stmf_i_local_port_t.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (struct stmf_i_local_port), addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct stmf_i_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in stmf_i_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&lport, sizeof (stmf_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.ilport_lport) != sizeof (stmf_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in stmf_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&fport, sizeof (fct_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)lport.lport_port_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (fct_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fport.port_fct_private);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteilport2iport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port *iportp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iportp = __ilport2iport(addr, flags, argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iportp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", iportp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* is the alias always 16 bytes in size ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char alias[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(alias, 0, sizeof (alias));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (fct_i_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iportp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (fct_i_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "at %p\n", iportp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport.iport_alias &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_vread(alias, sizeof (alias),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.iport_alias)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (alias)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in memory at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport.iport_alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port: %p\n", iport.iport_port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport.iport_alias)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" alias: %s\n", alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by wwn, we can only find one local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct stmf_i_local_port *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefind_lport_by_wwn(uint8_t wwn[8])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port *siport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port *fiport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_local_port fport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {NULL, };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((siport = next_stmf_port(&ws)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fiport = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fiport == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (fct_i_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)fiport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (fct_i_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&fport, sizeof (fct_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.iport_port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (fct_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("pwwn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fport.port_pwwn[0], fport.port_pwwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fport.port_pwwn[2], fport.port_pwwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fport.port_pwwn[4], fport.port_pwwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fport.port_pwwn[6], fport.port_pwwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(fport.port_pwwn, wwn, 8) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (siport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_ilport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port *siport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = parse_options(argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to free options manually ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || ! options->lpname_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("lpname=<wwn.12345678 or 12345678> "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((siport = find_lport_by_wwn(options->lpname)) != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", siport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irp_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_local_port port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Can not perform global walk");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be fct_i_local_port_t.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (struct fct_i_local_port), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.iport_port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_max_logins = port.port_max_logins;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)iport.iport_rp_slots;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irp_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status = WALK_NEXT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rp_index++ >= port_max_logins)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (fct_i_remote_port_t *),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read address of fct_i_remote_port_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rp != NULL && wsp->walk_callback != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback((uintptr_t)rp, rp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(((fct_i_remote_port_t **)wsp->walk_addr)[1]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irp_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to set remote_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewalk_fct_irp_cb(uintptr_t p, const void * arg, void *cbdata)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((uintptr_t *)cbdata) = p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static uint64_t cbdata = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {walk_fct_irp_cb, &cbdata, addr};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("fct_i_local_port_t address should be specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irp_walk_i(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (fct_irp_walk_s(&ws) == WALK_NEXT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irpp = *((fct_i_remote_port_t **)ws.walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (irpp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", irpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (irp),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)irpp) != sizeof (irp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_i_remote_port at %p\n", irpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" remote port: %p\n", irp.irp_rp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port id: %x\n", irp.irp_portid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irp_walk_f(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uintptr_t cur_iport_for_irp_loop = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fct_i_remote_port_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext_rport(struct fct_i_local_port *iport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static uint64_t cbdata = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static mdb_walk_state_t ws = {walk_fct_irp_cb, &cbdata};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ws.walk_addr == NULL || cur_iport_for_irp_loop !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_iport_for_irp_loop = (uintptr_t)iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ws.walk_addr = (uintptr_t)iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fct_irp_walk_i(&ws) == WALK_ERR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irp_walk_f(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ws.walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irp_walk_f(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((ret = fct_irp_walk_s(&ws)) == WALK_NEXT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*((fct_i_remote_port_t **)ws.walk_cbdata) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = *((fct_i_remote_port_t **)ws.walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (irp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irp_walk_f(&ws);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it is WALK_DONE, there may be one remote port there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == WALK_DONE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = *((fct_i_remote_port_t **)ws.walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (irp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct stmf_i_local_port *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteirp_to_ilport(struct fct_i_remote_port *irpp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_remote_port irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_remote_port rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_local_port port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_local_port lport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (struct fct_i_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)irpp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (struct fct_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)irp.irp_rp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)rp.rp_port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&lport, sizeof (struct stmf_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)port.port_lport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct stmf_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in stmf_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (lport.lport_stmf_private);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by wwn, we may find more than one remote port, so we need to know its
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * corresponding local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct fct_i_remote_port *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefind_irp_by_wwn(struct stmf_i_local_port *siport, uint8_t wwn[8])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port *fiport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_remote_port irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_remote_port rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *ret = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fiport = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fiport == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((irpp = next_rport(fiport)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (struct fct_i_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)irpp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (struct fct_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)irp.irp_rp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(rp.rp_pwwn, wwn, 8) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = irpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_iport_for_irp_loop = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_fct_irp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port *siport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {NULL, };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = parse_options(argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to free options manually ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || (options->rpname_defined == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->rp_defined == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("rpname=<wwn.12345678> or rp=<3000586778734>"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->rpname_defined && options->rp_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("rpname=<wwn.12345678> or rp=<3000586778734>"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " should be specified, but not both\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->rp_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siport = irp_to_ilport(options->rp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (siport != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("stmf_i_local_port=%p,"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " fct_i_remote_port=%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siport, options->rp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if options->rpname_defined */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((siport = next_stmf_port(&ws)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irpp = find_irp_by_wwn(siport, options->rpname)) != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("stmf_i_local_port=%p, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_i_remote_port=%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siport, irpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef void (*cmd_filter_t) (struct fct_i_cmd *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_tasks(struct fct_i_cmd *icmdp, struct find_options *options, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_cmd cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&icmd, sizeof (struct fct_i_cmd),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmdp) != sizeof (struct fct_i_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_cmd\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&cmd, sizeof (struct fct_cmd),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmd.icmd_cmd) != sizeof (struct fct_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_cmd\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd.cmd_type == FCT_CMD_FCP_XCHG) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_task task;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int colon_printed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&task, sizeof (struct scsi_task),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)cmd.cmd_specific)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct scsi_task)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in scsi_task\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p", cmd.cmd_specific);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->show_task_flags) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(":");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_printed = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" task_flags=%x", task.task_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->show_lport) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (colon_printed == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(":");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_printed = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" lport=%p", task.task_lport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_tasks_on_rp(struct fct_i_cmd *icmdp, struct find_options *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_cmd cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&icmd, sizeof (struct fct_i_cmd),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmdp) != sizeof (struct fct_i_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_cmd\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&cmd, sizeof (struct fct_cmd),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmd.icmd_cmd) != sizeof (struct fct_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_cmd\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* arg is a pointer to fct_i_remote_port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (struct fct_i_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)arg) != sizeof (struct fct_i_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd.cmd_type == FCT_CMD_FCP_XCHG && cmd.cmd_rp == irp.irp_rp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_task task;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int colon_printed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&task, sizeof (struct scsi_task),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)cmd.cmd_specific)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct scsi_task)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in scsi_task\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p", cmd.cmd_specific);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->show_task_flags) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(":");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_printed = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" task_flags=%x", task.task_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->show_lport) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (colon_printed == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(":");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_printed = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" lport=%p", task.task_lport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_all_cmds(struct fct_i_cmd *icmd, struct find_options *options, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find outstanding cmds (fct_i_cmd) on local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteoutstanding_cmds_on_lport(struct stmf_i_local_port *siport, cmd_filter_t filter,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port *iportp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_local_port port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_cmd_slot *slotp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_cmd_slot slot;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iportp = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iportp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (struct fct_i_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iportp) != sizeof (struct fct_i_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.iport_port) != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slotp = iport.iport_cmd_slots;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < port.port_max_xchges; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&slot, sizeof (struct fct_cmd_slot),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)slotp) != sizeof (struct fct_cmd_slot)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_cmd_slot\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (slot.slot_cmd != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (filter == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", slot.slot_cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte filter(slot.slot_cmd, options, arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slotp ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_tasks(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port *siport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = parse_options(argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (options->lpname_defined == 0 && options->rpname_defined == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("lpname=<wwn.12345678> or rpname=<wwn.12345678>"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->lpname_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siport = find_lport_by_wwn(options->lpname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (siport == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outstanding_cmds_on_lport(siport, print_tasks, options, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options->rpname_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {NULL, };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((siport = next_stmf_port(&ws)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irpp = find_irp_by_wwn(siport, options->rpname))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outstanding_cmds_on_lport(siport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_tasks_on_rp, options, irpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_find_cmds(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_i_local_port *siport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = parse_options(argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || options->lpname_defined == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("lpname=<wwn.12345678> should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siport = find_lport_by_wwn(options->lpname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (siport == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outstanding_cmds_on_lport(siport, print_all_cmds, options, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_icmds(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_local_port iport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd *icmdp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr = (char *)argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr[0] == '-')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ptr == 'v')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("fct_i_local_port_t address should be specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (struct fct_i_local_port), addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port at %p\n", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmdp = iport.iport_cached_cmdlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (icmdp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&icmd, sizeof (struct fct_i_cmd),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmdp) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fct_i_cmd at %p", icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p\n", icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fct cmd: %p\n", icmd.icmd_cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmdp = icmd.icmd_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct find_options *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparse_options(int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = mdb_zalloc(sizeof (struct find_options), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (argv[i].a_type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MDB_TYPE_STRING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MDB_TYPE_IMMEDIATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MDB_TYPE_CHAR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("unknown type\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ptr = strchr(argv[i].a_un.a_str, '=')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("invalid argument: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[i].a_un.a_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = ptr - argv[i].a_un.a_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr++; /* point to value now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (len == strlen("lpname") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(argv[i].a_un.a_str, "lpname", len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(ptr, "wwn.") == ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr += 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = string2wwn(ptr, options->lpname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("wwn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn[0], wwn[1], wwn[2], wwn[3], wwn[4], wwn[5], wwn[6], wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->lpname_defined = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (len == strlen("rp") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(argv[i].a_un.a_str, "rp", len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->rp_defined = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->rp =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(unsigned long)mdb_strtoull(ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (len == strlen("rpname") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(argv[i].a_un.a_str, "rpname", len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(ptr, "wwn.") == ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr += 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = string2wwn(ptr, options->rpname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->rpname_defined = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (len == strlen("show") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(argv[i].a_un.a_str, "show", len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = strchr(ptr, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l = s - ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l = strlen(ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l == strlen("task_flags") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(ptr, "task_flags", l) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->show_task_flags = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (l == strlen("lport") &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(ptr, "lport", l) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options->show_lport = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("unknown shower: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (s == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr = s + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("unknown argument: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[i].a_un.a_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteout:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(options, sizeof (struct find_options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestring2wwn(const char *s, uint8_t wwn[8])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmp[17];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(s) > 16) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("invalid wwn %s\n", s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(tmp, s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = tmp + strlen(tmp) - 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(wwn, 0, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* figure out wwn from the tail to beginning */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 7; i >= 0 && p >= tmp; i--, p -= 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn[i] = mdb_strtoull(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_find_cmds_help(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all cached fct_i_cmd_t for a local port. If a local port \n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "name is specified, find all pending cmds for it and print the \n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "address. Example:\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " fct_find_cmds lpname=<wwn.12345678 or 12345678>\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_ilport_help(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find the fct_i_local_port if local port name is "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "specified. Example:\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " stmf_find_ilport lpname=<wwn.12345678 or 12345678>\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_fct_irp_help(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "If a remote port name or stmf_i_remote_port_t address is\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "specified, loop through all local ports, to which this remote \n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "port has logged in, print address for stmf_i_local_port_t and \n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmf_i_remote_port. Example:\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " stmf_find_fct_irp rpname=<wwn.12345678 or 12345678>\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " stmf_find_fct_irp rp=<3000586778734>\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_tasks_help(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all pending scsi_task_t for a given local port and/or\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "remote port. Various different fields for each task are printed\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "depending on what is requested. Example:\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " stmf_find_tasks rpname=<wwn.12345678 or 12345678>\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " stmf_find_tasks lpname=<wwn.12345678 or 12345678> "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "show=task_flags,lport\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_dcmd_t dcmds[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_ilports", "[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_local_port", stmf_ilports },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ilport2iport", "?[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Convert stmf_i_local_port to corresponding fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilport2iport },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_iss", "?[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List all active sessions for a given local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_iss },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_ilus", "[-v]", "Print a list of stmf_i_lu", stmf_ilus },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_i_lu_providers", "[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_lu_provider", stmf_i_lu_providers },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_i_port_providers", "[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_port_provider", stmf_i_port_providers },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fct_irps", "?[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print all fct_i_remote_port for a given fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_irps },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fct_icmds", "?[-v]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print all cached fct_i_cmd_t on fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_icmds },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fct_find_cmds", "lpname",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all fct_i_cmd_t for a given local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_find_cmds, fct_find_cmds_help},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_find_ilport", "lpname",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find local port information based on its wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_find_ilport, stmf_find_ilport_help},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_find_fct_irp", "rpname|rp",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print fct remote port information based on its wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_find_fct_irp, stmf_find_fct_irp_help},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_find_tasks", "lpname|rpname [show]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all pending task for a local port or remote port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_find_tasks, stmf_find_tasks_help},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_walker_t walkers[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_modinfo_t modinfo = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDB_API_VERSION, dcmds, walkers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst mdb_modinfo_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_mdb_init(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (&modinfo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}