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
585995d5d19489bf178112c08c8c61ffc049ff6eYu Renia Miao * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we #include <string.h> then other definitions fail. This is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the easiest way of getting access to the function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *strtok(char *string, const char *sepset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* we need 26 bytes for the cftime() call */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* for backward compatibility */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville port walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize the fc_fca_port_t walker by either using the given starting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * address, or reading the value of the kernel's fctl_fca_portlist pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We also allocate a fc_fca_port_t for storage, and save this using the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walk_data pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "fctl_fca_portlist") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (fc_fca_port_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At each step, read a fc_fca_port_t into our private storage, and then invoke
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the callback function. We terminate when we reach a NULL p_next pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (fc_fca_port_t), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fc_fca_port_t at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((fc_fca_port_t *)wsp->walk_data)->port_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk. Since we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dynamically allocated a fc_fca_port_t in port_walk_i, we must free it now.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (fc_fca_port_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteports(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'l', MDB_OPT_SETBITS, TRUE, &longlist) != argc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is the first invocation of the command, print a nice
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * header line for the output that will follow.
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(&portlist, sizeof (fc_fca_port_t), addr) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now read that port in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (fc_local_port_t), (uintptr_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portlist.port_handle) == sizeof (fc_local_port_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read port info at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville ULP walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "fctl_ulp_list") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (fc_ulp_list_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (fc_ulp_list_t), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fctl_ulp_list %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((fc_ulp_list_t *)wsp->walk_data)->ulp_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (fc_ulp_list_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteulps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If no fc_ulp_list_t address was specified on the command line, we can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * print out all processes by invoking the walker, using this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dcmd itself as the callback.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("ulps", "ulps", argc, argv) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is the first invocation of the command, print a nice
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * header line for the output that will follow.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%30s %4s %8s\n", "ULP Name", "Type", "Revision");
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(&ulplist, sizeof (fc_ulp_list_t), addr) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now read that port in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)ulplist.ulp_info) == sizeof (fc_ulp_modinfo_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville ULP module walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "fctl_ulp_modules") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (fc_ulp_module_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (fc_ulp_module_t), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fctl_ulp_modules %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((fc_ulp_module_t *)wsp->walk_data)->mod_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (fc_ulp_module_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteulpmods(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("ulpmods", "ulpmods", argc, argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is the first invocation of the command, print a nice
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * header line for the output that will follow.
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(&modlist, sizeof (fc_ulp_module_t), addr) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now read that module info in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&modinfo, sizeof (fc_ulp_modinfo_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)modlist.mod_info) == sizeof (fc_ulp_modinfo_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now read all the ports for this module */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&ulp_port, sizeof (fc_ulp_ports_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display an fc_local_port_t struct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("Sorry, you must provide an address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must read the fc_fca_portlist to get the fc_local_port addr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&portlist, sizeof (fc_fca_port_t), addr) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("Reading fc_local_port_t at %p:\n", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For each port, we just need to read the fc_local_port_t struct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_state : 0x%-8x\n", port.fp_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_fca_handle : 0x%p\n", port.fp_fca_handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_fca_tran : 0x%p\n", port.fp_fca_tran);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_job_head : 0x%p\n", port.fp_job_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_job_tail : 0x%p\n", port.fp_job_tail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_wait_head : 0x%p\n", port.fp_wait_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_wait_tail : 0x%p\n", port.fp_wait_tail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_topology : %u\n", port.fp_topology);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_last_task : %d\n", port.fp_last_task);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_port_num : %d\n", port.fp_port_num);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_instance : %d\n", port.fp_instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_ulp_attach : %d\n", port.fp_ulp_attach);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_dev_count : %d\n", port.fp_dev_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_total_devices : %d\n", port.fp_total_devices);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_options : 0x%-8x\n", port.fp_options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_ub_count : %d\n", port.fp_ub_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_active_ubs : %d\n", port.fp_active_ubs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_port_dip : 0x%p\n", port.fp_port_dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_fca_dip : 0x%p\n", port.fp_fca_dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ":%-2x:%-2x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_pm_level : %d\n", port.fp_pm_level);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_pm_busy : %d\n", port.fp_pm_busy);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" fp_rscn_count : %d\n", port.fp_rscn_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fc_local_port_t at 0x%p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville remote_port walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to be given the address of a port structure in order to start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walking. From that, we can read the pwwn table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("pd_by_pwwn walk doesn't support global walks\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate space for the pwwn_hash table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fp_pwwn_table = mdb_alloc(sizeof (struct pwwn_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be an fc_local_port_t, so read it to get the pwwn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * table's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (fc_local_port_t), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the port structure address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(fp_pwwn_table, sizeof (struct pwwn_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PWWN_HASH_TABLE_SIZE, (uintptr_t)port.fp_pwwn_table) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the pwwn hash table\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fp_pwwn_table[pd_hash_index].pwwn_head == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)fp_pwwn_table[pd_hash_index].pwwn_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (fc_remote_port_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At each step, read a fc_remote_port_t into our private storage, and then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke the callback function. We terminate when we reach a NULL p_next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (fc_remote_port_t), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fc_remote_port at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((fc_remote_port_t *)wsp->walk_data)->pd_wwn_hnext);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try the next hash list, if there is one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fp_pwwn_table[pd_hash_index].pwwn_head == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We're done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)fp_pwwn_table[pd_hash_index].pwwn_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (fc_remote_port_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(fp_pwwn_table, sizeof (struct pwwn_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the same walker as pd_by_pwwn, but we walk the D_ID hash table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("pd_by_did walk doesn't support global walks\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate space for the did_hash table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fp_did_table = mdb_alloc(sizeof (struct d_id_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be an fc_local_port_t, so read it to get the d_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * table's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (fc_local_port_t), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the port structure address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(fp_did_table, sizeof (struct d_id_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_ID_HASH_TABLE_SIZE, (uintptr_t)port.fp_did_table) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Unable to read in the D_ID hash table\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fp_did_table[pd_hash_index].d_id_head == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)fp_did_table[pd_hash_index].d_id_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (fc_remote_port_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At each step, read a fc_remote_port_t into our private storage, and then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke the callback function. We terminate when we reach a NULL p_next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (fc_remote_port_t), wsp->walk_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read fc_remote_port at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((fc_remote_port_t *)wsp->walk_data)->pd_did_hnext);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try the next hash list, if there is one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fp_did_table[pd_hash_index].d_id_head == NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We're done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)fp_did_table[pd_hash_index].d_id_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The walker's fini function is invoked at the end of each walk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (fc_remote_port_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(fp_did_table, sizeof (struct d_id_hash) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display a remote_port structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremote_port(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("Sorry, you must provide an address\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&pd, sizeof (fc_remote_port_t), addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("Reading remote_port at 0x%p\n", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port_id : 0x%-8x\n", pd.pd_port_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" port_name : 0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd.pd_port_name.raw_wwn[0], pd.pd_port_name.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd.pd_port_name.raw_wwn[2], pd.pd_port_name.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd.pd_port_name.raw_wwn[4], pd.pd_port_name.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd.pd_port_name.raw_wwn[6], pd.pd_port_name.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" login_count : %d\n", pd.pd_login_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" remote node : 0x%p\n", pd.pd_remote_nodep);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" hard_addr : 0x%x\n", pd.pd_hard_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" login_class : 0x%x\n", pd.pd_login_class);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" recipient : %d\n", pd.pd_recepient);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" ref_count : %d\n", pd.pd_ref_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" aux_flags : 0x%x ", pd.pd_aux_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" active : %d\n", pd.pd_logo_tc.active);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" counter : %d\n", pd.pd_logo_tc.counter);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" max_value : %d\n", pd.pd_logo_tc.max_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(" timer : %d\n", pd.pd_logo_tc.timer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefc_dump_logmsg(fc_trace_dmsg_t *addr, uint_t pktstart, uint_t pktend,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&msg, sizeof (msg), (uintptr_t)addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read message pointer in kernel");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " in kernel");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "the buffer\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* funky packet processing stuff */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find the equals sign, and put a null there */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pktnum >= pktstart) && (pktnum <= pktend)) {
585995d5d19489bf178112c08c8c61ffc049ff6eYu Renia Miao "[%Y:%03d:%03d:%03d] %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefc_dump_old_logmsg(fc_trace_dmsgv1_t *addr, uint_t pktstart, uint_t pktend,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&msg, sizeof (msg), (uintptr_t)addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read message pointer in kernel");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " in kernel");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "the buffer\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* funky packet processing stuff */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pktnum >= pktstart) && (pktnum <= pktend)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefc_trace_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t printed = 0; /* have we printed anything? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&logq, sizeof (logq), addr) != sizeof (logq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = fc_dump_logmsg((fc_trace_dmsg_t *)logq.il_msgh, pktstart,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = fc_dump_old_logmsg((fc_trace_dmsgv1_t *)logq.il_msgh,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " criteria given");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefp_trace_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefcp_trace_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville job_request walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to be given the address of a local port structure in order to start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walking. From that, we can read the job_request list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fc_local_port_t, so read it to get the job_request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (fc_local_port_t), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct job_request), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct job_request),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the job_request at 0x%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct job_request *)wsp->walk_data)->job_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 job_request));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Leadville fc_orphan walker/dcmd code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to be given the address of a port structure in order to start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walking. From that, we can read the orphan list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " structure must be given\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input should be a fc_local_port_t, so read it to get the orphan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lists's head
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&port, sizeof (fc_local_port_t), wsp->walk_addr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(port.fp_orphan_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_alloc(sizeof (struct fc_orphan), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (struct fc_orphan),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("Failed to read in the fc_orphan at 0x%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)(((struct fc_orphan *)wsp->walk_data)->orp_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 fc_orphan));
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 { "ports", "[-l]", "Leadville port list", ports },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ulpmods", NULL, "Leadville ULP module list", ulpmods },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcport", NULL, "Display a Leadville fc_local_port structure",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "remote_port", NULL, "Display fc_remote_port structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fcptrace", "[-s m][-e n] (m < n)", "Dump the fcp trace buffer, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "optionally supplying starting and ending packet numbers.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fptrace", "[-s m][-e n] (m < n)", "Dump the fp trace buffer, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "optionally supplying starting and ending packet numbers.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ports", "walk list of Leadville port structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ulps", "walk list of Leadville ULP structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ulpmods", "walk list of Leadville ULP module structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "pd_by_pwwn", "walk list of fc_remote_port structures hashed by PWWN",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd_by_pwwn_walk_i, pd_by_pwwn_walk_s, pd_by_pwwn_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "pd_by_did", "walk list of fc_remote_port structures hashed by D_ID",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pd_by_did_walk_i, pd_by_did_walk_s, pd_by_did_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "job_request", "walk list of job_request structures for a local port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte job_request_walk_i, job_request_walk_s, job_request_walk_f },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "orphan", "walk list of orphan structures for a local port",