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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FCP mdb module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "fcp_port_head") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_port), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fcp_port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_port at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_port *)wsp->walk_data)->port_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_port));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For each port, we just need to read the fc_fca_port_t struct, read
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the port_handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&pinfo, sizeof (struct fcp_port), addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
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(" 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 "%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 "%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(" 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(" 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(" 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 * Leadville cmds walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_lun, so read it to get the fcp_pkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
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 wsp->walk_data = mdb_alloc(sizeof (struct fcp_pkt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fcp_pkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_pkt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_pkt *)wsp->walk_data)->cmd_forw);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_pkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville luns walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_tgt, so read it to get the fcp_lun
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
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 wsp->walk_data = mdb_alloc(sizeof (struct fcp_lun), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fcp_lun),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_pkt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_lun *)wsp->walk_data)->lun_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_lun));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville targets walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_port, so read it to get the port_tgt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * table's head
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 while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(port.port_tgt_hash_table[tgt_hash_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fcp_tgt), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fcp_tgt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fcp_tgt at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_tgt *)wsp->walk_data)->tgt_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate the next hash list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* You're done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(port.port_tgt_hash_table[tgt_hash_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_tgt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp_ipkt walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fcp_port, so read it to get the ipkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fcp_port), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
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 if (mdb_vread(wsp->walk_data, sizeof (struct fcp_ipkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_ipkt *)wsp->walk_data)->ipkt_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_ipkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fcp_pkt walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be an fcp_port, so read it to get the pkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (struct fcp_port), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct fcp_port)) {
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 if (mdb_vread(wsp->walk_data, sizeof (struct fcp_pkt),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fcp_pkt *)wsp->walk_data)->cmd_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct fcp_pkt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDB module linkage information:
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 { "cmds", "Walk list of SCSI commands in fcp's per-lun queue",
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 { "fcp_pkt", "Walk list of packets queued on a local port",