a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER START
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * The contents of this file are subject to the terms of the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Common Development and Distribution License (the "License").
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You may not use this file except in compliance with the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * See the License for the specific language governing permissions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * and limitations under the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * When distributing Covered Code, include this CDDL HEADER in each
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If applicable, add the following below this CDDL HEADER, with the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * fields enclosed by brackets "[]" replaced with your own identifying
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * information: Portions Copyright [yyyy] [name of copyright owner]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER END
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States#define IDM_CN_NOTIFY_STRINGS
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#include <iscsi.h>
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * We want to be able to print multiple levels of object hierarchy with a
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * single dcmd information, and preferably also exclude intermediate
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * levels if desired. For example some of the target objects have the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * following relationship:
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * target --> session --> connection --> task
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * The session dcmd should allow the printing of all associated tasks for the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * sessions without printing all the associated connections. To accomplish
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * this the following structure contains a bit for each object type. Dcmds
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * should invoke the functions for child objects if any bits are set
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * in iscsi_dcmd_ctrl_t but the functions for the child object should only
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * print data if their associated bit is set. Each object type should print
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * a header for its first occurrence or if it is being printed as a child
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * object for the first occurrence under each parent. For the model to follow
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * see how idc->idc_header is handled in iscsi_sess_impl.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Each dcmd should provide an external interface with the standard MDB API
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * and an internal interface that accepts iscsi_dcmd_ctrl_t. To display
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * child objects the dcmd calls the internal interface for the child object
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * directly. Dcmds invoked from the command line will, of course, call the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * external interface. See iscsi_conn() and iscsi_conn_impl().
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlaptypedef struct {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Our connection dcmd code works off the global connection lists
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * in IDM since we want to know about connections even when they
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * have not progressed to the point that they have an associated
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * session. If we use "::iscsi_sess [-c]" then we only want to
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * see connections associated with particular session. To avoid
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * writing a separate set of code to print session-specific connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * the session code should set the sessions kernel address in the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * following field. The connection code will then only print
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * connections that match.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_walk_all_sess(iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_walk_all_conn(iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tgt_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tpgt_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tpg_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_portal_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_sess_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_conn_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_buffer_walk_cb(uintptr_t addr, const void *list_walker_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_svc_walk_cb(uintptr_t addr, const void *list_walker_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_hba_walk_cb(uintptr_t addr, const void *vhba,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_sess_walk_cb(uintptr_t addr, const void *vsess,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_conn_walk_cb(uintptr_t addr, const void *vconn,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_lun_walk_cb(uintptr_t addr, const void *vlun,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_cmd_walk_cb(uintptr_t addr, const void *vcmd,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tgt_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tpgt_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_tpg_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_portal_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_sess_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_conn_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic void iscsi_print_iscsit_conn_data(idm_conn_t *ict);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic void iscsi_print_ini_conn_data(idm_conn_t *ict);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic void iscsi_print_idm_conn_data(idm_conn_t *ict);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_task_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic void iscsi_print_iscsit_task_data(idm_task_t *idt);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_buffer_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic idm_conn_type_t idm_conn_type(uintptr_t addr);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_i_task_impl(idm_task_t *idt, uintptr_t addr,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_isns(uintptr_t addr, uint_t flags, int argc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_svc_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_hba_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_print_ini_sess(uintptr_t addr, iscsi_sess_t *sess,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_print_ini_lun(uintptr_t addr, const iscsi_lun_t *lun,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_print_ini_cmd(uintptr_t addr, const iscsi_cmd_t *cmd,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_sess_walk_init(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_sess_step(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_conn_walk_init(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_conn_step(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_lun_walk_init(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_lun_step(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_cmd_walk_init(mdb_walk_state_t *wsp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gillstatic int iscsi_ini_cmd_step(mdb_walk_state_t *wsp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_idm_conn_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_tgt_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_sess_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_login_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_cmd_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_sess_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_idm_conn_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_idm_task_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_tgt_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_sess_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsit_login_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_cmd_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_sess_state(unsigned int state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_conn_state(unsigned int state);
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United Statesstatic const char *iscsi_iscsi_conn_event(unsigned int event);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_iscsi_login_state(unsigned int state);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic void iscsi_format_timestamp(char *ts_str, int strlen,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic char *iscsi_inet_ntop(int af, const void *addr, char *buf, int addrlen);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic void convert2ascii(char *, const in6_addr_t *);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int sa_to_str(struct sockaddr_storage *sa, char *addr);
e42a0851889d583925aa3bd2d9bd139189031cb0peter dunlapstatic int iscsi_isns_esi_cb(uintptr_t addr, const void *walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int iscsi_isns_portal_cb(uintptr_t addr, const void *walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * ::iscsi_tgt [-scatgpbSRv]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_tgt - Print out information associated with an iscsit target instance
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * s Print associated session information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * c Print associated connection information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * a Print IP addresses with connection information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * t Print associated task information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * g Print associated TPG information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * p Print portals with TPG information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * b Print associated buffer information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * S Print recent state events and transitions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * R Print reference count audit data
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * v Verbose output about the connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tgt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap uintptr_t iscsit_global_addr, avl_addr, list_addr;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If no address was specified on the command line, we
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * print out all tgtions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("failed to find symbol 'iscsit_global'");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_tgt_walk_cb, &idc, avl_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("avl walk failed for global target tree");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap offsetof(iscsit_global_t, global_deleted_target_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for deleted target list");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tpg(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Always print tpgs and portals */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If no address was specified on the command line, we
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * print out all tgtions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("failed to find symbol 'iscsit_global'");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_tpg_walk_cb, &idc, avl_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("avl walk failed for global target tree");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_tpgt [-pR]
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Print tpgt information.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * R Print reference count audit data
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * p Print portal data
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_tpgt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill uintptr_t iscsit_global_addr, avl_addr, list_addr;
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If no address was specified on the command line,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * print out all tpgts
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to find symbol 'iscsit_global'");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("avl", iscsi_tgt_walk_cb, &idc, avl_addr) == -1) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("avl walk failed for global target tree");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill offsetof(iscsit_global_t, global_deleted_target_list);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("list walk failed for deleted target list");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_sess [-ablmtvcSRIT]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_sess - Print out information associated with an iSCSI session
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * I Print only initiator sessions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * T Print only target sessions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * c Print associated connection information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * a Print IP addresses with connection information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * t Print associated task information
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * l Print associated lun information (with -I)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * m Print associated initiator command information (with -I)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * b Print associated buffer information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * S Print recent state events and transitions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * R Print reference count audit data
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * v Verbose output about the connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_sess(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap int buffer = 0, task = 0, conn = 0, print_ip = 0;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If no address was specified on the command line, we
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * print out all sessions
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_conn [-abmtvSRIT]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_conn - Print out information associated with an iSCSI connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * I Print only initiator connections
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * T Print only target connections
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * a Print IP addresses with connection information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * t Print associated task information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * b Print associated buffer information
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * m Print associated initiator commands (with -I)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * S Print recent state events and transitions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * R Print reference count audit data
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * v Verbose output about the connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_conn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If no address was specified on the command line, we
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * print out all connections
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_svc [-vR]
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * iscsi_svc - Print out information associated with an iSCSI svc
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * R Print reference count audit data
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * v Verbose output about the service
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_svc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill svc_list_addr = idm_addr + offsetof(idm_global_t,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_portal -R
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * iscsi_portal - Print out information associated with an iSCSI portal
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * R Print reference count audit data
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_portal(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to find symbol 'iscsit_global'");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* get and print the global default tpg */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(&iscsit_global, sizeof (iscsit_global_t),
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill iscsit_global_addr) != sizeof (iscsit_global_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (iscsi_tpg_impl((uintptr_t)iscsit_global.global_default_tpg,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Walk the tpgs for the rest of the portals */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill tpg_avl_addr = iscsit_global_addr + offsetof(iscsit_global_t,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("list walk failed for global tpg tree");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * ::iscsi_cmd -S
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * iscsi_cmd - Print out information associated with an iSCSI cmd
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * S Print state audit data
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_cmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_hba", iscsi_ini_hba_walk_cb,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(&cmd, sizeof (iscsi_cmd_t), addr) !=
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_hba_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(&ih, sizeof (ih), addr) != sizeof (ih)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_sess", iscsi_ini_sess_walk_cb, idc,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * ::iscsi_task [-bv]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_task - Print out information associated with an iSCSI task
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * b Print associated buffer information
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * S Print recent state events and transitions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * R Print reference count audit data
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * v Verbose output about the connection
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_task(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If no address was specified on the command line, we
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * print out all connections
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * ::iscsi_refcnt
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_refcnt - Dump an idm_refcnt_t structure
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_refcnt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * ::iscsi_states
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsi_states - Dump events and state transitions recoreded in an
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * idm_sm_audit_t structure
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_states(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /* Initiator sessions */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Always print hba info on this path */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_hba", iscsi_ini_hba_walk_cb,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /* Target sessions */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk discovery sessions */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("failed to find symbol 'iscsit_global'");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap offsetof(iscsit_global_t, global_discovery_sessions);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_sess_walk_cb, idc, avl_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("avl walk failed for discovery sessions");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk targets printing all session info */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_tgt_walk_cb, idc, avl_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("avl walk failed for target/session tree");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk deleting targets printing all session info */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap offsetof(iscsit_global_t, global_deleted_target_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_tgt_walk_cb, idc, list_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for deleted target list");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk initiator connections */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk connection list associated with the initiator */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap list_addr = idm_global_addr + offsetof(idm_global_t, idm_ini_conn_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_conn_walk_cb, idc, list_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for initiator connections");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk connection list associated with the target */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap list_addr = idm_global_addr + offsetof(idm_global_t, idm_tgt_conn_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_conn_walk_cb, idc, list_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for target service instances");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tpg_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tgt_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tpgt_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_portal_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_sess_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_sess_conn_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * This function is different from iscsi_conn_walk_cb because
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * we get an iscsit_conn_t instead of an idm_conn_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_conn_t, use to get idm_conn_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&ict, sizeof (iscsit_conn_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap rc = iscsi_conn_impl((uintptr_t)ict.ict_ic, idc);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_conn_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_buffer_walk_cb(uintptr_t addr, const void *list_walker_data,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* We don't particularly care about the list walker data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return ((rc == DCMD_OK) ? WALK_NEXT : WALK_ERR);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_svc_walk_cb(uintptr_t addr, const void *list_walker_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_hba_walk_cb(uintptr_t addr, const void *vhba,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_sess_walk_cb(uintptr_t addr, const void *vsess, void *idc_void)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill rc = iscsi_print_ini_sess(addr, (iscsi_sess_t *)vsess,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_conn_walk_cb(uintptr_t addr, const void *vconn, void *idc_void)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Look up the idm_conn_t in the iscsi_conn_t and call the general
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * connection handler.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_lun_walk_cb(uintptr_t addr, const void *vlun, void *idc_void)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill rc = iscsi_print_ini_lun(addr, (iscsi_lun_t *)vlun,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tgt_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_tgt_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&tgt, sizeof (iscsit_tgt_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read target name if available
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Brief output
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tgt_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tgt_t.target_stmf_state
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tgt_t.target_sess_list.avl_numnodes (session count)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* For now we will ignore the verbose flag */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print target data */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Indent and disable verbose for any child structures */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print states if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap states_addr = addr + offsetof(iscsit_tgt_t, target_state_audit);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("State History(target_state_audit):\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (iscsi_sm_audit_impl(states_addr) != DCMD_OK)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print refcnt audit data if requested
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Reference History(target_sess_refcnt):\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Reference History(target_refcnt):\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Any child objects to walk? */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_tpgt || idc->u.child.idc_portal) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk TPGT tree */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_sess || idc->u.child.idc_conn ||
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill idc->u.child.idc_task || idc->u.child.idc_buffer) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_tgt || idc->u.child.idc_tpgt ||
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk sess tree */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap avl_addr = addr + offsetof(iscsit_tgt_t, target_sess_list);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If tgts were handled decrease indent and reset header */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tpgt_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_tpgt_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&tpgt, sizeof (iscsit_tpgt_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_tpg_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&tpg, sizeof (iscsit_tpg_t), tpg_addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Brief output
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tpgt_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tpg_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* For now we will ignore the verbose flag */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print target data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "iscsit_tpgt_t", "iscsit_tpg_t", "Name", "Tag");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%?p %?p %-18s 0x%04x\n", addr, tpgt.tpgt_tpg,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill rc_addr = addr + offsetof(iscsit_tpgt_t, tpgt_refcnt);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Assume for now that anyone interested in TPGT wants to see the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * portals as well. Enable idc_header for the portals.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap avl_addr = tpg_addr + offsetof(iscsit_tpg_t, tpg_portal_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_portal_walk_cb, idc, avl_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_tpg_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_tpg_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&tpg, sizeof (iscsit_tpg_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Brief output
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tpgt_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_tpg_t pointer
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Print tpg data */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill rc_addr = addr + offsetof(iscsit_tpg_t, tpg_refcnt);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill avl_addr = addr + offsetof(iscsit_tpg_t, tpg_portal_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_portal_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_portal_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&portal, sizeof (iscsit_portal_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print portal data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%?p %?p %s\n", addr, portal.portal_svc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill portal.portal_default ? "(Default)" : portal_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Reference History(portal_refcnt):\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_sess_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (iscsi_print_ini_sess(addr, &ini_sess, idc) != DCMD_OK) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read iscsit_sess_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&ist, sizeof (iscsit_sess_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Brief output
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_sess_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_sess_t.ist_state/iscsit_sess_t.ist_ffp_conn_count
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_sess_t.ist_tsih
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * iscsit_sess_t.ist_initiator_name
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read initiator name if available
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read target name if available
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%16s: %02x%02x%02x%02x%02x%02x\n", "ISID",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ist.ist_isid[0], ist.ist_isid[1], ist.ist_isid[2],
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ist.ist_isid[3], ist.ist_isid[4], ist.ist_isid[5]);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print session data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%?p %4d/%-4d %02x%02x%02x%02x%02x%02x "
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ist.ist_isid[0], ist.ist_isid[1], ist.ist_isid[2],
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ist.ist_isid[3], ist.ist_isid[4], ist.ist_isid[5],
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Indent for any child structures
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print states if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap states_addr = addr + offsetof(iscsit_sess_t, ist_state_audit);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (iscsi_sm_audit_impl(states_addr) != DCMD_OK)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print state history for child objects */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print refcnt audit data if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print audit data for child objects */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Any child objects to walk? */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (idc->u.child.idc_conn || idc->u.child.idc_task ||
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If a session has been printed enable headers for
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * any child structs.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk conn list */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap list_addr = addr + offsetof(iscsit_sess_t, ist_conn_list);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_sess_conn_walk_cb, idc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If a session was handled decrease indent and reset header. */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_print_ini_sess(uintptr_t addr, iscsi_sess_t *sess,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("%22s: %p\n", "Completion Queue Head",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("%22s: %p\n", "Connnection List Head",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Indent for any child structures */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("State History(sess_state_audit):\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (iscsi_sm_audit_impl(states_addr) != DCMD_OK) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_lun && sess->sess_lun_list) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_lun", iscsi_ini_lun_walk_cb, idc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If requested print the cmds in the session queue */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If any other structs printed enable header */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_sess || idc->u.child.idc_lun) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_cmd", iscsi_ini_cmd_walk_cb,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_cmd", iscsi_ini_cmd_walk_cb,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill idc, (uintptr_t)sess->sess_queue_completion.head)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If connections or cmds requested walk the connections */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_conn || idc->u.child.idc_cmd) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If idc_conn is not set don't enable header or the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * commands may get extraneous headers.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_pwalk("iscsi_ini_conn", iscsi_ini_conn_walk_cb, idc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* If sessions were handled decrease indent and reset header */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_conn_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap uintptr_t idm_global_addr, states_addr, rc_addr;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Get pointer to task table
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap idm_global_addr + offsetof(idm_global_t, idm_taskid_table)) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("Failed to read address of task table");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read idm_conn_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&ic, sizeof (idm_conn_t), addr) != sizeof (idm_conn_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If filter bits are set to only print targets or only initiators
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * skip entries of the other type.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill ((idc->idc_ini && (ic.ic_conn_type != CONN_TYPE_INI)) ||
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (idc->idc_tgt && (ic.ic_conn_type != CONN_TYPE_TGT)))) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap conn_type = (ic.ic_conn_type == CONN_TYPE_INI) ? "Ini" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (ic.ic_conn_type == CONN_TYPE_TGT) ? "Tgt" : "Unk";
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Brief output
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * idm_conn_t pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * idm_conn_t.ic_conn_type
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * idm_conn_t.ic_statet+idm_conn_t.ic_ffp
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If targets(-T) and/or initiators (-I) are specifically requested,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * fetch the iscsit_conn_t and/or iscsi_conn_t struct as a sanity
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * check and for use below.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "handle data\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "connection handle data\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print connection data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%?p %-6s %-10s %6d/%-6d\n", addr, conn_type,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Indent for any child structs */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print states if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap states_addr = addr + offsetof(idm_conn_t, ic_state_audit);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (iscsi_sm_audit_impl(states_addr) != DCMD_OK)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If targets are specifically requested show the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * state audit for the target specific connection struct
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (iscsi_sm_audit_impl(states_addr) != DCMD_OK) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If initiators are specifically requested show the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * state audit for the initiator specific connection struct
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "conn_state_audit):\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (iscsi_sm_audit_impl(states_addr) != DCMD_OK) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print state history for child objects */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Print refcnt audit data for the connection struct if requested.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap rc_addr = addr + offsetof(idm_conn_t, ic_refcnt);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If targets are specifically requested show the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Refcounts for the target specific connection struct
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Reference History(ict_dispatch_refcnt):\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print audit data for child objects */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (idc->u.child.idc_task || idc->u.child.idc_buffer) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read the next idm_task_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&idt, sizeof (idm_task_t), task_addr)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap != sizeof (idm_task_t)) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "task tree");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->idc_ini && IDM_CONN_ISINI(&ic) && idc->u.child.idc_cmd) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (idc->u.child.idc_conn || idc->u.child.idc_task) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (mdb_pwalk("iscsi_ini_cmd", iscsi_ini_cmd_walk_cb, idc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)ini_conn.conn_queue_active.head) == -1)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (mdb_pwalk("iscsi_ini_cmd", iscsi_ini_cmd_walk_cb, idc,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)ini_conn.conn_queue_idm_aborting.head) == -1)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * If connection information was handled unset header and
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * decrease indent
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_svc_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "(iser_svc is_refcnt):\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Sanity check the iser svc struct */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (uintptr_t)ic->ic_handle) != sizeof (iscsit_conn_t)) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("**Failed to read conn private data\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (ict.ict_login_sm.icl_login_state != ILS_LOGIN_DONE) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (ict.ict_login_sm.icl_login_state == ILS_LOGIN_ERROR) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: 0x%04x\n", "CID", ict.ict_cid);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: 0x%08x\n", "StatSN", ict.ict_statsn);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)ic->ic_handle) != sizeof (iscsi_conn_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Failed to read conn private data\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ((ic->ic_conn_type == CONN_TYPE_TGT) ? "Target" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ((ic->ic_conn_type == CONN_TYPE_INI) ? "Initiator" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "Unknown")));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (ic->ic_transport_type == IDM_TRANSPORT_TYPE_ISER) ? "ISER_IB" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (ic->ic_transport_type == IDM_TRANSPORT_TYPE_SOCKETS) ? "SOCKETS" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (ic->ic_refcnt.ir_waiting == REF_NOWAIT) ? "" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ((ic->ic_refcnt.ir_waiting == REF_WAIT_SYNC) ? "REF_WAIT_SYNC" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ((ic->ic_refcnt.ir_waiting == REF_WAIT_ASYNC) ? "REF_WAIT_ASYNC" :
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "UNKNOWN")));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_i_task_impl(idm_task_t *idt, uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap conn_type = idm_conn_type((uintptr_t)idt->idt_ic);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print task data */
bf604c6405d5cbc4e94e3d0ecc9e6e074ed4ea67Peter Dunlap "%<u>%-?s %-16s %-4s %-8s %-8s%</u>\n",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print states if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap states_addr = addr + offsetof(idm_task_t, idt_state_audit);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (iscsi_sm_audit_impl(states_addr) != DCMD_OK)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print state history for child objects */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print refcnt audit data if requested
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Don't print audit data for child objects */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Buffers are leaf objects and always get headers so the
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * user can discern between in and out buffers.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk in buffer list */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap list_addr = addr + offsetof(idm_task_t, idt_inbufv);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_buffer_walk_cb, idc, list_addr) ==
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for task in buffers");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Walk out buffer list */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap list_addr = addr + offsetof(idm_task_t, idt_outbufv);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_buffer_walk_cb, idc, list_addr) ==
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("list walk failed for task out buffers\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_task_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read idm_conn_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&idt, sizeof (idm_task_t), addr) != sizeof (idm_task_t)) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (uintptr_t)idt->idt_private) != sizeof (iscsit_task_t)) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("**Failed to read idt_private data\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&scsi_task, sizeof (scsi_task_t),
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (uintptr_t)itask.it_stmf_task) != sizeof (scsi_task_t)) {
bf604c6405d5cbc4e94e3d0ecc9e6e074ed4ea67Peter Dunlap mdb_printf("%20s: %d/%d\n", "STMF abort/IDM aborted",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap itask.it_stmf_task, good_scsi_task ? scsi_task.task_lu_private : 0,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: %02x %02x %02x %02x %02x %02x %02x %02x\n",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "LU number",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap scsi_task.task_lun_no[0], scsi_task.task_lun_no[1],
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap scsi_task.task_lun_no[2], scsi_task.task_lun_no[3],
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap scsi_task.task_lun_no[4], scsi_task.task_lun_no[5],
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap scsi_task.task_lun_no[6], scsi_task.task_lun_no[7]);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: %d/%d\n", "STMF cur/max bufs",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: 0x%08x/0x%08x/0x%08x\n", "Bytes Exp/Cmd/Done",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: 0x%x/0x%x\n", "TX-ini start/done",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%20s: 0x%x/0x%x\n", "RX-ini start/done",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_print_ini_lun(uintptr_t addr, const iscsi_lun_t *lun,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_print_ini_cmd(uintptr_t addr, const iscsi_cmd_t *cmd,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("%<u>%-?s %-?s %4s %6s/%-6s %-?s%</u>\n",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill addr, cmd->cmd_itp, cmd->cmd_type, cmd->cmd_state,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Print states if requested
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill states_addr = addr + offsetof(iscsi_cmd_t, cmd_state_audit);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_buffer_impl(uintptr_t addr, iscsi_dcmd_ctrl_t *idc)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Read idm_buf_t
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&idb, sizeof (idm_buf_t), addr) != sizeof (idm_buf_t)) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%<u>%-?s %?s/%-8s %8s %8s %8s%</u>\n",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Print buffer data */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("%?p %?p/%08x %8x %8x %08x\n", addr,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Buffers are leaf objects */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print refcnt info
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&refcnt, sizeof (idm_refcnt_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap MDB_SYM_FUZZY, c, sizeof (c),
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap MDB_SYM_FUZZY, c, sizeof (c),
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Print refcnt info
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&audit_buf, sizeof (sm_audit_buf_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap audit_buf.sab_index &= audit_buf.sab_max_index;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap sar = audit_buf.sab_records + audit_buf.sab_index;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap iscsi_format_timestamp(ts_string, 40, &sar->sar_timestamp);
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States case SAS_ISCSI_CONN:
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States state_name =
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States iscsi_iscsi_conn_state(sar->sar_state);
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States event_name=
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States iscsi_iscsi_conn_event(sar->sar_event);
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States break;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "New State", new_state_name, sar->sar_new_state);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap audit_buf.sab_index &= audit_buf.sab_max_index;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((event < CE_MAX_EVENT) ? idm_ce_name[event] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((event < TE_MAX_EVENT) ? iscsit_te_name[event] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((event < SE_MAX_EVENT) ? iscsit_se_name[event] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((event < ILE_MAX_EVENT) ? iscsit_ile_name[event] : "N/A");
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < CS_MAX_STATE) ? idm_cs_name[state] : "N/A");
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United Statesstatic const char *
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United Statesiscsi_iscsi_conn_event(unsigned int event)
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States{
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States return ((event < CN_MAX) ? idm_cn_strings[event] : "N/A");
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States}
5f7d09c6770c7413ed11bfa981c6d50666ca0f4dPeter Cudhea - Sun Microsystems - Burlington, MA United States
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ("N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < TS_MAX_STATE) ? iscsit_ts_name[state] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < SS_MAX_STATE) ? iscsit_ss_name[state] : "N/A");
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < ILS_MAX_STATE) ? iscsit_ils_name[state] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < ISCSI_CONN_STATE_MAX) ? iscsi_ics_name[state] : "N/A");
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap return ((state < LOGIN_MAX) ? iscsi_login_state_names[state] : "N/A");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Retrieve connection type given a kernel address
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap idm_conn_type_addr = addr + offsetof(idm_conn_t, ic_conn_type);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) mdb_vread(&result, sizeof (result), idm_conn_type_addr);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Convert a sockaddr to the string representation, suitable for
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * storing in an nvlist or printing out in a list.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapsa_to_str(struct sockaddr_storage *sa, char *buf)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return (-1);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_nhconvert(&port, &sin->sin_port, sizeof (uint16_t));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap return (-1);
c89a15d415257cb029ed5e5efc36d64a60667972Richard Lowe mdb_nhconvert(&port, &sin6->sin6_port, sizeof (uint16_t));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_snprintf(pbuf, sizeof (pbuf), ":%u", port);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_format_timestamp(char *ts_str, int strlen, timespec_t *ts)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_snprintf(ts_str, strlen, "%Y:%03d:%03d:%03d", ts->tv_sec,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (ts->tv_nsec / 1000000) % 1000, (ts->tv_nsec / 1000) % 1000,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Help information for the iscsi_isns dcmd
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("-s: Print iSNS server information\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("-v: Add verbosity to the other options' output\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("-R: Add Refcount information to '-t' output\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_isns_esi_cb(uintptr_t addr, const void *walker_data, void *data)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&tinfo, sizeof (isns_esi_tinfo_t), addr) !=
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("ESI thread/thr did : 0x%p / %d\n", tinfo.esi_thread,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("ESI sonode : 0x%p\n", tinfo.esi_so);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_isns_portal_cb(uintptr_t addr, const void *walker_data, void *data)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap iscsi_dcmd_ctrl_t *idc = (iscsi_dcmd_ctrl_t *)data;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States isns_portal_t portal;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_vread(&portal, sizeof (isns_portal_t), addr) !=
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States sizeof (isns_portal_t)) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (portal.portal_default == B_TRUE) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (portal.portal_iscsit != NULL) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("(Part of TPG: 0x%p)\n", portal.portal_iscsit);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States }
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States iscsi_format_timestamp(ts_string, 40, &portal.portal_esi_timestamp);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Portal ESI timestamp: %s\n\n", ts_string);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if ((portal.portal_iscsit != NULL) && (idc->idc_verbose)) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_inc_indent(4);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap iscsi_portal_impl((uintptr_t)portal.portal_iscsit, idc);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_dec_indent(4);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("All Active Portals:\n");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_lookup_by_name("isns_all_portals", &sym) == -1) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_warn("failed to find symbol 'isns_all_portals'");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States return (DCMD_ERR);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States }
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States portal_list = (uintptr_t)sym.st_value;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States idc->idc_header = 1;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_pwalk("avl", iscsi_isns_portal_cb, idc, portal_list) == -1) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_warn("avl walk failed for isns_all_portals");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States return (DCMD_ERR);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States }
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("\nPortals from TPGs:\n");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_lookup_by_name("isns_tpg_portals", &sym) == -1) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_warn("failed to find symbol 'isns_tpg_portals'");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_pwalk("avl", iscsi_isns_portal_cb, idc, portal_list) == -1) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_warn("avl walk failed for isns_tpg_portals");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_isns_targets_cb(uintptr_t addr, const void *walker_data, void *data)
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States iscsi_dcmd_ctrl_t *idc = (iscsi_dcmd_ctrl_t *)data;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States isns_target_t itarget;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States int rc = 0;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&itarget, sizeof (isns_target_t), addr) !=
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Target: %p\n", addr);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Update needed: %s\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States (itarget.target_update_needed) ? "Yes" : "No");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Target Info: %p\n", itarget.target_info);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Prevent target refcounts from showing through this path */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap rc = iscsi_tgt_impl((uintptr_t)itarget.target, idc);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_printf("Reference History(isns_target_info ti_refcnt):\n");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_lookup_by_name("isns_target_list", &sym) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("failed to find symbol 'isns_target_list'");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("avl", iscsi_isns_targets_cb, idc,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("avl walk failed for isns_target_list");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_isns_servers_cb(uintptr_t addr, const void *walker_data, void *data)
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States iscsi_dcmd_ctrl_t *idc = (iscsi_dcmd_ctrl_t *)data;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States uintptr_t avl_addr;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_vread(&server, sizeof (iscsit_isns_svr_t), addr) !=
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("ESI Interval: %d seconds\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States server.svr_esi_interval);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Last message: %d seconds ago\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Retry Count: %d\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States server.svr_retry_count);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Targets Changes Pending: %s\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States (server.svr_targets_changed) ? "Yes" : "No");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Delete Pending: %s\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States (server.svr_delete_needed) ? "Yes" : "No");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_printf("Replace-All Needed: %s\n",
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States (server.svr_reset_needed) ? "Yes" : "No");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (idc->idc_verbose) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States idc->idc_header = 1;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States idc->u.child.idc_tgt = 1;
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_inc_indent(2);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States avl_addr = addr + offsetof(iscsit_isns_svr_t,
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States svr_target_list);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States if (mdb_pwalk("avl", iscsi_isns_targets_cb, idc,
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States avl_addr) == -1) {
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_warn("avl walk failed for svr_target_list");
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States return (WALK_ERR);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States }
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States mdb_dec_indent(2);
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States }
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States
bdbe8dc662f9700c12eafcbcceb5c724615278cfPeter Cudhea - Sun Microsystems - Burlington, MA United States return (WALK_NEXT);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_lookup_by_name("iscsit_global", &sym) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_warn("failed to find symbol 'iscsit_global'");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap offsetof(iscsit_global_t, global_isns_cfg.isns_svrs);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (mdb_pwalk("list", iscsi_isns_servers_cb, idc, list_addr) == -1) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapiscsi_isns(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap int portals = 0, esi = 0, targets = 0, verbose = 0, servers = 0;
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("Only one of e, p, s, and t must be provided");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if ((esi | portals | targets | servers) == 0) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_printf("Exactly one of e, p, s, or t must be provided");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("<iscsi_sess_t addr>::walk iscsi_ini_sess");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill wsp->walk_data = mdb_alloc(sizeof (iscsi_sess_t), UM_SLEEP|UM_GC);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(wsp->walk_data, sizeof (iscsi_sess_t), wsp->walk_addr)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill != sizeof (iscsi_sess_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to read iscsi_sess_t at %p", wsp->walk_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)(((iscsi_sess_t *)wsp->walk_data)->sess_next);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("<iscsi_conn_t addr>::walk iscsi_ini_conn");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill wsp->walk_data = mdb_alloc(sizeof (iscsi_conn_t), UM_SLEEP|UM_GC);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(wsp->walk_data, sizeof (iscsi_conn_t), wsp->walk_addr)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill != sizeof (iscsi_conn_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to read iscsi_conn_t at %p", wsp->walk_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)(((iscsi_conn_t *)wsp->walk_data)->conn_next);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("<iscsi_lun_t addr>::walk iscsi_ini_lun");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill wsp->walk_data = mdb_alloc(sizeof (iscsi_lun_t), UM_SLEEP|UM_GC);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(wsp->walk_data, sizeof (iscsi_lun_t), wsp->walk_addr)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill != sizeof (iscsi_lun_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to read iscsi_lun_t at %p", wsp->walk_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)(((iscsi_lun_t *)wsp->walk_data)->lun_next);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("<iscsi_cmd_t addr>::walk iscsi_ini_cmd");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill wsp->walk_data = mdb_alloc(sizeof (iscsi_cmd_t), UM_SLEEP|UM_GC);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(wsp->walk_data, sizeof (iscsi_cmd_t), wsp->walk_addr)
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill != sizeof (iscsi_cmd_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to read iscsi_cmd_t at %p", wsp->walk_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)(((iscsi_cmd_t *)wsp->walk_data)->cmd_next);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gilliscsi_ini_cmd_walk_cb(uintptr_t addr, const void *vcmd,
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("unable to allocate storage for iscsi_ini_hba walk");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("iscsi_ini_hba only supports global walk");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Read in the array and setup the walk struct.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_readvar(&state_addr, "iscsi_state") == -1) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("state variable iscsi_state not found.\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill ss = (struct i_ddi_soft_state *)mdb_alloc(sizeof (*ss),
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(ss, sizeof (*ss), state_addr) != sizeof (*ss)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "(Invalid pointer?).\n");
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Where to get the data */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Where to put the data */
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill hwi->array = mdb_alloc(array_size, UM_SLEEP|UM_GC);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill if (mdb_vread(hwi->array, array_size, array_addr) !=
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill idm_hba_walk_info_t *hwi = (idm_hba_walk_info_t *)wsp->walk_data;
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill for (; hwi->cur_element < hwi->n_elements; hwi->cur_element++) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill hwi->data = (iscsi_hba_t *)mdb_alloc(sizeof (iscsi_hba_t),
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill (uintptr_t)hwi->array[hwi->cur_element]) != sizeof (iscsi_hba_t)) {
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill mdb_warn("failed to read iscsi_sess_t at %p", wsp->walk_addr);
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill status = wsp->walk_callback((uintptr_t)hwi->array[hwi->cur_element],
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill /* Increment cur_element for next iteration */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iscsi_inet_ntop -- Convert an IPv4 or IPv6 address in binary form into
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * printable form, and return a pointer to that string. Caller should
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * provide a buffer of correct length to store string into.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Note: this routine is kernel version of inet_ntop. It has similar
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * format as iscsi_inet_ntop() defined in rfc2553. But it does not do
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * error handling operations exactly as rfc2553 defines. This function
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * is used by kernel inet directory routines only for debugging.
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * This iscsi_inet_ntop() function, does not return NULL if third argument
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * is NULL. The reason is simple that we don't want kernel to panic
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * as the output of this function is directly fed to ip<n>dbg macro.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Instead it uses a local buffer for destination address for
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * those calls which purposely pass NULL ptr for the destination
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * buffer. This function is thread-safe when the caller passes a non-
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * null buffer with the third argument.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapiscsi_inet_ntop(int af, const void *addr, char *buf, int addrlen)
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * We don't allow thread unsafe iscsi_inet_ntop calls, they
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * must pass a non-null buffer pointer. For DEBUG mode
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * we use the ASSERT() and for non-debug kernel it will
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * silently allow it for now. Someday we should remove
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * the static buffer from this function.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Let user know politely not to send NULL or unaligned addr */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "%03d.%03d.%03d.%03d",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap UC(v4addr[0]), UC(v4addr[1]), UC(v4addr[2]), UC(v4addr[3]));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "::ffff:%d.%d.%d.%d",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "::%d.%d.%d.%d",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) mdb_snprintf(buf, INET6_ADDRSTRLEN, "::");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * v6 formats supported
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * General format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * The short hand notation :: is used for COMPAT addr
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Other forms : fe80::xxxx:xxxx:xxxx:xxxx
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapconvert2ascii(char *buf, const in6_addr_t *addr)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* tempbuf must be big enough to hold ffff:\0 */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* First count if trailing zeroes higher in number */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap for (hexdigits = 0; hexdigits < 8; hexdigits++) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if (tail_zero > head_zero && (head_zero + tail_zero) != 7)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap for (hexdigits = 0; hexdigits < 8; hexdigits++) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* if entry is a 0 */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * address starts with 0s ..
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * stick in leading ':' of pair
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* add another */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap mdb_nhconvert(&out_addr_component, addr_component,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) mdb_snprintf(tempbuf, 6, "%x:", out_addr_component);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * MDB module linkage information:
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * We declare a list of structures describing our dcmds, a list of structures
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * describing our walkers and a function named _mdb_init to return a pointer
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * to our module information.
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "iSCSI target portal group tag information", iscsi_tpgt },
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "iSCSI target portal group information", iscsi_tpg },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "print audit informtion for idm_refcnt_t", iscsi_refcnt },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "dump events and state transitions recorded in an\t"
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap "\t\tidm_sm_audit_t structure", iscsi_states },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "print iscsit iSNS information", iscsi_isns, iscsi_isns_help },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "iSCSI command information (initiator only)", iscsi_cmd },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill * Basic walkers for the initiator linked lists
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill { "iscsi_ini_hba", "global walk of the initiator iscsi_hba_t "
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill "list", iscsi_ini_hba_walk_init, iscsi_ini_hba_step, NULL},
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill { "iscsi_ini_sess", "walk list of initiator iscsi_sess_t structures",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill iscsi_ini_sess_walk_init, iscsi_ini_sess_step, NULL },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill { "iscsi_ini_conn", "walk list of initiator iscsi_conn_t structures",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill iscsi_ini_conn_walk_init, iscsi_ini_conn_step, NULL },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill { "iscsi_ini_lun", "walk list of initiator iscsi_lun_t structures",
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill iscsi_ini_lun_walk_init, iscsi_ini_lun_step, NULL },
5819f75e225cf93d9c11f52e04ee71c2dcd0eca9Peter Gill { "iscsi_ini_cmd", "walk list of initiator iscsi_cmd_t structures",