17836SJohn.Forte@Sun.COM /* 27836SJohn.Forte@Sun.COM * CDDL HEADER START 37836SJohn.Forte@Sun.COM * 47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 77836SJohn.Forte@Sun.COM * 87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 117836SJohn.Forte@Sun.COM * and limitations under the License. 127836SJohn.Forte@Sun.COM * 137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187836SJohn.Forte@Sun.COM * 197836SJohn.Forte@Sun.COM * CDDL HEADER END 207836SJohn.Forte@Sun.COM */ 217836SJohn.Forte@Sun.COM 22*9156SDaniel.Beauregard@Sun.COM /* Copyright 2009 QLogic Corporation */ 237836SJohn.Forte@Sun.COM 247836SJohn.Forte@Sun.COM /* 257836SJohn.Forte@Sun.COM * ISP2xxx Solaris Fibre Channel Adapter (FCA) qlc mdb source file. 267836SJohn.Forte@Sun.COM * 277836SJohn.Forte@Sun.COM * *********************************************************************** 287836SJohn.Forte@Sun.COM * * ** 297836SJohn.Forte@Sun.COM * * NOTICE ** 30*9156SDaniel.Beauregard@Sun.COM * * COPYRIGHT (C) 1996-2009 QLOGIC CORPORATION ** 317836SJohn.Forte@Sun.COM * * ALL RIGHTS RESERVED ** 327836SJohn.Forte@Sun.COM * * ** 337836SJohn.Forte@Sun.COM * *********************************************************************** 347836SJohn.Forte@Sun.COM * 357836SJohn.Forte@Sun.COM */ 367836SJohn.Forte@Sun.COM 37*9156SDaniel.Beauregard@Sun.COM #pragma ident "Copyright 2009 QLogic Corporation; ql_mdb.c" 387836SJohn.Forte@Sun.COM 397836SJohn.Forte@Sun.COM #include <sys/mdb_modapi.h> 40*9156SDaniel.Beauregard@Sun.COM #include <ql_apps.h> 41*9156SDaniel.Beauregard@Sun.COM #include <ql_api.h> 42*9156SDaniel.Beauregard@Sun.COM #include <ql_init.h> 43*9156SDaniel.Beauregard@Sun.COM #include <ql_debug.h> 447836SJohn.Forte@Sun.COM 457836SJohn.Forte@Sun.COM /* 467836SJohn.Forte@Sun.COM * local prototypes 477836SJohn.Forte@Sun.COM */ 487836SJohn.Forte@Sun.COM static int32_t ql_doprint(uintptr_t, int8_t *); 497836SJohn.Forte@Sun.COM static void ql_dump_flags(uint64_t, int8_t **); 507836SJohn.Forte@Sun.COM static int qlclinks_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 517836SJohn.Forte@Sun.COM static int qlcstate_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 527836SJohn.Forte@Sun.COM static int qlc_osc_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 53*9156SDaniel.Beauregard@Sun.COM static int qlc_wdog_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 54*9156SDaniel.Beauregard@Sun.COM static int qlc_getdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 55*9156SDaniel.Beauregard@Sun.COM static int qlc_gettrace_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 56*9156SDaniel.Beauregard@Sun.COM #if 0 57*9156SDaniel.Beauregard@Sun.COM static int qlc_triggerdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 58*9156SDaniel.Beauregard@Sun.COM #endif 597836SJohn.Forte@Sun.COM static int qlcver_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 607836SJohn.Forte@Sun.COM static int qlstates_walk_init(mdb_walk_state_t *); 617836SJohn.Forte@Sun.COM static int qlstates_walk_step(mdb_walk_state_t *); 627836SJohn.Forte@Sun.COM static void qlstates_walk_fini(mdb_walk_state_t *); 637836SJohn.Forte@Sun.COM static int qlsrb_walk_init(mdb_walk_state_t *); 647836SJohn.Forte@Sun.COM static int qlsrb_walk_step(mdb_walk_state_t *); 657836SJohn.Forte@Sun.COM static void qlsrb_walk_fini(mdb_walk_state_t *); 667836SJohn.Forte@Sun.COM static int get_next_link(ql_link_t *); 677836SJohn.Forte@Sun.COM static int get_first_link(ql_head_t *, ql_link_t *); 687836SJohn.Forte@Sun.COM 697836SJohn.Forte@Sun.COM static int ql_24xx_dump_dcmd(ql_adapter_state_t *, uint_t, int, 707836SJohn.Forte@Sun.COM const mdb_arg_t *); 717836SJohn.Forte@Sun.COM static int ql_23xx_dump_dcmd(ql_adapter_state_t *, uint_t, int, 727836SJohn.Forte@Sun.COM const mdb_arg_t *); 737836SJohn.Forte@Sun.COM static int ql_25xx_dump_dcmd(ql_adapter_state_t *, uint_t, int, 747836SJohn.Forte@Sun.COM const mdb_arg_t *); 757836SJohn.Forte@Sun.COM static void ql_elog_common(ql_adapter_state_t *, boolean_t); 767836SJohn.Forte@Sun.COM 777836SJohn.Forte@Sun.COM /* 787836SJohn.Forte@Sun.COM * local adapter state flags strings 797836SJohn.Forte@Sun.COM */ 807836SJohn.Forte@Sun.COM int8_t *adapter_state_flags[] = { 817836SJohn.Forte@Sun.COM "FCA_BOUND", 827836SJohn.Forte@Sun.COM "QL_OPENED", 837836SJohn.Forte@Sun.COM "ONLINE", 847836SJohn.Forte@Sun.COM "INTERRUPTS_ENABLED", 85*9156SDaniel.Beauregard@Sun.COM "ABORT_CMDS_LOOP_DOWN_TMO", 867836SJohn.Forte@Sun.COM "POINT_TO_POINT", 877836SJohn.Forte@Sun.COM "IP_ENABLED", 887836SJohn.Forte@Sun.COM "IP_INITIALIZED", 897836SJohn.Forte@Sun.COM "TARGET_MODE_INITIALIZED", 907836SJohn.Forte@Sun.COM "ADAPTER_SUSPENDED", 917836SJohn.Forte@Sun.COM "ADAPTER_TIMER_BUSY", 927836SJohn.Forte@Sun.COM "PARITY_ERROR", 937836SJohn.Forte@Sun.COM "FLASH_ERRLOG_MARKER", 947836SJohn.Forte@Sun.COM "VP_ENABLED", 957836SJohn.Forte@Sun.COM "FDISC_ENABLED", 967836SJohn.Forte@Sun.COM "MENLO_LOGIN_OPERATIONAL", 977836SJohn.Forte@Sun.COM NULL 987836SJohn.Forte@Sun.COM }; 997836SJohn.Forte@Sun.COM 1007836SJohn.Forte@Sun.COM int8_t *adapter_config_flags[] = { 1017836SJohn.Forte@Sun.COM "ENABLE_HARD_ADDRESS", 1027836SJohn.Forte@Sun.COM "ENABLE_64BIT_ADDRESSING", 1037836SJohn.Forte@Sun.COM "ENABLE_LIP_RESET", 1047836SJohn.Forte@Sun.COM "ENABLE_FULL_LIP_LOGIN", 1057836SJohn.Forte@Sun.COM "ENABLE_TARGET_RESET", 1067836SJohn.Forte@Sun.COM "ENABLE_LINK_DOWN_REPORTING", 1077836SJohn.Forte@Sun.COM "ENABLE_TARGET_MODE", 1087836SJohn.Forte@Sun.COM "ENABLE_FCP_2_SUPPORT", 1097836SJohn.Forte@Sun.COM "MULTI_CHIP_ADAPTER", 1107836SJohn.Forte@Sun.COM "SBUS_CARD", 1117836SJohn.Forte@Sun.COM "CTRL_2300", 1127836SJohn.Forte@Sun.COM "CTRL_6322", 1137836SJohn.Forte@Sun.COM "CTRL_2200", 1147836SJohn.Forte@Sun.COM "CTRL_2422", 1157836SJohn.Forte@Sun.COM "CTRL_25XX", 1167836SJohn.Forte@Sun.COM "ENABLE_EXTENDED_LOGGING", 1177836SJohn.Forte@Sun.COM "DISABLE_RISC_CODE_LOAD", 1187836SJohn.Forte@Sun.COM "SET_CACHE_LINE_SIZE_1", 1197836SJohn.Forte@Sun.COM "TARGET_MODE_ENABLE", 1207836SJohn.Forte@Sun.COM "EXT_FW_INTERFACE", 1217836SJohn.Forte@Sun.COM "LOAD_FLASH_FW", 1227836SJohn.Forte@Sun.COM "DUMP_MAILBOX_TIMEOUT", 1237836SJohn.Forte@Sun.COM "DUMP_ISP_SYSTEM_ERROR", 1247836SJohn.Forte@Sun.COM "DUMP_DRIVER_COMMAND_TIMEOUT", 1257836SJohn.Forte@Sun.COM "DUMP_LOOP_OFFLINE_TIMEOUT", 1267836SJohn.Forte@Sun.COM "ENABLE_FWEXTTRACE", 1277836SJohn.Forte@Sun.COM "ENABLE_FWFCETRACE", 1287836SJohn.Forte@Sun.COM "FW_MISMATCH", 1297836SJohn.Forte@Sun.COM "CTRL_MENLO", 130*9156SDaniel.Beauregard@Sun.COM "DISABLE_EXTENDED_LOGGING_TRACE", 1317836SJohn.Forte@Sun.COM NULL 1327836SJohn.Forte@Sun.COM }; 1337836SJohn.Forte@Sun.COM 1347836SJohn.Forte@Sun.COM /* 1357836SJohn.Forte@Sun.COM * local task daemon flags strings 1367836SJohn.Forte@Sun.COM */ 1377836SJohn.Forte@Sun.COM int8_t *task_daemon_flags[] = { 1387836SJohn.Forte@Sun.COM "TASK_DAEMON_STOP_FLG", 1397836SJohn.Forte@Sun.COM "TASK_DAEMON_SLEEPING_FLG", 1407836SJohn.Forte@Sun.COM "TASK_DAEMON_ALIVE_FLG", 1417836SJohn.Forte@Sun.COM "TASK_DAEMON_IDLE_CHK_FLG", 1427836SJohn.Forte@Sun.COM "SUSPENDED_WAKEUP_FLG", 1437836SJohn.Forte@Sun.COM "FC_STATE_CHANGE", 1447836SJohn.Forte@Sun.COM "NEED_UNSOLICITED_BUFFERS", 1457836SJohn.Forte@Sun.COM "RESET_MARKER_NEEDED", 1467836SJohn.Forte@Sun.COM "RESET_ACTIVE", 1477836SJohn.Forte@Sun.COM "ISP_ABORT_NEEDED", 1487836SJohn.Forte@Sun.COM "ABORT_ISP_ACTIVE", 1497836SJohn.Forte@Sun.COM "LOOP_RESYNC_NEEDED", 1507836SJohn.Forte@Sun.COM "LOOP_RESYNC_ACTIVE", 1517836SJohn.Forte@Sun.COM "LOOP_DOWN", 1527836SJohn.Forte@Sun.COM "DRIVER_STALL", 1537836SJohn.Forte@Sun.COM "COMMAND_WAIT_NEEDED", 1547836SJohn.Forte@Sun.COM "COMMAND_WAIT_ACTIVE", 1557836SJohn.Forte@Sun.COM "STATE_ONLINE", 1567836SJohn.Forte@Sun.COM "ABORT_QUEUES_NEEDED", 1577836SJohn.Forte@Sun.COM "TASK_DAEMON_STALLED_FLG", 1587836SJohn.Forte@Sun.COM "TASK_THREAD_CALLED", 1597836SJohn.Forte@Sun.COM "FIRMWARE_UP", 1607836SJohn.Forte@Sun.COM "LIP_RESET_PENDING", 1617836SJohn.Forte@Sun.COM "FIRMWARE_LOADED", 1627836SJohn.Forte@Sun.COM "RSCN_UPDATE_NEEDED", 1637836SJohn.Forte@Sun.COM "HANDLE_PORT_BYPASS_CHANGE", 1647836SJohn.Forte@Sun.COM "PORT_RETRY_NEEDED", 1657836SJohn.Forte@Sun.COM "TASK_DAEMON_POWERING_DOWN", 1667836SJohn.Forte@Sun.COM "TD_IIDMA_NEEDED", 1677836SJohn.Forte@Sun.COM NULL 1687836SJohn.Forte@Sun.COM }; 1697836SJohn.Forte@Sun.COM 1707836SJohn.Forte@Sun.COM /* 1717836SJohn.Forte@Sun.COM * local interrupt aif flags 1727836SJohn.Forte@Sun.COM */ 1737836SJohn.Forte@Sun.COM int8_t *aif_flags[] = { 1747836SJohn.Forte@Sun.COM "IFLG_INTR_LEGACY", 1757836SJohn.Forte@Sun.COM "IFLG_INTR_MSI", 1767836SJohn.Forte@Sun.COM "IFLG_INTR_FIXED", 1777836SJohn.Forte@Sun.COM NULL 1787836SJohn.Forte@Sun.COM }; 1797836SJohn.Forte@Sun.COM 1807836SJohn.Forte@Sun.COM int8_t *qlsrb_flags[] = { 1817836SJohn.Forte@Sun.COM "SRB_ISP_STARTED", 1827836SJohn.Forte@Sun.COM "SRB_ISP_COMPLETED", 1837836SJohn.Forte@Sun.COM "SRB_RETRY", 1847836SJohn.Forte@Sun.COM "SRB_POLL", 1857836SJohn.Forte@Sun.COM "SRB_WATCHDOG_ENABLED", 1867836SJohn.Forte@Sun.COM "SRB_ABORT", 1877836SJohn.Forte@Sun.COM "SRB_UB_IN_FCA", 1887836SJohn.Forte@Sun.COM "SRB_UB_IN_ISP", 1897836SJohn.Forte@Sun.COM "SRB_UB_CALLBACK", 1907836SJohn.Forte@Sun.COM "SRB_UB_RSCN", 1917836SJohn.Forte@Sun.COM "SRB_UB_FCP", 1927836SJohn.Forte@Sun.COM "SRB_FCP_CMD_PKT", 1937836SJohn.Forte@Sun.COM "SRB_FCP_DATA_PKT", 1947836SJohn.Forte@Sun.COM "SRB_FCP_RSP_PKT", 1957836SJohn.Forte@Sun.COM "SRB_IP_PKT", 1967836SJohn.Forte@Sun.COM "SRB_GENERIC_SERVICES_PKT", 1977836SJohn.Forte@Sun.COM "SRB_COMMAND_TIMEOUT", 1987836SJohn.Forte@Sun.COM "SRB_ABORTING", 1997836SJohn.Forte@Sun.COM "SRB_IN_DEVICE_QUEUE", 2007836SJohn.Forte@Sun.COM "SRB_IN_TOKEN_ARRAY", 2017836SJohn.Forte@Sun.COM "SRB_UB_FREE_REQUESTED", 2027836SJohn.Forte@Sun.COM "SRB_UB_ACQUIRED", 2037836SJohn.Forte@Sun.COM "SRB_MS_PKT", 2047836SJohn.Forte@Sun.COM NULL 2057836SJohn.Forte@Sun.COM }; 2067836SJohn.Forte@Sun.COM 2077836SJohn.Forte@Sun.COM int8_t *qllun_flags[] = { 2087836SJohn.Forte@Sun.COM "LQF_UNTAGGED_PENDING", 2097836SJohn.Forte@Sun.COM NULL 2107836SJohn.Forte@Sun.COM }; 2117836SJohn.Forte@Sun.COM 2127836SJohn.Forte@Sun.COM 2137836SJohn.Forte@Sun.COM int8_t *qltgt_flags[] = { 2147836SJohn.Forte@Sun.COM "TQF_TAPE_DEVICE", 2157836SJohn.Forte@Sun.COM "TQF_QUEUE_SUSPENDED", 2167836SJohn.Forte@Sun.COM "TQF_FABRIC_DEVICE", 2177836SJohn.Forte@Sun.COM "TQF_INITIATOR_DEVICE", 2187836SJohn.Forte@Sun.COM "TQF_RSCN_RCVD", 2197836SJohn.Forte@Sun.COM "TQF_NEED_AUTHENTICATION", 2207836SJohn.Forte@Sun.COM "TQF_PLOGI_PROGRS", 2217836SJohn.Forte@Sun.COM "TQF_IIDMA_NEEDED", 2227836SJohn.Forte@Sun.COM NULL 2237836SJohn.Forte@Sun.COM }; 2247836SJohn.Forte@Sun.COM 225*9156SDaniel.Beauregard@Sun.COM int8_t *qldump_flags[] = { 226*9156SDaniel.Beauregard@Sun.COM "QL_DUMPING", 227*9156SDaniel.Beauregard@Sun.COM "QL_DUMP_VALID", 228*9156SDaniel.Beauregard@Sun.COM "QL_DUMP_UPLOADED", 229*9156SDaniel.Beauregard@Sun.COM NULL 230*9156SDaniel.Beauregard@Sun.COM }; 231*9156SDaniel.Beauregard@Sun.COM 2327836SJohn.Forte@Sun.COM /* 2337836SJohn.Forte@Sun.COM * qlclinks_dcmd 2347836SJohn.Forte@Sun.COM * mdb dcmd which prints out the ql_hba pointers 2357836SJohn.Forte@Sun.COM * 2367836SJohn.Forte@Sun.COM * Input: 2377836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 2387836SJohn.Forte@Sun.COM * flags = mdb flags. 2397836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 2407836SJohn.Forte@Sun.COM * argv = Arg array. 2417836SJohn.Forte@Sun.COM * 2427836SJohn.Forte@Sun.COM * Returns: 2437836SJohn.Forte@Sun.COM * DCMD_ERR, DCMD_USAGE, or DCMD_OK 2447836SJohn.Forte@Sun.COM * 2457836SJohn.Forte@Sun.COM * Context: 2467836SJohn.Forte@Sun.COM * User context. 2477836SJohn.Forte@Sun.COM * 2487836SJohn.Forte@Sun.COM */ 2497836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2507836SJohn.Forte@Sun.COM static int 2517836SJohn.Forte@Sun.COM qlclinks_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 2527836SJohn.Forte@Sun.COM { 2537836SJohn.Forte@Sun.COM ql_head_t ql_hba; 2547836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 2557836SJohn.Forte@Sun.COM uintptr_t hbaptr = NULL; 2567836SJohn.Forte@Sun.COM 2577836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc != 0) { 2587836SJohn.Forte@Sun.COM return (DCMD_USAGE); 2597836SJohn.Forte@Sun.COM } 2607836SJohn.Forte@Sun.COM 2617836SJohn.Forte@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 2627836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 2637836SJohn.Forte@Sun.COM return (DCMD_ERR); 2647836SJohn.Forte@Sun.COM } 2657836SJohn.Forte@Sun.COM 2667836SJohn.Forte@Sun.COM if (&ql_hba == NULL) { 2677836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure -- is qlc loaded?"); 2687836SJohn.Forte@Sun.COM return (DCMD_ERR); 2697836SJohn.Forte@Sun.COM } 2707836SJohn.Forte@Sun.COM 2717836SJohn.Forte@Sun.COM mdb_printf("\nqlc adapter state linkages (f=0x%llx, l=0x%llx)\n\n", 2727836SJohn.Forte@Sun.COM ql_hba.first, ql_hba.last); 2737836SJohn.Forte@Sun.COM 2747836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc( 2757836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 2767836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 2777836SJohn.Forte@Sun.COM return (DCMD_OK); 2787836SJohn.Forte@Sun.COM } 2797836SJohn.Forte@Sun.COM 2807836SJohn.Forte@Sun.COM (void) mdb_inc_indent((ulong_t)4); 2817836SJohn.Forte@Sun.COM mdb_printf("%<u>%-?s\t%-45s%</u>\n\n", "baseaddr", "instance"); 2827836SJohn.Forte@Sun.COM 2837836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 2847836SJohn.Forte@Sun.COM while (hbaptr != NULL) { 2857836SJohn.Forte@Sun.COM 2867836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), 2877836SJohn.Forte@Sun.COM hbaptr) == -1) { 2887836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 2897836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 2907836SJohn.Forte@Sun.COM hbaptr); 2917836SJohn.Forte@Sun.COM return (DCMD_OK); 2927836SJohn.Forte@Sun.COM } 2937836SJohn.Forte@Sun.COM 2947836SJohn.Forte@Sun.COM mdb_printf("%<b>0x%016p%t%d%</b>\n", 2957836SJohn.Forte@Sun.COM qlstate->hba.base_address, qlstate->instance); 2967836SJohn.Forte@Sun.COM 2977836SJohn.Forte@Sun.COM /* 2987836SJohn.Forte@Sun.COM * If vp exists, loop through those 2997836SJohn.Forte@Sun.COM */ 3007836SJohn.Forte@Sun.COM 3017836SJohn.Forte@Sun.COM if ((qlstate->flags & VP_ENABLED) && 3027836SJohn.Forte@Sun.COM (qlstate->vp_next != NULL)) { 3037836SJohn.Forte@Sun.COM 3047836SJohn.Forte@Sun.COM ql_adapter_state_t *vqlstate; 3057836SJohn.Forte@Sun.COM uintptr_t vhbaptr = NULL; 3067836SJohn.Forte@Sun.COM 3077836SJohn.Forte@Sun.COM vhbaptr = (uintptr_t)qlstate->vp_next; 3087836SJohn.Forte@Sun.COM 3097836SJohn.Forte@Sun.COM if ((vqlstate = (ql_adapter_state_t *)mdb_alloc( 3107836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 3117836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for " 3127836SJohn.Forte@Sun.COM "ql_adapter_state vp\n"); 3137836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 3147836SJohn.Forte@Sun.COM return (DCMD_OK); 3157836SJohn.Forte@Sun.COM } 3167836SJohn.Forte@Sun.COM 3177836SJohn.Forte@Sun.COM (void) mdb_inc_indent((ulong_t)30); 3187836SJohn.Forte@Sun.COM 3197836SJohn.Forte@Sun.COM mdb_printf("%<u>vp baseaddr\t\tvp index%</u>\n"); 3207836SJohn.Forte@Sun.COM 3217836SJohn.Forte@Sun.COM while (vhbaptr != NULL) { 3227836SJohn.Forte@Sun.COM 3237836SJohn.Forte@Sun.COM if (mdb_vread(vqlstate, 324*9156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), vhbaptr) == 325*9156SDaniel.Beauregard@Sun.COM -1) { 3267836SJohn.Forte@Sun.COM mdb_free(vqlstate, 3277836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t)); 3287836SJohn.Forte@Sun.COM mdb_free(qlstate, 3297836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t)); 3307836SJohn.Forte@Sun.COM mdb_warn("failed to read vp " 3317836SJohn.Forte@Sun.COM "ql_adapter_state at %p", vhbaptr); 3327836SJohn.Forte@Sun.COM return (DCMD_OK); 3337836SJohn.Forte@Sun.COM } 3347836SJohn.Forte@Sun.COM 3357836SJohn.Forte@Sun.COM mdb_printf("%<b>0x%016p%t%d%</b>\n", 3367836SJohn.Forte@Sun.COM vqlstate->hba.base_address, 3377836SJohn.Forte@Sun.COM vqlstate->vp_index); 3387836SJohn.Forte@Sun.COM 3397836SJohn.Forte@Sun.COM vhbaptr = (uintptr_t)vqlstate->vp_next; 3407836SJohn.Forte@Sun.COM } 3417836SJohn.Forte@Sun.COM 3427836SJohn.Forte@Sun.COM mdb_free(vqlstate, sizeof (ql_adapter_state_t)); 3437836SJohn.Forte@Sun.COM 3447836SJohn.Forte@Sun.COM (void) mdb_dec_indent((ulong_t)30); 3457836SJohn.Forte@Sun.COM 3467836SJohn.Forte@Sun.COM mdb_printf("\n"); 3477836SJohn.Forte@Sun.COM } 3487836SJohn.Forte@Sun.COM 3497836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 3507836SJohn.Forte@Sun.COM } 3517836SJohn.Forte@Sun.COM 3527836SJohn.Forte@Sun.COM (void) mdb_dec_indent((ulong_t)4); 3537836SJohn.Forte@Sun.COM 3547836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 3557836SJohn.Forte@Sun.COM 3567836SJohn.Forte@Sun.COM return (DCMD_OK); 3577836SJohn.Forte@Sun.COM } 3587836SJohn.Forte@Sun.COM 3597836SJohn.Forte@Sun.COM /* 3607836SJohn.Forte@Sun.COM * qlcver_dcmd 3617836SJohn.Forte@Sun.COM * mdb dcmd which prints out the qlc driver version the mdb 3627836SJohn.Forte@Sun.COM * module was compiled with, and the verison of qlc which is 3637836SJohn.Forte@Sun.COM * currently loaded on the machine. 3647836SJohn.Forte@Sun.COM * 3657836SJohn.Forte@Sun.COM * Input: 3667836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 3677836SJohn.Forte@Sun.COM * flags = mdb flags. 3687836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 3697836SJohn.Forte@Sun.COM * argv = Arg array. 3707836SJohn.Forte@Sun.COM * 3717836SJohn.Forte@Sun.COM * Returns: 3727836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 3737836SJohn.Forte@Sun.COM * 3747836SJohn.Forte@Sun.COM * Context: 3757836SJohn.Forte@Sun.COM * User context. 3767836SJohn.Forte@Sun.COM * 3777836SJohn.Forte@Sun.COM */ 3787836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3797836SJohn.Forte@Sun.COM static int 3807836SJohn.Forte@Sun.COM qlcver_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 3817836SJohn.Forte@Sun.COM { 382*9156SDaniel.Beauregard@Sun.COM int8_t qlcversion[100]; 383*9156SDaniel.Beauregard@Sun.COM struct fw_table fw_table[10], *fwt = NULL; 384*9156SDaniel.Beauregard@Sun.COM uint8_t *fwverptr = NULL; 385*9156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 386*9156SDaniel.Beauregard@Sun.COM uint32_t found = 0; 3877836SJohn.Forte@Sun.COM 3887836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc != 0) { 3897836SJohn.Forte@Sun.COM return (DCMD_USAGE); 3907836SJohn.Forte@Sun.COM } 3917836SJohn.Forte@Sun.COM 3927836SJohn.Forte@Sun.COM if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) { 3937836SJohn.Forte@Sun.COM mdb_warn("unable to read qlc driver version\n"); 3947836SJohn.Forte@Sun.COM } else { 395*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%s version currently loaded is: %s\n", 3967836SJohn.Forte@Sun.COM QL_NAME, qlcversion); 3977836SJohn.Forte@Sun.COM } 3987836SJohn.Forte@Sun.COM 399*9156SDaniel.Beauregard@Sun.COM mdb_printf("qlc mdb library compiled with %s version: %s\n", 400*9156SDaniel.Beauregard@Sun.COM QL_NAME, QL_VERSION); 401*9156SDaniel.Beauregard@Sun.COM 402*9156SDaniel.Beauregard@Sun.COM if ((fwverptr = (uint8_t *)(mdb_alloc(50, UM_SLEEP))) == NULL) { 403*9156SDaniel.Beauregard@Sun.COM mdb_warn("unable to alloc fwverptr\n"); 404*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 405*9156SDaniel.Beauregard@Sun.COM } 406*9156SDaniel.Beauregard@Sun.COM 407*9156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&fw_table, "fw_table") == -1) { 408*9156SDaniel.Beauregard@Sun.COM mdb_warn("unable to read firmware table\n"); 409*9156SDaniel.Beauregard@Sun.COM } else { 410*9156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *qlstate; 411*9156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 412*9156SDaniel.Beauregard@Sun.COM 413*9156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 414*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 415*9156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 416*9156SDaniel.Beauregard@Sun.COM } 417*9156SDaniel.Beauregard@Sun.COM 418*9156SDaniel.Beauregard@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc( 419*9156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 420*9156SDaniel.Beauregard@Sun.COM mdb_warn("Unable to allocate memory for " 421*9156SDaniel.Beauregard@Sun.COM "ql_adapter_state\n"); 422*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 423*9156SDaniel.Beauregard@Sun.COM } 424*9156SDaniel.Beauregard@Sun.COM 425*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%-8s%-11s%s\n", "f/w", "compiled", "loaded"); 426*9156SDaniel.Beauregard@Sun.COM mdb_printf("%<u>%-8s%-11s%-13s%s%</u>\n\n", "class", "version", 427*9156SDaniel.Beauregard@Sun.COM "version", "instance list"); 428*9156SDaniel.Beauregard@Sun.COM 429*9156SDaniel.Beauregard@Sun.COM for (fwt = &fw_table[0]; fwt->fw_class; fwt++) { 430*9156SDaniel.Beauregard@Sun.COM 431*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(fwverptr, sizeof (void *), 432*9156SDaniel.Beauregard@Sun.COM (uintptr_t)fwt->fw_version) == -1) { 433*9156SDaniel.Beauregard@Sun.COM mdb_warn("unable to read fwverptr\n"); 434*9156SDaniel.Beauregard@Sun.COM mdb_free(fwverptr, sizeof (void *)); 435*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 436*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 437*9156SDaniel.Beauregard@Sun.COM } 438*9156SDaniel.Beauregard@Sun.COM 439*9156SDaniel.Beauregard@Sun.COM mdb_printf("%x\t%-11s", fwt->fw_class, fwverptr); 440*9156SDaniel.Beauregard@Sun.COM 441*9156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 442*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 443*9156SDaniel.Beauregard@Sun.COM hbaptr = NULL; 444*9156SDaniel.Beauregard@Sun.COM } else { 445*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 446*9156SDaniel.Beauregard@Sun.COM } 447*9156SDaniel.Beauregard@Sun.COM 448*9156SDaniel.Beauregard@Sun.COM found = 0; 449*9156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 450*9156SDaniel.Beauregard@Sun.COM 451*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, 452*9156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), hbaptr) == 453*9156SDaniel.Beauregard@Sun.COM -1) { 454*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 455*9156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 456*9156SDaniel.Beauregard@Sun.COM break; 457*9156SDaniel.Beauregard@Sun.COM } 458*9156SDaniel.Beauregard@Sun.COM 459*9156SDaniel.Beauregard@Sun.COM if (qlstate->fw_class == fwt->fw_class) { 460*9156SDaniel.Beauregard@Sun.COM if (found == 0) { 461*9156SDaniel.Beauregard@Sun.COM mdb_printf("%x.%02x.%02x\t", 462*9156SDaniel.Beauregard@Sun.COM qlstate->fw_major_version, 463*9156SDaniel.Beauregard@Sun.COM qlstate->fw_minor_version, 464*9156SDaniel.Beauregard@Sun.COM qlstate-> 465*9156SDaniel.Beauregard@Sun.COM fw_subminor_version); 466*9156SDaniel.Beauregard@Sun.COM mdb_printf("%d", 467*9156SDaniel.Beauregard@Sun.COM qlstate->instance); 468*9156SDaniel.Beauregard@Sun.COM } else { 469*9156SDaniel.Beauregard@Sun.COM mdb_printf(", %d", 470*9156SDaniel.Beauregard@Sun.COM qlstate->instance); 471*9156SDaniel.Beauregard@Sun.COM } 472*9156SDaniel.Beauregard@Sun.COM found = 1; 473*9156SDaniel.Beauregard@Sun.COM } 474*9156SDaniel.Beauregard@Sun.COM 475*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 476*9156SDaniel.Beauregard@Sun.COM } 477*9156SDaniel.Beauregard@Sun.COM 478*9156SDaniel.Beauregard@Sun.COM if (found == 1) { 479*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 480*9156SDaniel.Beauregard@Sun.COM } else { 481*9156SDaniel.Beauregard@Sun.COM mdb_printf("not loaded\n"); 482*9156SDaniel.Beauregard@Sun.COM } 483*9156SDaniel.Beauregard@Sun.COM } 484*9156SDaniel.Beauregard@Sun.COM 485*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 486*9156SDaniel.Beauregard@Sun.COM mdb_free(fwverptr, sizeof (void *)); 487*9156SDaniel.Beauregard@Sun.COM } 488*9156SDaniel.Beauregard@Sun.COM 4897836SJohn.Forte@Sun.COM return (DCMD_OK); 4907836SJohn.Forte@Sun.COM } 4917836SJohn.Forte@Sun.COM 4927836SJohn.Forte@Sun.COM /* 4937836SJohn.Forte@Sun.COM * qlc_el_dcmd 4947836SJohn.Forte@Sun.COM * mdb dcmd which turns the extended logging bit on or off 4957836SJohn.Forte@Sun.COM * for the specificed qlc instance(s). 4967836SJohn.Forte@Sun.COM * 4977836SJohn.Forte@Sun.COM * Input: 4987836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 4997836SJohn.Forte@Sun.COM * flags = mdb flags. 5007836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 5017836SJohn.Forte@Sun.COM * argv = Arg array. 5027836SJohn.Forte@Sun.COM * 5037836SJohn.Forte@Sun.COM * Returns: 5047836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 5057836SJohn.Forte@Sun.COM * 5067836SJohn.Forte@Sun.COM * Context: 5077836SJohn.Forte@Sun.COM * User context. 5087836SJohn.Forte@Sun.COM * 5097836SJohn.Forte@Sun.COM */ 5107836SJohn.Forte@Sun.COM /*ARGSUSED*/ 5117836SJohn.Forte@Sun.COM static int 5127836SJohn.Forte@Sun.COM qlc_el_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 5137836SJohn.Forte@Sun.COM { 5147836SJohn.Forte@Sun.COM int8_t qlcversion[100]; 5157836SJohn.Forte@Sun.COM boolean_t elswitch; 5167836SJohn.Forte@Sun.COM uint32_t argcnt; 5177836SJohn.Forte@Sun.COM int mdbs; 5187836SJohn.Forte@Sun.COM uint32_t instance; 5197836SJohn.Forte@Sun.COM uint32_t qlsize = sizeof (ql_adapter_state_t); 5207836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 5217836SJohn.Forte@Sun.COM uintptr_t hbaptr = NULL; 5227836SJohn.Forte@Sun.COM ql_head_t ql_hba; 5237836SJohn.Forte@Sun.COM 5247836SJohn.Forte@Sun.COM if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) { 5257836SJohn.Forte@Sun.COM mdb_warn("Cannot change core file data (state=%xh)\n", mdbs); 5267836SJohn.Forte@Sun.COM return (DCMD_OK); 5277836SJohn.Forte@Sun.COM } 5287836SJohn.Forte@Sun.COM 5297836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc < 2) { 5307836SJohn.Forte@Sun.COM return (DCMD_USAGE); 5317836SJohn.Forte@Sun.COM } 5327836SJohn.Forte@Sun.COM 5337836SJohn.Forte@Sun.COM /* 5347836SJohn.Forte@Sun.COM * Check and make sure the driver version and the mdb versions 5357836SJohn.Forte@Sun.COM * match so all the structures and flags line up 5367836SJohn.Forte@Sun.COM */ 5377836SJohn.Forte@Sun.COM 5387836SJohn.Forte@Sun.COM if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) { 5397836SJohn.Forte@Sun.COM mdb_warn("unable to read qlc driver version\n"); 5407836SJohn.Forte@Sun.COM return (DCMD_OK); 5417836SJohn.Forte@Sun.COM } 5427836SJohn.Forte@Sun.COM 5437836SJohn.Forte@Sun.COM if ((strcmp(QL_VERSION, (const char *)&qlcversion)) != 0) { 5447836SJohn.Forte@Sun.COM mdb_warn("Error: qlc driver/qlc mdb version mismatch\n"); 5457836SJohn.Forte@Sun.COM mdb_printf("\tqlc mdb library compiled version is: %s\n", 5467836SJohn.Forte@Sun.COM QL_VERSION); 5477836SJohn.Forte@Sun.COM mdb_printf("\tqlc driver version is: %s\n", qlcversion); 5487836SJohn.Forte@Sun.COM 5497836SJohn.Forte@Sun.COM return (DCMD_OK); 5507836SJohn.Forte@Sun.COM } 5517836SJohn.Forte@Sun.COM 5527836SJohn.Forte@Sun.COM if ((strcasecmp(argv[0].a_un.a_str, "on")) == 0) { 5537836SJohn.Forte@Sun.COM elswitch = TRUE; 5547836SJohn.Forte@Sun.COM } else if ((strcasecmp(argv[0].a_un.a_str, "off")) == 0) { 5557836SJohn.Forte@Sun.COM elswitch = FALSE; 5567836SJohn.Forte@Sun.COM } else { 5577836SJohn.Forte@Sun.COM return (DCMD_USAGE); 5587836SJohn.Forte@Sun.COM } 5597836SJohn.Forte@Sun.COM 5607836SJohn.Forte@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 5617836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 5627836SJohn.Forte@Sun.COM return (DCMD_ERR); 5637836SJohn.Forte@Sun.COM } 5647836SJohn.Forte@Sun.COM 5657836SJohn.Forte@Sun.COM if (&ql_hba == NULL) { 5667836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure - is qlc loaded?"); 5677836SJohn.Forte@Sun.COM return (DCMD_ERR); 5687836SJohn.Forte@Sun.COM } 5697836SJohn.Forte@Sun.COM 5707836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize, 5717836SJohn.Forte@Sun.COM UM_SLEEP)) == NULL) { 5727836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for " 5737836SJohn.Forte@Sun.COM "ql_adapter_state\n"); 5747836SJohn.Forte@Sun.COM return (DCMD_OK); 5757836SJohn.Forte@Sun.COM } 5767836SJohn.Forte@Sun.COM 5777836SJohn.Forte@Sun.COM 5787836SJohn.Forte@Sun.COM if ((strcasecmp(argv[1].a_un.a_str, "all")) == 0) { 5797836SJohn.Forte@Sun.COM 5807836SJohn.Forte@Sun.COM if (argc != 2) { 5817836SJohn.Forte@Sun.COM mdb_free(qlstate, qlsize); 5827836SJohn.Forte@Sun.COM return (DCMD_USAGE); 5837836SJohn.Forte@Sun.COM } 5847836SJohn.Forte@Sun.COM 5857836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 5867836SJohn.Forte@Sun.COM 5877836SJohn.Forte@Sun.COM while (hbaptr != NULL) { 5887836SJohn.Forte@Sun.COM 5897836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 5907836SJohn.Forte@Sun.COM mdb_free(qlstate, qlsize); 5917836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state " 5927836SJohn.Forte@Sun.COM "at %p", hbaptr); 5937836SJohn.Forte@Sun.COM return (DCMD_OK); 5947836SJohn.Forte@Sun.COM } 5957836SJohn.Forte@Sun.COM 5967836SJohn.Forte@Sun.COM ql_elog_common(qlstate, elswitch); 5977836SJohn.Forte@Sun.COM 5987836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 5997836SJohn.Forte@Sun.COM } 6007836SJohn.Forte@Sun.COM } else { 6017836SJohn.Forte@Sun.COM for (argcnt = 1; argcnt < argc; argcnt++) { 6027836SJohn.Forte@Sun.COM 6037836SJohn.Forte@Sun.COM instance = (uint32_t)mdb_strtoull( 6047836SJohn.Forte@Sun.COM argv[argcnt].a_un.a_str); 6057836SJohn.Forte@Sun.COM 6067836SJohn.Forte@Sun.COM /* find the correct instance to change */ 6077836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 6087836SJohn.Forte@Sun.COM while (hbaptr != NULL) { 6097836SJohn.Forte@Sun.COM 6107836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 6117836SJohn.Forte@Sun.COM mdb_free(qlstate, qlsize); 612*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 613*9156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 6147836SJohn.Forte@Sun.COM return (DCMD_OK); 6157836SJohn.Forte@Sun.COM } 6167836SJohn.Forte@Sun.COM 6177836SJohn.Forte@Sun.COM if (qlstate->instance == instance) { 6187836SJohn.Forte@Sun.COM break; 6197836SJohn.Forte@Sun.COM } 6207836SJohn.Forte@Sun.COM 6217836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 6227836SJohn.Forte@Sun.COM } 6237836SJohn.Forte@Sun.COM 6247836SJohn.Forte@Sun.COM if (hbaptr == NULL) { 6257836SJohn.Forte@Sun.COM mdb_printf("instance %d is not loaded", 6267836SJohn.Forte@Sun.COM instance); 6277836SJohn.Forte@Sun.COM continue; 6287836SJohn.Forte@Sun.COM } 6297836SJohn.Forte@Sun.COM 6307836SJohn.Forte@Sun.COM ql_elog_common(qlstate, elswitch); 6317836SJohn.Forte@Sun.COM } 6327836SJohn.Forte@Sun.COM } 6337836SJohn.Forte@Sun.COM 6347836SJohn.Forte@Sun.COM mdb_free(qlstate, qlsize); 6357836SJohn.Forte@Sun.COM 6367836SJohn.Forte@Sun.COM return (DCMD_OK); 6377836SJohn.Forte@Sun.COM } 6387836SJohn.Forte@Sun.COM 6397836SJohn.Forte@Sun.COM /* 6407836SJohn.Forte@Sun.COM * qlc_elog_common 6417836SJohn.Forte@Sun.COM * mdb helper function which set/resets the extended logging bit 6427836SJohn.Forte@Sun.COM * 6437836SJohn.Forte@Sun.COM * Input: 6447836SJohn.Forte@Sun.COM * qlstate = adapter state structure 6457836SJohn.Forte@Sun.COM * elswitch = boolean which specifies to reset (0) or set (1) the 6467836SJohn.Forte@Sun.COM * extended logging bit. 6477836SJohn.Forte@Sun.COM * 6487836SJohn.Forte@Sun.COM * Returns: 6497836SJohn.Forte@Sun.COM * 6507836SJohn.Forte@Sun.COM * Context: 6517836SJohn.Forte@Sun.COM * User context. 6527836SJohn.Forte@Sun.COM * 6537836SJohn.Forte@Sun.COM */ 6547836SJohn.Forte@Sun.COM static void 6557836SJohn.Forte@Sun.COM ql_elog_common(ql_adapter_state_t *qlstate, boolean_t elswitch) 6567836SJohn.Forte@Sun.COM { 6577836SJohn.Forte@Sun.COM uintptr_t hbaptr = (uintptr_t)qlstate->hba.base_address; 6587836SJohn.Forte@Sun.COM size_t qlsize = sizeof (ql_adapter_state_t); 6597836SJohn.Forte@Sun.COM 6607836SJohn.Forte@Sun.COM if (elswitch) { 6617836SJohn.Forte@Sun.COM if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) == 0) { 6627836SJohn.Forte@Sun.COM 6637836SJohn.Forte@Sun.COM qlstate->cfg_flags |= CFG_ENABLE_EXTENDED_LOGGING; 6647836SJohn.Forte@Sun.COM 6657836SJohn.Forte@Sun.COM if ((mdb_vwrite((const void *)qlstate, qlsize, 6667836SJohn.Forte@Sun.COM hbaptr)) != (ssize_t)qlsize) { 6677836SJohn.Forte@Sun.COM mdb_warn("instance %d - unable to update", 6687836SJohn.Forte@Sun.COM qlstate->instance); 6697836SJohn.Forte@Sun.COM } else { 6707836SJohn.Forte@Sun.COM mdb_printf("instance %d extended logging is " 6717836SJohn.Forte@Sun.COM "now on\n", qlstate->instance); 6727836SJohn.Forte@Sun.COM } 6737836SJohn.Forte@Sun.COM } else { 6747836SJohn.Forte@Sun.COM mdb_printf("instance %d extended logging is " 6757836SJohn.Forte@Sun.COM "already on\n", qlstate->instance); 6767836SJohn.Forte@Sun.COM } 6777836SJohn.Forte@Sun.COM } else { 6787836SJohn.Forte@Sun.COM if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) != 0) { 6797836SJohn.Forte@Sun.COM 6807836SJohn.Forte@Sun.COM qlstate->cfg_flags &= ~CFG_ENABLE_EXTENDED_LOGGING; 6817836SJohn.Forte@Sun.COM 6827836SJohn.Forte@Sun.COM if ((mdb_vwrite((const void *)qlstate, qlsize, 6837836SJohn.Forte@Sun.COM hbaptr)) != (ssize_t)qlsize) { 6847836SJohn.Forte@Sun.COM mdb_warn("instance %d - unable to update", 6857836SJohn.Forte@Sun.COM qlstate->instance); 6867836SJohn.Forte@Sun.COM } else { 6877836SJohn.Forte@Sun.COM mdb_printf("instance %d extended logging is " 6887836SJohn.Forte@Sun.COM "now off\n", qlstate->instance); 6897836SJohn.Forte@Sun.COM } 6907836SJohn.Forte@Sun.COM } else { 6917836SJohn.Forte@Sun.COM mdb_printf("instance %d extended logging is " 6927836SJohn.Forte@Sun.COM "already off\n", qlstate->instance); 6937836SJohn.Forte@Sun.COM } 6947836SJohn.Forte@Sun.COM } 6957836SJohn.Forte@Sun.COM } 6967836SJohn.Forte@Sun.COM 6977836SJohn.Forte@Sun.COM /* 6987836SJohn.Forte@Sun.COM * qlc_ocs_dcmd 6997836SJohn.Forte@Sun.COM * mdb dcmd which prints out the outstanding command array using 7007836SJohn.Forte@Sun.COM * caller supplied address (which sb the ha structure). 7017836SJohn.Forte@Sun.COM * 7027836SJohn.Forte@Sun.COM * Input: 7037836SJohn.Forte@Sun.COM * addr = User supplied ha address. 7047836SJohn.Forte@Sun.COM * flags = mdb flags. 7057836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 7067836SJohn.Forte@Sun.COM * argv = Arg array. 7077836SJohn.Forte@Sun.COM * 7087836SJohn.Forte@Sun.COM * Returns: 7097836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 7107836SJohn.Forte@Sun.COM * 7117836SJohn.Forte@Sun.COM * Context: 7127836SJohn.Forte@Sun.COM * User context. 7137836SJohn.Forte@Sun.COM * 7147836SJohn.Forte@Sun.COM * 7157836SJohn.Forte@Sun.COM */ 7167836SJohn.Forte@Sun.COM static int 7177836SJohn.Forte@Sun.COM /*ARGSUSED*/ 7187836SJohn.Forte@Sun.COM qlc_osc_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 7197836SJohn.Forte@Sun.COM { 7207836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 7217836SJohn.Forte@Sun.COM uintptr_t qlosc, ptr1; 7227836SJohn.Forte@Sun.COM uint32_t indx, found = 0; 7237836SJohn.Forte@Sun.COM ql_srb_t *qlsrb; 7247836SJohn.Forte@Sun.COM 7257836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) { 7267836SJohn.Forte@Sun.COM return (DCMD_USAGE); 7277836SJohn.Forte@Sun.COM } 7287836SJohn.Forte@Sun.COM 7297836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *) 7307836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 7317836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 7327836SJohn.Forte@Sun.COM return (DCMD_OK); 7337836SJohn.Forte@Sun.COM } 7347836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) { 7357836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 7367836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 7377836SJohn.Forte@Sun.COM return (DCMD_OK); 7387836SJohn.Forte@Sun.COM } 7397836SJohn.Forte@Sun.COM 7407836SJohn.Forte@Sun.COM qlosc = (uintptr_t)qlstate->outstanding_cmds; 7417836SJohn.Forte@Sun.COM mdb_printf("qlc instance: %d, base addr = %llx, osc base = %p\n", 7427836SJohn.Forte@Sun.COM qlstate->instance, qlstate->hba.base_address, qlosc); 7437836SJohn.Forte@Sun.COM 7447836SJohn.Forte@Sun.COM 7457836SJohn.Forte@Sun.COM if ((qlsrb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP)) == 7467836SJohn.Forte@Sun.COM NULL) { 7477836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 7487836SJohn.Forte@Sun.COM mdb_warn("failed to allocate space for srb_t\n"); 7497836SJohn.Forte@Sun.COM return (DCMD_OK); 7507836SJohn.Forte@Sun.COM } 7517836SJohn.Forte@Sun.COM for (indx = 0; indx < MAX_OUTSTANDING_COMMANDS; indx++, qlosc += 8) { 7527836SJohn.Forte@Sun.COM if (mdb_vread(&ptr1, 8, qlosc) == -1) { 7537836SJohn.Forte@Sun.COM mdb_warn("failed to read ptr1, indx=%d", indx); 7547836SJohn.Forte@Sun.COM break; 7557836SJohn.Forte@Sun.COM } 7567836SJohn.Forte@Sun.COM if (ptr1 == 0) { 7577836SJohn.Forte@Sun.COM continue; 7587836SJohn.Forte@Sun.COM } 7597836SJohn.Forte@Sun.COM 7607836SJohn.Forte@Sun.COM mdb_printf("osc ptr = %p, indx = %xh\n", ptr1, indx); 7617836SJohn.Forte@Sun.COM 7627836SJohn.Forte@Sun.COM if (mdb_vread(qlsrb, sizeof (ql_srb_t), ptr1) == -1) { 7637836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t at %p", ptr1); 7647836SJohn.Forte@Sun.COM break; 7657836SJohn.Forte@Sun.COM } 7667836SJohn.Forte@Sun.COM (void) ql_doprint(ptr1, "struct ql_srb"); 7677836SJohn.Forte@Sun.COM found++; 7687836SJohn.Forte@Sun.COM } 7697836SJohn.Forte@Sun.COM 7707836SJohn.Forte@Sun.COM mdb_free(qlsrb, sizeof (ql_srb_t)); 7717836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 7727836SJohn.Forte@Sun.COM 7737836SJohn.Forte@Sun.COM mdb_printf("number of outstanding command srb's is: %d\n", found); 7747836SJohn.Forte@Sun.COM 7757836SJohn.Forte@Sun.COM return (DCMD_OK); 7767836SJohn.Forte@Sun.COM } 7777836SJohn.Forte@Sun.COM 7787836SJohn.Forte@Sun.COM /* 7797836SJohn.Forte@Sun.COM * qlc_wdog_dcmd 7807836SJohn.Forte@Sun.COM * mdb dcmd which prints out the commands which are linked 7817836SJohn.Forte@Sun.COM * on the watchdog linked list. Caller supplied address (which 7827836SJohn.Forte@Sun.COM * sb the ha structure). 7837836SJohn.Forte@Sun.COM * 7847836SJohn.Forte@Sun.COM * Input: 7857836SJohn.Forte@Sun.COM * addr = User supplied ha address. 7867836SJohn.Forte@Sun.COM * flags = mdb flags. 7877836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 7887836SJohn.Forte@Sun.COM * argv = Arg array. 7897836SJohn.Forte@Sun.COM * 7907836SJohn.Forte@Sun.COM * Returns: 7917836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 7927836SJohn.Forte@Sun.COM * 7937836SJohn.Forte@Sun.COM * Context: 7947836SJohn.Forte@Sun.COM * User context. 7957836SJohn.Forte@Sun.COM * 7967836SJohn.Forte@Sun.COM * 7977836SJohn.Forte@Sun.COM */ 7987836SJohn.Forte@Sun.COM static int 7997836SJohn.Forte@Sun.COM /*ARGSUSED*/ 8007836SJohn.Forte@Sun.COM qlc_wdog_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 8017836SJohn.Forte@Sun.COM { 8027836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 8037836SJohn.Forte@Sun.COM uint16_t index, count; 8047836SJohn.Forte@Sun.COM ql_head_t *dev; 8057836SJohn.Forte@Sun.COM ql_srb_t *srb; 8067836SJohn.Forte@Sun.COM ql_tgt_t *tq; 8077836SJohn.Forte@Sun.COM ql_lun_t *lq; 8087836SJohn.Forte@Sun.COM ql_link_t *tqlink, *srblink, *lqlink; 8097836SJohn.Forte@Sun.COM int nextlink; 8107836SJohn.Forte@Sun.COM 8117836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) { 8127836SJohn.Forte@Sun.COM mdb_warn("Address required\n", addr); 8137836SJohn.Forte@Sun.COM return (DCMD_USAGE); 8147836SJohn.Forte@Sun.COM } 8157836SJohn.Forte@Sun.COM 8167836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *) 8177836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 8187836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 8197836SJohn.Forte@Sun.COM return (DCMD_OK); 8207836SJohn.Forte@Sun.COM } 8217836SJohn.Forte@Sun.COM 8227836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) { 8237836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 8247836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 8257836SJohn.Forte@Sun.COM return (DCMD_OK); 8267836SJohn.Forte@Sun.COM } 8277836SJohn.Forte@Sun.COM 8287836SJohn.Forte@Sun.COM /* 8297836SJohn.Forte@Sun.COM * Read in the device array 8307836SJohn.Forte@Sun.COM */ 8317836SJohn.Forte@Sun.COM dev = (ql_head_t *) 8327836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP); 8337836SJohn.Forte@Sun.COM 8347836SJohn.Forte@Sun.COM if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, 8357836SJohn.Forte@Sun.COM (uintptr_t)qlstate->dev) == -1) { 8367836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_head_t (dev) at %p", qlstate->dev); 8377836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 8387836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE); 8397836SJohn.Forte@Sun.COM return (DCMD_OK); 8407836SJohn.Forte@Sun.COM } 8417836SJohn.Forte@Sun.COM 8427836SJohn.Forte@Sun.COM tqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8437836SJohn.Forte@Sun.COM tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP); 8447836SJohn.Forte@Sun.COM lqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8457836SJohn.Forte@Sun.COM lq = (ql_lun_t *)mdb_alloc(sizeof (ql_lun_t), UM_SLEEP); 8467836SJohn.Forte@Sun.COM srblink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8477836SJohn.Forte@Sun.COM srb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP); 8487836SJohn.Forte@Sun.COM 8497836SJohn.Forte@Sun.COM /* 8507836SJohn.Forte@Sun.COM * Validate the devices watchdog queue 8517836SJohn.Forte@Sun.COM */ 8527836SJohn.Forte@Sun.COM for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) { 8537836SJohn.Forte@Sun.COM 8547836SJohn.Forte@Sun.COM /* Skip empty ones */ 8557836SJohn.Forte@Sun.COM if (dev[index].first == NULL) { 8567836SJohn.Forte@Sun.COM continue; 8577836SJohn.Forte@Sun.COM } 8587836SJohn.Forte@Sun.COM 8597836SJohn.Forte@Sun.COM mdb_printf("dev array index = %x\n", index); 8607836SJohn.Forte@Sun.COM 8617836SJohn.Forte@Sun.COM /* Loop through targets on device linked list */ 8627836SJohn.Forte@Sun.COM /* get the first link */ 8637836SJohn.Forte@Sun.COM 8647836SJohn.Forte@Sun.COM nextlink = get_first_link(&dev[index], tqlink); 8657836SJohn.Forte@Sun.COM 8667836SJohn.Forte@Sun.COM /* 8677836SJohn.Forte@Sun.COM * traverse the targets linked list at this device array index. 8687836SJohn.Forte@Sun.COM */ 8697836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 8707836SJohn.Forte@Sun.COM /* Get the target */ 8717836SJohn.Forte@Sun.COM if (mdb_vread(tq, sizeof (ql_tgt_t), 8727836SJohn.Forte@Sun.COM (uintptr_t)(tqlink->base_address)) == -1) { 8737836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_tgt at %p", 8747836SJohn.Forte@Sun.COM tqlink->base_address); 8757836SJohn.Forte@Sun.COM break; 8767836SJohn.Forte@Sun.COM } 8777836SJohn.Forte@Sun.COM mdb_printf("tgt q base = %llx, ", 8787836SJohn.Forte@Sun.COM tqlink->base_address); 8797836SJohn.Forte@Sun.COM 8807836SJohn.Forte@Sun.COM mdb_printf("flags: (%xh)", tq->flags); 8817836SJohn.Forte@Sun.COM 8827836SJohn.Forte@Sun.COM if (tq->flags) { 8837836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)tq->flags, qltgt_flags); 8847836SJohn.Forte@Sun.COM } 8857836SJohn.Forte@Sun.COM 8867836SJohn.Forte@Sun.COM mdb_printf("tgt: %02x%02x%02x%02x%02x%02x%02x%02x ", 8877836SJohn.Forte@Sun.COM tq->node_name[0], tq->node_name[1], 8887836SJohn.Forte@Sun.COM tq->node_name[2], tq->node_name[3], 8897836SJohn.Forte@Sun.COM tq->node_name[4], tq->node_name[5], 8907836SJohn.Forte@Sun.COM tq->node_name[6], tq->node_name[7]); 8917836SJohn.Forte@Sun.COM 8927836SJohn.Forte@Sun.COM /* 8937836SJohn.Forte@Sun.COM * Loop through commands on this targets watchdog queue. 8947836SJohn.Forte@Sun.COM */ 8957836SJohn.Forte@Sun.COM 8967836SJohn.Forte@Sun.COM /* Get the first link on the targets cmd wdg q. */ 8977836SJohn.Forte@Sun.COM if (tq->wdg.first == NULL) { 8987836SJohn.Forte@Sun.COM mdb_printf(" watchdog list empty "); 8997836SJohn.Forte@Sun.COM break; 9007836SJohn.Forte@Sun.COM } else { 9017836SJohn.Forte@Sun.COM if (mdb_vread(srblink, sizeof (ql_link_t), 9027836SJohn.Forte@Sun.COM (uintptr_t)tq->wdg.first) == -1) { 9037836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t" 9047836SJohn.Forte@Sun.COM " at %p", tq->wdg.first); 9057836SJohn.Forte@Sun.COM break; 9067836SJohn.Forte@Sun.COM } 9077836SJohn.Forte@Sun.COM /* There is aleast one. */ 9087836SJohn.Forte@Sun.COM count = 1; 9097836SJohn.Forte@Sun.COM /* 9107836SJohn.Forte@Sun.COM * Count the remaining items in the 9117836SJohn.Forte@Sun.COM * cmd watchdog list. 9127836SJohn.Forte@Sun.COM */ 9137836SJohn.Forte@Sun.COM while (srblink->next != NULL) { 9147836SJohn.Forte@Sun.COM /* Read in the next ql_link_t header */ 9157836SJohn.Forte@Sun.COM if (mdb_vread(srblink, 9167836SJohn.Forte@Sun.COM sizeof (ql_link_t), 9177836SJohn.Forte@Sun.COM (uintptr_t)srblink->next) == -1) { 9187836SJohn.Forte@Sun.COM mdb_warn("failed to read" 9197836SJohn.Forte@Sun.COM " ql_link_t next at %p", 9207836SJohn.Forte@Sun.COM srblink->next); 9217836SJohn.Forte@Sun.COM break; 9227836SJohn.Forte@Sun.COM } 9237836SJohn.Forte@Sun.COM count = (uint16_t)(count + 1); 9247836SJohn.Forte@Sun.COM } 9257836SJohn.Forte@Sun.COM mdb_printf(" watchdog list: %d entries\n", 9267836SJohn.Forte@Sun.COM count); 9277836SJohn.Forte@Sun.COM /* get the first one again */ 9287836SJohn.Forte@Sun.COM if (mdb_vread(srblink, sizeof (ql_link_t), 9297836SJohn.Forte@Sun.COM (uintptr_t)tq->wdg.first) == -1) { 9307836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t" 9317836SJohn.Forte@Sun.COM " at %p", tq->wdg.first); 9327836SJohn.Forte@Sun.COM break; 9337836SJohn.Forte@Sun.COM } 9347836SJohn.Forte@Sun.COM } 9357836SJohn.Forte@Sun.COM /* 9367836SJohn.Forte@Sun.COM * Traverse the targets cmd watchdog linked list 9377836SJohn.Forte@Sun.COM * verifying srb's from the list are on a lun cmd list. 9387836SJohn.Forte@Sun.COM */ 9397836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 9407836SJohn.Forte@Sun.COM int found = 0; 9417836SJohn.Forte@Sun.COM /* get the srb */ 9427836SJohn.Forte@Sun.COM if (mdb_vread(srb, sizeof (ql_srb_t), 9437836SJohn.Forte@Sun.COM (uintptr_t)srblink->base_address) == -1) { 9447836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t" 9457836SJohn.Forte@Sun.COM " at %p", srblink->base_address); 9467836SJohn.Forte@Sun.COM break; 9477836SJohn.Forte@Sun.COM } 9487836SJohn.Forte@Sun.COM mdb_printf("ql_srb %llx ", 9497836SJohn.Forte@Sun.COM srblink->base_address); 9507836SJohn.Forte@Sun.COM 9517836SJohn.Forte@Sun.COM /* 9527836SJohn.Forte@Sun.COM * Get the lun q the srb is on 9537836SJohn.Forte@Sun.COM */ 9547836SJohn.Forte@Sun.COM if (mdb_vread(lq, sizeof (ql_lun_t), 9557836SJohn.Forte@Sun.COM (uintptr_t)srb->lun_queue) == -1) { 9567836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t" 9577836SJohn.Forte@Sun.COM " at %p", srb->lun_queue); 9587836SJohn.Forte@Sun.COM break; 9597836SJohn.Forte@Sun.COM } 9607836SJohn.Forte@Sun.COM nextlink = get_first_link(&lq->cmd, lqlink); 9617836SJohn.Forte@Sun.COM /* 9627836SJohn.Forte@Sun.COM * traverse the lun cmd linked list looking 9637836SJohn.Forte@Sun.COM * for the srb from the targets watchdog list 9647836SJohn.Forte@Sun.COM */ 9657836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 9667836SJohn.Forte@Sun.COM if (srblink->base_address == 9677836SJohn.Forte@Sun.COM lqlink->base_address) { 9687836SJohn.Forte@Sun.COM mdb_printf("on lun %d cmd q\n", 9697836SJohn.Forte@Sun.COM lq->lun_no); 9707836SJohn.Forte@Sun.COM found = 1; 9717836SJohn.Forte@Sun.COM break; 9727836SJohn.Forte@Sun.COM } 9737836SJohn.Forte@Sun.COM /* get next item on lun cmd list */ 9747836SJohn.Forte@Sun.COM nextlink = get_next_link(lqlink); 9757836SJohn.Forte@Sun.COM } 9767836SJohn.Forte@Sun.COM if (!found) { 9777836SJohn.Forte@Sun.COM mdb_printf("not found on lun cmd q\n"); 9787836SJohn.Forte@Sun.COM } 9797836SJohn.Forte@Sun.COM /* get next item in the watchdog list */ 9807836SJohn.Forte@Sun.COM nextlink = get_next_link(srblink); 9817836SJohn.Forte@Sun.COM } /* End targets command watchdog list */ 9827836SJohn.Forte@Sun.COM /* get next item in this target list */ 9837836SJohn.Forte@Sun.COM nextlink = get_next_link(tqlink); 9847836SJohn.Forte@Sun.COM } /* End traverse the device targets linked list */ 9857836SJohn.Forte@Sun.COM mdb_printf("\n"); 9867836SJohn.Forte@Sun.COM } /* End device array */ 9877836SJohn.Forte@Sun.COM 9887836SJohn.Forte@Sun.COM mdb_free(tq, sizeof (ql_tgt_t)); 9897836SJohn.Forte@Sun.COM mdb_free(lq, sizeof (ql_lun_t)); 9907836SJohn.Forte@Sun.COM mdb_free(srb, sizeof (ql_srb_t)); 9917836SJohn.Forte@Sun.COM mdb_free(tqlink, sizeof (ql_link_t)); 9927836SJohn.Forte@Sun.COM mdb_free(srblink, sizeof (ql_link_t)); 9937836SJohn.Forte@Sun.COM mdb_free(lqlink, sizeof (ql_link_t)); 9947836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 9957836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE); 9967836SJohn.Forte@Sun.COM 9977836SJohn.Forte@Sun.COM return (DCMD_OK); 9987836SJohn.Forte@Sun.COM } 9997836SJohn.Forte@Sun.COM 10007836SJohn.Forte@Sun.COM /* 10017836SJohn.Forte@Sun.COM * get_first_link 10027836SJohn.Forte@Sun.COM * Gets the first ql_link_t header on ql_head. 10037836SJohn.Forte@Sun.COM * 10047836SJohn.Forte@Sun.COM * Input: 10057836SJohn.Forte@Sun.COM * ql_head = pointer to a ql_head_t structure. 10067836SJohn.Forte@Sun.COM * ql_link = pointer to a ql_link_t structure. 10077836SJohn.Forte@Sun.COM * 10087836SJohn.Forte@Sun.COM * Returns: 10097836SJohn.Forte@Sun.COM * DCMD_ABORT, or DCMD_OK 10107836SJohn.Forte@Sun.COM * 10117836SJohn.Forte@Sun.COM * Context: 10127836SJohn.Forte@Sun.COM * User context. 10137836SJohn.Forte@Sun.COM * 10147836SJohn.Forte@Sun.COM */ 10157836SJohn.Forte@Sun.COM static int 10167836SJohn.Forte@Sun.COM get_first_link(ql_head_t *qlhead, ql_link_t *qllink) 10177836SJohn.Forte@Sun.COM { 10187836SJohn.Forte@Sun.COM int rval = DCMD_ABORT; 10197836SJohn.Forte@Sun.COM 10207836SJohn.Forte@Sun.COM if (qlhead != NULL) { 10217836SJohn.Forte@Sun.COM if (qlhead->first != NULL) { 10227836SJohn.Forte@Sun.COM /* Read in the first ql_link_t header */ 10237836SJohn.Forte@Sun.COM if (mdb_vread(qllink, sizeof (ql_link_t), 10247836SJohn.Forte@Sun.COM (uintptr_t)(qlhead->first)) == -1) { 10257836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 10267836SJohn.Forte@Sun.COM "next at %p", qlhead->first); 10277836SJohn.Forte@Sun.COM } else { 10287836SJohn.Forte@Sun.COM rval = DCMD_OK; 10297836SJohn.Forte@Sun.COM } 10307836SJohn.Forte@Sun.COM } 10317836SJohn.Forte@Sun.COM } 10327836SJohn.Forte@Sun.COM return (rval); 10337836SJohn.Forte@Sun.COM } 10347836SJohn.Forte@Sun.COM 10357836SJohn.Forte@Sun.COM /* 10367836SJohn.Forte@Sun.COM * get_next_link 10377836SJohn.Forte@Sun.COM * Gets the next ql_link_t structure. 10387836SJohn.Forte@Sun.COM * 10397836SJohn.Forte@Sun.COM * Input: 10407836SJohn.Forte@Sun.COM * ql_link = pointer to a ql_link_t structure. 10417836SJohn.Forte@Sun.COM * 10427836SJohn.Forte@Sun.COM * Returns: 10437836SJohn.Forte@Sun.COM * DCMD_ABORT, or DCMD_OK 10447836SJohn.Forte@Sun.COM * 10457836SJohn.Forte@Sun.COM * Context: 10467836SJohn.Forte@Sun.COM * User context. 10477836SJohn.Forte@Sun.COM * 10487836SJohn.Forte@Sun.COM */ 10497836SJohn.Forte@Sun.COM static int 10507836SJohn.Forte@Sun.COM get_next_link(ql_link_t *qllink) 10517836SJohn.Forte@Sun.COM { 10527836SJohn.Forte@Sun.COM int rval = DCMD_ABORT; 10537836SJohn.Forte@Sun.COM 10547836SJohn.Forte@Sun.COM if (qllink != NULL) { 10557836SJohn.Forte@Sun.COM if (qllink->next != NULL) { 10567836SJohn.Forte@Sun.COM /* Read in the next ql_link_t header */ 10577836SJohn.Forte@Sun.COM if (mdb_vread(qllink, sizeof (ql_link_t), 10587836SJohn.Forte@Sun.COM (uintptr_t)(qllink->next)) == -1) { 10597836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 10607836SJohn.Forte@Sun.COM "next at %p", qllink->next); 10617836SJohn.Forte@Sun.COM } else { 10627836SJohn.Forte@Sun.COM rval = DCMD_OK; 10637836SJohn.Forte@Sun.COM } 10647836SJohn.Forte@Sun.COM } 10657836SJohn.Forte@Sun.COM } 10667836SJohn.Forte@Sun.COM return (rval); 10677836SJohn.Forte@Sun.COM } 10687836SJohn.Forte@Sun.COM 10697836SJohn.Forte@Sun.COM 10707836SJohn.Forte@Sun.COM /* 10717836SJohn.Forte@Sun.COM * qlcstate_dcmd 10727836SJohn.Forte@Sun.COM * mdb dcmd which prints out the ql_state info using 10737836SJohn.Forte@Sun.COM * caller supplied address. 10747836SJohn.Forte@Sun.COM * 10757836SJohn.Forte@Sun.COM * Input: 10767836SJohn.Forte@Sun.COM * addr = User supplied address. 10777836SJohn.Forte@Sun.COM * flags = mdb flags. 10787836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 10797836SJohn.Forte@Sun.COM * argv = Arg array. 10807836SJohn.Forte@Sun.COM * 10817836SJohn.Forte@Sun.COM * Returns: 10827836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 10837836SJohn.Forte@Sun.COM * 10847836SJohn.Forte@Sun.COM * Context: 10857836SJohn.Forte@Sun.COM * User context. 10867836SJohn.Forte@Sun.COM * 10877836SJohn.Forte@Sun.COM */ 10887836SJohn.Forte@Sun.COM static int 10897836SJohn.Forte@Sun.COM qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 10907836SJohn.Forte@Sun.COM { 10917836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 10927836SJohn.Forte@Sun.COM int verbose = 0; 10937836SJohn.Forte@Sun.COM 10947836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) { 10957836SJohn.Forte@Sun.COM return (DCMD_USAGE); 10967836SJohn.Forte@Sun.COM } 10977836SJohn.Forte@Sun.COM 10987836SJohn.Forte@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 10997836SJohn.Forte@Sun.COM argc) { 11007836SJohn.Forte@Sun.COM return (DCMD_USAGE); 11017836SJohn.Forte@Sun.COM } 11027836SJohn.Forte@Sun.COM 11037836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *) 11047836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 11057836SJohn.Forte@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 11067836SJohn.Forte@Sun.COM return (DCMD_OK); 11077836SJohn.Forte@Sun.COM } 11087836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) { 11097836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 11107836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 11117836SJohn.Forte@Sun.COM return (DCMD_OK); 11127836SJohn.Forte@Sun.COM } 11137836SJohn.Forte@Sun.COM 11147836SJohn.Forte@Sun.COM mdb_printf("qlc instance: %d, base addr = %llx\n", qlstate->instance, 11157836SJohn.Forte@Sun.COM addr); 11167836SJohn.Forte@Sun.COM 11177836SJohn.Forte@Sun.COM mdb_printf("\nadapter state flags:\n"); 11187836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags); 11197836SJohn.Forte@Sun.COM mdb_printf("\nadapter cfg flags:\n"); 11207836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags); 11217836SJohn.Forte@Sun.COM mdb_printf("\ntask daemon state flags:\n"); 11227836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->task_daemon_flags, 11237836SJohn.Forte@Sun.COM task_daemon_flags); 11247836SJohn.Forte@Sun.COM 11257836SJohn.Forte@Sun.COM if (verbose) { 11267836SJohn.Forte@Sun.COM (void) ql_doprint(addr, "struct ql_adapter_state"); 11277836SJohn.Forte@Sun.COM } 11287836SJohn.Forte@Sun.COM 11297836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 11307836SJohn.Forte@Sun.COM 11317836SJohn.Forte@Sun.COM return (DCMD_OK); 11327836SJohn.Forte@Sun.COM } 11337836SJohn.Forte@Sun.COM 11347836SJohn.Forte@Sun.COM /* 11357836SJohn.Forte@Sun.COM * qlcstates_walk_init 11367836SJohn.Forte@Sun.COM * mdb walker init which prints out all qlc states info. 11377836SJohn.Forte@Sun.COM * 11387836SJohn.Forte@Sun.COM * Input: 11397836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 11407836SJohn.Forte@Sun.COM * 11417836SJohn.Forte@Sun.COM * Returns: 11427836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 11437836SJohn.Forte@Sun.COM * 11447836SJohn.Forte@Sun.COM * Context: 11457836SJohn.Forte@Sun.COM * User context. 11467836SJohn.Forte@Sun.COM * 11477836SJohn.Forte@Sun.COM */ 11487836SJohn.Forte@Sun.COM static int 11497836SJohn.Forte@Sun.COM qlstates_walk_init(mdb_walk_state_t *wsp) 11507836SJohn.Forte@Sun.COM { 11517836SJohn.Forte@Sun.COM ql_head_t ql_hba; 11527836SJohn.Forte@Sun.COM 11537836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 11547836SJohn.Forte@Sun.COM if ((mdb_readvar(&ql_hba, "ql_hba") == -1) || 11557836SJohn.Forte@Sun.COM (&ql_hba == NULL)) { 11567836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 11577836SJohn.Forte@Sun.COM return (WALK_ERR); 11587836SJohn.Forte@Sun.COM } 11597836SJohn.Forte@Sun.COM 11607836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t)ql_hba.first; 11617836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_adapter_state_t), 11627836SJohn.Forte@Sun.COM UM_SLEEP); 11637836SJohn.Forte@Sun.COM return (WALK_NEXT); 11647836SJohn.Forte@Sun.COM } else { 11657836SJohn.Forte@Sun.COM return (ql_doprint(wsp->walk_addr, "struct ql_adapter_state")); 11667836SJohn.Forte@Sun.COM } 11677836SJohn.Forte@Sun.COM } 11687836SJohn.Forte@Sun.COM 11697836SJohn.Forte@Sun.COM /* 11707836SJohn.Forte@Sun.COM * qlstates_walk_step 11717836SJohn.Forte@Sun.COM * mdb walker step which prints out all qlc states info. 11727836SJohn.Forte@Sun.COM * 11737836SJohn.Forte@Sun.COM * Input: 11747836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 11757836SJohn.Forte@Sun.COM * 11767836SJohn.Forte@Sun.COM * Returns: 11777836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 11787836SJohn.Forte@Sun.COM * 11797836SJohn.Forte@Sun.COM * Context: 11807836SJohn.Forte@Sun.COM * User context. 11817836SJohn.Forte@Sun.COM * 11827836SJohn.Forte@Sun.COM */ 11837836SJohn.Forte@Sun.COM static int 11847836SJohn.Forte@Sun.COM qlstates_walk_step(mdb_walk_state_t *wsp) 11857836SJohn.Forte@Sun.COM { 11867836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 11877836SJohn.Forte@Sun.COM 11887836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 11897836SJohn.Forte@Sun.COM return (WALK_DONE); 11907836SJohn.Forte@Sun.COM } 11917836SJohn.Forte@Sun.COM 11927836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_adapter_state_t), 11937836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 11947836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 11957836SJohn.Forte@Sun.COM wsp->walk_addr); 11967836SJohn.Forte@Sun.COM return (WALK_DONE); 11977836SJohn.Forte@Sun.COM } 11987836SJohn.Forte@Sun.COM 11997836SJohn.Forte@Sun.COM qlstate = (ql_adapter_state_t *)(wsp->walk_data); 12007836SJohn.Forte@Sun.COM mdb_printf("qlc instance: %d, base addr = %llx\n", 12017836SJohn.Forte@Sun.COM qlstate->instance, wsp->walk_addr); 12027836SJohn.Forte@Sun.COM 12037836SJohn.Forte@Sun.COM mdb_printf("\nadapter state flags:\n"); 12047836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags); 12057836SJohn.Forte@Sun.COM mdb_printf("\nadapter cfg flags:\n"); 12067836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags); 12077836SJohn.Forte@Sun.COM mdb_printf("\ntask daemon state flags:\n"); 12087836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->task_daemon_flags, 12097836SJohn.Forte@Sun.COM task_daemon_flags); 12107836SJohn.Forte@Sun.COM 12117836SJohn.Forte@Sun.COM mdb_printf("\nadapter state:\n"); 12127836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_adapter_state"); 12137836SJohn.Forte@Sun.COM 12147836SJohn.Forte@Sun.COM mdb_printf("\n"); 12157836SJohn.Forte@Sun.COM 12167836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t) 12177836SJohn.Forte@Sun.COM (((ql_adapter_state_t *)wsp->walk_data)->hba.next); 12187836SJohn.Forte@Sun.COM 12197836SJohn.Forte@Sun.COM return (WALK_NEXT); 12207836SJohn.Forte@Sun.COM } 12217836SJohn.Forte@Sun.COM 12227836SJohn.Forte@Sun.COM /* 12237836SJohn.Forte@Sun.COM * qlstates_walk_fini 12247836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 12257836SJohn.Forte@Sun.COM * 12267836SJohn.Forte@Sun.COM * Input: 12277836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 12287836SJohn.Forte@Sun.COM * 12297836SJohn.Forte@Sun.COM * Returns: 12307836SJohn.Forte@Sun.COM * 12317836SJohn.Forte@Sun.COM * Context: 12327836SJohn.Forte@Sun.COM * User context. 12337836SJohn.Forte@Sun.COM * 12347836SJohn.Forte@Sun.COM */ 12357836SJohn.Forte@Sun.COM static void 12367836SJohn.Forte@Sun.COM qlstates_walk_fini(mdb_walk_state_t *wsp) 12377836SJohn.Forte@Sun.COM { 12387836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_adapter_state_t)); 12397836SJohn.Forte@Sun.COM } 12407836SJohn.Forte@Sun.COM 12417836SJohn.Forte@Sun.COM /* 12427836SJohn.Forte@Sun.COM * qlsrb_walk_init 12437836SJohn.Forte@Sun.COM * mdb walker init which prints out linked srb's 12447836SJohn.Forte@Sun.COM * 12457836SJohn.Forte@Sun.COM * Input: 12467836SJohn.Forte@Sun.COM * wsp - Pointer to walker ql_srb struct 12477836SJohn.Forte@Sun.COM * 12487836SJohn.Forte@Sun.COM * Returns: 12497836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 12507836SJohn.Forte@Sun.COM * 12517836SJohn.Forte@Sun.COM * Context: 12527836SJohn.Forte@Sun.COM * User context. 12537836SJohn.Forte@Sun.COM * 12547836SJohn.Forte@Sun.COM */ 12557836SJohn.Forte@Sun.COM static int 12567836SJohn.Forte@Sun.COM qlsrb_walk_init(mdb_walk_state_t *wsp) 12577836SJohn.Forte@Sun.COM { 12587836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 12597836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb addr at %p", 12607836SJohn.Forte@Sun.COM wsp->walk_addr); 12617836SJohn.Forte@Sun.COM return (WALK_ERR); 12627836SJohn.Forte@Sun.COM } 12637836SJohn.Forte@Sun.COM 12647836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_srb_t), UM_SLEEP); 12657836SJohn.Forte@Sun.COM 12667836SJohn.Forte@Sun.COM return (WALK_NEXT); 12677836SJohn.Forte@Sun.COM } 12687836SJohn.Forte@Sun.COM 12697836SJohn.Forte@Sun.COM /* 12707836SJohn.Forte@Sun.COM * qlcsrb_walk_step 12717836SJohn.Forte@Sun.COM * mdb walker step which prints out linked ql_srb structures 12727836SJohn.Forte@Sun.COM * 12737836SJohn.Forte@Sun.COM * Input: 12747836SJohn.Forte@Sun.COM * wsp - Pointer to walker srb struct 12757836SJohn.Forte@Sun.COM * 12767836SJohn.Forte@Sun.COM * Returns: 12777836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 12787836SJohn.Forte@Sun.COM * 12797836SJohn.Forte@Sun.COM * Context: 12807836SJohn.Forte@Sun.COM * User context. 12817836SJohn.Forte@Sun.COM * 12827836SJohn.Forte@Sun.COM */ 12837836SJohn.Forte@Sun.COM static int 12847836SJohn.Forte@Sun.COM qlsrb_walk_step(mdb_walk_state_t *wsp) 12857836SJohn.Forte@Sun.COM { 12867836SJohn.Forte@Sun.COM ql_srb_t *qlsrb; 12877836SJohn.Forte@Sun.COM 12887836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) 12897836SJohn.Forte@Sun.COM return (WALK_DONE); 12907836SJohn.Forte@Sun.COM 12917836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_srb_t), 12927836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 12937836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb at %p", wsp->walk_addr); 12947836SJohn.Forte@Sun.COM return (WALK_DONE); 12957836SJohn.Forte@Sun.COM } 12967836SJohn.Forte@Sun.COM 12977836SJohn.Forte@Sun.COM qlsrb = (ql_srb_t *)(wsp->walk_data); 12987836SJohn.Forte@Sun.COM mdb_printf("ql_srb base addr = %llx\n", wsp->walk_addr); 12997836SJohn.Forte@Sun.COM 13007836SJohn.Forte@Sun.COM mdb_printf("\nql_srb flags:\n"); 13017836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlsrb->flags, qlsrb_flags); 13027836SJohn.Forte@Sun.COM 13037836SJohn.Forte@Sun.COM mdb_printf("\nql_srb:\n"); 13047836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_srb"); 13057836SJohn.Forte@Sun.COM 13067836SJohn.Forte@Sun.COM mdb_printf("\n"); 13077836SJohn.Forte@Sun.COM 13087836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t) 13097836SJohn.Forte@Sun.COM (((ql_srb_t *)wsp->walk_data)->cmd.next); 13107836SJohn.Forte@Sun.COM 13117836SJohn.Forte@Sun.COM return (WALK_NEXT); 13127836SJohn.Forte@Sun.COM } 13137836SJohn.Forte@Sun.COM 13147836SJohn.Forte@Sun.COM /* 13157836SJohn.Forte@Sun.COM * qlsrb_walk_fini 13167836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 13177836SJohn.Forte@Sun.COM * 13187836SJohn.Forte@Sun.COM * Input: 13197836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 13207836SJohn.Forte@Sun.COM * 13217836SJohn.Forte@Sun.COM * Returns: 13227836SJohn.Forte@Sun.COM * 13237836SJohn.Forte@Sun.COM * Context: 13247836SJohn.Forte@Sun.COM * User context. 13257836SJohn.Forte@Sun.COM * 13267836SJohn.Forte@Sun.COM */ 13277836SJohn.Forte@Sun.COM static void 13287836SJohn.Forte@Sun.COM qlsrb_walk_fini(mdb_walk_state_t *wsp) 13297836SJohn.Forte@Sun.COM { 13307836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_srb_t)); 13317836SJohn.Forte@Sun.COM } 13327836SJohn.Forte@Sun.COM 13337836SJohn.Forte@Sun.COM /* 13347836SJohn.Forte@Sun.COM * qllunq_dcmd 13357836SJohn.Forte@Sun.COM * mdb walker which prints out lun q's 13367836SJohn.Forte@Sun.COM * 13377836SJohn.Forte@Sun.COM * Input: 13387836SJohn.Forte@Sun.COM * wsp - Pointer to walker ql_lun struct 13397836SJohn.Forte@Sun.COM * 13407836SJohn.Forte@Sun.COM * Returns: 13417836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 13427836SJohn.Forte@Sun.COM * 13437836SJohn.Forte@Sun.COM * Context: 13447836SJohn.Forte@Sun.COM * User context. 13457836SJohn.Forte@Sun.COM * 13467836SJohn.Forte@Sun.COM */ 13477836SJohn.Forte@Sun.COM static int 13487836SJohn.Forte@Sun.COM qllunq_walk_init(mdb_walk_state_t *wsp) 13497836SJohn.Forte@Sun.COM { 13507836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 13517836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_lun addr at %p", 13527836SJohn.Forte@Sun.COM wsp->walk_addr); 13537836SJohn.Forte@Sun.COM return (WALK_ERR); 13547836SJohn.Forte@Sun.COM } 13557836SJohn.Forte@Sun.COM 13567836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_lun_t), UM_SLEEP); 13577836SJohn.Forte@Sun.COM 13587836SJohn.Forte@Sun.COM return (WALK_NEXT); 13597836SJohn.Forte@Sun.COM } 13607836SJohn.Forte@Sun.COM 13617836SJohn.Forte@Sun.COM /* 13627836SJohn.Forte@Sun.COM * qlclunq_walk_step 13637836SJohn.Forte@Sun.COM * mdb walker step which prints out linked ql_lun structures 13647836SJohn.Forte@Sun.COM * 13657836SJohn.Forte@Sun.COM * Input: 13667836SJohn.Forte@Sun.COM * wsp - Pointer to walker srb struct 13677836SJohn.Forte@Sun.COM * 13687836SJohn.Forte@Sun.COM * Returns: 13697836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 13707836SJohn.Forte@Sun.COM * 13717836SJohn.Forte@Sun.COM * Context: 13727836SJohn.Forte@Sun.COM * User context. 13737836SJohn.Forte@Sun.COM * 13747836SJohn.Forte@Sun.COM */ 13757836SJohn.Forte@Sun.COM static int 13767836SJohn.Forte@Sun.COM qllunq_walk_step(mdb_walk_state_t *wsp) 13777836SJohn.Forte@Sun.COM { 13787836SJohn.Forte@Sun.COM ql_lun_t *qllun; 13797836SJohn.Forte@Sun.COM ql_link_t ql_link; 13807836SJohn.Forte@Sun.COM ql_link_t *qllink; 13817836SJohn.Forte@Sun.COM 13827836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) 13837836SJohn.Forte@Sun.COM return (WALK_DONE); 13847836SJohn.Forte@Sun.COM 13857836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_lun_t), 13867836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 13877836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_lun at %p", wsp->walk_addr); 13887836SJohn.Forte@Sun.COM return (WALK_DONE); 13897836SJohn.Forte@Sun.COM } 13907836SJohn.Forte@Sun.COM 13917836SJohn.Forte@Sun.COM qllun = (ql_lun_t *)(wsp->walk_data); 13927836SJohn.Forte@Sun.COM mdb_printf("ql_lun base addr = %llx\n", wsp->walk_addr); 13937836SJohn.Forte@Sun.COM 13947836SJohn.Forte@Sun.COM mdb_printf("\nql_lun flags:\n"); 13957836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qllun->flags, qllun_flags); 13967836SJohn.Forte@Sun.COM 13977836SJohn.Forte@Sun.COM mdb_printf("\nql_lun:\n"); 13987836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_lun"); 13997836SJohn.Forte@Sun.COM 14007836SJohn.Forte@Sun.COM mdb_printf("\n"); 14017836SJohn.Forte@Sun.COM 14027836SJohn.Forte@Sun.COM qllink = (ql_link_t *) 14037836SJohn.Forte@Sun.COM (((ql_lun_t *)wsp->walk_data)->link.next); 14047836SJohn.Forte@Sun.COM 14057836SJohn.Forte@Sun.COM if (qllink == NULL) { 14067836SJohn.Forte@Sun.COM return (WALK_DONE); 14077836SJohn.Forte@Sun.COM } else { 14087836SJohn.Forte@Sun.COM /* 14097836SJohn.Forte@Sun.COM * Read in the next link_t header 14107836SJohn.Forte@Sun.COM */ 14117836SJohn.Forte@Sun.COM if (mdb_vread(&ql_link, sizeof (ql_link_t), 14127836SJohn.Forte@Sun.COM (uintptr_t)qllink) == -1) { 14137836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 14147836SJohn.Forte@Sun.COM "next at %p", qllink->next); 14157836SJohn.Forte@Sun.COM return (WALK_DONE); 14167836SJohn.Forte@Sun.COM } 14177836SJohn.Forte@Sun.COM qllink = &ql_link; 14187836SJohn.Forte@Sun.COM } 14197836SJohn.Forte@Sun.COM 14207836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t)qllink->base_address; 14217836SJohn.Forte@Sun.COM 14227836SJohn.Forte@Sun.COM return (WALK_NEXT); 14237836SJohn.Forte@Sun.COM } 14247836SJohn.Forte@Sun.COM 14257836SJohn.Forte@Sun.COM /* 14267836SJohn.Forte@Sun.COM * qllunq_walk_fini 14277836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 14287836SJohn.Forte@Sun.COM * 14297836SJohn.Forte@Sun.COM * Input: 14307836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 14317836SJohn.Forte@Sun.COM * 14327836SJohn.Forte@Sun.COM * Returns: 14337836SJohn.Forte@Sun.COM * 14347836SJohn.Forte@Sun.COM * Context: 14357836SJohn.Forte@Sun.COM * User context. 14367836SJohn.Forte@Sun.COM * 14377836SJohn.Forte@Sun.COM */ 14387836SJohn.Forte@Sun.COM static void 14397836SJohn.Forte@Sun.COM qllunq_walk_fini(mdb_walk_state_t *wsp) 14407836SJohn.Forte@Sun.COM { 14417836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_lun_t)); 14427836SJohn.Forte@Sun.COM } 14437836SJohn.Forte@Sun.COM 14447836SJohn.Forte@Sun.COM /* 14457836SJohn.Forte@Sun.COM * qltgtq_dcmd 14467836SJohn.Forte@Sun.COM * mdb dcmd which prints out an hs's tq struct info. 14477836SJohn.Forte@Sun.COM * 14487836SJohn.Forte@Sun.COM * Input: 14497836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 14507836SJohn.Forte@Sun.COM * flags = mdb flags. 14517836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 14527836SJohn.Forte@Sun.COM * argv = Arg array. 14537836SJohn.Forte@Sun.COM * 14547836SJohn.Forte@Sun.COM * Returns: 14557836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 14567836SJohn.Forte@Sun.COM * 14577836SJohn.Forte@Sun.COM * Context: 14587836SJohn.Forte@Sun.COM * User context. 14597836SJohn.Forte@Sun.COM * 14607836SJohn.Forte@Sun.COM */ 14617836SJohn.Forte@Sun.COM /*ARGSUSED*/ 14627836SJohn.Forte@Sun.COM static int 14637836SJohn.Forte@Sun.COM qltgtq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 14647836SJohn.Forte@Sun.COM { 14657836SJohn.Forte@Sun.COM ql_adapter_state_t *ha; 14667836SJohn.Forte@Sun.COM ql_link_t *link; 14677836SJohn.Forte@Sun.COM ql_tgt_t *tq; 14687836SJohn.Forte@Sun.COM uint32_t index; 14697836SJohn.Forte@Sun.COM ql_head_t *dev; 14707836SJohn.Forte@Sun.COM 14717836SJohn.Forte@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 14727836SJohn.Forte@Sun.COM mdb_warn("ql_hba structure addr is required"); 14737836SJohn.Forte@Sun.COM return (DCMD_USAGE); 14747836SJohn.Forte@Sun.COM } 14757836SJohn.Forte@Sun.COM 14767836SJohn.Forte@Sun.COM /* 14777836SJohn.Forte@Sun.COM * Get the adapter state struct which was passed 14787836SJohn.Forte@Sun.COM */ 14797836SJohn.Forte@Sun.COM 14807836SJohn.Forte@Sun.COM ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 14817836SJohn.Forte@Sun.COM UM_SLEEP); 14827836SJohn.Forte@Sun.COM 14837836SJohn.Forte@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 14847836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 14857836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 14867836SJohn.Forte@Sun.COM return (DCMD_OK); 14877836SJohn.Forte@Sun.COM } 14887836SJohn.Forte@Sun.COM 14897836SJohn.Forte@Sun.COM if (ha->dev == NULL) { 14907836SJohn.Forte@Sun.COM mdb_warn("dev ptr is NULL for ha: %p", addr); 14917836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 14927836SJohn.Forte@Sun.COM return (DCMD_OK); 14937836SJohn.Forte@Sun.COM } 14947836SJohn.Forte@Sun.COM 14957836SJohn.Forte@Sun.COM /* 14967836SJohn.Forte@Sun.COM * Read in the device array 14977836SJohn.Forte@Sun.COM */ 14987836SJohn.Forte@Sun.COM dev = (ql_head_t *) 14997836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP); 15007836SJohn.Forte@Sun.COM 15017836SJohn.Forte@Sun.COM if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, 15027836SJohn.Forte@Sun.COM (uintptr_t)ha->dev) == -1) { 15037836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_head_t (dev) at %p", ha->dev); 15047836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 15057836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE); 15067836SJohn.Forte@Sun.COM } 15077836SJohn.Forte@Sun.COM 15087836SJohn.Forte@Sun.COM tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP); 15097836SJohn.Forte@Sun.COM link = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 15107836SJohn.Forte@Sun.COM 15117836SJohn.Forte@Sun.COM for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) { 15127836SJohn.Forte@Sun.COM 15137836SJohn.Forte@Sun.COM if (dev[index].first == NULL) { 15147836SJohn.Forte@Sun.COM continue; 15157836SJohn.Forte@Sun.COM } 15167836SJohn.Forte@Sun.COM 15177836SJohn.Forte@Sun.COM if (mdb_vread(link, sizeof (ql_link_t), 15187836SJohn.Forte@Sun.COM (uintptr_t)dev[index].first) == -1) { 15197836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t at %p", 15207836SJohn.Forte@Sun.COM dev[index].first); 15217836SJohn.Forte@Sun.COM break; 15227836SJohn.Forte@Sun.COM } 15237836SJohn.Forte@Sun.COM 15247836SJohn.Forte@Sun.COM while (link != NULL) { 15257836SJohn.Forte@Sun.COM if (mdb_vread(tq, sizeof (ql_tgt_t), 15267836SJohn.Forte@Sun.COM (uintptr_t)(link->base_address)) == -1) { 15277836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_tgt at %p", 15287836SJohn.Forte@Sun.COM link->base_address); 15297836SJohn.Forte@Sun.COM break; 15307836SJohn.Forte@Sun.COM } 15317836SJohn.Forte@Sun.COM 15327836SJohn.Forte@Sun.COM mdb_printf("tgt queue base addr = %llx\n", 15337836SJohn.Forte@Sun.COM link->base_address); 15347836SJohn.Forte@Sun.COM 15357836SJohn.Forte@Sun.COM mdb_printf("\ntgt queue flags: (%xh)\n", tq->flags); 15367836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)tq->flags, qltgt_flags); 15377836SJohn.Forte@Sun.COM 15387836SJohn.Forte@Sun.COM mdb_printf("\ntgt queue:\n"); 15397836SJohn.Forte@Sun.COM 15407836SJohn.Forte@Sun.COM (void) ql_doprint((uintptr_t)link->base_address, 15417836SJohn.Forte@Sun.COM "struct ql_target"); 15427836SJohn.Forte@Sun.COM 15437836SJohn.Forte@Sun.COM mdb_printf("\n"); 15447836SJohn.Forte@Sun.COM 15457836SJohn.Forte@Sun.COM if (get_next_link(link) != DCMD_OK) { 15467836SJohn.Forte@Sun.COM break; 15477836SJohn.Forte@Sun.COM } 15487836SJohn.Forte@Sun.COM } 15497836SJohn.Forte@Sun.COM } 15507836SJohn.Forte@Sun.COM 15517836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 15527836SJohn.Forte@Sun.COM mdb_free(tq, sizeof (ql_tgt_t)); 15537836SJohn.Forte@Sun.COM mdb_free(link, sizeof (ql_link_t)); 15547836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE); 15557836SJohn.Forte@Sun.COM 15567836SJohn.Forte@Sun.COM return (DCMD_OK); 15577836SJohn.Forte@Sun.COM } 15587836SJohn.Forte@Sun.COM 15597836SJohn.Forte@Sun.COM /* 1560*9156SDaniel.Beauregard@Sun.COM * ql_triggerdump_dcmd 1561*9156SDaniel.Beauregard@Sun.COM * Triggers the driver to take a firmware dump 1562*9156SDaniel.Beauregard@Sun.COM * 1563*9156SDaniel.Beauregard@Sun.COM * Input: 1564*9156SDaniel.Beauregard@Sun.COM * addr = User supplied address (optional) 1565*9156SDaniel.Beauregard@Sun.COM * flags = mdb flags. 1566*9156SDaniel.Beauregard@Sun.COM * argc = Number of user supplied args. 1567*9156SDaniel.Beauregard@Sun.COM * argv = Arg array (instance #, optional). 1568*9156SDaniel.Beauregard@Sun.COM * 1569*9156SDaniel.Beauregard@Sun.COM * Returns: 1570*9156SDaniel.Beauregard@Sun.COM * DCMD_OK or DCMD_ERR 1571*9156SDaniel.Beauregard@Sun.COM * 1572*9156SDaniel.Beauregard@Sun.COM * Context: 1573*9156SDaniel.Beauregard@Sun.COM * User context. 1574*9156SDaniel.Beauregard@Sun.COM * 1575*9156SDaniel.Beauregard@Sun.COM */ 1576*9156SDaniel.Beauregard@Sun.COM 1577*9156SDaniel.Beauregard@Sun.COM #if 0 1578*9156SDaniel.Beauregard@Sun.COM 1579*9156SDaniel.Beauregard@Sun.COM /*ARGSUSED*/ 1580*9156SDaniel.Beauregard@Sun.COM static int 1581*9156SDaniel.Beauregard@Sun.COM qlc_triggerdump_dcmd(uintptr_t addr, uint_t flags, int argc, 1582*9156SDaniel.Beauregard@Sun.COM const mdb_arg_t *argv) 1583*9156SDaniel.Beauregard@Sun.COM { 1584*9156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *qlstate; 1585*9156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 1586*9156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 1587*9156SDaniel.Beauregard@Sun.COM uint32_t qlsize = sizeof (ql_adapter_state_t); 1588*9156SDaniel.Beauregard@Sun.COM int mdbs; 1589*9156SDaniel.Beauregard@Sun.COM 1590*9156SDaniel.Beauregard@Sun.COM if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) { 1591*9156SDaniel.Beauregard@Sun.COM mdb_warn("Cannot change core file data (state=%xh)\n", mdbs); 1592*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1593*9156SDaniel.Beauregard@Sun.COM } 1594*9156SDaniel.Beauregard@Sun.COM 1595*9156SDaniel.Beauregard@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize, 1596*9156SDaniel.Beauregard@Sun.COM UM_SLEEP)) == NULL) { 1597*9156SDaniel.Beauregard@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 1598*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1599*9156SDaniel.Beauregard@Sun.COM } 1600*9156SDaniel.Beauregard@Sun.COM 1601*9156SDaniel.Beauregard@Sun.COM if (addr == NULL) { 1602*9156SDaniel.Beauregard@Sun.COM char *tptr; 1603*9156SDaniel.Beauregard@Sun.COM uint32_t instance; 1604*9156SDaniel.Beauregard@Sun.COM 1605*9156SDaniel.Beauregard@Sun.COM if (argc == 0) { 1606*9156SDaniel.Beauregard@Sun.COM mdb_warn("must specify either the ha addr or " 1607*9156SDaniel.Beauregard@Sun.COM "the instance number\n"); 1608*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1609*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1610*9156SDaniel.Beauregard@Sun.COM } 1611*9156SDaniel.Beauregard@Sun.COM 1612*9156SDaniel.Beauregard@Sun.COM /* 1613*9156SDaniel.Beauregard@Sun.COM * find the specified instance in the ha list 1614*9156SDaniel.Beauregard@Sun.COM */ 1615*9156SDaniel.Beauregard@Sun.COM 1616*9156SDaniel.Beauregard@Sun.COM instance = (uint32_t)strtol(argv[1].a_un.a_str, &tptr, 16); 1617*9156SDaniel.Beauregard@Sun.COM if (tptr == argv[1].a_un.a_str) { 1618*9156SDaniel.Beauregard@Sun.COM mdb_printf("instance # is illegal: '%s'\n", 1619*9156SDaniel.Beauregard@Sun.COM argv[1].a_un.a_str); 1620*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1621*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1622*9156SDaniel.Beauregard@Sun.COM } 1623*9156SDaniel.Beauregard@Sun.COM 1624*9156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 1625*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 1626*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1627*9156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 1628*9156SDaniel.Beauregard@Sun.COM } 1629*9156SDaniel.Beauregard@Sun.COM 1630*9156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 1631*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure - " 1632*9156SDaniel.Beauregard@Sun.COM "is qlc loaded?"); 1633*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1634*9156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 1635*9156SDaniel.Beauregard@Sun.COM } 1636*9156SDaniel.Beauregard@Sun.COM 1637*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 1638*9156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 1639*9156SDaniel.Beauregard@Sun.COM 1640*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 1641*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1642*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 1643*9156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 1644*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1645*9156SDaniel.Beauregard@Sun.COM } 1646*9156SDaniel.Beauregard@Sun.COM 1647*9156SDaniel.Beauregard@Sun.COM if (qlstate->instance == instance) { 1648*9156SDaniel.Beauregard@Sun.COM break; 1649*9156SDaniel.Beauregard@Sun.COM } 1650*9156SDaniel.Beauregard@Sun.COM 1651*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 1652*9156SDaniel.Beauregard@Sun.COM } 1653*9156SDaniel.Beauregard@Sun.COM } else { 1654*9156SDaniel.Beauregard@Sun.COM 1655*9156SDaniel.Beauregard@Sun.COM /* 1656*9156SDaniel.Beauregard@Sun.COM * verify the addr specified 1657*9156SDaniel.Beauregard@Sun.COM */ 1658*9156SDaniel.Beauregard@Sun.COM 1659*9156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 1660*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 1661*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1662*9156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 1663*9156SDaniel.Beauregard@Sun.COM } 1664*9156SDaniel.Beauregard@Sun.COM 1665*9156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 1666*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure - " 1667*9156SDaniel.Beauregard@Sun.COM "is qlc loaded?"); 1668*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1669*9156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 1670*9156SDaniel.Beauregard@Sun.COM } 1671*9156SDaniel.Beauregard@Sun.COM 1672*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 1673*9156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 1674*9156SDaniel.Beauregard@Sun.COM 1675*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 1676*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1677*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 1678*9156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 1679*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1680*9156SDaniel.Beauregard@Sun.COM } 1681*9156SDaniel.Beauregard@Sun.COM 1682*9156SDaniel.Beauregard@Sun.COM if (hbaptr == addr) { 1683*9156SDaniel.Beauregard@Sun.COM break; 1684*9156SDaniel.Beauregard@Sun.COM } 1685*9156SDaniel.Beauregard@Sun.COM 1686*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 1687*9156SDaniel.Beauregard@Sun.COM } 1688*9156SDaniel.Beauregard@Sun.COM } 1689*9156SDaniel.Beauregard@Sun.COM 1690*9156SDaniel.Beauregard@Sun.COM if (hbaptr == NULL) { 1691*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1692*9156SDaniel.Beauregard@Sun.COM if (argc == 0) { 1693*9156SDaniel.Beauregard@Sun.COM mdb_warn("addr specified is not in the hba list\n"); 1694*9156SDaniel.Beauregard@Sun.COM } else { 1695*9156SDaniel.Beauregard@Sun.COM mdb_warn("instance specified does not exist\n"); 1696*9156SDaniel.Beauregard@Sun.COM } 1697*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1698*9156SDaniel.Beauregard@Sun.COM } 1699*9156SDaniel.Beauregard@Sun.COM 1700*9156SDaniel.Beauregard@Sun.COM if (((qlstate->ql_dump_state & QL_DUMP_VALID) != 0) || 1701*9156SDaniel.Beauregard@Sun.COM (qlstate->ql_dump_ptr != NULL)) { 1702*9156SDaniel.Beauregard@Sun.COM mdb_warn("instance %d already has a valid dump\n", 1703*9156SDaniel.Beauregard@Sun.COM qlstate->instance); 1704*9156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 1705*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1706*9156SDaniel.Beauregard@Sun.COM } 1707*9156SDaniel.Beauregard@Sun.COM 1708*9156SDaniel.Beauregard@Sun.COM 1709*9156SDaniel.Beauregard@Sun.COM } 1710*9156SDaniel.Beauregard@Sun.COM #endif 1711*9156SDaniel.Beauregard@Sun.COM 1712*9156SDaniel.Beauregard@Sun.COM /* 1713*9156SDaniel.Beauregard@Sun.COM * ql_getdump_dcmd 17147836SJohn.Forte@Sun.COM * prints out the firmware dump buffer 17157836SJohn.Forte@Sun.COM * 17167836SJohn.Forte@Sun.COM * Input: 1717*9156SDaniel.Beauregard@Sun.COM * addr = User supplied address. (NB: must be an ha) 17187836SJohn.Forte@Sun.COM * flags = mdb flags. 17197836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 17207836SJohn.Forte@Sun.COM * argv = Arg array. 17217836SJohn.Forte@Sun.COM * 17227836SJohn.Forte@Sun.COM * Returns: 17237836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 17247836SJohn.Forte@Sun.COM * 17257836SJohn.Forte@Sun.COM * Context: 17267836SJohn.Forte@Sun.COM * User context. 17277836SJohn.Forte@Sun.COM * 17287836SJohn.Forte@Sun.COM */ 17297836SJohn.Forte@Sun.COM static int 1730*9156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 17317836SJohn.Forte@Sun.COM { 17327836SJohn.Forte@Sun.COM ql_adapter_state_t *ha; 1733*9156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 1734*9156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 1735*9156SDaniel.Beauregard@Sun.COM int verbose = 0; 17367836SJohn.Forte@Sun.COM 17377836SJohn.Forte@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 17387836SJohn.Forte@Sun.COM mdb_warn("ql_adapter_state structure addr is required"); 17397836SJohn.Forte@Sun.COM return (DCMD_USAGE); 17407836SJohn.Forte@Sun.COM } 17417836SJohn.Forte@Sun.COM 1742*9156SDaniel.Beauregard@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 1743*9156SDaniel.Beauregard@Sun.COM argc) { 1744*9156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 1745*9156SDaniel.Beauregard@Sun.COM } 1746*9156SDaniel.Beauregard@Sun.COM 17477836SJohn.Forte@Sun.COM /* 17487836SJohn.Forte@Sun.COM * Get the adapter state struct which was passed 17497836SJohn.Forte@Sun.COM */ 17507836SJohn.Forte@Sun.COM if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 17517836SJohn.Forte@Sun.COM UM_SLEEP)) == NULL) { 17527836SJohn.Forte@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 17537836SJohn.Forte@Sun.COM return (DCMD_OK); 17547836SJohn.Forte@Sun.COM } 17557836SJohn.Forte@Sun.COM 1756*9156SDaniel.Beauregard@Sun.COM /* 1757*9156SDaniel.Beauregard@Sun.COM * show user which instances have valid f/w dumps available if 1758*9156SDaniel.Beauregard@Sun.COM * user has specified verbose option 1759*9156SDaniel.Beauregard@Sun.COM */ 1760*9156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 1761*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 1762*9156SDaniel.Beauregard@Sun.COM } else if (&ql_hba == NULL) { 1763*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure -- is qlc loaded?"); 1764*9156SDaniel.Beauregard@Sun.COM } else if (verbose) { 1765*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 1766*9156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 1767*9156SDaniel.Beauregard@Sun.COM 1768*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), 1769*9156SDaniel.Beauregard@Sun.COM hbaptr) == -1) { 1770*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 1771*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed read ql_adapter_state at %p", 1772*9156SDaniel.Beauregard@Sun.COM hbaptr); 1773*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1774*9156SDaniel.Beauregard@Sun.COM } 1775*9156SDaniel.Beauregard@Sun.COM 1776*9156SDaniel.Beauregard@Sun.COM mdb_printf("instance %d:\n", ha->instance); 1777*9156SDaniel.Beauregard@Sun.COM (void) mdb_inc_indent((ulong_t)4); 1778*9156SDaniel.Beauregard@Sun.COM 1779*9156SDaniel.Beauregard@Sun.COM if (ha->ql_dump_state == 0) { 1780*9156SDaniel.Beauregard@Sun.COM mdb_printf("no dump flags\n"); 1781*9156SDaniel.Beauregard@Sun.COM } else { 1782*9156SDaniel.Beauregard@Sun.COM ql_dump_flags((uint64_t)ha->ql_dump_state, 1783*9156SDaniel.Beauregard@Sun.COM qldump_flags); 1784*9156SDaniel.Beauregard@Sun.COM } 1785*9156SDaniel.Beauregard@Sun.COM 1786*9156SDaniel.Beauregard@Sun.COM if (ha->ql_dump_ptr == NULL) { 1787*9156SDaniel.Beauregard@Sun.COM mdb_printf("no dump address\n"); 1788*9156SDaniel.Beauregard@Sun.COM } else { 1789*9156SDaniel.Beauregard@Sun.COM mdb_printf("dump address is: %p\n", 1790*9156SDaniel.Beauregard@Sun.COM ha->ql_dump_ptr); 1791*9156SDaniel.Beauregard@Sun.COM } 1792*9156SDaniel.Beauregard@Sun.COM 1793*9156SDaniel.Beauregard@Sun.COM (void) mdb_dec_indent((ulong_t)4); 1794*9156SDaniel.Beauregard@Sun.COM 1795*9156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ha->hba.next; 1796*9156SDaniel.Beauregard@Sun.COM } 1797*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 1798*9156SDaniel.Beauregard@Sun.COM } 1799*9156SDaniel.Beauregard@Sun.COM 18007836SJohn.Forte@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 18017836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 18027836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 18037836SJohn.Forte@Sun.COM return (DCMD_OK); 18047836SJohn.Forte@Sun.COM } 18057836SJohn.Forte@Sun.COM 1806*9156SDaniel.Beauregard@Sun.COM /* 1807*9156SDaniel.Beauregard@Sun.COM * If its not a valid dump or there's not a f/w dump binary (???) 1808*9156SDaniel.Beauregard@Sun.COM * then bail out 1809*9156SDaniel.Beauregard@Sun.COM */ 1810*9156SDaniel.Beauregard@Sun.COM if (((ha->ql_dump_state & QL_DUMP_VALID) == 0) || 1811*9156SDaniel.Beauregard@Sun.COM (ha->ql_dump_ptr == NULL)) { 1812*9156SDaniel.Beauregard@Sun.COM mdb_warn("dump does not exist for instance %d (%x, %p)\n", 1813*9156SDaniel.Beauregard@Sun.COM ha->instance, ha->ql_dump_state, ha->ql_dump_ptr); 1814*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 1815*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 1816*9156SDaniel.Beauregard@Sun.COM } 1817*9156SDaniel.Beauregard@Sun.COM 18187836SJohn.Forte@Sun.COM if (CFG_IST(ha, CFG_CTRL_2422)) { 18197836SJohn.Forte@Sun.COM (void) ql_24xx_dump_dcmd(ha, flags, argc, argv); 18207836SJohn.Forte@Sun.COM } else if (CFG_IST(ha, CFG_CTRL_25XX)) { 18217836SJohn.Forte@Sun.COM (void) ql_25xx_dump_dcmd(ha, flags, argc, argv); 18227836SJohn.Forte@Sun.COM } else { 18237836SJohn.Forte@Sun.COM (void) ql_23xx_dump_dcmd(ha, flags, argc, argv); 18247836SJohn.Forte@Sun.COM } 18257836SJohn.Forte@Sun.COM 18267836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 18277836SJohn.Forte@Sun.COM 18287836SJohn.Forte@Sun.COM return (DCMD_OK); 18297836SJohn.Forte@Sun.COM } 18307836SJohn.Forte@Sun.COM 18317836SJohn.Forte@Sun.COM /* 18327836SJohn.Forte@Sun.COM * ql_23xx_dump_dcmd 18337836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 18347836SJohn.Forte@Sun.COM * 18357836SJohn.Forte@Sun.COM * Input: 18367836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 18377836SJohn.Forte@Sun.COM * flags = mdb flags. 18387836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 18397836SJohn.Forte@Sun.COM * argv = Arg array. 18407836SJohn.Forte@Sun.COM * 18417836SJohn.Forte@Sun.COM * Returns: 18427836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 18437836SJohn.Forte@Sun.COM * 18447836SJohn.Forte@Sun.COM * Context: 18457836SJohn.Forte@Sun.COM * User context. 18467836SJohn.Forte@Sun.COM * 18477836SJohn.Forte@Sun.COM */ 18487836SJohn.Forte@Sun.COM /*ARGSUSED*/ 18497836SJohn.Forte@Sun.COM static int 18507836SJohn.Forte@Sun.COM ql_23xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 18517836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 18527836SJohn.Forte@Sun.COM { 18537836SJohn.Forte@Sun.COM ql_fw_dump_t *fw; 18547836SJohn.Forte@Sun.COM uint32_t cnt = 0; 18557836SJohn.Forte@Sun.COM int mbox_cnt; 18567836SJohn.Forte@Sun.COM 1857*9156SDaniel.Beauregard@Sun.COM fw = (ql_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 1858*9156SDaniel.Beauregard@Sun.COM 1859*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 1860*9156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 18617836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 1862*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 18637836SJohn.Forte@Sun.COM return (DCMD_OK); 18647836SJohn.Forte@Sun.COM } 18657836SJohn.Forte@Sun.COM 18667836SJohn.Forte@Sun.COM if (ha->cfg_flags & CFG_CTRL_2300) { 18677836SJohn.Forte@Sun.COM mdb_printf("\nISP 2300IP "); 18687836SJohn.Forte@Sun.COM } else if (ha->cfg_flags & CFG_CTRL_6322) { 18697836SJohn.Forte@Sun.COM mdb_printf("\nISP 6322FLX "); 18707836SJohn.Forte@Sun.COM } else { 18717836SJohn.Forte@Sun.COM mdb_printf("\nISP 2200IP "); 18727836SJohn.Forte@Sun.COM } 18737836SJohn.Forte@Sun.COM 18747836SJohn.Forte@Sun.COM mdb_printf("Firmware Version %d.%d.%d\n", 18757836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 18767836SJohn.Forte@Sun.COM ha->fw_subminor_version); 18777836SJohn.Forte@Sun.COM 18787836SJohn.Forte@Sun.COM mdb_printf("\nPBIU Registers:"); 18797836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) { 18807836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 18817836SJohn.Forte@Sun.COM mdb_printf("\n"); 18827836SJohn.Forte@Sun.COM } 18837836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->pbiu_reg[cnt]); 18847836SJohn.Forte@Sun.COM } 18857836SJohn.Forte@Sun.COM 18867836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 18877836SJohn.Forte@Sun.COM mdb_printf("\n\nReqQ-RspQ-Risc2Host Status registers:"); 18887836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) { 18897836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 18907836SJohn.Forte@Sun.COM mdb_printf("\n"); 18917836SJohn.Forte@Sun.COM } 18927836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_host_reg[cnt]); 18937836SJohn.Forte@Sun.COM } 18947836SJohn.Forte@Sun.COM } 18957836SJohn.Forte@Sun.COM 18967836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers:"); 18977836SJohn.Forte@Sun.COM mbox_cnt = (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) ? 16 : 8; 18987836SJohn.Forte@Sun.COM for (cnt = 0; cnt < mbox_cnt; cnt++) { 18997836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19007836SJohn.Forte@Sun.COM mdb_printf("\n"); 19017836SJohn.Forte@Sun.COM } 19027836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 19037836SJohn.Forte@Sun.COM } 19047836SJohn.Forte@Sun.COM 19057836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 19067836SJohn.Forte@Sun.COM mdb_printf("\n\nAuto Request Response DMA Registers:"); 19077836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) { 19087836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19097836SJohn.Forte@Sun.COM mdb_printf("\n"); 19107836SJohn.Forte@Sun.COM } 19117836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->resp_dma_reg[cnt]); 19127836SJohn.Forte@Sun.COM } 19137836SJohn.Forte@Sun.COM } 19147836SJohn.Forte@Sun.COM 19157836SJohn.Forte@Sun.COM mdb_printf("\n\nDMA Registers:"); 19167836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) { 19177836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19187836SJohn.Forte@Sun.COM mdb_printf("\n"); 19197836SJohn.Forte@Sun.COM } 19207836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->dma_reg[cnt]); 19217836SJohn.Forte@Sun.COM } 19227836SJohn.Forte@Sun.COM 19237836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC Hardware Registers:"); 19247836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) { 19257836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19267836SJohn.Forte@Sun.COM mdb_printf("\n"); 19277836SJohn.Forte@Sun.COM } 19287836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_hdw_reg[cnt]); 19297836SJohn.Forte@Sun.COM } 19307836SJohn.Forte@Sun.COM 19317836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP0 Registers:"); 19327836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) { 19337836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19347836SJohn.Forte@Sun.COM mdb_printf("\n"); 19357836SJohn.Forte@Sun.COM } 19367836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp0_reg[cnt]); 19377836SJohn.Forte@Sun.COM } 19387836SJohn.Forte@Sun.COM 19397836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP1 Registers:"); 19407836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) { 19417836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19427836SJohn.Forte@Sun.COM mdb_printf("\n"); 19437836SJohn.Forte@Sun.COM } 19447836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp1_reg[cnt]); 19457836SJohn.Forte@Sun.COM } 19467836SJohn.Forte@Sun.COM 19477836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP2 Registers:"); 19487836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) { 19497836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19507836SJohn.Forte@Sun.COM mdb_printf("\n"); 19517836SJohn.Forte@Sun.COM } 19527836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp2_reg[cnt]); 19537836SJohn.Forte@Sun.COM } 19547836SJohn.Forte@Sun.COM 19557836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP3 Registers:"); 19567836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) { 19577836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19587836SJohn.Forte@Sun.COM mdb_printf("\n"); 19597836SJohn.Forte@Sun.COM } 19607836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp3_reg[cnt]); 19617836SJohn.Forte@Sun.COM } 19627836SJohn.Forte@Sun.COM 19637836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP4 Registers:"); 19647836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) { 19657836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19667836SJohn.Forte@Sun.COM mdb_printf("\n"); 19677836SJohn.Forte@Sun.COM } 19687836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp4_reg[cnt]); 19697836SJohn.Forte@Sun.COM } 19707836SJohn.Forte@Sun.COM 19717836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP5 Registers:"); 19727836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) { 19737836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19747836SJohn.Forte@Sun.COM mdb_printf("\n"); 19757836SJohn.Forte@Sun.COM } 19767836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp5_reg[cnt]); 19777836SJohn.Forte@Sun.COM } 19787836SJohn.Forte@Sun.COM 19797836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP6 Registers:"); 19807836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) { 19817836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19827836SJohn.Forte@Sun.COM mdb_printf("\n"); 19837836SJohn.Forte@Sun.COM } 19847836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp6_reg[cnt]); 19857836SJohn.Forte@Sun.COM } 19867836SJohn.Forte@Sun.COM 19877836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP7 Registers:"); 19887836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) { 19897836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19907836SJohn.Forte@Sun.COM mdb_printf("\n"); 19917836SJohn.Forte@Sun.COM } 19927836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp7_reg[cnt]); 19937836SJohn.Forte@Sun.COM } 19947836SJohn.Forte@Sun.COM 19957836SJohn.Forte@Sun.COM mdb_printf("\n\nFrame Buffer Hardware Registers:"); 19967836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) { 19977836SJohn.Forte@Sun.COM if ((cnt == 16) && 19987836SJohn.Forte@Sun.COM ((ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) == 0)) { 19997836SJohn.Forte@Sun.COM break; 20007836SJohn.Forte@Sun.COM } 20017836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20027836SJohn.Forte@Sun.COM mdb_printf("\n"); 20037836SJohn.Forte@Sun.COM } 20047836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->frame_buf_hdw_reg[cnt]); 20057836SJohn.Forte@Sun.COM } 20067836SJohn.Forte@Sun.COM 20077836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM B0 Registers:"); 20087836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) { 20097836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20107836SJohn.Forte@Sun.COM mdb_printf("\n"); 20117836SJohn.Forte@Sun.COM } 20127836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->fpm_b0_reg[cnt]); 20137836SJohn.Forte@Sun.COM } 20147836SJohn.Forte@Sun.COM 20157836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM B1 Registers:"); 20167836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) { 20177836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20187836SJohn.Forte@Sun.COM mdb_printf("\n"); 20197836SJohn.Forte@Sun.COM } 20207836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->fpm_b1_reg[cnt]); 20217836SJohn.Forte@Sun.COM } 20227836SJohn.Forte@Sun.COM 20237836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 20247836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM Dump:"); 20257836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) { 20267836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20277836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x0800); 20287836SJohn.Forte@Sun.COM } 20297836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_ram[cnt]); 20307836SJohn.Forte@Sun.COM } 20317836SJohn.Forte@Sun.COM 20327836SJohn.Forte@Sun.COM mdb_printf("\n\nStack RAM Dump:"); 20337836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) { 20347836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20357836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x010000); 20367836SJohn.Forte@Sun.COM } 20377836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->stack_ram[cnt]); 20387836SJohn.Forte@Sun.COM } 20397836SJohn.Forte@Sun.COM 20407836SJohn.Forte@Sun.COM mdb_printf("\n\nData RAM Dump:"); 20417836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) { 20427836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20437836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x010800); 20447836SJohn.Forte@Sun.COM } 20457836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->data_ram[cnt]); 20467836SJohn.Forte@Sun.COM } 20477836SJohn.Forte@Sun.COM 20487836SJohn.Forte@Sun.COM mdb_printf("\n\n[<==END] ISP Debug Dump.\n"); 2049*9156SDaniel.Beauregard@Sun.COM 2050*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 2051*9156SDaniel.Beauregard@Sun.COM 2052*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 2053*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2054*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2055*9156SDaniel.Beauregard@Sun.COM } 2056*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 2057*9156SDaniel.Beauregard@Sun.COM } 2058*9156SDaniel.Beauregard@Sun.COM 2059*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 2060*9156SDaniel.Beauregard@Sun.COM 2061*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 2062*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2063*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2064*9156SDaniel.Beauregard@Sun.COM } 2065*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 2066*9156SDaniel.Beauregard@Sun.COM } 2067*9156SDaniel.Beauregard@Sun.COM 2068*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 2069*9156SDaniel.Beauregard@Sun.COM 20707836SJohn.Forte@Sun.COM } else { 20717836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC SRAM:"); 20727836SJohn.Forte@Sun.COM for (cnt = 0; cnt < 0xf000; cnt++) { 20737836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20747836SJohn.Forte@Sun.COM mdb_printf("\n%04x: ", cnt + 0x1000); 20757836SJohn.Forte@Sun.COM } 20767836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_ram[cnt]); 20777836SJohn.Forte@Sun.COM } 20787836SJohn.Forte@Sun.COM } 20797836SJohn.Forte@Sun.COM 2080*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 2081*9156SDaniel.Beauregard@Sun.COM 20827836SJohn.Forte@Sun.COM return (DCMD_OK); 20837836SJohn.Forte@Sun.COM } 20847836SJohn.Forte@Sun.COM 20857836SJohn.Forte@Sun.COM /* 20867836SJohn.Forte@Sun.COM * ql_24xx_dump_dcmd 20877836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 20887836SJohn.Forte@Sun.COM * 20897836SJohn.Forte@Sun.COM * Input: 20907836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 20917836SJohn.Forte@Sun.COM * flags = mdb flags. 20927836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 20937836SJohn.Forte@Sun.COM * argv = Arg array. 20947836SJohn.Forte@Sun.COM * 20957836SJohn.Forte@Sun.COM * Returns: 20967836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 20977836SJohn.Forte@Sun.COM * 20987836SJohn.Forte@Sun.COM * Context: 20997836SJohn.Forte@Sun.COM * User context. 21007836SJohn.Forte@Sun.COM * 21017836SJohn.Forte@Sun.COM */ 21027836SJohn.Forte@Sun.COM /*ARGSUSED*/ 21037836SJohn.Forte@Sun.COM static int 21047836SJohn.Forte@Sun.COM ql_24xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 21057836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 21067836SJohn.Forte@Sun.COM { 21077836SJohn.Forte@Sun.COM ql_24xx_fw_dump_t *fw; 21087836SJohn.Forte@Sun.COM uint32_t cnt = 0; 21097836SJohn.Forte@Sun.COM 2110*9156SDaniel.Beauregard@Sun.COM fw = (ql_24xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 2111*9156SDaniel.Beauregard@Sun.COM 2112*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 2113*9156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 21147836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 2115*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 21167836SJohn.Forte@Sun.COM return (DCMD_OK); 21177836SJohn.Forte@Sun.COM } 21187836SJohn.Forte@Sun.COM 21197836SJohn.Forte@Sun.COM mdb_printf("ISP FW Version %d.%02d.%02d Attributes %X\n", 21207836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 21217836SJohn.Forte@Sun.COM ha->fw_subminor_version, ha->fw_attributes); 21227836SJohn.Forte@Sun.COM 21237836SJohn.Forte@Sun.COM mdb_printf("\nHCCR Register\n%08x\n", fw->hccr); 21247836SJohn.Forte@Sun.COM 21257836SJohn.Forte@Sun.COM mdb_printf("\nHost Interface Registers"); 21267836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) { 21277836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21287836SJohn.Forte@Sun.COM mdb_printf("\n"); 21297836SJohn.Forte@Sun.COM } 21307836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->host_reg[cnt]); 21317836SJohn.Forte@Sun.COM } 21327836SJohn.Forte@Sun.COM 21337836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers"); 21347836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 21357836SJohn.Forte@Sun.COM if (cnt % 16 == 0) { 21367836SJohn.Forte@Sun.COM mdb_printf("\n"); 21377836SJohn.Forte@Sun.COM } 21387836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 21397836SJohn.Forte@Sun.COM } 21407836SJohn.Forte@Sun.COM 21417836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ GP Registers"); 21427836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) { 21437836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21447836SJohn.Forte@Sun.COM mdb_printf("\n"); 21457836SJohn.Forte@Sun.COM } 21467836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_gp_reg[cnt]); 21477836SJohn.Forte@Sun.COM } 21487836SJohn.Forte@Sun.COM 21497836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-0 Registers"); 21507836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) { 21517836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21527836SJohn.Forte@Sun.COM mdb_printf("\n"); 21537836SJohn.Forte@Sun.COM } 21547836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_0_reg[cnt]); 21557836SJohn.Forte@Sun.COM } 21567836SJohn.Forte@Sun.COM 21577836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-1 Registers"); 21587836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) { 21597836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21607836SJohn.Forte@Sun.COM mdb_printf("\n"); 21617836SJohn.Forte@Sun.COM } 21627836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_1_reg[cnt]); 21637836SJohn.Forte@Sun.COM } 21647836SJohn.Forte@Sun.COM 21657836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ GP Registers"); 21667836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) { 21677836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21687836SJohn.Forte@Sun.COM mdb_printf("\n"); 21697836SJohn.Forte@Sun.COM } 21707836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_gp_reg[cnt]); 21717836SJohn.Forte@Sun.COM } 21727836SJohn.Forte@Sun.COM 21737836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-0 Registers"); 21747836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) { 21757836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21767836SJohn.Forte@Sun.COM mdb_printf("\n"); 21777836SJohn.Forte@Sun.COM } 21787836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_0_reg[cnt]); 21797836SJohn.Forte@Sun.COM } 21807836SJohn.Forte@Sun.COM 21817836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-1 Registers"); 21827836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) { 21837836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21847836SJohn.Forte@Sun.COM mdb_printf("\n"); 21857836SJohn.Forte@Sun.COM } 21867836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_1_reg[cnt]); 21877836SJohn.Forte@Sun.COM } 21887836SJohn.Forte@Sun.COM 21897836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-2 Registers"); 21907836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) { 21917836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21927836SJohn.Forte@Sun.COM mdb_printf("\n"); 21937836SJohn.Forte@Sun.COM } 21947836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_2_reg[cnt]); 21957836SJohn.Forte@Sun.COM } 21967836SJohn.Forte@Sun.COM 21977836SJohn.Forte@Sun.COM mdb_printf("\n\nCommand DMA Registers"); 21987836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) { 21997836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22007836SJohn.Forte@Sun.COM mdb_printf("\n"); 22017836SJohn.Forte@Sun.COM } 22027836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->cmd_dma_reg[cnt]); 22037836SJohn.Forte@Sun.COM } 22047836SJohn.Forte@Sun.COM 22057836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest0 Queue DMA Channel Registers"); 22067836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) { 22077836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22087836SJohn.Forte@Sun.COM mdb_printf("\n"); 22097836SJohn.Forte@Sun.COM } 22107836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req0_dma_reg[cnt]); 22117836SJohn.Forte@Sun.COM } 22127836SJohn.Forte@Sun.COM 22137836SJohn.Forte@Sun.COM mdb_printf("\n\nResponse0 Queue DMA Channel Registers"); 22147836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) { 22157836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22167836SJohn.Forte@Sun.COM mdb_printf("\n"); 22177836SJohn.Forte@Sun.COM } 22187836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->resp0_dma_reg[cnt]); 22197836SJohn.Forte@Sun.COM } 22207836SJohn.Forte@Sun.COM 22217836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest1 Queue DMA Channel Registers"); 22227836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) { 22237836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22247836SJohn.Forte@Sun.COM mdb_printf("\n"); 22257836SJohn.Forte@Sun.COM } 22267836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req1_dma_reg[cnt]); 22277836SJohn.Forte@Sun.COM } 22287836SJohn.Forte@Sun.COM 22297836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT0 Data DMA Registers"); 22307836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) { 22317836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22327836SJohn.Forte@Sun.COM mdb_printf("\n"); 22337836SJohn.Forte@Sun.COM } 22347836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]); 22357836SJohn.Forte@Sun.COM } 22367836SJohn.Forte@Sun.COM 22377836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT1 Data DMA Registers"); 22387836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) { 22397836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22407836SJohn.Forte@Sun.COM mdb_printf("\n"); 22417836SJohn.Forte@Sun.COM } 22427836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]); 22437836SJohn.Forte@Sun.COM } 22447836SJohn.Forte@Sun.COM 22457836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT2 Data DMA Registers"); 22467836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) { 22477836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22487836SJohn.Forte@Sun.COM mdb_printf("\n"); 22497836SJohn.Forte@Sun.COM } 22507836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]); 22517836SJohn.Forte@Sun.COM } 22527836SJohn.Forte@Sun.COM 22537836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT3 Data DMA Registers"); 22547836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) { 22557836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22567836SJohn.Forte@Sun.COM mdb_printf("\n"); 22577836SJohn.Forte@Sun.COM } 22587836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]); 22597836SJohn.Forte@Sun.COM } 22607836SJohn.Forte@Sun.COM 22617836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT4 Data DMA Registers"); 22627836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) { 22637836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22647836SJohn.Forte@Sun.COM mdb_printf("\n"); 22657836SJohn.Forte@Sun.COM } 22667836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]); 22677836SJohn.Forte@Sun.COM } 22687836SJohn.Forte@Sun.COM 22697836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT Data DMA Common Registers"); 22707836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) { 22717836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22727836SJohn.Forte@Sun.COM mdb_printf("\n"); 22737836SJohn.Forte@Sun.COM } 22747836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]); 22757836SJohn.Forte@Sun.COM } 22767836SJohn.Forte@Sun.COM 22777836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 0 Data DMA Registers"); 22787836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) { 22797836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22807836SJohn.Forte@Sun.COM mdb_printf("\n"); 22817836SJohn.Forte@Sun.COM } 22827836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]); 22837836SJohn.Forte@Sun.COM } 22847836SJohn.Forte@Sun.COM 22857836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 1 Data DMA Registers"); 22867836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) { 22877836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22887836SJohn.Forte@Sun.COM mdb_printf("\n"); 22897836SJohn.Forte@Sun.COM } 22907836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]); 22917836SJohn.Forte@Sun.COM } 22927836SJohn.Forte@Sun.COM 22937836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP Registers"); 22947836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) { 22957836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22967836SJohn.Forte@Sun.COM mdb_printf("\n"); 22977836SJohn.Forte@Sun.COM } 22987836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->risc_gp_reg[cnt]); 22997836SJohn.Forte@Sun.COM } 23007836SJohn.Forte@Sun.COM 23017836SJohn.Forte@Sun.COM mdb_printf("\n\nShadow Registers"); 23027836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) { 23037836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23047836SJohn.Forte@Sun.COM mdb_printf("\n"); 23057836SJohn.Forte@Sun.COM } 23067836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->shadow_reg[cnt]); 23077836SJohn.Forte@Sun.COM } 23087836SJohn.Forte@Sun.COM 23097836SJohn.Forte@Sun.COM mdb_printf("\n\nLMC Registers"); 23107836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) { 23117836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23127836SJohn.Forte@Sun.COM mdb_printf("\n"); 23137836SJohn.Forte@Sun.COM } 23147836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->lmc_reg[cnt]); 23157836SJohn.Forte@Sun.COM } 23167836SJohn.Forte@Sun.COM 23177836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM Hardware Registers"); 23187836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) { 23197836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23207836SJohn.Forte@Sun.COM mdb_printf("\n"); 23217836SJohn.Forte@Sun.COM } 23227836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]); 23237836SJohn.Forte@Sun.COM } 23247836SJohn.Forte@Sun.COM 23257836SJohn.Forte@Sun.COM mdb_printf("\n\nFB Hardware Registers"); 23267836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) { 23277836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23287836SJohn.Forte@Sun.COM mdb_printf("\n"); 23297836SJohn.Forte@Sun.COM } 23307836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fb_hdw_reg[cnt]); 23317836SJohn.Forte@Sun.COM } 23327836SJohn.Forte@Sun.COM 23337836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM"); 23347836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) { 23357836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23367836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x20000); 23377836SJohn.Forte@Sun.COM } 23387836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->code_ram[cnt]); 23397836SJohn.Forte@Sun.COM } 23407836SJohn.Forte@Sun.COM 23417836SJohn.Forte@Sun.COM mdb_printf("\n\nExternal Memory"); 23427836SJohn.Forte@Sun.COM for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) { 23437836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23447836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x100000); 23457836SJohn.Forte@Sun.COM } 23467836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->ext_mem[cnt]); 23477836SJohn.Forte@Sun.COM } 23487836SJohn.Forte@Sun.COM 23497836SJohn.Forte@Sun.COM mdb_printf("\n[<==END] ISP Debug Dump"); 23507836SJohn.Forte@Sun.COM 2351*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 2352*9156SDaniel.Beauregard@Sun.COM 2353*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 2354*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2355*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2356*9156SDaniel.Beauregard@Sun.COM } 2357*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 2358*9156SDaniel.Beauregard@Sun.COM } 2359*9156SDaniel.Beauregard@Sun.COM 2360*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 2361*9156SDaniel.Beauregard@Sun.COM 2362*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 2363*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2364*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2365*9156SDaniel.Beauregard@Sun.COM } 2366*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 2367*9156SDaniel.Beauregard@Sun.COM } 2368*9156SDaniel.Beauregard@Sun.COM 2369*9156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) && 2370*9156SDaniel.Beauregard@Sun.COM (ha->fwexttracebuf.bp != NULL)) { 2371*9156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 2372*9156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwexttracebuf.bp; 2373*9156SDaniel.Beauregard@Sun.COM 2374*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nExtended Trace Buffer Memory"); 2375*9156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 2376*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) { 2377*9156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 2378*9156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 2379*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 2380*9156SDaniel.Beauregard@Sun.COM } 2381*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->ext_trace_buf[cnt]); 2382*9156SDaniel.Beauregard@Sun.COM } 2383*9156SDaniel.Beauregard@Sun.COM } 2384*9156SDaniel.Beauregard@Sun.COM 2385*9156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) && 2386*9156SDaniel.Beauregard@Sun.COM (ha->fwfcetracebuf.bp != NULL)) { 2387*9156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 2388*9156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwfcetracebuf.bp; 2389*9156SDaniel.Beauregard@Sun.COM 2390*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nFC Event Trace Buffer Memory"); 2391*9156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 2392*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) { 2393*9156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 2394*9156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 2395*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 2396*9156SDaniel.Beauregard@Sun.COM } 2397*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->fce_trace_buf[cnt]); 2398*9156SDaniel.Beauregard@Sun.COM } 2399*9156SDaniel.Beauregard@Sun.COM } 2400*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 24017836SJohn.Forte@Sun.COM 24027836SJohn.Forte@Sun.COM return (DCMD_OK); 24037836SJohn.Forte@Sun.COM } 24047836SJohn.Forte@Sun.COM 24057836SJohn.Forte@Sun.COM /* 24067836SJohn.Forte@Sun.COM * ql_25xx_dump_dcmd 24077836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 24087836SJohn.Forte@Sun.COM * 24097836SJohn.Forte@Sun.COM * Input: 24107836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 24117836SJohn.Forte@Sun.COM * flags = mdb flags. 24127836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 24137836SJohn.Forte@Sun.COM * argv = Arg array. 24147836SJohn.Forte@Sun.COM * 24157836SJohn.Forte@Sun.COM * Returns: 24167836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 24177836SJohn.Forte@Sun.COM * 24187836SJohn.Forte@Sun.COM * Context: 24197836SJohn.Forte@Sun.COM * User context. 24207836SJohn.Forte@Sun.COM * 24217836SJohn.Forte@Sun.COM */ 24227836SJohn.Forte@Sun.COM /*ARGSUSED*/ 24237836SJohn.Forte@Sun.COM static int 24247836SJohn.Forte@Sun.COM ql_25xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 24257836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 24267836SJohn.Forte@Sun.COM { 24277836SJohn.Forte@Sun.COM ql_25xx_fw_dump_t *fw; 24287836SJohn.Forte@Sun.COM uint32_t cnt = 0; 24297836SJohn.Forte@Sun.COM 2430*9156SDaniel.Beauregard@Sun.COM fw = (ql_25xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 2431*9156SDaniel.Beauregard@Sun.COM 2432*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 2433*9156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 24347836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 2435*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 24367836SJohn.Forte@Sun.COM return (DCMD_OK); 24377836SJohn.Forte@Sun.COM } 24387836SJohn.Forte@Sun.COM 2439*9156SDaniel.Beauregard@Sun.COM mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n", 24407836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 24417836SJohn.Forte@Sun.COM ha->fw_subminor_version, ha->fw_attributes); 24427836SJohn.Forte@Sun.COM 24437836SJohn.Forte@Sun.COM mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status); 24447836SJohn.Forte@Sun.COM 2445*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nHostRisc Registers"); 24467836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) { 24477836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24487836SJohn.Forte@Sun.COM mdb_printf("\n"); 24497836SJohn.Forte@Sun.COM } 24507836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->hostrisc_reg[cnt]); 24517836SJohn.Forte@Sun.COM } 24527836SJohn.Forte@Sun.COM 2453*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nPCIe Registers"); 24547836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) { 24557836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24567836SJohn.Forte@Sun.COM mdb_printf("\n"); 24577836SJohn.Forte@Sun.COM } 24587836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->pcie_reg[cnt]); 24597836SJohn.Forte@Sun.COM } 24607836SJohn.Forte@Sun.COM 2461*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nHost Interface Registers"); 24627836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) { 24637836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24647836SJohn.Forte@Sun.COM mdb_printf("\n"); 24657836SJohn.Forte@Sun.COM } 24667836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->host_reg[cnt]); 24677836SJohn.Forte@Sun.COM } 24687836SJohn.Forte@Sun.COM 2469*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nShadow Registers"); 2470*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) { 2471*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2472*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 2473*9156SDaniel.Beauregard@Sun.COM } 2474*9156SDaniel.Beauregard@Sun.COM 2475*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->shadow_reg[cnt]); 2476*9156SDaniel.Beauregard@Sun.COM } 2477*9156SDaniel.Beauregard@Sun.COM 24787836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers"); 24797836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 24807836SJohn.Forte@Sun.COM if (cnt % 16 == 0) { 24817836SJohn.Forte@Sun.COM mdb_printf("\n"); 24827836SJohn.Forte@Sun.COM } 24837836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 24847836SJohn.Forte@Sun.COM } 24857836SJohn.Forte@Sun.COM 24867836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ GP Registers"); 24877836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) { 24887836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24897836SJohn.Forte@Sun.COM mdb_printf("\n"); 24907836SJohn.Forte@Sun.COM } 24917836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_gp_reg[cnt]); 24927836SJohn.Forte@Sun.COM } 24937836SJohn.Forte@Sun.COM 24947836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-0 Registers"); 24957836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) { 24967836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24977836SJohn.Forte@Sun.COM mdb_printf("\n"); 24987836SJohn.Forte@Sun.COM } 24997836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_0_reg[cnt]); 25007836SJohn.Forte@Sun.COM } 25017836SJohn.Forte@Sun.COM 25027836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-1 Registers"); 25037836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) { 25047836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25057836SJohn.Forte@Sun.COM mdb_printf("\n"); 25067836SJohn.Forte@Sun.COM } 25077836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_1_reg[cnt]); 25087836SJohn.Forte@Sun.COM } 25097836SJohn.Forte@Sun.COM 25107836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ GP Registers"); 25117836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) { 25127836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25137836SJohn.Forte@Sun.COM mdb_printf("\n"); 25147836SJohn.Forte@Sun.COM } 25157836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_gp_reg[cnt]); 25167836SJohn.Forte@Sun.COM } 25177836SJohn.Forte@Sun.COM 25187836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-0 Registers"); 25197836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) { 25207836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25217836SJohn.Forte@Sun.COM mdb_printf("\n"); 25227836SJohn.Forte@Sun.COM } 25237836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_0_reg[cnt]); 25247836SJohn.Forte@Sun.COM } 25257836SJohn.Forte@Sun.COM 25267836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-1 Registers"); 25277836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) { 25287836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25297836SJohn.Forte@Sun.COM mdb_printf("\n"); 25307836SJohn.Forte@Sun.COM } 25317836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_1_reg[cnt]); 25327836SJohn.Forte@Sun.COM } 25337836SJohn.Forte@Sun.COM 25347836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-2 Registers"); 25357836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) { 25367836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25377836SJohn.Forte@Sun.COM mdb_printf("\n"); 25387836SJohn.Forte@Sun.COM } 25397836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_2_reg[cnt]); 25407836SJohn.Forte@Sun.COM } 25417836SJohn.Forte@Sun.COM 25427836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ GP Registers"); 25437836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) { 25447836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25457836SJohn.Forte@Sun.COM mdb_printf("\n"); 25467836SJohn.Forte@Sun.COM } 25477836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_gp_reg[cnt]); 25487836SJohn.Forte@Sun.COM } 25497836SJohn.Forte@Sun.COM 25507836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-0 GP Registers"); 25517836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) { 25527836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25537836SJohn.Forte@Sun.COM mdb_printf("\n"); 25547836SJohn.Forte@Sun.COM } 25557836SJohn.Forte@Sun.COM 25567836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_0_reg[cnt]); 25577836SJohn.Forte@Sun.COM } 25587836SJohn.Forte@Sun.COM 25597836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-1 GP Registers"); 25607836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) { 25617836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25627836SJohn.Forte@Sun.COM mdb_printf("\n"); 25637836SJohn.Forte@Sun.COM } 25647836SJohn.Forte@Sun.COM 25657836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_1_reg[cnt]); 25667836SJohn.Forte@Sun.COM } 25677836SJohn.Forte@Sun.COM 25687836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-2 GP Registers"); 25697836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) { 25707836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25717836SJohn.Forte@Sun.COM mdb_printf("\n"); 25727836SJohn.Forte@Sun.COM } 25737836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_2_reg[cnt]); 25747836SJohn.Forte@Sun.COM } 25757836SJohn.Forte@Sun.COM 25767836SJohn.Forte@Sun.COM mdb_printf("\n\nCommand DMA Registers"); 25777836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) { 25787836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25797836SJohn.Forte@Sun.COM mdb_printf("\n"); 25807836SJohn.Forte@Sun.COM } 25817836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->cmd_dma_reg[cnt]); 25827836SJohn.Forte@Sun.COM } 25837836SJohn.Forte@Sun.COM 25847836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest0 Queue DMA Channel Registers"); 25857836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) { 25867836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25877836SJohn.Forte@Sun.COM mdb_printf("\n"); 25887836SJohn.Forte@Sun.COM } 25897836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req0_dma_reg[cnt]); 25907836SJohn.Forte@Sun.COM } 25917836SJohn.Forte@Sun.COM 25927836SJohn.Forte@Sun.COM mdb_printf("\n\nResponse0 Queue DMA Channel Registers"); 25937836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) { 25947836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25957836SJohn.Forte@Sun.COM mdb_printf("\n"); 25967836SJohn.Forte@Sun.COM } 25977836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->resp0_dma_reg[cnt]); 25987836SJohn.Forte@Sun.COM } 25997836SJohn.Forte@Sun.COM 26007836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest1 Queue DMA Channel Registers"); 26017836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) { 26027836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26037836SJohn.Forte@Sun.COM mdb_printf("\n"); 26047836SJohn.Forte@Sun.COM } 26057836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req1_dma_reg[cnt]); 26067836SJohn.Forte@Sun.COM } 26077836SJohn.Forte@Sun.COM 26087836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT0 Data DMA Registers"); 26097836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) { 26107836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26117836SJohn.Forte@Sun.COM mdb_printf("\n"); 26127836SJohn.Forte@Sun.COM } 26137836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]); 26147836SJohn.Forte@Sun.COM } 26157836SJohn.Forte@Sun.COM 26167836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT1 Data DMA Registers"); 26177836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) { 26187836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26197836SJohn.Forte@Sun.COM mdb_printf("\n"); 26207836SJohn.Forte@Sun.COM } 26217836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]); 26227836SJohn.Forte@Sun.COM } 26237836SJohn.Forte@Sun.COM 26247836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT2 Data DMA Registers"); 26257836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) { 26267836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26277836SJohn.Forte@Sun.COM mdb_printf("\n"); 26287836SJohn.Forte@Sun.COM } 26297836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]); 26307836SJohn.Forte@Sun.COM } 26317836SJohn.Forte@Sun.COM 26327836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT3 Data DMA Registers"); 26337836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) { 26347836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26357836SJohn.Forte@Sun.COM mdb_printf("\n"); 26367836SJohn.Forte@Sun.COM } 26377836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]); 26387836SJohn.Forte@Sun.COM } 26397836SJohn.Forte@Sun.COM 26407836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT4 Data DMA Registers"); 26417836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) { 26427836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26437836SJohn.Forte@Sun.COM mdb_printf("\n"); 26447836SJohn.Forte@Sun.COM } 26457836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]); 26467836SJohn.Forte@Sun.COM } 26477836SJohn.Forte@Sun.COM 26487836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT Data DMA Common Registers"); 26497836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) { 26507836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26517836SJohn.Forte@Sun.COM mdb_printf("\n"); 26527836SJohn.Forte@Sun.COM } 26537836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]); 26547836SJohn.Forte@Sun.COM } 26557836SJohn.Forte@Sun.COM 26567836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 0 Data DMA Registers"); 26577836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) { 26587836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26597836SJohn.Forte@Sun.COM mdb_printf("\n"); 26607836SJohn.Forte@Sun.COM } 26617836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]); 26627836SJohn.Forte@Sun.COM } 26637836SJohn.Forte@Sun.COM 26647836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 1 Data DMA Registers"); 26657836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) { 26667836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26677836SJohn.Forte@Sun.COM mdb_printf("\n"); 26687836SJohn.Forte@Sun.COM } 26697836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]); 26707836SJohn.Forte@Sun.COM } 26717836SJohn.Forte@Sun.COM 26727836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP Registers"); 26737836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) { 26747836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26757836SJohn.Forte@Sun.COM mdb_printf("\n"); 26767836SJohn.Forte@Sun.COM } 26777836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->risc_gp_reg[cnt]); 26787836SJohn.Forte@Sun.COM } 26797836SJohn.Forte@Sun.COM 26807836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io); 26817836SJohn.Forte@Sun.COM 26827836SJohn.Forte@Sun.COM mdb_printf("\n\nLMC Registers"); 26837836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) { 26847836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26857836SJohn.Forte@Sun.COM mdb_printf("\n"); 26867836SJohn.Forte@Sun.COM } 26877836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->lmc_reg[cnt]); 26887836SJohn.Forte@Sun.COM } 26897836SJohn.Forte@Sun.COM 26907836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM Hardware Registers"); 26917836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) { 26927836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26937836SJohn.Forte@Sun.COM mdb_printf("\n"); 26947836SJohn.Forte@Sun.COM } 26957836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]); 26967836SJohn.Forte@Sun.COM } 26977836SJohn.Forte@Sun.COM 26987836SJohn.Forte@Sun.COM mdb_printf("\n\nFB Hardware Registers"); 26997836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) { 27007836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 27017836SJohn.Forte@Sun.COM mdb_printf("\n"); 27027836SJohn.Forte@Sun.COM } 27037836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fb_hdw_reg[cnt]); 27047836SJohn.Forte@Sun.COM } 27057836SJohn.Forte@Sun.COM 27067836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM"); 27077836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) { 27087836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 27097836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x20000); 27107836SJohn.Forte@Sun.COM } 27117836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->code_ram[cnt]); 27127836SJohn.Forte@Sun.COM } 27137836SJohn.Forte@Sun.COM 27147836SJohn.Forte@Sun.COM mdb_printf("\n\nExternal Memory"); 27157836SJohn.Forte@Sun.COM for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) { 27167836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 27177836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x100000); 27187836SJohn.Forte@Sun.COM } 27197836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->ext_mem[cnt]); 27207836SJohn.Forte@Sun.COM } 27217836SJohn.Forte@Sun.COM 27227836SJohn.Forte@Sun.COM mdb_printf("\n[<==END] ISP Debug Dump"); 27237836SJohn.Forte@Sun.COM 2724*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 2725*9156SDaniel.Beauregard@Sun.COM 2726*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 2727*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2728*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2729*9156SDaniel.Beauregard@Sun.COM } 2730*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 2731*9156SDaniel.Beauregard@Sun.COM } 2732*9156SDaniel.Beauregard@Sun.COM 2733*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 2734*9156SDaniel.Beauregard@Sun.COM 2735*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 2736*9156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 2737*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 2738*9156SDaniel.Beauregard@Sun.COM } 2739*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 2740*9156SDaniel.Beauregard@Sun.COM } 2741*9156SDaniel.Beauregard@Sun.COM 2742*9156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) && 2743*9156SDaniel.Beauregard@Sun.COM (ha->fwexttracebuf.bp != NULL)) { 2744*9156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 2745*9156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwexttracebuf.bp; 2746*9156SDaniel.Beauregard@Sun.COM 2747*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nExtended Trace Buffer Memory"); 2748*9156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 2749*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) { 2750*9156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 2751*9156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 2752*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 2753*9156SDaniel.Beauregard@Sun.COM } 2754*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->ext_trace_buf[cnt]); 2755*9156SDaniel.Beauregard@Sun.COM } 2756*9156SDaniel.Beauregard@Sun.COM } 2757*9156SDaniel.Beauregard@Sun.COM 2758*9156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) && 2759*9156SDaniel.Beauregard@Sun.COM (ha->fwfcetracebuf.bp != NULL)) { 2760*9156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 2761*9156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwfcetracebuf.bp; 2762*9156SDaniel.Beauregard@Sun.COM 2763*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nFC Event Trace Buffer Memory"); 2764*9156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 2765*9156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) { 2766*9156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 2767*9156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 2768*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 2769*9156SDaniel.Beauregard@Sun.COM } 2770*9156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->fce_trace_buf[cnt]); 2771*9156SDaniel.Beauregard@Sun.COM } 2772*9156SDaniel.Beauregard@Sun.COM } 2773*9156SDaniel.Beauregard@Sun.COM 2774*9156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 2775*9156SDaniel.Beauregard@Sun.COM 2776*9156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nreturn exit\n"); 27777836SJohn.Forte@Sun.COM 27787836SJohn.Forte@Sun.COM return (DCMD_OK); 27797836SJohn.Forte@Sun.COM } 27807836SJohn.Forte@Sun.COM 27817836SJohn.Forte@Sun.COM /* 2782*9156SDaniel.Beauregard@Sun.COM * ql_gettrace_dcmd 2783*9156SDaniel.Beauregard@Sun.COM * prints out the Extended Logging trace buffer 2784*9156SDaniel.Beauregard@Sun.COM * 2785*9156SDaniel.Beauregard@Sun.COM * Input: 2786*9156SDaniel.Beauregard@Sun.COM * addr = User supplied address. (NB: must be an ha) 2787*9156SDaniel.Beauregard@Sun.COM * flags = mdb flags. 2788*9156SDaniel.Beauregard@Sun.COM * argc = Number of user supplied args. 2789*9156SDaniel.Beauregard@Sun.COM * argv = Arg array. 2790*9156SDaniel.Beauregard@Sun.COM * 2791*9156SDaniel.Beauregard@Sun.COM * Returns: 2792*9156SDaniel.Beauregard@Sun.COM * DCMD_OK or DCMD_ERR 2793*9156SDaniel.Beauregard@Sun.COM * 2794*9156SDaniel.Beauregard@Sun.COM * Context: 2795*9156SDaniel.Beauregard@Sun.COM * User context. 2796*9156SDaniel.Beauregard@Sun.COM * 2797*9156SDaniel.Beauregard@Sun.COM */ 2798*9156SDaniel.Beauregard@Sun.COM static int 2799*9156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 2800*9156SDaniel.Beauregard@Sun.COM { 2801*9156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *ha; 2802*9156SDaniel.Beauregard@Sun.COM int verbose = 0; 2803*9156SDaniel.Beauregard@Sun.COM int wrapped = 0; 2804*9156SDaniel.Beauregard@Sun.COM char *trace_start; 2805*9156SDaniel.Beauregard@Sun.COM char *trace_end; 2806*9156SDaniel.Beauregard@Sun.COM char *dump_start = 0; 2807*9156SDaniel.Beauregard@Sun.COM char *trace_next = 0; 2808*9156SDaniel.Beauregard@Sun.COM char *dump_current = 0; 2809*9156SDaniel.Beauregard@Sun.COM el_trace_desc_t *trace_desc; 2810*9156SDaniel.Beauregard@Sun.COM 2811*9156SDaniel.Beauregard@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 2812*9156SDaniel.Beauregard@Sun.COM mdb_warn("ql_adapter_state structure addr is required"); 2813*9156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 2814*9156SDaniel.Beauregard@Sun.COM } 2815*9156SDaniel.Beauregard@Sun.COM 2816*9156SDaniel.Beauregard@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 2817*9156SDaniel.Beauregard@Sun.COM argc) { 2818*9156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 2819*9156SDaniel.Beauregard@Sun.COM } 2820*9156SDaniel.Beauregard@Sun.COM 2821*9156SDaniel.Beauregard@Sun.COM /* 2822*9156SDaniel.Beauregard@Sun.COM * Get the adapter state struct which was passed 2823*9156SDaniel.Beauregard@Sun.COM */ 2824*9156SDaniel.Beauregard@Sun.COM if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 2825*9156SDaniel.Beauregard@Sun.COM UM_SLEEP)) == NULL) { 2826*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 2827*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2828*9156SDaniel.Beauregard@Sun.COM } 2829*9156SDaniel.Beauregard@Sun.COM 2830*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 2831*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 2832*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2833*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2834*9156SDaniel.Beauregard@Sun.COM } 2835*9156SDaniel.Beauregard@Sun.COM 2836*9156SDaniel.Beauregard@Sun.COM /* 2837*9156SDaniel.Beauregard@Sun.COM * If its not a valid trace descriptor then bail out 2838*9156SDaniel.Beauregard@Sun.COM */ 2839*9156SDaniel.Beauregard@Sun.COM if (ha->el_trace_desc == NULL) { 2840*9156SDaniel.Beauregard@Sun.COM mdb_warn("trace descriptor does not exist for instance %d\n", 2841*9156SDaniel.Beauregard@Sun.COM ha->instance); 2842*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2843*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2844*9156SDaniel.Beauregard@Sun.COM } else { 2845*9156SDaniel.Beauregard@Sun.COM trace_desc = (el_trace_desc_t *) 2846*9156SDaniel.Beauregard@Sun.COM mdb_alloc(sizeof (el_trace_desc_t), UM_SLEEP); 2847*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(trace_desc, sizeof (el_trace_desc_t), 2848*9156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->el_trace_desc) == -1) { 2849*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 2850*9156SDaniel.Beauregard@Sun.COM addr); 2851*9156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 2852*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2853*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2854*9156SDaniel.Beauregard@Sun.COM } 2855*9156SDaniel.Beauregard@Sun.COM if (trace_desc->trace_buffer == NULL) { 2856*9156SDaniel.Beauregard@Sun.COM mdb_warn("trace buffer does not exist for " 2857*9156SDaniel.Beauregard@Sun.COM "instance %d\n", ha->instance); 2858*9156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 2859*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2860*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2861*9156SDaniel.Beauregard@Sun.COM } 2862*9156SDaniel.Beauregard@Sun.COM } 2863*9156SDaniel.Beauregard@Sun.COM 2864*9156SDaniel.Beauregard@Sun.COM /* Get the trace buffer */ 2865*9156SDaniel.Beauregard@Sun.COM 2866*9156SDaniel.Beauregard@Sun.COM trace_start = (char *) 2867*9156SDaniel.Beauregard@Sun.COM mdb_zalloc(trace_desc->trace_buffer_size, UM_SLEEP); 2868*9156SDaniel.Beauregard@Sun.COM 2869*9156SDaniel.Beauregard@Sun.COM if (mdb_vread(trace_start, trace_desc->trace_buffer_size, 2870*9156SDaniel.Beauregard@Sun.COM (uintptr_t)trace_desc->trace_buffer) == -1) { 2871*9156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read trace buffer?)"); 2872*9156SDaniel.Beauregard@Sun.COM mdb_free(trace_start, trace_desc->trace_buffer_size); 2873*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2874*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2875*9156SDaniel.Beauregard@Sun.COM } 2876*9156SDaniel.Beauregard@Sun.COM 2877*9156SDaniel.Beauregard@Sun.COM /* set the end of the trace buffer. */ 2878*9156SDaniel.Beauregard@Sun.COM trace_end = trace_start + trace_desc->trace_buffer_size; 2879*9156SDaniel.Beauregard@Sun.COM 2880*9156SDaniel.Beauregard@Sun.COM /* Find the start point of trace. */ 2881*9156SDaniel.Beauregard@Sun.COM trace_next = trace_start + trace_desc->next; 2882*9156SDaniel.Beauregard@Sun.COM 2883*9156SDaniel.Beauregard@Sun.COM /* 2884*9156SDaniel.Beauregard@Sun.COM * If the buffer has not wrapped next will point at a null so 2885*9156SDaniel.Beauregard@Sun.COM * start is the begining of the buffer. If next points at a char 2886*9156SDaniel.Beauregard@Sun.COM * then we must traverse the buffer further until a null is detected. 2887*9156SDaniel.Beauregard@Sun.COM * The location after the null will be the beginning of the oldest 2888*9156SDaniel.Beauregard@Sun.COM * whole object in the buffer, which we use as the start. 2889*9156SDaniel.Beauregard@Sun.COM */ 2890*9156SDaniel.Beauregard@Sun.COM 2891*9156SDaniel.Beauregard@Sun.COM if ((trace_next + EL_BUFFER_RESERVE) >= trace_end) { 2892*9156SDaniel.Beauregard@Sun.COM dump_start = trace_start; 2893*9156SDaniel.Beauregard@Sun.COM } else if (*trace_next != NULL) { 2894*9156SDaniel.Beauregard@Sun.COM dump_start = trace_next + (strlen(trace_next) + 1); 2895*9156SDaniel.Beauregard@Sun.COM } else { 2896*9156SDaniel.Beauregard@Sun.COM dump_start = trace_start; 2897*9156SDaniel.Beauregard@Sun.COM } 2898*9156SDaniel.Beauregard@Sun.COM 2899*9156SDaniel.Beauregard@Sun.COM dump_current = dump_start; 2900*9156SDaniel.Beauregard@Sun.COM 2901*9156SDaniel.Beauregard@Sun.COM mdb_printf("\nExtended Logging trace buffer @%x, start @%x, " 2902*9156SDaniel.Beauregard@Sun.COM "size=%d\n\n", trace_start, dump_current, 2903*9156SDaniel.Beauregard@Sun.COM trace_desc->trace_buffer_size); 2904*9156SDaniel.Beauregard@Sun.COM 2905*9156SDaniel.Beauregard@Sun.COM /* Don't run off the end, no matter what. */ 2906*9156SDaniel.Beauregard@Sun.COM while (((uintptr_t)dump_current - (uintptr_t)trace_start) <= 2907*9156SDaniel.Beauregard@Sun.COM (uintptr_t)trace_desc->trace_buffer_size) { 2908*9156SDaniel.Beauregard@Sun.COM /* Show it... */ 2909*9156SDaniel.Beauregard@Sun.COM mdb_printf("%s", dump_current); 2910*9156SDaniel.Beauregard@Sun.COM /* Calculate the next and make it the current */ 2911*9156SDaniel.Beauregard@Sun.COM dump_current += (strlen(dump_current) + 1); 2912*9156SDaniel.Beauregard@Sun.COM /* check for wrap */ 2913*9156SDaniel.Beauregard@Sun.COM if ((dump_current + EL_BUFFER_RESERVE) >= trace_end) { 2914*9156SDaniel.Beauregard@Sun.COM mdb_printf("Wraping %x\n", dump_current); 2915*9156SDaniel.Beauregard@Sun.COM dump_current = trace_start; 2916*9156SDaniel.Beauregard@Sun.COM wrapped = 1; 2917*9156SDaniel.Beauregard@Sun.COM } else if (wrapped) { 2918*9156SDaniel.Beauregard@Sun.COM /* Don't go past next. */ 2919*9156SDaniel.Beauregard@Sun.COM if ((trace_start + trace_desc->next) <= dump_current) { 2920*9156SDaniel.Beauregard@Sun.COM mdb_printf("Done %x", dump_current); 2921*9156SDaniel.Beauregard@Sun.COM break; 2922*9156SDaniel.Beauregard@Sun.COM } 2923*9156SDaniel.Beauregard@Sun.COM } else if (*dump_current == NULL) { 2924*9156SDaniel.Beauregard@Sun.COM mdb_printf("Done %x(null)", dump_current); 2925*9156SDaniel.Beauregard@Sun.COM break; 2926*9156SDaniel.Beauregard@Sun.COM } 2927*9156SDaniel.Beauregard@Sun.COM } 2928*9156SDaniel.Beauregard@Sun.COM 2929*9156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 2930*9156SDaniel.Beauregard@Sun.COM mdb_free(trace_start, trace_desc->trace_buffer_size); 2931*9156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 2932*9156SDaniel.Beauregard@Sun.COM 2933*9156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 2934*9156SDaniel.Beauregard@Sun.COM } 2935*9156SDaniel.Beauregard@Sun.COM /* 29367836SJohn.Forte@Sun.COM * ql_doprint 29377836SJohn.Forte@Sun.COM * ql generic function to call the print dcmd 29387836SJohn.Forte@Sun.COM * 29397836SJohn.Forte@Sun.COM * Input: 29407836SJohn.Forte@Sun.COM * addr - address to struct 29417836SJohn.Forte@Sun.COM * prtsting - address to string 29427836SJohn.Forte@Sun.COM * 29437836SJohn.Forte@Sun.COM * Returns: 29447836SJohn.Forte@Sun.COM * WALK_DONE 29457836SJohn.Forte@Sun.COM * 29467836SJohn.Forte@Sun.COM * Context: 29477836SJohn.Forte@Sun.COM * User context. 29487836SJohn.Forte@Sun.COM * 29497836SJohn.Forte@Sun.COM */ 29507836SJohn.Forte@Sun.COM static int32_t 29517836SJohn.Forte@Sun.COM ql_doprint(uintptr_t addr, int8_t *prtstring) 29527836SJohn.Forte@Sun.COM { 29537836SJohn.Forte@Sun.COM struct mdb_arg printarg; 29547836SJohn.Forte@Sun.COM 29557836SJohn.Forte@Sun.COM printarg.a_un.a_str = (int8_t *)(mdb_zalloc(strlen(prtstring), 29567836SJohn.Forte@Sun.COM UM_SLEEP)); 29577836SJohn.Forte@Sun.COM printarg.a_type = MDB_TYPE_STRING; 29587836SJohn.Forte@Sun.COM (void) strcpy((int8_t *)(printarg.a_un.a_str), prtstring); 29597836SJohn.Forte@Sun.COM 29607836SJohn.Forte@Sun.COM if ((mdb_call_dcmd("print", addr, DCMD_ADDRSPEC, 1, 29617836SJohn.Forte@Sun.COM &printarg)) == -1) { 29627836SJohn.Forte@Sun.COM mdb_warn("ql_doprint: failed print dcmd: %s" 29637836SJohn.Forte@Sun.COM "at addr: %llxh", prtstring, addr); 29647836SJohn.Forte@Sun.COM } 29657836SJohn.Forte@Sun.COM 29667836SJohn.Forte@Sun.COM mdb_free((void *)(printarg.a_un.a_str), strlen(prtstring)); 29677836SJohn.Forte@Sun.COM return (WALK_DONE); 29687836SJohn.Forte@Sun.COM } 29697836SJohn.Forte@Sun.COM 29707836SJohn.Forte@Sun.COM /* 29717836SJohn.Forte@Sun.COM * ql_dump_flags 29727836SJohn.Forte@Sun.COM * mdb utility to print the flag string 29737836SJohn.Forte@Sun.COM * 29747836SJohn.Forte@Sun.COM * Input: 29757836SJohn.Forte@Sun.COM * flags - flags to print 29767836SJohn.Forte@Sun.COM * strings - text to print when flag is set 29777836SJohn.Forte@Sun.COM * 29787836SJohn.Forte@Sun.COM * Returns: 29797836SJohn.Forte@Sun.COM * 29807836SJohn.Forte@Sun.COM * 29817836SJohn.Forte@Sun.COM * Context: 29827836SJohn.Forte@Sun.COM * User context. 29837836SJohn.Forte@Sun.COM * 29847836SJohn.Forte@Sun.COM */ 29857836SJohn.Forte@Sun.COM static void 29867836SJohn.Forte@Sun.COM ql_dump_flags(uint64_t flags, int8_t **strings) 29877836SJohn.Forte@Sun.COM { 29887836SJohn.Forte@Sun.COM int i, linel, first = 1; 29897836SJohn.Forte@Sun.COM uint64_t mask = 1; 29907836SJohn.Forte@Sun.COM 29917836SJohn.Forte@Sun.COM linel = 8; 29927836SJohn.Forte@Sun.COM mdb_printf("\t"); 29937836SJohn.Forte@Sun.COM for (i = 0; i < 64; i++) { 29947836SJohn.Forte@Sun.COM if (strings[i] == NULL) 29957836SJohn.Forte@Sun.COM break; 29967836SJohn.Forte@Sun.COM if (flags & mask) { 29977836SJohn.Forte@Sun.COM if (!first) { 29987836SJohn.Forte@Sun.COM mdb_printf(" | "); 29997836SJohn.Forte@Sun.COM } else { 30007836SJohn.Forte@Sun.COM first = 0; 30017836SJohn.Forte@Sun.COM } 30027836SJohn.Forte@Sun.COM linel += (int32_t)strlen(strings[i]) + 3; 30037836SJohn.Forte@Sun.COM if (linel > 80) { 30047836SJohn.Forte@Sun.COM mdb_printf("\n\t"); 30057836SJohn.Forte@Sun.COM linel = (int32_t)strlen(strings[i]) + 1 + 8; 30067836SJohn.Forte@Sun.COM } 30077836SJohn.Forte@Sun.COM mdb_printf("%s", strings[i]); 30087836SJohn.Forte@Sun.COM } 30097836SJohn.Forte@Sun.COM mask <<= 1; 30107836SJohn.Forte@Sun.COM } 30117836SJohn.Forte@Sun.COM mdb_printf("\n"); 30127836SJohn.Forte@Sun.COM } 30137836SJohn.Forte@Sun.COM 30147836SJohn.Forte@Sun.COM /* 30157836SJohn.Forte@Sun.COM * MDB module linkage information 30167836SJohn.Forte@Sun.COM * 30177836SJohn.Forte@Sun.COM * 30187836SJohn.Forte@Sun.COM * dcmd structures for the _mdb_init function 30197836SJohn.Forte@Sun.COM */ 30207836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = { 30217836SJohn.Forte@Sun.COM { "qlclinks", NULL, "Prints qlc link information", qlclinks_dcmd }, 30227836SJohn.Forte@Sun.COM { "qlcosc", NULL, "Prints outstanding cmd info", qlc_osc_dcmd }, 30237836SJohn.Forte@Sun.COM { "qlcver", NULL, "Prints driver/mdb version", qlcver_dcmd }, 30247836SJohn.Forte@Sun.COM { "qlc_elog", "[on|off] [<inst #>|all]", "Turns qlc extended logging " 30257836SJohn.Forte@Sun.COM "on / off", qlc_el_dcmd }, 30267836SJohn.Forte@Sun.COM { "qlcstate", ":[-v]", "Prints qlc adapter state information", 30277836SJohn.Forte@Sun.COM qlcstate_dcmd }, 30287836SJohn.Forte@Sun.COM { "qlctgtq", NULL, "Prints qlc target queues", qltgtq_dcmd }, 30297836SJohn.Forte@Sun.COM { "qlcwdog", NULL, "Prints out watchdog linked list", qlc_wdog_dcmd}, 3030*9156SDaniel.Beauregard@Sun.COM { "qlcgetdump", ":[-v]", "Retrieves the ASCII f/w dump", 3031*9156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd }, 3032*9156SDaniel.Beauregard@Sun.COM { "qlcgettrace", ":[-v]", "Retrieves the ASCII Extended Logging trace", 3033*9156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd }, 30347836SJohn.Forte@Sun.COM { NULL } 30357836SJohn.Forte@Sun.COM }; 30367836SJohn.Forte@Sun.COM 30377836SJohn.Forte@Sun.COM /* 30387836SJohn.Forte@Sun.COM * walker structures for the _mdb_init function 30397836SJohn.Forte@Sun.COM */ 30407836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = { 30417836SJohn.Forte@Sun.COM { "qlcstates", "walk list of qlc ql_state_t structures", 30427836SJohn.Forte@Sun.COM qlstates_walk_init, qlstates_walk_step, qlstates_walk_fini }, 30437836SJohn.Forte@Sun.COM { "qlcsrbs", "walk list of qlc ql_srb_t strctures", 30447836SJohn.Forte@Sun.COM qlsrb_walk_init, qlsrb_walk_step, qlsrb_walk_fini }, 30457836SJohn.Forte@Sun.COM { "qlclunq", "walk list of qlc ql_lun_t strctures", 30467836SJohn.Forte@Sun.COM qllunq_walk_init, qllunq_walk_step, qllunq_walk_fini }, 30477836SJohn.Forte@Sun.COM { NULL } 30487836SJohn.Forte@Sun.COM }; 30497836SJohn.Forte@Sun.COM 30507836SJohn.Forte@Sun.COM static const mdb_modinfo_t ql_mdb_modinfo = { 30517836SJohn.Forte@Sun.COM MDB_API_VERSION, dcmds, walkers 30527836SJohn.Forte@Sun.COM }; 30537836SJohn.Forte@Sun.COM 30547836SJohn.Forte@Sun.COM /* 30557836SJohn.Forte@Sun.COM * Registration function which lists the dcmds and walker structures 30567836SJohn.Forte@Sun.COM */ 30577836SJohn.Forte@Sun.COM const mdb_modinfo_t * 30587836SJohn.Forte@Sun.COM _mdb_init(void) 30597836SJohn.Forte@Sun.COM { 30607836SJohn.Forte@Sun.COM return (&ql_mdb_modinfo); 30617836SJohn.Forte@Sun.COM } 3062