fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)state.stmf_ilportlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (stmf_i_local_port_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct stmf_i_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_local_port_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((struct stmf_i_local_port *)wsp->walk_data)->ilport_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct stmf_i_local_port));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedump_ilport(struct stmf_i_local_port *ilportp, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* here assume the alias is maximumly 1024 bytes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilport, sizeof (ilport), (uintptr_t)ilportp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_local_port at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lport.lport_alias && mdb_vread(alias, sizeof (alias),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port provider: %p\n", lport.lport_pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_ilports(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_ilport((stmf_i_local_port_t *)ws.walk_addr, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_ilport((stmf_i_local_port_t *)ws.walk_addr, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((struct stmf_i_local_port *)wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((struct stmf_i_local_port *)wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_iss(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("address of stmf_i_local_port should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be stmf_i_local_port_t.
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 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 Fortestmf_ilus(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilu, sizeof (struct stmf_i_lu), (uintptr_t)ilup)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_lu_t at %p", ilup);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX lu_alias? what is its size? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_i_lu_providers(uintptr_t addr, uint_t flags, int argc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ilp, sizeof (stmf_i_lu_provider_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_lu_provider_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_i_port_providers(uintptr_t addr, uint_t flags, int argc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readsym(&state, sizeof (struct stmf_state), "stmf_state")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ipp, sizeof (stmf_i_port_provider_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read stmf_i_port_provider_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cervert stmf_i_local_port to fct_i_local_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte__ilport2iport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("stmf_i_local_port address should be specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be stmf_i_local_port_t.
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 if (mdb_vread(&lport, sizeof (stmf_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.ilport_lport) != sizeof (stmf_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteilport2iport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iportp = __ilport2iport(addr, flags, argc, argv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* is the alias always 16 bytes in size ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (fct_i_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (alias)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by wwn, we can only find one local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fiport = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&iport, sizeof (fct_i_local_port_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_local_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("pwwn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_ilport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to free options manually ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || ! options->lpname_defined) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((siport = find_lport_by_wwn(options->lpname)) != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be fct_i_local_port_t.
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 if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)iport.iport_rp_slots;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (fct_i_remote_port_t *),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read address of fct_i_remote_port_t at %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to set remote_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewalk_fct_irp_cb(uintptr_t p, const void * arg, void *cbdata)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_walk_state_t ws = {walk_fct_irp_cb, &cbdata, addr};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("fct_i_local_port_t address should be specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irpp = *((fct_i_remote_port_t **)ws.walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static mdb_walk_state_t ws = {walk_fct_irp_cb, &cbdata};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ws.walk_addr == NULL || cur_iport_for_irp_loop !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
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 *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it is WALK_DONE, there may be one remote port there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *((fct_i_remote_port_t **)ws.walk_cbdata) = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (struct fct_i_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (struct fct_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&lport, sizeof (struct stmf_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct stmf_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by wwn, we may find more than one remote port, so we need to know its
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * corresponding local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefind_irp_by_wwn(struct stmf_i_local_port *siport, uint8_t wwn[8])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fiport = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&irp, sizeof (struct fct_i_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_i_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in fct_i_remote_port\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&rp, sizeof (struct fct_remote_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct fct_remote_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_fct_irp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to free options manually ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || (options->rpname_defined == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("rpname=<wwn.12345678> or rp=<3000586778734>"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " should be specified\n");
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 " fct_i_remote_port=%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if options->rpname_defined */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irpp = find_irp_by_wwn(siport, options->rpname)) != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_i_remote_port=%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct find_options *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_tasks(struct fct_i_cmd *icmdp, struct find_options *options, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmdp) != sizeof (struct fct_i_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmd.icmd_cmd) != sizeof (struct fct_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct scsi_task)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_tasks_on_rp(struct fct_i_cmd *icmdp, struct find_options *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmdp) != sizeof (struct fct_i_cmd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)icmd.icmd_cmd) != sizeof (struct fct_cmd)) {
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 if (cmd.cmd_type == FCT_CMD_FCP_XCHG && cmd.cmd_rp == irp.irp_rp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (struct scsi_task)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_all_cmds(struct fct_i_cmd *icmd, struct find_options *options, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find outstanding cmds (fct_i_cmd) on local port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteoutstanding_cmds_on_lport(struct stmf_i_local_port *siport, cmd_filter_t filter,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iportp = __ilport2iport((uintptr_t)siport, DCMD_ADDRSPEC, 0, NULL);
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 if (mdb_vread(&port, sizeof (struct fct_local_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)iport.iport_port) != sizeof (struct fct_local_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&slot, sizeof (struct fct_cmd_slot),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)slotp) != sizeof (struct fct_cmd_slot)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_find_tasks(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
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 outstanding_cmds_on_lport(siport, print_tasks, options, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irpp = find_irp_by_wwn(siport, options->rpname))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_find_cmds(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options == NULL || options->lpname_defined == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("lpname=<wwn.12345678> should be specified\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outstanding_cmds_on_lport(siport, print_all_cmds, options, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_icmds(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("fct_i_local_port_t address should be specified");
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 mdb_warn("failed to read fct_i_cmd at %p", icmdp);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Walker to list the addresses of all the active STMF scsi tasks (scsi_task_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * given a stmf_worker address
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * To list all the active STMF scsi tasks, use
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * "::walk stmf_worker |::walk stmf_scsi_task"
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * To list the active tasks of a particular worker, use
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * <stmf_worker addr>::walk stmf_scsi_task
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnanstmf_scsi_task_walk_init(mdb_walk_state_t *wsp)
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Input should be a stmf_worker, so read it to get the
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * worker_task_head to get the start of the task list
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("<worker addr>::walk stmf_scsi_task\n");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(&worker, sizeof (stmf_worker_t), wsp->walk_addr) !=
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read in the task address\n");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan wsp->walk_addr = (uintptr_t)(worker.worker_task_head);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan wsp->walk_data = mdb_alloc(sizeof (scsi_task_t), UM_SLEEP);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnanstmf_scsi_task_walk_step(mdb_walk_state_t *wsp)
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan /* Save the stmf_i_scsi_task for use later to get the next entry */
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(&itask, sizeof (stmf_i_scsi_task_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan wsp->walk_addr) != sizeof (stmf_i_scsi_task_t)) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read stmf_i_scsi_task at %p",
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan wsp->walk_addr = (uintptr_t)itask.itask_task;
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(wsp->walk_data, sizeof (scsi_task_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read scsi_task_t at %p", wsp->walk_addr);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan wsp->walk_addr = (uintptr_t)(itask.itask_worker_next);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnanstmf_scsi_task_walk_fini(mdb_walk_state_t *wsp)
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_free(wsp->walk_data, sizeof (scsi_task_t));
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnanstmf_scsi_task(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * A stmf_worker address is given to the left of ::stmf_scsi_task
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * i.e. display the scsi_task for the given worker
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_walk_dcmd("stmf_worker", "stmf_scsi_task", argc,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("Failed to walk the stmf_scsi_task entries");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (DCMD_HDRSPEC(flags) && (!(flags & DCMD_PIPE_OUT))) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(&worker, sizeof (stmf_worker_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read in the worker address");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan /* Read the scsi_task */
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(&itask, sizeof (stmf_i_scsi_task_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read stmf_i_scsi_task_t at %p",
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan (uintptr_t)task_addr) != sizeof (scsi_task_t)) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read scsi_task_t at %p", task_addr);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan /* pretty print */
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan task_addr, task.task_flags, task.task_lport);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Walker to list the addresses of all the stmf_worker in the queue
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan/* stmf_workers_state definition from stmf.c (static) */
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Initialize the stmf_worker_t walker by either using the given starting
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * address, or reading the value of the kernel's global stmf_workers pointer.
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_readvar(&worker_state, "stmf_workers_state") == -1) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read stmf_workers_state");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("stmf_workers_state not initialized");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * Look up the stmf_nworkers_accepting_cmds to
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan * determine number of entries in the worker queue
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_readvar(&nworkers, "stmf_nworkers_accepting_cmds") == -1) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read stmf_nworkers_accepting_cmds");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_readvar(&worker, "stmf_workers") == -1) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan walk_data = mdb_alloc(sizeof (stmf_worker_walk_data_t), UM_SLEEP);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan stmf_worker_walk_data_t *walk_data = wsp->walk_data;
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (walk_data->worker_current >= walk_data->worker_count) {
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_free(wsp->walk_data, sizeof (stmf_worker_walk_data_t));
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnanstmf_worker(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_walk_dcmd("stmf_worker", "stmf_worker", argc,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("Failed to walk the stmf_worker entries");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan if (mdb_vread(&worker, sizeof (stmf_worker_t),
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_warn("failed to read stmf_worker at %p", addr);
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan /* pretty print */
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_printf("%<u>%-19s %-10s %-10s %-10s%</u>\n",
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan "stmf_worker_t", "State", "Ref_Count", "Tasks");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan mdb_printf("%-19p %-10s %-10d %-5d%\n", addr,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan (worker.worker_flags == STMF_WORKER_STARTED) ? "STARTED" :
94360ae1f2b5d61a6b7fd32a528b0d0860f1f1d7Peter Cudhea - Sun Microsystems - Burlington, MA United States (worker.worker_flags & STMF_WORKER_ACTIVE) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte options = mdb_zalloc(sizeof (struct find_options), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < argc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ptr = strchr(argv[i].a_un.a_str, '=')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(argv[i].a_un.a_str, "lpname", len) == 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 strncmp(argv[i].a_un.a_str, "rpname", len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* figure out wwn from the tail to beginning */
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 "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 "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 "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");
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan "List all active scsi_task_t on a given stmf_worker_t. Example\n"
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan " addr::stmf_scsi_task\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_local_port", stmf_ilports },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Convert stmf_i_local_port to corresponding fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List all active sessions for a given local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "stmf_ilus", "[-v]", "Print a list of stmf_i_lu", stmf_ilus },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_lu_provider", stmf_i_lu_providers },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print a list of stmf_i_port_provider", stmf_i_port_providers },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print all fct_i_remote_port for a given fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print all cached fct_i_cmd_t on fct_i_local_port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all fct_i_cmd_t for a given local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find local port information based on its wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Print fct remote port information based on its wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Find all pending task for a local port or remote port",
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan { "stmf_worker", "?", "List all the stmf_worker entries", stmf_worker},
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan "List all the active STMF SCSI tasks per worker", stmf_scsi_task,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan { "stmf_worker", "Walk STMF worker queue", stmf_worker_walk_init,
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan stmf_worker_walk_step, stmf_worker_walk_fini},
8d2b0ea9d2a9f0e441345ec63219b0f8b91021f8Priya Krishnan { "stmf_scsi_task", "Walk active STMF SCSI tasks per worker",