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 * FCP mdb module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mdb_modapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mutex.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/modctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunndi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/ulp/fcpvar.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct fcp_port port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct fcp_tgt tgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct fcp_lun lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t tgt_hash_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "fcp_port_head") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read 'fcp_port_head'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_port), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
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 fcp_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_port at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_port *)wsp->walk_data)->port_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_port));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcp_port pinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("fcp", "fcp",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argc, argv) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to walk 'fcp_port_head'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("FCP structure at %p\n", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For each port, we just need to read the fc_fca_port_t struct, read
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the port_handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&pinfo, sizeof (struct fcp_port), addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_port at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" mutex : 0x%-08x\n", pinfo.port_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" ipkt_list : 0x%p\n", pinfo.port_ipkt_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" state : 0x%-08x\n", pinfo.port_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" phys_state : 0x%-08x\n", pinfo.port_phys_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" top : %u\n", pinfo.port_topology);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" sid : 0x%-06x\n", pinfo.port_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" reset_list : 0x%p\n", pinfo.port_reset_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" link_cnt : %u\n", pinfo.port_link_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" deadline : %d\n", pinfo.port_deadline);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port wwn : "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_pwwn.raw_wwn[0], pinfo.port_pwwn.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_pwwn.raw_wwn[2], pinfo.port_pwwn.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_pwwn.raw_wwn[4], pinfo.port_pwwn.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_pwwn.raw_wwn[6], pinfo.port_pwwn.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" node wwn : "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_nwwn.raw_wwn[0], pinfo.port_nwwn.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_nwwn.raw_wwn[2], pinfo.port_nwwn.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_nwwn.raw_wwn[4], pinfo.port_nwwn.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_nwwn.raw_wwn[6], pinfo.port_nwwn.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" handle : 0x%p\n", pinfo.port_fp_handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" cmd_mutex : 0x%-08x\n", pinfo.port_pkt_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" ncmds : %u\n", pinfo.port_npkts);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" pkt_head : 0x%p\n", pinfo.port_pkt_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" pkt_tail : 0x%p\n", pinfo.port_pkt_tail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" ipkt_cnt : %d\n", pinfo.port_ipkt_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" instance : %u\n", pinfo.port_instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" max_exch : %u\n", pinfo.port_max_exch);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" cmds_aborted : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_reset_action);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" cmds_dma_flags : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_cmds_dma_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fcp_dma : 0x%-08x\n", pinfo.port_fcp_dma);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" priv_pkt_len : %u\n", pinfo.port_priv_pkt_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" data_dma_attr : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_data_dma_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" cmd_dma_attr : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_cmd_dma_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" resp_dma_attr : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_resp_dma_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" dma_acc_attr : 0x%-08x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_dma_acc_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" tran : 0x%p\n", pinfo.port_tran);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" dip : 0x%p\n", pinfo.port_dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" reset_notify_listf: 0x%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfo.port_reset_notify_listf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" event_defs : 0x%p\n", pinfo.port_ndi_event_defs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" event_hdl : 0x%p\n", pinfo.port_ndi_event_hdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" events : 0x%p\n", pinfo.port_ndi_events);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" tgt_hash_table : 0x%p\n", pinfo.port_tgt_hash_table);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" mpxio : %d\n", pinfo.port_mpxio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville cmds walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecmds_walk_i(mdb_walk_state_t *wsp)
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 a fcp_lun, so read it to get the fcp_pkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&lun, sizeof (struct fcp_lun), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_lun)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the fcp_lun structure address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(lun.lun_pkt_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_pkt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecmds_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
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 fcp_pkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_pkt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_pkt *)wsp->walk_data)->cmd_forw);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecmds_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_pkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville luns walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteluns_walk_i(mdb_walk_state_t *wsp)
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 a fcp_tgt, so read it to get the fcp_lun
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&tgt, sizeof (struct fcp_tgt), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_tgt)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the fcp_tgt structure address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(tgt.tgt_lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_lun), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteluns_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
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 fcp_lun),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_pkt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_lun *)wsp->walk_data)->lun_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteluns_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_lun));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville targets walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetargets_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Can not perform global walk\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_port, so read it to get the port_tgt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * table's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fcp_port), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the port structure address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_hash_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tgt_hash_index < FCP_NUM_HASH)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_hash_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(port.port_tgt_hash_table[tgt_hash_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_tgt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetargets_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((wsp->walk_addr == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tgt_hash_index >= (FCP_NUM_HASH - 1))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fcp_tgt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_tgt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_tgt *)wsp->walk_data)->tgt_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate the next hash list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_hash_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tgt_hash_index < FCP_NUM_HASH)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_hash_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tgt_hash_index == FCP_NUM_HASH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* You're done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(port.port_tgt_hash_table[tgt_hash_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetargets_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_tgt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp_ipkt walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteipkt_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("The address of a fcp_port"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_port, so read it to get the ipkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fcp_port), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the fcp_port"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " at 0x%p\n", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(port.port_ipkt_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_ipkt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteipkt_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
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 fcp_ipkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the fcp_ipkt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " at 0x%p\n", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_ipkt *)wsp->walk_data)->ipkt_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteipkt_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_ipkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp_pkt walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepkt_walk_i(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("The address of a fcp_port"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be an fcp_port, so read it to get the pkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fcp_port), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the fcp_port"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " at 0x%p\n", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(port.port_pkt_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_pkt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepkt_walk_s(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
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 fcp_pkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the fcp_pkt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " at 0x%p\n", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_pkt *)wsp->walk_data)->cmd_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepkt_walk_f(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_pkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDB module linkage information:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We declare a list of structures describing our dcmds, a list of structures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * describing our walkers, and a function named _mdb_init to return a pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to our module information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_dcmd_t dcmds[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcp", NULL, "Leadville fcp instances", fcp },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_walker_t walkers[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcp", "Walk list of Leadville fcp instances",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcp_walk_i, fcp_walk_s, fcp_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "cmds", "Walk list of SCSI commands in fcp's per-lun queue",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmds_walk_i, cmds_walk_s, cmds_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "luns", "Walk list of LUNs in an fcp target",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte luns_walk_i, luns_walk_s, luns_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "targets", "Walk list of fcp targets attached to the local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targets_walk_i, targets_walk_s, targets_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcp_ipkt", "Walk list of internal packets queued on a local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipkt_walk_i, ipkt_walk_s, ipkt_walk_f},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcp_pkt", "Walk list of packets queued on a local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_walk_i, pkt_walk_s, pkt_walk_f},
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}