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 229156SDaniel.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 ** 309156SDaniel.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 379156SDaniel.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> 409156SDaniel.Beauregard@Sun.COM #include <ql_apps.h> 419156SDaniel.Beauregard@Sun.COM #include <ql_api.h> 429156SDaniel.Beauregard@Sun.COM #include <ql_init.h> 439156SDaniel.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 *); 539156SDaniel.Beauregard@Sun.COM static int qlc_wdog_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 549156SDaniel.Beauregard@Sun.COM static int qlc_getdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 559156SDaniel.Beauregard@Sun.COM static int qlc_gettrace_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 569156SDaniel.Beauregard@Sun.COM #if 0 579156SDaniel.Beauregard@Sun.COM static int qlc_triggerdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *); 589156SDaniel.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", 859156SDaniel.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", 89*9446SDaniel.Beauregard@Sun.COM "MENLO_LOGIN_OPERATIONAL", 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", 96*9446SDaniel.Beauregard@Sun.COM "FUNCTION_1", 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", 107*9446SDaniel.Beauregard@Sun.COM "DISABLE_EXTENDED_LOGGING_TRACE", 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", 119*9446SDaniel.Beauregard@Sun.COM "CTRL_MENLO", 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", 129*9446SDaniel.Beauregard@Sun.COM "CTRL_81XX", 1307836SJohn.Forte@Sun.COM NULL 1317836SJohn.Forte@Sun.COM }; 1327836SJohn.Forte@Sun.COM 1337836SJohn.Forte@Sun.COM /* 1347836SJohn.Forte@Sun.COM * local task daemon flags strings 1357836SJohn.Forte@Sun.COM */ 1367836SJohn.Forte@Sun.COM int8_t *task_daemon_flags[] = { 1377836SJohn.Forte@Sun.COM "TASK_DAEMON_STOP_FLG", 1387836SJohn.Forte@Sun.COM "TASK_DAEMON_SLEEPING_FLG", 1397836SJohn.Forte@Sun.COM "TASK_DAEMON_ALIVE_FLG", 1407836SJohn.Forte@Sun.COM "TASK_DAEMON_IDLE_CHK_FLG", 1417836SJohn.Forte@Sun.COM "SUSPENDED_WAKEUP_FLG", 1427836SJohn.Forte@Sun.COM "FC_STATE_CHANGE", 1437836SJohn.Forte@Sun.COM "NEED_UNSOLICITED_BUFFERS", 1447836SJohn.Forte@Sun.COM "RESET_MARKER_NEEDED", 1457836SJohn.Forte@Sun.COM "RESET_ACTIVE", 1467836SJohn.Forte@Sun.COM "ISP_ABORT_NEEDED", 1477836SJohn.Forte@Sun.COM "ABORT_ISP_ACTIVE", 1487836SJohn.Forte@Sun.COM "LOOP_RESYNC_NEEDED", 1497836SJohn.Forte@Sun.COM "LOOP_RESYNC_ACTIVE", 1507836SJohn.Forte@Sun.COM "LOOP_DOWN", 1517836SJohn.Forte@Sun.COM "DRIVER_STALL", 1527836SJohn.Forte@Sun.COM "COMMAND_WAIT_NEEDED", 1537836SJohn.Forte@Sun.COM "COMMAND_WAIT_ACTIVE", 1547836SJohn.Forte@Sun.COM "STATE_ONLINE", 1557836SJohn.Forte@Sun.COM "ABORT_QUEUES_NEEDED", 1567836SJohn.Forte@Sun.COM "TASK_DAEMON_STALLED_FLG", 1577836SJohn.Forte@Sun.COM "TASK_THREAD_CALLED", 1587836SJohn.Forte@Sun.COM "FIRMWARE_UP", 1597836SJohn.Forte@Sun.COM "LIP_RESET_PENDING", 1607836SJohn.Forte@Sun.COM "FIRMWARE_LOADED", 1617836SJohn.Forte@Sun.COM "RSCN_UPDATE_NEEDED", 1627836SJohn.Forte@Sun.COM "HANDLE_PORT_BYPASS_CHANGE", 1637836SJohn.Forte@Sun.COM "PORT_RETRY_NEEDED", 1647836SJohn.Forte@Sun.COM "TASK_DAEMON_POWERING_DOWN", 1657836SJohn.Forte@Sun.COM "TD_IIDMA_NEEDED", 166*9446SDaniel.Beauregard@Sun.COM "SEND_PLOGI", 167*9446SDaniel.Beauregard@Sun.COM "IDC_ACK_NEEDED", 1687836SJohn.Forte@Sun.COM NULL 1697836SJohn.Forte@Sun.COM }; 1707836SJohn.Forte@Sun.COM 1717836SJohn.Forte@Sun.COM /* 1727836SJohn.Forte@Sun.COM * local interrupt aif flags 1737836SJohn.Forte@Sun.COM */ 1747836SJohn.Forte@Sun.COM int8_t *aif_flags[] = { 1757836SJohn.Forte@Sun.COM "IFLG_INTR_LEGACY", 176*9446SDaniel.Beauregard@Sun.COM "IFLG_INTR_FIXED", 1777836SJohn.Forte@Sun.COM "IFLG_INTR_MSI", 178*9446SDaniel.Beauregard@Sun.COM "IFLG_INTR_MSIX", 1797836SJohn.Forte@Sun.COM NULL 1807836SJohn.Forte@Sun.COM }; 1817836SJohn.Forte@Sun.COM 1827836SJohn.Forte@Sun.COM int8_t *qlsrb_flags[] = { 1837836SJohn.Forte@Sun.COM "SRB_ISP_STARTED", 1847836SJohn.Forte@Sun.COM "SRB_ISP_COMPLETED", 1857836SJohn.Forte@Sun.COM "SRB_RETRY", 1867836SJohn.Forte@Sun.COM "SRB_POLL", 1877836SJohn.Forte@Sun.COM "SRB_WATCHDOG_ENABLED", 1887836SJohn.Forte@Sun.COM "SRB_ABORT", 1897836SJohn.Forte@Sun.COM "SRB_UB_IN_FCA", 1907836SJohn.Forte@Sun.COM "SRB_UB_IN_ISP", 1917836SJohn.Forte@Sun.COM "SRB_UB_CALLBACK", 1927836SJohn.Forte@Sun.COM "SRB_UB_RSCN", 1937836SJohn.Forte@Sun.COM "SRB_UB_FCP", 1947836SJohn.Forte@Sun.COM "SRB_FCP_CMD_PKT", 1957836SJohn.Forte@Sun.COM "SRB_FCP_DATA_PKT", 1967836SJohn.Forte@Sun.COM "SRB_FCP_RSP_PKT", 1977836SJohn.Forte@Sun.COM "SRB_IP_PKT", 1987836SJohn.Forte@Sun.COM "SRB_GENERIC_SERVICES_PKT", 1997836SJohn.Forte@Sun.COM "SRB_COMMAND_TIMEOUT", 2007836SJohn.Forte@Sun.COM "SRB_ABORTING", 2017836SJohn.Forte@Sun.COM "SRB_IN_DEVICE_QUEUE", 2027836SJohn.Forte@Sun.COM "SRB_IN_TOKEN_ARRAY", 2037836SJohn.Forte@Sun.COM "SRB_UB_FREE_REQUESTED", 2047836SJohn.Forte@Sun.COM "SRB_UB_ACQUIRED", 2057836SJohn.Forte@Sun.COM "SRB_MS_PKT", 2067836SJohn.Forte@Sun.COM NULL 2077836SJohn.Forte@Sun.COM }; 2087836SJohn.Forte@Sun.COM 2097836SJohn.Forte@Sun.COM int8_t *qllun_flags[] = { 2107836SJohn.Forte@Sun.COM "LQF_UNTAGGED_PENDING", 2117836SJohn.Forte@Sun.COM NULL 2127836SJohn.Forte@Sun.COM }; 2137836SJohn.Forte@Sun.COM 2147836SJohn.Forte@Sun.COM int8_t *qltgt_flags[] = { 2157836SJohn.Forte@Sun.COM "TQF_TAPE_DEVICE", 2167836SJohn.Forte@Sun.COM "TQF_QUEUE_SUSPENDED", 2177836SJohn.Forte@Sun.COM "TQF_FABRIC_DEVICE", 2187836SJohn.Forte@Sun.COM "TQF_INITIATOR_DEVICE", 2197836SJohn.Forte@Sun.COM "TQF_RSCN_RCVD", 2207836SJohn.Forte@Sun.COM "TQF_NEED_AUTHENTICATION", 2217836SJohn.Forte@Sun.COM "TQF_PLOGI_PROGRS", 2227836SJohn.Forte@Sun.COM "TQF_IIDMA_NEEDED", 2237836SJohn.Forte@Sun.COM NULL 2247836SJohn.Forte@Sun.COM }; 2257836SJohn.Forte@Sun.COM 2269156SDaniel.Beauregard@Sun.COM int8_t *qldump_flags[] = { 2279156SDaniel.Beauregard@Sun.COM "QL_DUMPING", 2289156SDaniel.Beauregard@Sun.COM "QL_DUMP_VALID", 2299156SDaniel.Beauregard@Sun.COM "QL_DUMP_UPLOADED", 2309156SDaniel.Beauregard@Sun.COM NULL 2319156SDaniel.Beauregard@Sun.COM }; 2329156SDaniel.Beauregard@Sun.COM 2337836SJohn.Forte@Sun.COM /* 2347836SJohn.Forte@Sun.COM * qlclinks_dcmd 2357836SJohn.Forte@Sun.COM * mdb dcmd which prints out the ql_hba pointers 2367836SJohn.Forte@Sun.COM * 2377836SJohn.Forte@Sun.COM * Input: 2387836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 2397836SJohn.Forte@Sun.COM * flags = mdb flags. 2407836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 2417836SJohn.Forte@Sun.COM * argv = Arg array. 2427836SJohn.Forte@Sun.COM * 2437836SJohn.Forte@Sun.COM * Returns: 2447836SJohn.Forte@Sun.COM * DCMD_ERR, DCMD_USAGE, or DCMD_OK 2457836SJohn.Forte@Sun.COM * 2467836SJohn.Forte@Sun.COM * Context: 2477836SJohn.Forte@Sun.COM * User context. 2487836SJohn.Forte@Sun.COM * 2497836SJohn.Forte@Sun.COM */ 2507836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2517836SJohn.Forte@Sun.COM static int 2527836SJohn.Forte@Sun.COM qlclinks_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 2537836SJohn.Forte@Sun.COM { 2547836SJohn.Forte@Sun.COM ql_head_t ql_hba; 2557836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 2567836SJohn.Forte@Sun.COM uintptr_t hbaptr = NULL; 2577836SJohn.Forte@Sun.COM 2587836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc != 0) { 2597836SJohn.Forte@Sun.COM return (DCMD_USAGE); 2607836SJohn.Forte@Sun.COM } 2617836SJohn.Forte@Sun.COM 2627836SJohn.Forte@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 2637836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 2647836SJohn.Forte@Sun.COM return (DCMD_ERR); 2657836SJohn.Forte@Sun.COM } 2667836SJohn.Forte@Sun.COM 2677836SJohn.Forte@Sun.COM if (&ql_hba == NULL) { 2687836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure -- is qlc loaded?"); 2697836SJohn.Forte@Sun.COM return (DCMD_ERR); 2707836SJohn.Forte@Sun.COM } 2717836SJohn.Forte@Sun.COM 2727836SJohn.Forte@Sun.COM mdb_printf("\nqlc adapter state linkages (f=0x%llx, l=0x%llx)\n\n", 2737836SJohn.Forte@Sun.COM ql_hba.first, ql_hba.last); 2747836SJohn.Forte@Sun.COM 2757836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc( 2767836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 2777836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 2787836SJohn.Forte@Sun.COM return (DCMD_OK); 2797836SJohn.Forte@Sun.COM } 2807836SJohn.Forte@Sun.COM 2817836SJohn.Forte@Sun.COM (void) mdb_inc_indent((ulong_t)4); 2827836SJohn.Forte@Sun.COM mdb_printf("%<u>%-?s\t%-45s%</u>\n\n", "baseaddr", "instance"); 2837836SJohn.Forte@Sun.COM 2847836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 2857836SJohn.Forte@Sun.COM while (hbaptr != NULL) { 2867836SJohn.Forte@Sun.COM 2877836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), 2887836SJohn.Forte@Sun.COM hbaptr) == -1) { 2897836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 2907836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 2917836SJohn.Forte@Sun.COM hbaptr); 2927836SJohn.Forte@Sun.COM return (DCMD_OK); 2937836SJohn.Forte@Sun.COM } 2947836SJohn.Forte@Sun.COM 2957836SJohn.Forte@Sun.COM mdb_printf("%<b>0x%016p%t%d%</b>\n", 2967836SJohn.Forte@Sun.COM qlstate->hba.base_address, qlstate->instance); 2977836SJohn.Forte@Sun.COM 2987836SJohn.Forte@Sun.COM /* 2997836SJohn.Forte@Sun.COM * If vp exists, loop through those 3007836SJohn.Forte@Sun.COM */ 3017836SJohn.Forte@Sun.COM 3027836SJohn.Forte@Sun.COM if ((qlstate->flags & VP_ENABLED) && 3037836SJohn.Forte@Sun.COM (qlstate->vp_next != NULL)) { 3047836SJohn.Forte@Sun.COM 3057836SJohn.Forte@Sun.COM ql_adapter_state_t *vqlstate; 3067836SJohn.Forte@Sun.COM uintptr_t vhbaptr = NULL; 3077836SJohn.Forte@Sun.COM 3087836SJohn.Forte@Sun.COM vhbaptr = (uintptr_t)qlstate->vp_next; 3097836SJohn.Forte@Sun.COM 3107836SJohn.Forte@Sun.COM if ((vqlstate = (ql_adapter_state_t *)mdb_alloc( 3117836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 3127836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for " 3137836SJohn.Forte@Sun.COM "ql_adapter_state vp\n"); 3147836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 3157836SJohn.Forte@Sun.COM return (DCMD_OK); 3167836SJohn.Forte@Sun.COM } 3177836SJohn.Forte@Sun.COM 3187836SJohn.Forte@Sun.COM (void) mdb_inc_indent((ulong_t)30); 3197836SJohn.Forte@Sun.COM 3207836SJohn.Forte@Sun.COM mdb_printf("%<u>vp baseaddr\t\tvp index%</u>\n"); 3217836SJohn.Forte@Sun.COM 3227836SJohn.Forte@Sun.COM while (vhbaptr != NULL) { 3237836SJohn.Forte@Sun.COM 3247836SJohn.Forte@Sun.COM if (mdb_vread(vqlstate, 3259156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), vhbaptr) == 3269156SDaniel.Beauregard@Sun.COM -1) { 3277836SJohn.Forte@Sun.COM mdb_free(vqlstate, 3287836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t)); 3297836SJohn.Forte@Sun.COM mdb_free(qlstate, 3307836SJohn.Forte@Sun.COM sizeof (ql_adapter_state_t)); 3317836SJohn.Forte@Sun.COM mdb_warn("failed to read vp " 3327836SJohn.Forte@Sun.COM "ql_adapter_state at %p", vhbaptr); 3337836SJohn.Forte@Sun.COM return (DCMD_OK); 3347836SJohn.Forte@Sun.COM } 3357836SJohn.Forte@Sun.COM 3367836SJohn.Forte@Sun.COM mdb_printf("%<b>0x%016p%t%d%</b>\n", 3377836SJohn.Forte@Sun.COM vqlstate->hba.base_address, 3387836SJohn.Forte@Sun.COM vqlstate->vp_index); 3397836SJohn.Forte@Sun.COM 3407836SJohn.Forte@Sun.COM vhbaptr = (uintptr_t)vqlstate->vp_next; 3417836SJohn.Forte@Sun.COM } 3427836SJohn.Forte@Sun.COM 3437836SJohn.Forte@Sun.COM mdb_free(vqlstate, sizeof (ql_adapter_state_t)); 3447836SJohn.Forte@Sun.COM 3457836SJohn.Forte@Sun.COM (void) mdb_dec_indent((ulong_t)30); 3467836SJohn.Forte@Sun.COM 3477836SJohn.Forte@Sun.COM mdb_printf("\n"); 3487836SJohn.Forte@Sun.COM } 3497836SJohn.Forte@Sun.COM 3507836SJohn.Forte@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 3517836SJohn.Forte@Sun.COM } 3527836SJohn.Forte@Sun.COM 3537836SJohn.Forte@Sun.COM (void) mdb_dec_indent((ulong_t)4); 3547836SJohn.Forte@Sun.COM 3557836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 3567836SJohn.Forte@Sun.COM 3577836SJohn.Forte@Sun.COM return (DCMD_OK); 3587836SJohn.Forte@Sun.COM } 3597836SJohn.Forte@Sun.COM 3607836SJohn.Forte@Sun.COM /* 3617836SJohn.Forte@Sun.COM * qlcver_dcmd 3627836SJohn.Forte@Sun.COM * mdb dcmd which prints out the qlc driver version the mdb 3637836SJohn.Forte@Sun.COM * module was compiled with, and the verison of qlc which is 3647836SJohn.Forte@Sun.COM * currently loaded on the machine. 3657836SJohn.Forte@Sun.COM * 3667836SJohn.Forte@Sun.COM * Input: 3677836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 3687836SJohn.Forte@Sun.COM * flags = mdb flags. 3697836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 3707836SJohn.Forte@Sun.COM * argv = Arg array. 3717836SJohn.Forte@Sun.COM * 3727836SJohn.Forte@Sun.COM * Returns: 3737836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 3747836SJohn.Forte@Sun.COM * 3757836SJohn.Forte@Sun.COM * Context: 3767836SJohn.Forte@Sun.COM * User context. 3777836SJohn.Forte@Sun.COM * 3787836SJohn.Forte@Sun.COM */ 3797836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3807836SJohn.Forte@Sun.COM static int 3817836SJohn.Forte@Sun.COM qlcver_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 3827836SJohn.Forte@Sun.COM { 3839156SDaniel.Beauregard@Sun.COM int8_t qlcversion[100]; 3849156SDaniel.Beauregard@Sun.COM struct fw_table fw_table[10], *fwt = NULL; 3859156SDaniel.Beauregard@Sun.COM uint8_t *fwverptr = NULL; 3869156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 3879156SDaniel.Beauregard@Sun.COM uint32_t found = 0; 3887836SJohn.Forte@Sun.COM 3897836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc != 0) { 3907836SJohn.Forte@Sun.COM return (DCMD_USAGE); 3917836SJohn.Forte@Sun.COM } 3927836SJohn.Forte@Sun.COM 3937836SJohn.Forte@Sun.COM if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) { 3947836SJohn.Forte@Sun.COM mdb_warn("unable to read qlc driver version\n"); 3957836SJohn.Forte@Sun.COM } else { 3969156SDaniel.Beauregard@Sun.COM mdb_printf("\n%s version currently loaded is: %s\n", 3977836SJohn.Forte@Sun.COM QL_NAME, qlcversion); 3987836SJohn.Forte@Sun.COM } 3997836SJohn.Forte@Sun.COM 4009156SDaniel.Beauregard@Sun.COM mdb_printf("qlc mdb library compiled with %s version: %s\n", 4019156SDaniel.Beauregard@Sun.COM QL_NAME, QL_VERSION); 4029156SDaniel.Beauregard@Sun.COM 4039156SDaniel.Beauregard@Sun.COM if ((fwverptr = (uint8_t *)(mdb_alloc(50, UM_SLEEP))) == NULL) { 4049156SDaniel.Beauregard@Sun.COM mdb_warn("unable to alloc fwverptr\n"); 4059156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 4069156SDaniel.Beauregard@Sun.COM } 4079156SDaniel.Beauregard@Sun.COM 4089156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&fw_table, "fw_table") == -1) { 4099156SDaniel.Beauregard@Sun.COM mdb_warn("unable to read firmware table\n"); 4109156SDaniel.Beauregard@Sun.COM } else { 4119156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *qlstate; 4129156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 4139156SDaniel.Beauregard@Sun.COM 4149156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 4159156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 4169156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 4179156SDaniel.Beauregard@Sun.COM } 4189156SDaniel.Beauregard@Sun.COM 4199156SDaniel.Beauregard@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc( 4209156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 4219156SDaniel.Beauregard@Sun.COM mdb_warn("Unable to allocate memory for " 4229156SDaniel.Beauregard@Sun.COM "ql_adapter_state\n"); 4239156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 4249156SDaniel.Beauregard@Sun.COM } 4259156SDaniel.Beauregard@Sun.COM 4269156SDaniel.Beauregard@Sun.COM mdb_printf("\n%-8s%-11s%s\n", "f/w", "compiled", "loaded"); 4279156SDaniel.Beauregard@Sun.COM mdb_printf("%<u>%-8s%-11s%-13s%s%</u>\n\n", "class", "version", 4289156SDaniel.Beauregard@Sun.COM "version", "instance list"); 4299156SDaniel.Beauregard@Sun.COM 4309156SDaniel.Beauregard@Sun.COM for (fwt = &fw_table[0]; fwt->fw_class; fwt++) { 4319156SDaniel.Beauregard@Sun.COM 4329156SDaniel.Beauregard@Sun.COM if (mdb_vread(fwverptr, sizeof (void *), 4339156SDaniel.Beauregard@Sun.COM (uintptr_t)fwt->fw_version) == -1) { 4349156SDaniel.Beauregard@Sun.COM mdb_warn("unable to read fwverptr\n"); 4359156SDaniel.Beauregard@Sun.COM mdb_free(fwverptr, sizeof (void *)); 4369156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 4379156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 4389156SDaniel.Beauregard@Sun.COM } 4399156SDaniel.Beauregard@Sun.COM 4409156SDaniel.Beauregard@Sun.COM mdb_printf("%x\t%-11s", fwt->fw_class, fwverptr); 4419156SDaniel.Beauregard@Sun.COM 4429156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 4439156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 4449156SDaniel.Beauregard@Sun.COM hbaptr = NULL; 4459156SDaniel.Beauregard@Sun.COM } else { 4469156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 4479156SDaniel.Beauregard@Sun.COM } 4489156SDaniel.Beauregard@Sun.COM 4499156SDaniel.Beauregard@Sun.COM found = 0; 4509156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 4519156SDaniel.Beauregard@Sun.COM 4529156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, 4539156SDaniel.Beauregard@Sun.COM sizeof (ql_adapter_state_t), hbaptr) == 4549156SDaniel.Beauregard@Sun.COM -1) { 4559156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 4569156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 4579156SDaniel.Beauregard@Sun.COM break; 4589156SDaniel.Beauregard@Sun.COM } 4599156SDaniel.Beauregard@Sun.COM 4609156SDaniel.Beauregard@Sun.COM if (qlstate->fw_class == fwt->fw_class) { 4619156SDaniel.Beauregard@Sun.COM if (found == 0) { 4629156SDaniel.Beauregard@Sun.COM mdb_printf("%x.%02x.%02x\t", 4639156SDaniel.Beauregard@Sun.COM qlstate->fw_major_version, 4649156SDaniel.Beauregard@Sun.COM qlstate->fw_minor_version, 4659156SDaniel.Beauregard@Sun.COM qlstate-> 4669156SDaniel.Beauregard@Sun.COM fw_subminor_version); 4679156SDaniel.Beauregard@Sun.COM mdb_printf("%d", 4689156SDaniel.Beauregard@Sun.COM qlstate->instance); 4699156SDaniel.Beauregard@Sun.COM } else { 4709156SDaniel.Beauregard@Sun.COM mdb_printf(", %d", 4719156SDaniel.Beauregard@Sun.COM qlstate->instance); 4729156SDaniel.Beauregard@Sun.COM } 4739156SDaniel.Beauregard@Sun.COM found = 1; 4749156SDaniel.Beauregard@Sun.COM } 4759156SDaniel.Beauregard@Sun.COM 4769156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 4779156SDaniel.Beauregard@Sun.COM } 4789156SDaniel.Beauregard@Sun.COM 4799156SDaniel.Beauregard@Sun.COM if (found == 1) { 4809156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 4819156SDaniel.Beauregard@Sun.COM } else { 4829156SDaniel.Beauregard@Sun.COM mdb_printf("not loaded\n"); 4839156SDaniel.Beauregard@Sun.COM } 4849156SDaniel.Beauregard@Sun.COM } 4859156SDaniel.Beauregard@Sun.COM 4869156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 4879156SDaniel.Beauregard@Sun.COM mdb_free(fwverptr, sizeof (void *)); 4889156SDaniel.Beauregard@Sun.COM } 4899156SDaniel.Beauregard@Sun.COM 4907836SJohn.Forte@Sun.COM return (DCMD_OK); 4917836SJohn.Forte@Sun.COM } 4927836SJohn.Forte@Sun.COM 4937836SJohn.Forte@Sun.COM /* 4947836SJohn.Forte@Sun.COM * qlc_el_dcmd 4957836SJohn.Forte@Sun.COM * mdb dcmd which turns the extended logging bit on or off 4967836SJohn.Forte@Sun.COM * for the specificed qlc instance(s). 4977836SJohn.Forte@Sun.COM * 4987836SJohn.Forte@Sun.COM * Input: 4997836SJohn.Forte@Sun.COM * addr = User supplied address -- error if supplied. 5007836SJohn.Forte@Sun.COM * flags = mdb flags. 5017836SJohn.Forte@Sun.COM * argc = Number of user supplied args -- error if non-zero. 5027836SJohn.Forte@Sun.COM * argv = Arg array. 5037836SJohn.Forte@Sun.COM * 5047836SJohn.Forte@Sun.COM * Returns: 5057836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 5067836SJohn.Forte@Sun.COM * 5077836SJohn.Forte@Sun.COM * Context: 5087836SJohn.Forte@Sun.COM * User context. 5097836SJohn.Forte@Sun.COM * 5107836SJohn.Forte@Sun.COM */ 5117836SJohn.Forte@Sun.COM /*ARGSUSED*/ 5127836SJohn.Forte@Sun.COM static int 5137836SJohn.Forte@Sun.COM qlc_el_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 5147836SJohn.Forte@Sun.COM { 5157836SJohn.Forte@Sun.COM int8_t qlcversion[100]; 5167836SJohn.Forte@Sun.COM boolean_t elswitch; 5177836SJohn.Forte@Sun.COM uint32_t argcnt; 5187836SJohn.Forte@Sun.COM int mdbs; 5197836SJohn.Forte@Sun.COM uint32_t instance; 5207836SJohn.Forte@Sun.COM uint32_t qlsize = sizeof (ql_adapter_state_t); 5217836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 5227836SJohn.Forte@Sun.COM uintptr_t hbaptr = NULL; 5237836SJohn.Forte@Sun.COM ql_head_t ql_hba; 5247836SJohn.Forte@Sun.COM 5257836SJohn.Forte@Sun.COM if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) { 5267836SJohn.Forte@Sun.COM mdb_warn("Cannot change core file data (state=%xh)\n", mdbs); 5277836SJohn.Forte@Sun.COM return (DCMD_OK); 5287836SJohn.Forte@Sun.COM } 5297836SJohn.Forte@Sun.COM 5307836SJohn.Forte@Sun.COM if ((flags & DCMD_ADDRSPEC) || argc < 2) { 5317836SJohn.Forte@Sun.COM return (DCMD_USAGE); 5327836SJohn.Forte@Sun.COM } 5337836SJohn.Forte@Sun.COM 5347836SJohn.Forte@Sun.COM /* 5357836SJohn.Forte@Sun.COM * Check and make sure the driver version and the mdb versions 5367836SJohn.Forte@Sun.COM * match so all the structures and flags line up 5377836SJohn.Forte@Sun.COM */ 5387836SJohn.Forte@Sun.COM 5397836SJohn.Forte@Sun.COM if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) { 5407836SJohn.Forte@Sun.COM mdb_warn("unable to read qlc driver version\n"); 5417836SJohn.Forte@Sun.COM return (DCMD_OK); 5427836SJohn.Forte@Sun.COM } 5437836SJohn.Forte@Sun.COM 5447836SJohn.Forte@Sun.COM if ((strcmp(QL_VERSION, (const char *)&qlcversion)) != 0) { 5457836SJohn.Forte@Sun.COM mdb_warn("Error: qlc driver/qlc mdb version mismatch\n"); 5467836SJohn.Forte@Sun.COM mdb_printf("\tqlc mdb library compiled version is: %s\n", 5477836SJohn.Forte@Sun.COM QL_VERSION); 5487836SJohn.Forte@Sun.COM mdb_printf("\tqlc driver version is: %s\n", qlcversion); 5497836SJohn.Forte@Sun.COM 5507836SJohn.Forte@Sun.COM return (DCMD_OK); 5517836SJohn.Forte@Sun.COM } 5527836SJohn.Forte@Sun.COM 5537836SJohn.Forte@Sun.COM if ((strcasecmp(argv[0].a_un.a_str, "on")) == 0) { 5547836SJohn.Forte@Sun.COM elswitch = TRUE; 5557836SJohn.Forte@Sun.COM } else if ((strcasecmp(argv[0].a_un.a_str, "off")) == 0) { 5567836SJohn.Forte@Sun.COM elswitch = FALSE; 5577836SJohn.Forte@Sun.COM } else { 5587836SJohn.Forte@Sun.COM return (DCMD_USAGE); 5597836SJohn.Forte@Sun.COM } 5607836SJohn.Forte@Sun.COM 5617836SJohn.Forte@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 5627836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 5637836SJohn.Forte@Sun.COM return (DCMD_ERR); 5647836SJohn.Forte@Sun.COM } 5657836SJohn.Forte@Sun.COM 5667836SJohn.Forte@Sun.COM if (&ql_hba == NULL) { 5677836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure - is qlc loaded?"); 5687836SJohn.Forte@Sun.COM return (DCMD_ERR); 5697836SJohn.Forte@Sun.COM } 5707836SJohn.Forte@Sun.COM 5717836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize, 5727836SJohn.Forte@Sun.COM UM_SLEEP)) == NULL) { 5737836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for " 5747836SJohn.Forte@Sun.COM "ql_adapter_state\n"); 5757836SJohn.Forte@Sun.COM return (DCMD_OK); 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); 6129156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 6139156SDaniel.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 if ((qlsrb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP)) == 7457836SJohn.Forte@Sun.COM NULL) { 7467836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 7477836SJohn.Forte@Sun.COM mdb_warn("failed to allocate space for srb_t\n"); 7487836SJohn.Forte@Sun.COM return (DCMD_OK); 7497836SJohn.Forte@Sun.COM } 7507836SJohn.Forte@Sun.COM for (indx = 0; indx < MAX_OUTSTANDING_COMMANDS; indx++, qlosc += 8) { 7517836SJohn.Forte@Sun.COM if (mdb_vread(&ptr1, 8, qlosc) == -1) { 7527836SJohn.Forte@Sun.COM mdb_warn("failed to read ptr1, indx=%d", indx); 7537836SJohn.Forte@Sun.COM break; 7547836SJohn.Forte@Sun.COM } 7557836SJohn.Forte@Sun.COM if (ptr1 == 0) { 7567836SJohn.Forte@Sun.COM continue; 7577836SJohn.Forte@Sun.COM } 7587836SJohn.Forte@Sun.COM 7597836SJohn.Forte@Sun.COM mdb_printf("osc ptr = %p, indx = %xh\n", ptr1, indx); 7607836SJohn.Forte@Sun.COM 7617836SJohn.Forte@Sun.COM if (mdb_vread(qlsrb, sizeof (ql_srb_t), ptr1) == -1) { 7627836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t at %p", ptr1); 7637836SJohn.Forte@Sun.COM break; 7647836SJohn.Forte@Sun.COM } 7657836SJohn.Forte@Sun.COM (void) ql_doprint(ptr1, "struct ql_srb"); 7667836SJohn.Forte@Sun.COM found++; 7677836SJohn.Forte@Sun.COM } 7687836SJohn.Forte@Sun.COM 7697836SJohn.Forte@Sun.COM mdb_free(qlsrb, sizeof (ql_srb_t)); 7707836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 7717836SJohn.Forte@Sun.COM 7727836SJohn.Forte@Sun.COM mdb_printf("number of outstanding command srb's is: %d\n", found); 7737836SJohn.Forte@Sun.COM 7747836SJohn.Forte@Sun.COM return (DCMD_OK); 7757836SJohn.Forte@Sun.COM } 7767836SJohn.Forte@Sun.COM 7777836SJohn.Forte@Sun.COM /* 7787836SJohn.Forte@Sun.COM * qlc_wdog_dcmd 7797836SJohn.Forte@Sun.COM * mdb dcmd which prints out the commands which are linked 7807836SJohn.Forte@Sun.COM * on the watchdog linked list. Caller supplied address (which 7817836SJohn.Forte@Sun.COM * sb the ha structure). 7827836SJohn.Forte@Sun.COM * 7837836SJohn.Forte@Sun.COM * Input: 7847836SJohn.Forte@Sun.COM * addr = User supplied ha address. 7857836SJohn.Forte@Sun.COM * flags = mdb flags. 7867836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 7877836SJohn.Forte@Sun.COM * argv = Arg array. 7887836SJohn.Forte@Sun.COM * 7897836SJohn.Forte@Sun.COM * Returns: 7907836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 7917836SJohn.Forte@Sun.COM * 7927836SJohn.Forte@Sun.COM * Context: 7937836SJohn.Forte@Sun.COM * User context. 7947836SJohn.Forte@Sun.COM * 7957836SJohn.Forte@Sun.COM * 7967836SJohn.Forte@Sun.COM */ 7977836SJohn.Forte@Sun.COM static int 7987836SJohn.Forte@Sun.COM /*ARGSUSED*/ 7997836SJohn.Forte@Sun.COM qlc_wdog_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 8007836SJohn.Forte@Sun.COM { 8017836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 8027836SJohn.Forte@Sun.COM uint16_t index, count; 8037836SJohn.Forte@Sun.COM ql_head_t *dev; 8047836SJohn.Forte@Sun.COM ql_srb_t *srb; 8057836SJohn.Forte@Sun.COM ql_tgt_t *tq; 8067836SJohn.Forte@Sun.COM ql_lun_t *lq; 8077836SJohn.Forte@Sun.COM ql_link_t *tqlink, *srblink, *lqlink; 8087836SJohn.Forte@Sun.COM int nextlink; 8097836SJohn.Forte@Sun.COM 8107836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) { 8117836SJohn.Forte@Sun.COM mdb_warn("Address required\n", addr); 8127836SJohn.Forte@Sun.COM return (DCMD_USAGE); 8137836SJohn.Forte@Sun.COM } 8147836SJohn.Forte@Sun.COM 8157836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *) 8167836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 8177836SJohn.Forte@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 8187836SJohn.Forte@Sun.COM return (DCMD_OK); 8197836SJohn.Forte@Sun.COM } 8207836SJohn.Forte@Sun.COM 8217836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) { 8227836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 8237836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 8247836SJohn.Forte@Sun.COM return (DCMD_OK); 8257836SJohn.Forte@Sun.COM } 8267836SJohn.Forte@Sun.COM 8277836SJohn.Forte@Sun.COM /* 8287836SJohn.Forte@Sun.COM * Read in the device array 8297836SJohn.Forte@Sun.COM */ 8307836SJohn.Forte@Sun.COM dev = (ql_head_t *) 8317836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP); 8327836SJohn.Forte@Sun.COM 8337836SJohn.Forte@Sun.COM if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, 8347836SJohn.Forte@Sun.COM (uintptr_t)qlstate->dev) == -1) { 8357836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_head_t (dev) at %p", qlstate->dev); 8367836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 8377836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE); 8387836SJohn.Forte@Sun.COM return (DCMD_OK); 8397836SJohn.Forte@Sun.COM } 8407836SJohn.Forte@Sun.COM 8417836SJohn.Forte@Sun.COM tqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8427836SJohn.Forte@Sun.COM tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP); 8437836SJohn.Forte@Sun.COM lqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8447836SJohn.Forte@Sun.COM lq = (ql_lun_t *)mdb_alloc(sizeof (ql_lun_t), UM_SLEEP); 8457836SJohn.Forte@Sun.COM srblink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 8467836SJohn.Forte@Sun.COM srb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP); 8477836SJohn.Forte@Sun.COM 8487836SJohn.Forte@Sun.COM /* 8497836SJohn.Forte@Sun.COM * Validate the devices watchdog queue 8507836SJohn.Forte@Sun.COM */ 8517836SJohn.Forte@Sun.COM for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) { 8527836SJohn.Forte@Sun.COM 8537836SJohn.Forte@Sun.COM /* Skip empty ones */ 8547836SJohn.Forte@Sun.COM if (dev[index].first == NULL) { 8557836SJohn.Forte@Sun.COM continue; 8567836SJohn.Forte@Sun.COM } 8577836SJohn.Forte@Sun.COM 8587836SJohn.Forte@Sun.COM mdb_printf("dev array index = %x\n", index); 8597836SJohn.Forte@Sun.COM 8607836SJohn.Forte@Sun.COM /* Loop through targets on device linked list */ 8617836SJohn.Forte@Sun.COM /* get the first link */ 8627836SJohn.Forte@Sun.COM 8637836SJohn.Forte@Sun.COM nextlink = get_first_link(&dev[index], tqlink); 8647836SJohn.Forte@Sun.COM 8657836SJohn.Forte@Sun.COM /* 8667836SJohn.Forte@Sun.COM * traverse the targets linked list at this device array index. 8677836SJohn.Forte@Sun.COM */ 8687836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 8697836SJohn.Forte@Sun.COM /* Get the target */ 8707836SJohn.Forte@Sun.COM if (mdb_vread(tq, sizeof (ql_tgt_t), 8717836SJohn.Forte@Sun.COM (uintptr_t)(tqlink->base_address)) == -1) { 8727836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_tgt at %p", 8737836SJohn.Forte@Sun.COM tqlink->base_address); 8747836SJohn.Forte@Sun.COM break; 8757836SJohn.Forte@Sun.COM } 8767836SJohn.Forte@Sun.COM mdb_printf("tgt q base = %llx, ", 8777836SJohn.Forte@Sun.COM tqlink->base_address); 8787836SJohn.Forte@Sun.COM 8797836SJohn.Forte@Sun.COM mdb_printf("flags: (%xh)", tq->flags); 8807836SJohn.Forte@Sun.COM 8817836SJohn.Forte@Sun.COM if (tq->flags) { 8827836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)tq->flags, qltgt_flags); 8837836SJohn.Forte@Sun.COM } 8847836SJohn.Forte@Sun.COM 8857836SJohn.Forte@Sun.COM mdb_printf("tgt: %02x%02x%02x%02x%02x%02x%02x%02x ", 8867836SJohn.Forte@Sun.COM tq->node_name[0], tq->node_name[1], 8877836SJohn.Forte@Sun.COM tq->node_name[2], tq->node_name[3], 8887836SJohn.Forte@Sun.COM tq->node_name[4], tq->node_name[5], 8897836SJohn.Forte@Sun.COM tq->node_name[6], tq->node_name[7]); 8907836SJohn.Forte@Sun.COM 8917836SJohn.Forte@Sun.COM /* 8927836SJohn.Forte@Sun.COM * Loop through commands on this targets watchdog queue. 8937836SJohn.Forte@Sun.COM */ 8947836SJohn.Forte@Sun.COM 8957836SJohn.Forte@Sun.COM /* Get the first link on the targets cmd wdg q. */ 8967836SJohn.Forte@Sun.COM if (tq->wdg.first == NULL) { 8977836SJohn.Forte@Sun.COM mdb_printf(" watchdog list empty "); 8987836SJohn.Forte@Sun.COM break; 8997836SJohn.Forte@Sun.COM } else { 9007836SJohn.Forte@Sun.COM if (mdb_vread(srblink, sizeof (ql_link_t), 9017836SJohn.Forte@Sun.COM (uintptr_t)tq->wdg.first) == -1) { 9027836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t" 9037836SJohn.Forte@Sun.COM " at %p", tq->wdg.first); 9047836SJohn.Forte@Sun.COM break; 9057836SJohn.Forte@Sun.COM } 9067836SJohn.Forte@Sun.COM /* There is aleast one. */ 9077836SJohn.Forte@Sun.COM count = 1; 9087836SJohn.Forte@Sun.COM /* 9097836SJohn.Forte@Sun.COM * Count the remaining items in the 9107836SJohn.Forte@Sun.COM * cmd watchdog list. 9117836SJohn.Forte@Sun.COM */ 9127836SJohn.Forte@Sun.COM while (srblink->next != NULL) { 9137836SJohn.Forte@Sun.COM /* Read in the next ql_link_t header */ 9147836SJohn.Forte@Sun.COM if (mdb_vread(srblink, 9157836SJohn.Forte@Sun.COM sizeof (ql_link_t), 9167836SJohn.Forte@Sun.COM (uintptr_t)srblink->next) == -1) { 9177836SJohn.Forte@Sun.COM mdb_warn("failed to read" 9187836SJohn.Forte@Sun.COM " ql_link_t next at %p", 9197836SJohn.Forte@Sun.COM srblink->next); 9207836SJohn.Forte@Sun.COM break; 9217836SJohn.Forte@Sun.COM } 9227836SJohn.Forte@Sun.COM count = (uint16_t)(count + 1); 9237836SJohn.Forte@Sun.COM } 9247836SJohn.Forte@Sun.COM mdb_printf(" watchdog list: %d entries\n", 9257836SJohn.Forte@Sun.COM count); 9267836SJohn.Forte@Sun.COM /* get the first one again */ 9277836SJohn.Forte@Sun.COM if (mdb_vread(srblink, sizeof (ql_link_t), 9287836SJohn.Forte@Sun.COM (uintptr_t)tq->wdg.first) == -1) { 9297836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t" 9307836SJohn.Forte@Sun.COM " at %p", tq->wdg.first); 9317836SJohn.Forte@Sun.COM break; 9327836SJohn.Forte@Sun.COM } 9337836SJohn.Forte@Sun.COM } 9347836SJohn.Forte@Sun.COM /* 9357836SJohn.Forte@Sun.COM * Traverse the targets cmd watchdog linked list 9367836SJohn.Forte@Sun.COM * verifying srb's from the list are on a lun cmd list. 9377836SJohn.Forte@Sun.COM */ 9387836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 9397836SJohn.Forte@Sun.COM int found = 0; 9407836SJohn.Forte@Sun.COM /* get the srb */ 9417836SJohn.Forte@Sun.COM if (mdb_vread(srb, sizeof (ql_srb_t), 9427836SJohn.Forte@Sun.COM (uintptr_t)srblink->base_address) == -1) { 9437836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t" 9447836SJohn.Forte@Sun.COM " at %p", srblink->base_address); 9457836SJohn.Forte@Sun.COM break; 9467836SJohn.Forte@Sun.COM } 9477836SJohn.Forte@Sun.COM mdb_printf("ql_srb %llx ", 9487836SJohn.Forte@Sun.COM srblink->base_address); 9497836SJohn.Forte@Sun.COM 9507836SJohn.Forte@Sun.COM /* 9517836SJohn.Forte@Sun.COM * Get the lun q the srb is on 9527836SJohn.Forte@Sun.COM */ 9537836SJohn.Forte@Sun.COM if (mdb_vread(lq, sizeof (ql_lun_t), 9547836SJohn.Forte@Sun.COM (uintptr_t)srb->lun_queue) == -1) { 9557836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb_t" 9567836SJohn.Forte@Sun.COM " at %p", srb->lun_queue); 9577836SJohn.Forte@Sun.COM break; 9587836SJohn.Forte@Sun.COM } 9597836SJohn.Forte@Sun.COM nextlink = get_first_link(&lq->cmd, lqlink); 9607836SJohn.Forte@Sun.COM /* 9617836SJohn.Forte@Sun.COM * traverse the lun cmd linked list looking 9627836SJohn.Forte@Sun.COM * for the srb from the targets watchdog list 9637836SJohn.Forte@Sun.COM */ 9647836SJohn.Forte@Sun.COM while (nextlink == DCMD_OK) { 9657836SJohn.Forte@Sun.COM if (srblink->base_address == 9667836SJohn.Forte@Sun.COM lqlink->base_address) { 9677836SJohn.Forte@Sun.COM mdb_printf("on lun %d cmd q\n", 9687836SJohn.Forte@Sun.COM lq->lun_no); 9697836SJohn.Forte@Sun.COM found = 1; 9707836SJohn.Forte@Sun.COM break; 9717836SJohn.Forte@Sun.COM } 9727836SJohn.Forte@Sun.COM /* get next item on lun cmd list */ 9737836SJohn.Forte@Sun.COM nextlink = get_next_link(lqlink); 9747836SJohn.Forte@Sun.COM } 9757836SJohn.Forte@Sun.COM if (!found) { 9767836SJohn.Forte@Sun.COM mdb_printf("not found on lun cmd q\n"); 9777836SJohn.Forte@Sun.COM } 9787836SJohn.Forte@Sun.COM /* get next item in the watchdog list */ 9797836SJohn.Forte@Sun.COM nextlink = get_next_link(srblink); 9807836SJohn.Forte@Sun.COM } /* End targets command watchdog list */ 9817836SJohn.Forte@Sun.COM /* get next item in this target list */ 9827836SJohn.Forte@Sun.COM nextlink = get_next_link(tqlink); 9837836SJohn.Forte@Sun.COM } /* End traverse the device targets linked list */ 9847836SJohn.Forte@Sun.COM mdb_printf("\n"); 9857836SJohn.Forte@Sun.COM } /* End device array */ 9867836SJohn.Forte@Sun.COM 9877836SJohn.Forte@Sun.COM mdb_free(tq, sizeof (ql_tgt_t)); 9887836SJohn.Forte@Sun.COM mdb_free(lq, sizeof (ql_lun_t)); 9897836SJohn.Forte@Sun.COM mdb_free(srb, sizeof (ql_srb_t)); 9907836SJohn.Forte@Sun.COM mdb_free(tqlink, sizeof (ql_link_t)); 9917836SJohn.Forte@Sun.COM mdb_free(srblink, sizeof (ql_link_t)); 9927836SJohn.Forte@Sun.COM mdb_free(lqlink, sizeof (ql_link_t)); 9937836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 9947836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE); 9957836SJohn.Forte@Sun.COM 9967836SJohn.Forte@Sun.COM return (DCMD_OK); 9977836SJohn.Forte@Sun.COM } 9987836SJohn.Forte@Sun.COM 9997836SJohn.Forte@Sun.COM /* 10007836SJohn.Forte@Sun.COM * get_first_link 10017836SJohn.Forte@Sun.COM * Gets the first ql_link_t header on ql_head. 10027836SJohn.Forte@Sun.COM * 10037836SJohn.Forte@Sun.COM * Input: 10047836SJohn.Forte@Sun.COM * ql_head = pointer to a ql_head_t structure. 10057836SJohn.Forte@Sun.COM * ql_link = pointer to a ql_link_t structure. 10067836SJohn.Forte@Sun.COM * 10077836SJohn.Forte@Sun.COM * Returns: 10087836SJohn.Forte@Sun.COM * DCMD_ABORT, or DCMD_OK 10097836SJohn.Forte@Sun.COM * 10107836SJohn.Forte@Sun.COM * Context: 10117836SJohn.Forte@Sun.COM * User context. 10127836SJohn.Forte@Sun.COM * 10137836SJohn.Forte@Sun.COM */ 10147836SJohn.Forte@Sun.COM static int 10157836SJohn.Forte@Sun.COM get_first_link(ql_head_t *qlhead, ql_link_t *qllink) 10167836SJohn.Forte@Sun.COM { 10177836SJohn.Forte@Sun.COM int rval = DCMD_ABORT; 10187836SJohn.Forte@Sun.COM 10197836SJohn.Forte@Sun.COM if (qlhead != NULL) { 10207836SJohn.Forte@Sun.COM if (qlhead->first != NULL) { 10217836SJohn.Forte@Sun.COM /* Read in the first ql_link_t header */ 10227836SJohn.Forte@Sun.COM if (mdb_vread(qllink, sizeof (ql_link_t), 10237836SJohn.Forte@Sun.COM (uintptr_t)(qlhead->first)) == -1) { 10247836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 10257836SJohn.Forte@Sun.COM "next at %p", qlhead->first); 10267836SJohn.Forte@Sun.COM } else { 10277836SJohn.Forte@Sun.COM rval = DCMD_OK; 10287836SJohn.Forte@Sun.COM } 10297836SJohn.Forte@Sun.COM } 10307836SJohn.Forte@Sun.COM } 10317836SJohn.Forte@Sun.COM return (rval); 10327836SJohn.Forte@Sun.COM } 10337836SJohn.Forte@Sun.COM 10347836SJohn.Forte@Sun.COM /* 10357836SJohn.Forte@Sun.COM * get_next_link 10367836SJohn.Forte@Sun.COM * Gets the next ql_link_t structure. 10377836SJohn.Forte@Sun.COM * 10387836SJohn.Forte@Sun.COM * Input: 10397836SJohn.Forte@Sun.COM * ql_link = pointer to a ql_link_t structure. 10407836SJohn.Forte@Sun.COM * 10417836SJohn.Forte@Sun.COM * Returns: 10427836SJohn.Forte@Sun.COM * DCMD_ABORT, or DCMD_OK 10437836SJohn.Forte@Sun.COM * 10447836SJohn.Forte@Sun.COM * Context: 10457836SJohn.Forte@Sun.COM * User context. 10467836SJohn.Forte@Sun.COM * 10477836SJohn.Forte@Sun.COM */ 10487836SJohn.Forte@Sun.COM static int 10497836SJohn.Forte@Sun.COM get_next_link(ql_link_t *qllink) 10507836SJohn.Forte@Sun.COM { 10517836SJohn.Forte@Sun.COM int rval = DCMD_ABORT; 10527836SJohn.Forte@Sun.COM 10537836SJohn.Forte@Sun.COM if (qllink != NULL) { 10547836SJohn.Forte@Sun.COM if (qllink->next != NULL) { 10557836SJohn.Forte@Sun.COM /* Read in the next ql_link_t header */ 10567836SJohn.Forte@Sun.COM if (mdb_vread(qllink, sizeof (ql_link_t), 10577836SJohn.Forte@Sun.COM (uintptr_t)(qllink->next)) == -1) { 10587836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 10597836SJohn.Forte@Sun.COM "next at %p", qllink->next); 10607836SJohn.Forte@Sun.COM } else { 10617836SJohn.Forte@Sun.COM rval = DCMD_OK; 10627836SJohn.Forte@Sun.COM } 10637836SJohn.Forte@Sun.COM } 10647836SJohn.Forte@Sun.COM } 10657836SJohn.Forte@Sun.COM return (rval); 10667836SJohn.Forte@Sun.COM } 10677836SJohn.Forte@Sun.COM 10687836SJohn.Forte@Sun.COM /* 10697836SJohn.Forte@Sun.COM * qlcstate_dcmd 10707836SJohn.Forte@Sun.COM * mdb dcmd which prints out the ql_state info using 10717836SJohn.Forte@Sun.COM * caller supplied address. 10727836SJohn.Forte@Sun.COM * 10737836SJohn.Forte@Sun.COM * Input: 10747836SJohn.Forte@Sun.COM * addr = User supplied address. 10757836SJohn.Forte@Sun.COM * flags = mdb flags. 10767836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 10777836SJohn.Forte@Sun.COM * argv = Arg array. 10787836SJohn.Forte@Sun.COM * 10797836SJohn.Forte@Sun.COM * Returns: 10807836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 10817836SJohn.Forte@Sun.COM * 10827836SJohn.Forte@Sun.COM * Context: 10837836SJohn.Forte@Sun.COM * User context. 10847836SJohn.Forte@Sun.COM * 10857836SJohn.Forte@Sun.COM */ 10867836SJohn.Forte@Sun.COM static int 10877836SJohn.Forte@Sun.COM qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 10887836SJohn.Forte@Sun.COM { 10897836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 10907836SJohn.Forte@Sun.COM int verbose = 0; 10917836SJohn.Forte@Sun.COM 10927836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) { 10937836SJohn.Forte@Sun.COM return (DCMD_USAGE); 10947836SJohn.Forte@Sun.COM } 10957836SJohn.Forte@Sun.COM 10967836SJohn.Forte@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 10977836SJohn.Forte@Sun.COM argc) { 10987836SJohn.Forte@Sun.COM return (DCMD_USAGE); 10997836SJohn.Forte@Sun.COM } 11007836SJohn.Forte@Sun.COM 11017836SJohn.Forte@Sun.COM if ((qlstate = (ql_adapter_state_t *) 11027836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) { 11037836SJohn.Forte@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 11047836SJohn.Forte@Sun.COM return (DCMD_OK); 11057836SJohn.Forte@Sun.COM } 11067836SJohn.Forte@Sun.COM if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) { 11077836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 11087836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 11097836SJohn.Forte@Sun.COM return (DCMD_OK); 11107836SJohn.Forte@Sun.COM } 11117836SJohn.Forte@Sun.COM 11127836SJohn.Forte@Sun.COM mdb_printf("qlc instance: %d, base addr = %llx\n", qlstate->instance, 11137836SJohn.Forte@Sun.COM addr); 11147836SJohn.Forte@Sun.COM 11157836SJohn.Forte@Sun.COM mdb_printf("\nadapter state flags:\n"); 11167836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags); 11177836SJohn.Forte@Sun.COM mdb_printf("\nadapter cfg flags:\n"); 11187836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags); 11197836SJohn.Forte@Sun.COM mdb_printf("\ntask daemon state flags:\n"); 11207836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->task_daemon_flags, 11217836SJohn.Forte@Sun.COM task_daemon_flags); 11227836SJohn.Forte@Sun.COM 11237836SJohn.Forte@Sun.COM if (verbose) { 11247836SJohn.Forte@Sun.COM (void) ql_doprint(addr, "struct ql_adapter_state"); 11257836SJohn.Forte@Sun.COM } 11267836SJohn.Forte@Sun.COM 11277836SJohn.Forte@Sun.COM mdb_free(qlstate, sizeof (ql_adapter_state_t)); 11287836SJohn.Forte@Sun.COM 11297836SJohn.Forte@Sun.COM return (DCMD_OK); 11307836SJohn.Forte@Sun.COM } 11317836SJohn.Forte@Sun.COM 11327836SJohn.Forte@Sun.COM /* 11337836SJohn.Forte@Sun.COM * qlcstates_walk_init 11347836SJohn.Forte@Sun.COM * mdb walker init which prints out all qlc states info. 11357836SJohn.Forte@Sun.COM * 11367836SJohn.Forte@Sun.COM * Input: 11377836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 11387836SJohn.Forte@Sun.COM * 11397836SJohn.Forte@Sun.COM * Returns: 11407836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 11417836SJohn.Forte@Sun.COM * 11427836SJohn.Forte@Sun.COM * Context: 11437836SJohn.Forte@Sun.COM * User context. 11447836SJohn.Forte@Sun.COM * 11457836SJohn.Forte@Sun.COM */ 11467836SJohn.Forte@Sun.COM static int 11477836SJohn.Forte@Sun.COM qlstates_walk_init(mdb_walk_state_t *wsp) 11487836SJohn.Forte@Sun.COM { 11497836SJohn.Forte@Sun.COM ql_head_t ql_hba; 11507836SJohn.Forte@Sun.COM 11517836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 11527836SJohn.Forte@Sun.COM if ((mdb_readvar(&ql_hba, "ql_hba") == -1) || 11537836SJohn.Forte@Sun.COM (&ql_hba == NULL)) { 11547836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_hba structure"); 11557836SJohn.Forte@Sun.COM return (WALK_ERR); 11567836SJohn.Forte@Sun.COM } 11577836SJohn.Forte@Sun.COM 11587836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t)ql_hba.first; 11597836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_adapter_state_t), 11607836SJohn.Forte@Sun.COM UM_SLEEP); 11617836SJohn.Forte@Sun.COM return (WALK_NEXT); 11627836SJohn.Forte@Sun.COM } else { 11637836SJohn.Forte@Sun.COM return (ql_doprint(wsp->walk_addr, "struct ql_adapter_state")); 11647836SJohn.Forte@Sun.COM } 11657836SJohn.Forte@Sun.COM } 11667836SJohn.Forte@Sun.COM 11677836SJohn.Forte@Sun.COM /* 11687836SJohn.Forte@Sun.COM * qlstates_walk_step 11697836SJohn.Forte@Sun.COM * mdb walker step which prints out all qlc states info. 11707836SJohn.Forte@Sun.COM * 11717836SJohn.Forte@Sun.COM * Input: 11727836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 11737836SJohn.Forte@Sun.COM * 11747836SJohn.Forte@Sun.COM * Returns: 11757836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 11767836SJohn.Forte@Sun.COM * 11777836SJohn.Forte@Sun.COM * Context: 11787836SJohn.Forte@Sun.COM * User context. 11797836SJohn.Forte@Sun.COM * 11807836SJohn.Forte@Sun.COM */ 11817836SJohn.Forte@Sun.COM static int 11827836SJohn.Forte@Sun.COM qlstates_walk_step(mdb_walk_state_t *wsp) 11837836SJohn.Forte@Sun.COM { 11847836SJohn.Forte@Sun.COM ql_adapter_state_t *qlstate; 11857836SJohn.Forte@Sun.COM 11867836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 11877836SJohn.Forte@Sun.COM return (WALK_DONE); 11887836SJohn.Forte@Sun.COM } 11897836SJohn.Forte@Sun.COM 11907836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_adapter_state_t), 11917836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 11927836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 11937836SJohn.Forte@Sun.COM wsp->walk_addr); 11947836SJohn.Forte@Sun.COM return (WALK_DONE); 11957836SJohn.Forte@Sun.COM } 11967836SJohn.Forte@Sun.COM 11977836SJohn.Forte@Sun.COM qlstate = (ql_adapter_state_t *)(wsp->walk_data); 11987836SJohn.Forte@Sun.COM mdb_printf("qlc instance: %d, base addr = %llx\n", 11997836SJohn.Forte@Sun.COM qlstate->instance, wsp->walk_addr); 12007836SJohn.Forte@Sun.COM 12017836SJohn.Forte@Sun.COM mdb_printf("\nadapter state flags:\n"); 12027836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags); 12037836SJohn.Forte@Sun.COM mdb_printf("\nadapter cfg flags:\n"); 12047836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags); 12057836SJohn.Forte@Sun.COM mdb_printf("\ntask daemon state flags:\n"); 12067836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlstate->task_daemon_flags, 12077836SJohn.Forte@Sun.COM task_daemon_flags); 12087836SJohn.Forte@Sun.COM 12097836SJohn.Forte@Sun.COM mdb_printf("\nadapter state:\n"); 12107836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_adapter_state"); 12117836SJohn.Forte@Sun.COM 12127836SJohn.Forte@Sun.COM mdb_printf("\n"); 12137836SJohn.Forte@Sun.COM 12147836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t) 12157836SJohn.Forte@Sun.COM (((ql_adapter_state_t *)wsp->walk_data)->hba.next); 12167836SJohn.Forte@Sun.COM 12177836SJohn.Forte@Sun.COM return (WALK_NEXT); 12187836SJohn.Forte@Sun.COM } 12197836SJohn.Forte@Sun.COM 12207836SJohn.Forte@Sun.COM /* 12217836SJohn.Forte@Sun.COM * qlstates_walk_fini 12227836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 12237836SJohn.Forte@Sun.COM * 12247836SJohn.Forte@Sun.COM * Input: 12257836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 12267836SJohn.Forte@Sun.COM * 12277836SJohn.Forte@Sun.COM * Returns: 12287836SJohn.Forte@Sun.COM * 12297836SJohn.Forte@Sun.COM * Context: 12307836SJohn.Forte@Sun.COM * User context. 12317836SJohn.Forte@Sun.COM * 12327836SJohn.Forte@Sun.COM */ 12337836SJohn.Forte@Sun.COM static void 12347836SJohn.Forte@Sun.COM qlstates_walk_fini(mdb_walk_state_t *wsp) 12357836SJohn.Forte@Sun.COM { 12367836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_adapter_state_t)); 12377836SJohn.Forte@Sun.COM } 12387836SJohn.Forte@Sun.COM 12397836SJohn.Forte@Sun.COM /* 12407836SJohn.Forte@Sun.COM * qlsrb_walk_init 12417836SJohn.Forte@Sun.COM * mdb walker init which prints out linked srb's 12427836SJohn.Forte@Sun.COM * 12437836SJohn.Forte@Sun.COM * Input: 12447836SJohn.Forte@Sun.COM * wsp - Pointer to walker ql_srb struct 12457836SJohn.Forte@Sun.COM * 12467836SJohn.Forte@Sun.COM * Returns: 12477836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 12487836SJohn.Forte@Sun.COM * 12497836SJohn.Forte@Sun.COM * Context: 12507836SJohn.Forte@Sun.COM * User context. 12517836SJohn.Forte@Sun.COM * 12527836SJohn.Forte@Sun.COM */ 12537836SJohn.Forte@Sun.COM static int 12547836SJohn.Forte@Sun.COM qlsrb_walk_init(mdb_walk_state_t *wsp) 12557836SJohn.Forte@Sun.COM { 12567836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 12577836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb addr at %p", 12587836SJohn.Forte@Sun.COM wsp->walk_addr); 12597836SJohn.Forte@Sun.COM return (WALK_ERR); 12607836SJohn.Forte@Sun.COM } 12617836SJohn.Forte@Sun.COM 12627836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_srb_t), UM_SLEEP); 12637836SJohn.Forte@Sun.COM 12647836SJohn.Forte@Sun.COM return (WALK_NEXT); 12657836SJohn.Forte@Sun.COM } 12667836SJohn.Forte@Sun.COM 12677836SJohn.Forte@Sun.COM /* 12687836SJohn.Forte@Sun.COM * qlcsrb_walk_step 12697836SJohn.Forte@Sun.COM * mdb walker step which prints out linked ql_srb structures 12707836SJohn.Forte@Sun.COM * 12717836SJohn.Forte@Sun.COM * Input: 12727836SJohn.Forte@Sun.COM * wsp - Pointer to walker srb struct 12737836SJohn.Forte@Sun.COM * 12747836SJohn.Forte@Sun.COM * Returns: 12757836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 12767836SJohn.Forte@Sun.COM * 12777836SJohn.Forte@Sun.COM * Context: 12787836SJohn.Forte@Sun.COM * User context. 12797836SJohn.Forte@Sun.COM * 12807836SJohn.Forte@Sun.COM */ 12817836SJohn.Forte@Sun.COM static int 12827836SJohn.Forte@Sun.COM qlsrb_walk_step(mdb_walk_state_t *wsp) 12837836SJohn.Forte@Sun.COM { 12847836SJohn.Forte@Sun.COM ql_srb_t *qlsrb; 12857836SJohn.Forte@Sun.COM 12867836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) 12877836SJohn.Forte@Sun.COM return (WALK_DONE); 12887836SJohn.Forte@Sun.COM 12897836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_srb_t), 12907836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 12917836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_srb at %p", wsp->walk_addr); 12927836SJohn.Forte@Sun.COM return (WALK_DONE); 12937836SJohn.Forte@Sun.COM } 12947836SJohn.Forte@Sun.COM 12957836SJohn.Forte@Sun.COM qlsrb = (ql_srb_t *)(wsp->walk_data); 12967836SJohn.Forte@Sun.COM mdb_printf("ql_srb base addr = %llx\n", wsp->walk_addr); 12977836SJohn.Forte@Sun.COM 12987836SJohn.Forte@Sun.COM mdb_printf("\nql_srb flags:\n"); 12997836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qlsrb->flags, qlsrb_flags); 13007836SJohn.Forte@Sun.COM 13017836SJohn.Forte@Sun.COM mdb_printf("\nql_srb:\n"); 13027836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_srb"); 13037836SJohn.Forte@Sun.COM 13047836SJohn.Forte@Sun.COM mdb_printf("\n"); 13057836SJohn.Forte@Sun.COM 13067836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t) 13077836SJohn.Forte@Sun.COM (((ql_srb_t *)wsp->walk_data)->cmd.next); 13087836SJohn.Forte@Sun.COM 13097836SJohn.Forte@Sun.COM return (WALK_NEXT); 13107836SJohn.Forte@Sun.COM } 13117836SJohn.Forte@Sun.COM 13127836SJohn.Forte@Sun.COM /* 13137836SJohn.Forte@Sun.COM * qlsrb_walk_fini 13147836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 13157836SJohn.Forte@Sun.COM * 13167836SJohn.Forte@Sun.COM * Input: 13177836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 13187836SJohn.Forte@Sun.COM * 13197836SJohn.Forte@Sun.COM * Returns: 13207836SJohn.Forte@Sun.COM * 13217836SJohn.Forte@Sun.COM * Context: 13227836SJohn.Forte@Sun.COM * User context. 13237836SJohn.Forte@Sun.COM * 13247836SJohn.Forte@Sun.COM */ 13257836SJohn.Forte@Sun.COM static void 13267836SJohn.Forte@Sun.COM qlsrb_walk_fini(mdb_walk_state_t *wsp) 13277836SJohn.Forte@Sun.COM { 13287836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_srb_t)); 13297836SJohn.Forte@Sun.COM } 13307836SJohn.Forte@Sun.COM 13317836SJohn.Forte@Sun.COM /* 13327836SJohn.Forte@Sun.COM * qllunq_dcmd 13337836SJohn.Forte@Sun.COM * mdb walker which prints out lun q's 13347836SJohn.Forte@Sun.COM * 13357836SJohn.Forte@Sun.COM * Input: 13367836SJohn.Forte@Sun.COM * wsp - Pointer to walker ql_lun struct 13377836SJohn.Forte@Sun.COM * 13387836SJohn.Forte@Sun.COM * Returns: 13397836SJohn.Forte@Sun.COM * WALK_ERR, or WALK_NEXT 13407836SJohn.Forte@Sun.COM * 13417836SJohn.Forte@Sun.COM * Context: 13427836SJohn.Forte@Sun.COM * User context. 13437836SJohn.Forte@Sun.COM * 13447836SJohn.Forte@Sun.COM */ 13457836SJohn.Forte@Sun.COM static int 13467836SJohn.Forte@Sun.COM qllunq_walk_init(mdb_walk_state_t *wsp) 13477836SJohn.Forte@Sun.COM { 13487836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) { 13497836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_lun addr at %p", 13507836SJohn.Forte@Sun.COM wsp->walk_addr); 13517836SJohn.Forte@Sun.COM return (WALK_ERR); 13527836SJohn.Forte@Sun.COM } 13537836SJohn.Forte@Sun.COM 13547836SJohn.Forte@Sun.COM wsp->walk_data = mdb_alloc(sizeof (ql_lun_t), UM_SLEEP); 13557836SJohn.Forte@Sun.COM 13567836SJohn.Forte@Sun.COM return (WALK_NEXT); 13577836SJohn.Forte@Sun.COM } 13587836SJohn.Forte@Sun.COM 13597836SJohn.Forte@Sun.COM /* 13607836SJohn.Forte@Sun.COM * qlclunq_walk_step 13617836SJohn.Forte@Sun.COM * mdb walker step which prints out linked ql_lun structures 13627836SJohn.Forte@Sun.COM * 13637836SJohn.Forte@Sun.COM * Input: 13647836SJohn.Forte@Sun.COM * wsp - Pointer to walker srb struct 13657836SJohn.Forte@Sun.COM * 13667836SJohn.Forte@Sun.COM * Returns: 13677836SJohn.Forte@Sun.COM * WALK_DONE, or WALK_NEXT 13687836SJohn.Forte@Sun.COM * 13697836SJohn.Forte@Sun.COM * Context: 13707836SJohn.Forte@Sun.COM * User context. 13717836SJohn.Forte@Sun.COM * 13727836SJohn.Forte@Sun.COM */ 13737836SJohn.Forte@Sun.COM static int 13747836SJohn.Forte@Sun.COM qllunq_walk_step(mdb_walk_state_t *wsp) 13757836SJohn.Forte@Sun.COM { 13767836SJohn.Forte@Sun.COM ql_lun_t *qllun; 13777836SJohn.Forte@Sun.COM ql_link_t ql_link; 13787836SJohn.Forte@Sun.COM ql_link_t *qllink; 13797836SJohn.Forte@Sun.COM 13807836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL) 13817836SJohn.Forte@Sun.COM return (WALK_DONE); 13827836SJohn.Forte@Sun.COM 13837836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data, sizeof (ql_lun_t), 13847836SJohn.Forte@Sun.COM wsp->walk_addr) == -1) { 13857836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_lun at %p", wsp->walk_addr); 13867836SJohn.Forte@Sun.COM return (WALK_DONE); 13877836SJohn.Forte@Sun.COM } 13887836SJohn.Forte@Sun.COM 13897836SJohn.Forte@Sun.COM qllun = (ql_lun_t *)(wsp->walk_data); 13907836SJohn.Forte@Sun.COM mdb_printf("ql_lun base addr = %llx\n", wsp->walk_addr); 13917836SJohn.Forte@Sun.COM 13927836SJohn.Forte@Sun.COM mdb_printf("\nql_lun flags:\n"); 13937836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)qllun->flags, qllun_flags); 13947836SJohn.Forte@Sun.COM 13957836SJohn.Forte@Sun.COM mdb_printf("\nql_lun:\n"); 13967836SJohn.Forte@Sun.COM (void) ql_doprint(wsp->walk_addr, "struct ql_lun"); 13977836SJohn.Forte@Sun.COM 13987836SJohn.Forte@Sun.COM mdb_printf("\n"); 13997836SJohn.Forte@Sun.COM 14007836SJohn.Forte@Sun.COM qllink = (ql_link_t *) 14017836SJohn.Forte@Sun.COM (((ql_lun_t *)wsp->walk_data)->link.next); 14027836SJohn.Forte@Sun.COM 14037836SJohn.Forte@Sun.COM if (qllink == NULL) { 14047836SJohn.Forte@Sun.COM return (WALK_DONE); 14057836SJohn.Forte@Sun.COM } else { 14067836SJohn.Forte@Sun.COM /* 14077836SJohn.Forte@Sun.COM * Read in the next link_t header 14087836SJohn.Forte@Sun.COM */ 14097836SJohn.Forte@Sun.COM if (mdb_vread(&ql_link, sizeof (ql_link_t), 14107836SJohn.Forte@Sun.COM (uintptr_t)qllink) == -1) { 14117836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t " 14127836SJohn.Forte@Sun.COM "next at %p", qllink->next); 14137836SJohn.Forte@Sun.COM return (WALK_DONE); 14147836SJohn.Forte@Sun.COM } 14157836SJohn.Forte@Sun.COM qllink = &ql_link; 14167836SJohn.Forte@Sun.COM } 14177836SJohn.Forte@Sun.COM 14187836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t)qllink->base_address; 14197836SJohn.Forte@Sun.COM 14207836SJohn.Forte@Sun.COM return (WALK_NEXT); 14217836SJohn.Forte@Sun.COM } 14227836SJohn.Forte@Sun.COM 14237836SJohn.Forte@Sun.COM /* 14247836SJohn.Forte@Sun.COM * qllunq_walk_fini 14257836SJohn.Forte@Sun.COM * mdb walker fini which wraps up the walker 14267836SJohn.Forte@Sun.COM * 14277836SJohn.Forte@Sun.COM * Input: 14287836SJohn.Forte@Sun.COM * wsp - Pointer to walker state struct 14297836SJohn.Forte@Sun.COM * 14307836SJohn.Forte@Sun.COM * Returns: 14317836SJohn.Forte@Sun.COM * 14327836SJohn.Forte@Sun.COM * Context: 14337836SJohn.Forte@Sun.COM * User context. 14347836SJohn.Forte@Sun.COM * 14357836SJohn.Forte@Sun.COM */ 14367836SJohn.Forte@Sun.COM static void 14377836SJohn.Forte@Sun.COM qllunq_walk_fini(mdb_walk_state_t *wsp) 14387836SJohn.Forte@Sun.COM { 14397836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (ql_lun_t)); 14407836SJohn.Forte@Sun.COM } 14417836SJohn.Forte@Sun.COM 14427836SJohn.Forte@Sun.COM /* 14437836SJohn.Forte@Sun.COM * qltgtq_dcmd 14447836SJohn.Forte@Sun.COM * mdb dcmd which prints out an hs's tq struct info. 14457836SJohn.Forte@Sun.COM * 14467836SJohn.Forte@Sun.COM * Input: 14477836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 14487836SJohn.Forte@Sun.COM * flags = mdb flags. 14497836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 14507836SJohn.Forte@Sun.COM * argv = Arg array. 14517836SJohn.Forte@Sun.COM * 14527836SJohn.Forte@Sun.COM * Returns: 14537836SJohn.Forte@Sun.COM * DCMD_USAGE, or DCMD_OK 14547836SJohn.Forte@Sun.COM * 14557836SJohn.Forte@Sun.COM * Context: 14567836SJohn.Forte@Sun.COM * User context. 14577836SJohn.Forte@Sun.COM * 14587836SJohn.Forte@Sun.COM */ 14597836SJohn.Forte@Sun.COM /*ARGSUSED*/ 14607836SJohn.Forte@Sun.COM static int 14617836SJohn.Forte@Sun.COM qltgtq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 14627836SJohn.Forte@Sun.COM { 14637836SJohn.Forte@Sun.COM ql_adapter_state_t *ha; 14647836SJohn.Forte@Sun.COM ql_link_t *link; 14657836SJohn.Forte@Sun.COM ql_tgt_t *tq; 14667836SJohn.Forte@Sun.COM uint32_t index; 14677836SJohn.Forte@Sun.COM ql_head_t *dev; 14687836SJohn.Forte@Sun.COM 14697836SJohn.Forte@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 14707836SJohn.Forte@Sun.COM mdb_warn("ql_hba structure addr is required"); 14717836SJohn.Forte@Sun.COM return (DCMD_USAGE); 14727836SJohn.Forte@Sun.COM } 14737836SJohn.Forte@Sun.COM 14747836SJohn.Forte@Sun.COM /* 14757836SJohn.Forte@Sun.COM * Get the adapter state struct which was passed 14767836SJohn.Forte@Sun.COM */ 14777836SJohn.Forte@Sun.COM 14787836SJohn.Forte@Sun.COM ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 14797836SJohn.Forte@Sun.COM UM_SLEEP); 14807836SJohn.Forte@Sun.COM 14817836SJohn.Forte@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 14827836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 14837836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 14847836SJohn.Forte@Sun.COM return (DCMD_OK); 14857836SJohn.Forte@Sun.COM } 14867836SJohn.Forte@Sun.COM 14877836SJohn.Forte@Sun.COM if (ha->dev == NULL) { 14887836SJohn.Forte@Sun.COM mdb_warn("dev ptr is NULL for ha: %p", addr); 14897836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 14907836SJohn.Forte@Sun.COM return (DCMD_OK); 14917836SJohn.Forte@Sun.COM } 14927836SJohn.Forte@Sun.COM 14937836SJohn.Forte@Sun.COM /* 14947836SJohn.Forte@Sun.COM * Read in the device array 14957836SJohn.Forte@Sun.COM */ 14967836SJohn.Forte@Sun.COM dev = (ql_head_t *) 14977836SJohn.Forte@Sun.COM mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP); 14987836SJohn.Forte@Sun.COM 14997836SJohn.Forte@Sun.COM if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, 15007836SJohn.Forte@Sun.COM (uintptr_t)ha->dev) == -1) { 15017836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_head_t (dev) at %p", ha->dev); 15027836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 15037836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE); 15047836SJohn.Forte@Sun.COM } 15057836SJohn.Forte@Sun.COM 15067836SJohn.Forte@Sun.COM tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP); 15077836SJohn.Forte@Sun.COM link = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP); 15087836SJohn.Forte@Sun.COM 15097836SJohn.Forte@Sun.COM for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) { 15107836SJohn.Forte@Sun.COM 15117836SJohn.Forte@Sun.COM if (dev[index].first == NULL) { 15127836SJohn.Forte@Sun.COM continue; 15137836SJohn.Forte@Sun.COM } 15147836SJohn.Forte@Sun.COM 15157836SJohn.Forte@Sun.COM if (mdb_vread(link, sizeof (ql_link_t), 15167836SJohn.Forte@Sun.COM (uintptr_t)dev[index].first) == -1) { 15177836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_link_t at %p", 15187836SJohn.Forte@Sun.COM dev[index].first); 15197836SJohn.Forte@Sun.COM break; 15207836SJohn.Forte@Sun.COM } 15217836SJohn.Forte@Sun.COM 15227836SJohn.Forte@Sun.COM while (link != NULL) { 15237836SJohn.Forte@Sun.COM if (mdb_vread(tq, sizeof (ql_tgt_t), 15247836SJohn.Forte@Sun.COM (uintptr_t)(link->base_address)) == -1) { 15257836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_tgt at %p", 15267836SJohn.Forte@Sun.COM link->base_address); 15277836SJohn.Forte@Sun.COM break; 15287836SJohn.Forte@Sun.COM } 15297836SJohn.Forte@Sun.COM 15307836SJohn.Forte@Sun.COM mdb_printf("tgt queue base addr = %llx\n", 15317836SJohn.Forte@Sun.COM link->base_address); 15327836SJohn.Forte@Sun.COM 15337836SJohn.Forte@Sun.COM mdb_printf("\ntgt queue flags: (%xh)\n", tq->flags); 15347836SJohn.Forte@Sun.COM ql_dump_flags((uint64_t)tq->flags, qltgt_flags); 15357836SJohn.Forte@Sun.COM 15367836SJohn.Forte@Sun.COM mdb_printf("\ntgt queue:\n"); 15377836SJohn.Forte@Sun.COM 15387836SJohn.Forte@Sun.COM (void) ql_doprint((uintptr_t)link->base_address, 15397836SJohn.Forte@Sun.COM "struct ql_target"); 15407836SJohn.Forte@Sun.COM 15417836SJohn.Forte@Sun.COM mdb_printf("\n"); 15427836SJohn.Forte@Sun.COM 15437836SJohn.Forte@Sun.COM if (get_next_link(link) != DCMD_OK) { 15447836SJohn.Forte@Sun.COM break; 15457836SJohn.Forte@Sun.COM } 15467836SJohn.Forte@Sun.COM } 15477836SJohn.Forte@Sun.COM } 15487836SJohn.Forte@Sun.COM 15497836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 15507836SJohn.Forte@Sun.COM mdb_free(tq, sizeof (ql_tgt_t)); 15517836SJohn.Forte@Sun.COM mdb_free(link, sizeof (ql_link_t)); 15527836SJohn.Forte@Sun.COM mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE); 15537836SJohn.Forte@Sun.COM 15547836SJohn.Forte@Sun.COM return (DCMD_OK); 15557836SJohn.Forte@Sun.COM } 15567836SJohn.Forte@Sun.COM 15577836SJohn.Forte@Sun.COM /* 15589156SDaniel.Beauregard@Sun.COM * ql_triggerdump_dcmd 15599156SDaniel.Beauregard@Sun.COM * Triggers the driver to take a firmware dump 15609156SDaniel.Beauregard@Sun.COM * 15619156SDaniel.Beauregard@Sun.COM * Input: 15629156SDaniel.Beauregard@Sun.COM * addr = User supplied address (optional) 15639156SDaniel.Beauregard@Sun.COM * flags = mdb flags. 15649156SDaniel.Beauregard@Sun.COM * argc = Number of user supplied args. 15659156SDaniel.Beauregard@Sun.COM * argv = Arg array (instance #, optional). 15669156SDaniel.Beauregard@Sun.COM * 15679156SDaniel.Beauregard@Sun.COM * Returns: 15689156SDaniel.Beauregard@Sun.COM * DCMD_OK or DCMD_ERR 15699156SDaniel.Beauregard@Sun.COM * 15709156SDaniel.Beauregard@Sun.COM * Context: 15719156SDaniel.Beauregard@Sun.COM * User context. 15729156SDaniel.Beauregard@Sun.COM * 15739156SDaniel.Beauregard@Sun.COM */ 15749156SDaniel.Beauregard@Sun.COM 15759156SDaniel.Beauregard@Sun.COM #if 0 15769156SDaniel.Beauregard@Sun.COM 15779156SDaniel.Beauregard@Sun.COM /*ARGSUSED*/ 15789156SDaniel.Beauregard@Sun.COM static int 15799156SDaniel.Beauregard@Sun.COM qlc_triggerdump_dcmd(uintptr_t addr, uint_t flags, int argc, 15809156SDaniel.Beauregard@Sun.COM const mdb_arg_t *argv) 15819156SDaniel.Beauregard@Sun.COM { 15829156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *qlstate; 15839156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 15849156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 15859156SDaniel.Beauregard@Sun.COM uint32_t qlsize = sizeof (ql_adapter_state_t); 15869156SDaniel.Beauregard@Sun.COM int mdbs; 15879156SDaniel.Beauregard@Sun.COM 15889156SDaniel.Beauregard@Sun.COM if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) { 15899156SDaniel.Beauregard@Sun.COM mdb_warn("Cannot change core file data (state=%xh)\n", mdbs); 15909156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 15919156SDaniel.Beauregard@Sun.COM } 15929156SDaniel.Beauregard@Sun.COM 15939156SDaniel.Beauregard@Sun.COM if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize, 15949156SDaniel.Beauregard@Sun.COM UM_SLEEP)) == NULL) { 15959156SDaniel.Beauregard@Sun.COM mdb_warn("Unable to allocate memory for ql_adapter_state\n"); 15969156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 15979156SDaniel.Beauregard@Sun.COM } 15989156SDaniel.Beauregard@Sun.COM 15999156SDaniel.Beauregard@Sun.COM if (addr == NULL) { 16009156SDaniel.Beauregard@Sun.COM char *tptr; 16019156SDaniel.Beauregard@Sun.COM uint32_t instance; 16029156SDaniel.Beauregard@Sun.COM 16039156SDaniel.Beauregard@Sun.COM if (argc == 0) { 16049156SDaniel.Beauregard@Sun.COM mdb_warn("must specify either the ha addr or " 16059156SDaniel.Beauregard@Sun.COM "the instance number\n"); 16069156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16079156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 16089156SDaniel.Beauregard@Sun.COM } 16099156SDaniel.Beauregard@Sun.COM 16109156SDaniel.Beauregard@Sun.COM /* 16119156SDaniel.Beauregard@Sun.COM * find the specified instance in the ha list 16129156SDaniel.Beauregard@Sun.COM */ 16139156SDaniel.Beauregard@Sun.COM 16149156SDaniel.Beauregard@Sun.COM instance = (uint32_t)strtol(argv[1].a_un.a_str, &tptr, 16); 16159156SDaniel.Beauregard@Sun.COM if (tptr == argv[1].a_un.a_str) { 16169156SDaniel.Beauregard@Sun.COM mdb_printf("instance # is illegal: '%s'\n", 16179156SDaniel.Beauregard@Sun.COM argv[1].a_un.a_str); 16189156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16199156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 16209156SDaniel.Beauregard@Sun.COM } 16219156SDaniel.Beauregard@Sun.COM 16229156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 16239156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 16249156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16259156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 16269156SDaniel.Beauregard@Sun.COM } 16279156SDaniel.Beauregard@Sun.COM 16289156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 16299156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure - " 16309156SDaniel.Beauregard@Sun.COM "is qlc loaded?"); 16319156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16329156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 16339156SDaniel.Beauregard@Sun.COM } 16349156SDaniel.Beauregard@Sun.COM 16359156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 16369156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 16379156SDaniel.Beauregard@Sun.COM 16389156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 16399156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16409156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 16419156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 16429156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 16439156SDaniel.Beauregard@Sun.COM } 16449156SDaniel.Beauregard@Sun.COM 16459156SDaniel.Beauregard@Sun.COM if (qlstate->instance == instance) { 16469156SDaniel.Beauregard@Sun.COM break; 16479156SDaniel.Beauregard@Sun.COM } 16489156SDaniel.Beauregard@Sun.COM 16499156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 16509156SDaniel.Beauregard@Sun.COM } 16519156SDaniel.Beauregard@Sun.COM } else { 16529156SDaniel.Beauregard@Sun.COM 16539156SDaniel.Beauregard@Sun.COM /* 16549156SDaniel.Beauregard@Sun.COM * verify the addr specified 16559156SDaniel.Beauregard@Sun.COM */ 16569156SDaniel.Beauregard@Sun.COM 16579156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 16589156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 16599156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16609156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 16619156SDaniel.Beauregard@Sun.COM } 16629156SDaniel.Beauregard@Sun.COM 16639156SDaniel.Beauregard@Sun.COM if (&ql_hba == NULL) { 16649156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure - " 16659156SDaniel.Beauregard@Sun.COM "is qlc loaded?"); 16669156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16679156SDaniel.Beauregard@Sun.COM return (DCMD_ERR); 16689156SDaniel.Beauregard@Sun.COM } 16699156SDaniel.Beauregard@Sun.COM 16709156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 16719156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 16729156SDaniel.Beauregard@Sun.COM 16739156SDaniel.Beauregard@Sun.COM if (mdb_vread(qlstate, qlsize, hbaptr) == -1) { 16749156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16759156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read " 16769156SDaniel.Beauregard@Sun.COM "ql_adapter_state at %p", hbaptr); 16779156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 16789156SDaniel.Beauregard@Sun.COM } 16799156SDaniel.Beauregard@Sun.COM 16809156SDaniel.Beauregard@Sun.COM if (hbaptr == addr) { 16819156SDaniel.Beauregard@Sun.COM break; 16829156SDaniel.Beauregard@Sun.COM } 16839156SDaniel.Beauregard@Sun.COM 16849156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)qlstate->hba.next; 16859156SDaniel.Beauregard@Sun.COM } 16869156SDaniel.Beauregard@Sun.COM } 16879156SDaniel.Beauregard@Sun.COM 16889156SDaniel.Beauregard@Sun.COM if (hbaptr == NULL) { 16899156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 16909156SDaniel.Beauregard@Sun.COM if (argc == 0) { 16919156SDaniel.Beauregard@Sun.COM mdb_warn("addr specified is not in the hba list\n"); 16929156SDaniel.Beauregard@Sun.COM } else { 16939156SDaniel.Beauregard@Sun.COM mdb_warn("instance specified does not exist\n"); 16949156SDaniel.Beauregard@Sun.COM } 16959156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 16969156SDaniel.Beauregard@Sun.COM } 16979156SDaniel.Beauregard@Sun.COM 16989156SDaniel.Beauregard@Sun.COM if (((qlstate->ql_dump_state & QL_DUMP_VALID) != 0) || 16999156SDaniel.Beauregard@Sun.COM (qlstate->ql_dump_ptr != NULL)) { 17009156SDaniel.Beauregard@Sun.COM mdb_warn("instance %d already has a valid dump\n", 17019156SDaniel.Beauregard@Sun.COM qlstate->instance); 17029156SDaniel.Beauregard@Sun.COM mdb_free(qlstate, qlsize); 17039156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 17049156SDaniel.Beauregard@Sun.COM } 17059156SDaniel.Beauregard@Sun.COM } 17069156SDaniel.Beauregard@Sun.COM #endif 17079156SDaniel.Beauregard@Sun.COM 17089156SDaniel.Beauregard@Sun.COM /* 17099156SDaniel.Beauregard@Sun.COM * ql_getdump_dcmd 17107836SJohn.Forte@Sun.COM * prints out the firmware dump buffer 17117836SJohn.Forte@Sun.COM * 17127836SJohn.Forte@Sun.COM * Input: 17139156SDaniel.Beauregard@Sun.COM * addr = User supplied address. (NB: must be an ha) 17147836SJohn.Forte@Sun.COM * flags = mdb flags. 17157836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 17167836SJohn.Forte@Sun.COM * argv = Arg array. 17177836SJohn.Forte@Sun.COM * 17187836SJohn.Forte@Sun.COM * Returns: 17197836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 17207836SJohn.Forte@Sun.COM * 17217836SJohn.Forte@Sun.COM * Context: 17227836SJohn.Forte@Sun.COM * User context. 17237836SJohn.Forte@Sun.COM * 17247836SJohn.Forte@Sun.COM */ 17257836SJohn.Forte@Sun.COM static int 17269156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 17277836SJohn.Forte@Sun.COM { 17287836SJohn.Forte@Sun.COM ql_adapter_state_t *ha; 17299156SDaniel.Beauregard@Sun.COM ql_head_t ql_hba; 17309156SDaniel.Beauregard@Sun.COM uintptr_t hbaptr = NULL; 17319156SDaniel.Beauregard@Sun.COM int verbose = 0; 17327836SJohn.Forte@Sun.COM 17337836SJohn.Forte@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 17347836SJohn.Forte@Sun.COM mdb_warn("ql_adapter_state structure addr is required"); 17357836SJohn.Forte@Sun.COM return (DCMD_USAGE); 17367836SJohn.Forte@Sun.COM } 17377836SJohn.Forte@Sun.COM 17389156SDaniel.Beauregard@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 17399156SDaniel.Beauregard@Sun.COM argc) { 17409156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 17419156SDaniel.Beauregard@Sun.COM } 17429156SDaniel.Beauregard@Sun.COM 17437836SJohn.Forte@Sun.COM /* 17447836SJohn.Forte@Sun.COM * Get the adapter state struct which was passed 17457836SJohn.Forte@Sun.COM */ 17467836SJohn.Forte@Sun.COM if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 17477836SJohn.Forte@Sun.COM UM_SLEEP)) == NULL) { 17487836SJohn.Forte@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 17497836SJohn.Forte@Sun.COM return (DCMD_OK); 17507836SJohn.Forte@Sun.COM } 17517836SJohn.Forte@Sun.COM 17529156SDaniel.Beauregard@Sun.COM /* 17539156SDaniel.Beauregard@Sun.COM * show user which instances have valid f/w dumps available if 17549156SDaniel.Beauregard@Sun.COM * user has specified verbose option 17559156SDaniel.Beauregard@Sun.COM */ 17569156SDaniel.Beauregard@Sun.COM if (mdb_readvar(&ql_hba, "ql_hba") == -1) { 17579156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure"); 17589156SDaniel.Beauregard@Sun.COM } else if (&ql_hba == NULL) { 17599156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_hba structure -- is qlc loaded?"); 17609156SDaniel.Beauregard@Sun.COM } else if (verbose) { 17619156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ql_hba.first; 17629156SDaniel.Beauregard@Sun.COM while (hbaptr != NULL) { 17639156SDaniel.Beauregard@Sun.COM 17649156SDaniel.Beauregard@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), 17659156SDaniel.Beauregard@Sun.COM hbaptr) == -1) { 17669156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 17679156SDaniel.Beauregard@Sun.COM mdb_warn("failed read ql_adapter_state at %p", 17689156SDaniel.Beauregard@Sun.COM hbaptr); 17699156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 17709156SDaniel.Beauregard@Sun.COM } 17719156SDaniel.Beauregard@Sun.COM 17729156SDaniel.Beauregard@Sun.COM mdb_printf("instance %d:\n", ha->instance); 17739156SDaniel.Beauregard@Sun.COM (void) mdb_inc_indent((ulong_t)4); 17749156SDaniel.Beauregard@Sun.COM 17759156SDaniel.Beauregard@Sun.COM if (ha->ql_dump_state == 0) { 17769156SDaniel.Beauregard@Sun.COM mdb_printf("no dump flags\n"); 17779156SDaniel.Beauregard@Sun.COM } else { 17789156SDaniel.Beauregard@Sun.COM ql_dump_flags((uint64_t)ha->ql_dump_state, 17799156SDaniel.Beauregard@Sun.COM qldump_flags); 17809156SDaniel.Beauregard@Sun.COM } 17819156SDaniel.Beauregard@Sun.COM 17829156SDaniel.Beauregard@Sun.COM if (ha->ql_dump_ptr == NULL) { 17839156SDaniel.Beauregard@Sun.COM mdb_printf("no dump address\n"); 17849156SDaniel.Beauregard@Sun.COM } else { 17859156SDaniel.Beauregard@Sun.COM mdb_printf("dump address is: %p\n", 17869156SDaniel.Beauregard@Sun.COM ha->ql_dump_ptr); 17879156SDaniel.Beauregard@Sun.COM } 17889156SDaniel.Beauregard@Sun.COM 17899156SDaniel.Beauregard@Sun.COM (void) mdb_dec_indent((ulong_t)4); 17909156SDaniel.Beauregard@Sun.COM 17919156SDaniel.Beauregard@Sun.COM hbaptr = (uintptr_t)ha->hba.next; 17929156SDaniel.Beauregard@Sun.COM } 17939156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 17949156SDaniel.Beauregard@Sun.COM } 17959156SDaniel.Beauregard@Sun.COM 17967836SJohn.Forte@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 17977836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 17987836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 17997836SJohn.Forte@Sun.COM return (DCMD_OK); 18007836SJohn.Forte@Sun.COM } 18017836SJohn.Forte@Sun.COM 18029156SDaniel.Beauregard@Sun.COM /* 18039156SDaniel.Beauregard@Sun.COM * If its not a valid dump or there's not a f/w dump binary (???) 18049156SDaniel.Beauregard@Sun.COM * then bail out 18059156SDaniel.Beauregard@Sun.COM */ 18069156SDaniel.Beauregard@Sun.COM if (((ha->ql_dump_state & QL_DUMP_VALID) == 0) || 18079156SDaniel.Beauregard@Sun.COM (ha->ql_dump_ptr == NULL)) { 18089156SDaniel.Beauregard@Sun.COM mdb_warn("dump does not exist for instance %d (%x, %p)\n", 18099156SDaniel.Beauregard@Sun.COM ha->instance, ha->ql_dump_state, ha->ql_dump_ptr); 18109156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 18119156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 18129156SDaniel.Beauregard@Sun.COM } 18139156SDaniel.Beauregard@Sun.COM 18147836SJohn.Forte@Sun.COM if (CFG_IST(ha, CFG_CTRL_2422)) { 18157836SJohn.Forte@Sun.COM (void) ql_24xx_dump_dcmd(ha, flags, argc, argv); 1816*9446SDaniel.Beauregard@Sun.COM } else if (CFG_IST(ha, CFG_CTRL_2581)) { 18177836SJohn.Forte@Sun.COM (void) ql_25xx_dump_dcmd(ha, flags, argc, argv); 18187836SJohn.Forte@Sun.COM } else { 18197836SJohn.Forte@Sun.COM (void) ql_23xx_dump_dcmd(ha, flags, argc, argv); 18207836SJohn.Forte@Sun.COM } 18217836SJohn.Forte@Sun.COM 18227836SJohn.Forte@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 18237836SJohn.Forte@Sun.COM 18247836SJohn.Forte@Sun.COM return (DCMD_OK); 18257836SJohn.Forte@Sun.COM } 18267836SJohn.Forte@Sun.COM 18277836SJohn.Forte@Sun.COM /* 18287836SJohn.Forte@Sun.COM * ql_23xx_dump_dcmd 18297836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 18307836SJohn.Forte@Sun.COM * 18317836SJohn.Forte@Sun.COM * Input: 18327836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 18337836SJohn.Forte@Sun.COM * flags = mdb flags. 18347836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 18357836SJohn.Forte@Sun.COM * argv = Arg array. 18367836SJohn.Forte@Sun.COM * 18377836SJohn.Forte@Sun.COM * Returns: 18387836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 18397836SJohn.Forte@Sun.COM * 18407836SJohn.Forte@Sun.COM * Context: 18417836SJohn.Forte@Sun.COM * User context. 18427836SJohn.Forte@Sun.COM * 18437836SJohn.Forte@Sun.COM */ 18447836SJohn.Forte@Sun.COM /*ARGSUSED*/ 18457836SJohn.Forte@Sun.COM static int 18467836SJohn.Forte@Sun.COM ql_23xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 18477836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 18487836SJohn.Forte@Sun.COM { 18497836SJohn.Forte@Sun.COM ql_fw_dump_t *fw; 18507836SJohn.Forte@Sun.COM uint32_t cnt = 0; 18517836SJohn.Forte@Sun.COM int mbox_cnt; 18527836SJohn.Forte@Sun.COM 18539156SDaniel.Beauregard@Sun.COM fw = (ql_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 18549156SDaniel.Beauregard@Sun.COM 18559156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 18569156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 18577836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 18589156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 18597836SJohn.Forte@Sun.COM return (DCMD_OK); 18607836SJohn.Forte@Sun.COM } 18617836SJohn.Forte@Sun.COM 18627836SJohn.Forte@Sun.COM if (ha->cfg_flags & CFG_CTRL_2300) { 18637836SJohn.Forte@Sun.COM mdb_printf("\nISP 2300IP "); 18647836SJohn.Forte@Sun.COM } else if (ha->cfg_flags & CFG_CTRL_6322) { 18657836SJohn.Forte@Sun.COM mdb_printf("\nISP 6322FLX "); 18667836SJohn.Forte@Sun.COM } else { 18677836SJohn.Forte@Sun.COM mdb_printf("\nISP 2200IP "); 18687836SJohn.Forte@Sun.COM } 18697836SJohn.Forte@Sun.COM 18707836SJohn.Forte@Sun.COM mdb_printf("Firmware Version %d.%d.%d\n", 18717836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 18727836SJohn.Forte@Sun.COM ha->fw_subminor_version); 18737836SJohn.Forte@Sun.COM 18747836SJohn.Forte@Sun.COM mdb_printf("\nPBIU Registers:"); 18757836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) { 18767836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 18777836SJohn.Forte@Sun.COM mdb_printf("\n"); 18787836SJohn.Forte@Sun.COM } 18797836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->pbiu_reg[cnt]); 18807836SJohn.Forte@Sun.COM } 18817836SJohn.Forte@Sun.COM 18827836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 18837836SJohn.Forte@Sun.COM mdb_printf("\n\nReqQ-RspQ-Risc2Host Status registers:"); 18847836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) { 18857836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 18867836SJohn.Forte@Sun.COM mdb_printf("\n"); 18877836SJohn.Forte@Sun.COM } 18887836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_host_reg[cnt]); 18897836SJohn.Forte@Sun.COM } 18907836SJohn.Forte@Sun.COM } 18917836SJohn.Forte@Sun.COM 18927836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers:"); 18937836SJohn.Forte@Sun.COM mbox_cnt = (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) ? 16 : 8; 18947836SJohn.Forte@Sun.COM for (cnt = 0; cnt < mbox_cnt; cnt++) { 18957836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 18967836SJohn.Forte@Sun.COM mdb_printf("\n"); 18977836SJohn.Forte@Sun.COM } 18987836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 18997836SJohn.Forte@Sun.COM } 19007836SJohn.Forte@Sun.COM 19017836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 19027836SJohn.Forte@Sun.COM mdb_printf("\n\nAuto Request Response DMA Registers:"); 19037836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) { 19047836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19057836SJohn.Forte@Sun.COM mdb_printf("\n"); 19067836SJohn.Forte@Sun.COM } 19077836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->resp_dma_reg[cnt]); 19087836SJohn.Forte@Sun.COM } 19097836SJohn.Forte@Sun.COM } 19107836SJohn.Forte@Sun.COM 19117836SJohn.Forte@Sun.COM mdb_printf("\n\nDMA Registers:"); 19127836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) { 19137836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19147836SJohn.Forte@Sun.COM mdb_printf("\n"); 19157836SJohn.Forte@Sun.COM } 19167836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->dma_reg[cnt]); 19177836SJohn.Forte@Sun.COM } 19187836SJohn.Forte@Sun.COM 19197836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC Hardware Registers:"); 19207836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) { 19217836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19227836SJohn.Forte@Sun.COM mdb_printf("\n"); 19237836SJohn.Forte@Sun.COM } 19247836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_hdw_reg[cnt]); 19257836SJohn.Forte@Sun.COM } 19267836SJohn.Forte@Sun.COM 19277836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP0 Registers:"); 19287836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) { 19297836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19307836SJohn.Forte@Sun.COM mdb_printf("\n"); 19317836SJohn.Forte@Sun.COM } 19327836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp0_reg[cnt]); 19337836SJohn.Forte@Sun.COM } 19347836SJohn.Forte@Sun.COM 19357836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP1 Registers:"); 19367836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) { 19377836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19387836SJohn.Forte@Sun.COM mdb_printf("\n"); 19397836SJohn.Forte@Sun.COM } 19407836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp1_reg[cnt]); 19417836SJohn.Forte@Sun.COM } 19427836SJohn.Forte@Sun.COM 19437836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP2 Registers:"); 19447836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) { 19457836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19467836SJohn.Forte@Sun.COM mdb_printf("\n"); 19477836SJohn.Forte@Sun.COM } 19487836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp2_reg[cnt]); 19497836SJohn.Forte@Sun.COM } 19507836SJohn.Forte@Sun.COM 19517836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP3 Registers:"); 19527836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) { 19537836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19547836SJohn.Forte@Sun.COM mdb_printf("\n"); 19557836SJohn.Forte@Sun.COM } 19567836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp3_reg[cnt]); 19577836SJohn.Forte@Sun.COM } 19587836SJohn.Forte@Sun.COM 19597836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP4 Registers:"); 19607836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) { 19617836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19627836SJohn.Forte@Sun.COM mdb_printf("\n"); 19637836SJohn.Forte@Sun.COM } 19647836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp4_reg[cnt]); 19657836SJohn.Forte@Sun.COM } 19667836SJohn.Forte@Sun.COM 19677836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP5 Registers:"); 19687836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) { 19697836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19707836SJohn.Forte@Sun.COM mdb_printf("\n"); 19717836SJohn.Forte@Sun.COM } 19727836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp5_reg[cnt]); 19737836SJohn.Forte@Sun.COM } 19747836SJohn.Forte@Sun.COM 19757836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP6 Registers:"); 19767836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) { 19777836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19787836SJohn.Forte@Sun.COM mdb_printf("\n"); 19797836SJohn.Forte@Sun.COM } 19807836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp6_reg[cnt]); 19817836SJohn.Forte@Sun.COM } 19827836SJohn.Forte@Sun.COM 19837836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP7 Registers:"); 19847836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) { 19857836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19867836SJohn.Forte@Sun.COM mdb_printf("\n"); 19877836SJohn.Forte@Sun.COM } 19887836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_gp7_reg[cnt]); 19897836SJohn.Forte@Sun.COM } 19907836SJohn.Forte@Sun.COM 19917836SJohn.Forte@Sun.COM mdb_printf("\n\nFrame Buffer Hardware Registers:"); 19927836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) { 19937836SJohn.Forte@Sun.COM if ((cnt == 16) && 19947836SJohn.Forte@Sun.COM ((ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) == 0)) { 19957836SJohn.Forte@Sun.COM break; 19967836SJohn.Forte@Sun.COM } 19977836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 19987836SJohn.Forte@Sun.COM mdb_printf("\n"); 19997836SJohn.Forte@Sun.COM } 20007836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->frame_buf_hdw_reg[cnt]); 20017836SJohn.Forte@Sun.COM } 20027836SJohn.Forte@Sun.COM 20037836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM B0 Registers:"); 20047836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) { 20057836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20067836SJohn.Forte@Sun.COM mdb_printf("\n"); 20077836SJohn.Forte@Sun.COM } 20087836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->fpm_b0_reg[cnt]); 20097836SJohn.Forte@Sun.COM } 20107836SJohn.Forte@Sun.COM 20117836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM B1 Registers:"); 20127836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) { 20137836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20147836SJohn.Forte@Sun.COM mdb_printf("\n"); 20157836SJohn.Forte@Sun.COM } 20167836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->fpm_b1_reg[cnt]); 20177836SJohn.Forte@Sun.COM } 20187836SJohn.Forte@Sun.COM 20197836SJohn.Forte@Sun.COM if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) { 20207836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM Dump:"); 20217836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) { 20227836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20237836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x0800); 20247836SJohn.Forte@Sun.COM } 20257836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_ram[cnt]); 20267836SJohn.Forte@Sun.COM } 20277836SJohn.Forte@Sun.COM 20287836SJohn.Forte@Sun.COM mdb_printf("\n\nStack RAM Dump:"); 20297836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) { 20307836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20317836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x010000); 20327836SJohn.Forte@Sun.COM } 20337836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->stack_ram[cnt]); 20347836SJohn.Forte@Sun.COM } 20357836SJohn.Forte@Sun.COM 20367836SJohn.Forte@Sun.COM mdb_printf("\n\nData RAM Dump:"); 20377836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) { 20387836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20397836SJohn.Forte@Sun.COM mdb_printf("\n%05x: ", cnt + 0x010800); 20407836SJohn.Forte@Sun.COM } 20417836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->data_ram[cnt]); 20427836SJohn.Forte@Sun.COM } 20437836SJohn.Forte@Sun.COM 20447836SJohn.Forte@Sun.COM mdb_printf("\n\n[<==END] ISP Debug Dump.\n"); 20459156SDaniel.Beauregard@Sun.COM 20469156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 20479156SDaniel.Beauregard@Sun.COM 20489156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 20499156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 20509156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 20519156SDaniel.Beauregard@Sun.COM } 20529156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 20539156SDaniel.Beauregard@Sun.COM } 20549156SDaniel.Beauregard@Sun.COM 20559156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 20569156SDaniel.Beauregard@Sun.COM 20579156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 20589156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 20599156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 20609156SDaniel.Beauregard@Sun.COM } 20619156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 20629156SDaniel.Beauregard@Sun.COM } 20639156SDaniel.Beauregard@Sun.COM 20649156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 20659156SDaniel.Beauregard@Sun.COM 20667836SJohn.Forte@Sun.COM } else { 20677836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC SRAM:"); 20687836SJohn.Forte@Sun.COM for (cnt = 0; cnt < 0xf000; cnt++) { 20697836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 20707836SJohn.Forte@Sun.COM mdb_printf("\n%04x: ", cnt + 0x1000); 20717836SJohn.Forte@Sun.COM } 20727836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->risc_ram[cnt]); 20737836SJohn.Forte@Sun.COM } 20747836SJohn.Forte@Sun.COM } 20757836SJohn.Forte@Sun.COM 20769156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 20779156SDaniel.Beauregard@Sun.COM 20787836SJohn.Forte@Sun.COM return (DCMD_OK); 20797836SJohn.Forte@Sun.COM } 20807836SJohn.Forte@Sun.COM 20817836SJohn.Forte@Sun.COM /* 20827836SJohn.Forte@Sun.COM * ql_24xx_dump_dcmd 20837836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 20847836SJohn.Forte@Sun.COM * 20857836SJohn.Forte@Sun.COM * Input: 20867836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 20877836SJohn.Forte@Sun.COM * flags = mdb flags. 20887836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 20897836SJohn.Forte@Sun.COM * argv = Arg array. 20907836SJohn.Forte@Sun.COM * 20917836SJohn.Forte@Sun.COM * Returns: 20927836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 20937836SJohn.Forte@Sun.COM * 20947836SJohn.Forte@Sun.COM * Context: 20957836SJohn.Forte@Sun.COM * User context. 20967836SJohn.Forte@Sun.COM * 20977836SJohn.Forte@Sun.COM */ 20987836SJohn.Forte@Sun.COM /*ARGSUSED*/ 20997836SJohn.Forte@Sun.COM static int 21007836SJohn.Forte@Sun.COM ql_24xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 21017836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 21027836SJohn.Forte@Sun.COM { 21037836SJohn.Forte@Sun.COM ql_24xx_fw_dump_t *fw; 21047836SJohn.Forte@Sun.COM uint32_t cnt = 0; 21057836SJohn.Forte@Sun.COM 21069156SDaniel.Beauregard@Sun.COM fw = (ql_24xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 21079156SDaniel.Beauregard@Sun.COM 21089156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 21099156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 21107836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 21119156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 21127836SJohn.Forte@Sun.COM return (DCMD_OK); 21137836SJohn.Forte@Sun.COM } 21147836SJohn.Forte@Sun.COM 21157836SJohn.Forte@Sun.COM mdb_printf("ISP FW Version %d.%02d.%02d Attributes %X\n", 21167836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 21177836SJohn.Forte@Sun.COM ha->fw_subminor_version, ha->fw_attributes); 21187836SJohn.Forte@Sun.COM 21197836SJohn.Forte@Sun.COM mdb_printf("\nHCCR Register\n%08x\n", fw->hccr); 21207836SJohn.Forte@Sun.COM 21217836SJohn.Forte@Sun.COM mdb_printf("\nHost Interface Registers"); 21227836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) { 21237836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21247836SJohn.Forte@Sun.COM mdb_printf("\n"); 21257836SJohn.Forte@Sun.COM } 21267836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->host_reg[cnt]); 21277836SJohn.Forte@Sun.COM } 21287836SJohn.Forte@Sun.COM 21297836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers"); 21307836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 21317836SJohn.Forte@Sun.COM if (cnt % 16 == 0) { 21327836SJohn.Forte@Sun.COM mdb_printf("\n"); 21337836SJohn.Forte@Sun.COM } 21347836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 21357836SJohn.Forte@Sun.COM } 21367836SJohn.Forte@Sun.COM 21377836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ GP Registers"); 21387836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) { 21397836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21407836SJohn.Forte@Sun.COM mdb_printf("\n"); 21417836SJohn.Forte@Sun.COM } 21427836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_gp_reg[cnt]); 21437836SJohn.Forte@Sun.COM } 21447836SJohn.Forte@Sun.COM 21457836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-0 Registers"); 21467836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) { 21477836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21487836SJohn.Forte@Sun.COM mdb_printf("\n"); 21497836SJohn.Forte@Sun.COM } 21507836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_0_reg[cnt]); 21517836SJohn.Forte@Sun.COM } 21527836SJohn.Forte@Sun.COM 21537836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-1 Registers"); 21547836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) { 21557836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21567836SJohn.Forte@Sun.COM mdb_printf("\n"); 21577836SJohn.Forte@Sun.COM } 21587836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_1_reg[cnt]); 21597836SJohn.Forte@Sun.COM } 21607836SJohn.Forte@Sun.COM 21617836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ GP Registers"); 21627836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) { 21637836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21647836SJohn.Forte@Sun.COM mdb_printf("\n"); 21657836SJohn.Forte@Sun.COM } 21667836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_gp_reg[cnt]); 21677836SJohn.Forte@Sun.COM } 21687836SJohn.Forte@Sun.COM 21697836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-0 Registers"); 21707836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) { 21717836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21727836SJohn.Forte@Sun.COM mdb_printf("\n"); 21737836SJohn.Forte@Sun.COM } 21747836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_0_reg[cnt]); 21757836SJohn.Forte@Sun.COM } 21767836SJohn.Forte@Sun.COM 21777836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-1 Registers"); 21787836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) { 21797836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21807836SJohn.Forte@Sun.COM mdb_printf("\n"); 21817836SJohn.Forte@Sun.COM } 21827836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_1_reg[cnt]); 21837836SJohn.Forte@Sun.COM } 21847836SJohn.Forte@Sun.COM 21857836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-2 Registers"); 21867836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) { 21877836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21887836SJohn.Forte@Sun.COM mdb_printf("\n"); 21897836SJohn.Forte@Sun.COM } 21907836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_2_reg[cnt]); 21917836SJohn.Forte@Sun.COM } 21927836SJohn.Forte@Sun.COM 21937836SJohn.Forte@Sun.COM mdb_printf("\n\nCommand DMA Registers"); 21947836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) { 21957836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 21967836SJohn.Forte@Sun.COM mdb_printf("\n"); 21977836SJohn.Forte@Sun.COM } 21987836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->cmd_dma_reg[cnt]); 21997836SJohn.Forte@Sun.COM } 22007836SJohn.Forte@Sun.COM 22017836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest0 Queue DMA Channel Registers"); 22027836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) { 22037836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22047836SJohn.Forte@Sun.COM mdb_printf("\n"); 22057836SJohn.Forte@Sun.COM } 22067836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req0_dma_reg[cnt]); 22077836SJohn.Forte@Sun.COM } 22087836SJohn.Forte@Sun.COM 22097836SJohn.Forte@Sun.COM mdb_printf("\n\nResponse0 Queue DMA Channel Registers"); 22107836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) { 22117836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22127836SJohn.Forte@Sun.COM mdb_printf("\n"); 22137836SJohn.Forte@Sun.COM } 22147836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->resp0_dma_reg[cnt]); 22157836SJohn.Forte@Sun.COM } 22167836SJohn.Forte@Sun.COM 22177836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest1 Queue DMA Channel Registers"); 22187836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) { 22197836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22207836SJohn.Forte@Sun.COM mdb_printf("\n"); 22217836SJohn.Forte@Sun.COM } 22227836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req1_dma_reg[cnt]); 22237836SJohn.Forte@Sun.COM } 22247836SJohn.Forte@Sun.COM 22257836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT0 Data DMA Registers"); 22267836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) { 22277836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22287836SJohn.Forte@Sun.COM mdb_printf("\n"); 22297836SJohn.Forte@Sun.COM } 22307836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]); 22317836SJohn.Forte@Sun.COM } 22327836SJohn.Forte@Sun.COM 22337836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT1 Data DMA Registers"); 22347836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) { 22357836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22367836SJohn.Forte@Sun.COM mdb_printf("\n"); 22377836SJohn.Forte@Sun.COM } 22387836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]); 22397836SJohn.Forte@Sun.COM } 22407836SJohn.Forte@Sun.COM 22417836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT2 Data DMA Registers"); 22427836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) { 22437836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22447836SJohn.Forte@Sun.COM mdb_printf("\n"); 22457836SJohn.Forte@Sun.COM } 22467836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]); 22477836SJohn.Forte@Sun.COM } 22487836SJohn.Forte@Sun.COM 22497836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT3 Data DMA Registers"); 22507836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) { 22517836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22527836SJohn.Forte@Sun.COM mdb_printf("\n"); 22537836SJohn.Forte@Sun.COM } 22547836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]); 22557836SJohn.Forte@Sun.COM } 22567836SJohn.Forte@Sun.COM 22577836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT4 Data DMA Registers"); 22587836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) { 22597836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22607836SJohn.Forte@Sun.COM mdb_printf("\n"); 22617836SJohn.Forte@Sun.COM } 22627836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]); 22637836SJohn.Forte@Sun.COM } 22647836SJohn.Forte@Sun.COM 22657836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT Data DMA Common Registers"); 22667836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) { 22677836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22687836SJohn.Forte@Sun.COM mdb_printf("\n"); 22697836SJohn.Forte@Sun.COM } 22707836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]); 22717836SJohn.Forte@Sun.COM } 22727836SJohn.Forte@Sun.COM 22737836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 0 Data DMA Registers"); 22747836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) { 22757836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22767836SJohn.Forte@Sun.COM mdb_printf("\n"); 22777836SJohn.Forte@Sun.COM } 22787836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]); 22797836SJohn.Forte@Sun.COM } 22807836SJohn.Forte@Sun.COM 22817836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 1 Data DMA Registers"); 22827836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) { 22837836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22847836SJohn.Forte@Sun.COM mdb_printf("\n"); 22857836SJohn.Forte@Sun.COM } 22867836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]); 22877836SJohn.Forte@Sun.COM } 22887836SJohn.Forte@Sun.COM 22897836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP Registers"); 22907836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) { 22917836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 22927836SJohn.Forte@Sun.COM mdb_printf("\n"); 22937836SJohn.Forte@Sun.COM } 22947836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->risc_gp_reg[cnt]); 22957836SJohn.Forte@Sun.COM } 22967836SJohn.Forte@Sun.COM 22977836SJohn.Forte@Sun.COM mdb_printf("\n\nShadow Registers"); 22987836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) { 22997836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23007836SJohn.Forte@Sun.COM mdb_printf("\n"); 23017836SJohn.Forte@Sun.COM } 23027836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->shadow_reg[cnt]); 23037836SJohn.Forte@Sun.COM } 23047836SJohn.Forte@Sun.COM 23057836SJohn.Forte@Sun.COM mdb_printf("\n\nLMC Registers"); 23067836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) { 23077836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23087836SJohn.Forte@Sun.COM mdb_printf("\n"); 23097836SJohn.Forte@Sun.COM } 23107836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->lmc_reg[cnt]); 23117836SJohn.Forte@Sun.COM } 23127836SJohn.Forte@Sun.COM 23137836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM Hardware Registers"); 23147836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) { 23157836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23167836SJohn.Forte@Sun.COM mdb_printf("\n"); 23177836SJohn.Forte@Sun.COM } 23187836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]); 23197836SJohn.Forte@Sun.COM } 23207836SJohn.Forte@Sun.COM 23217836SJohn.Forte@Sun.COM mdb_printf("\n\nFB Hardware Registers"); 23227836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) { 23237836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23247836SJohn.Forte@Sun.COM mdb_printf("\n"); 23257836SJohn.Forte@Sun.COM } 23267836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fb_hdw_reg[cnt]); 23277836SJohn.Forte@Sun.COM } 23287836SJohn.Forte@Sun.COM 23297836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM"); 23307836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) { 23317836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23327836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x20000); 23337836SJohn.Forte@Sun.COM } 23347836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->code_ram[cnt]); 23357836SJohn.Forte@Sun.COM } 23367836SJohn.Forte@Sun.COM 23377836SJohn.Forte@Sun.COM mdb_printf("\n\nExternal Memory"); 23387836SJohn.Forte@Sun.COM for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) { 23397836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 23407836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x100000); 23417836SJohn.Forte@Sun.COM } 23427836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->ext_mem[cnt]); 23437836SJohn.Forte@Sun.COM } 23447836SJohn.Forte@Sun.COM 23457836SJohn.Forte@Sun.COM mdb_printf("\n[<==END] ISP Debug Dump"); 23467836SJohn.Forte@Sun.COM 23479156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 23489156SDaniel.Beauregard@Sun.COM 23499156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 23509156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 23519156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 23529156SDaniel.Beauregard@Sun.COM } 23539156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 23549156SDaniel.Beauregard@Sun.COM } 23559156SDaniel.Beauregard@Sun.COM 23569156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 23579156SDaniel.Beauregard@Sun.COM 23589156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 23599156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 23609156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 23619156SDaniel.Beauregard@Sun.COM } 23629156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 23639156SDaniel.Beauregard@Sun.COM } 23649156SDaniel.Beauregard@Sun.COM 23659156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) && 23669156SDaniel.Beauregard@Sun.COM (ha->fwexttracebuf.bp != NULL)) { 23679156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 23689156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwexttracebuf.bp; 23699156SDaniel.Beauregard@Sun.COM 23709156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nExtended Trace Buffer Memory"); 23719156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 23729156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) { 23739156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 23749156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 23759156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 23769156SDaniel.Beauregard@Sun.COM } 23779156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->ext_trace_buf[cnt]); 23789156SDaniel.Beauregard@Sun.COM } 23799156SDaniel.Beauregard@Sun.COM } 23809156SDaniel.Beauregard@Sun.COM 23819156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) && 23829156SDaniel.Beauregard@Sun.COM (ha->fwfcetracebuf.bp != NULL)) { 23839156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 23849156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwfcetracebuf.bp; 23859156SDaniel.Beauregard@Sun.COM 23869156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nFC Event Trace Buffer Memory"); 23879156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 23889156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) { 23899156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 23909156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 23919156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 23929156SDaniel.Beauregard@Sun.COM } 23939156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->fce_trace_buf[cnt]); 23949156SDaniel.Beauregard@Sun.COM } 23959156SDaniel.Beauregard@Sun.COM } 23969156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 23977836SJohn.Forte@Sun.COM 23987836SJohn.Forte@Sun.COM return (DCMD_OK); 23997836SJohn.Forte@Sun.COM } 24007836SJohn.Forte@Sun.COM 24017836SJohn.Forte@Sun.COM /* 24027836SJohn.Forte@Sun.COM * ql_25xx_dump_dcmd 24037836SJohn.Forte@Sun.COM * prints out a firmware dump buffer 24047836SJohn.Forte@Sun.COM * 24057836SJohn.Forte@Sun.COM * Input: 24067836SJohn.Forte@Sun.COM * addr = User supplied address. (NB: nust be an ha) 24077836SJohn.Forte@Sun.COM * flags = mdb flags. 24087836SJohn.Forte@Sun.COM * argc = Number of user supplied args. 24097836SJohn.Forte@Sun.COM * argv = Arg array. 24107836SJohn.Forte@Sun.COM * 24117836SJohn.Forte@Sun.COM * Returns: 24127836SJohn.Forte@Sun.COM * DCMD_OK or DCMD_ERR 24137836SJohn.Forte@Sun.COM * 24147836SJohn.Forte@Sun.COM * Context: 24157836SJohn.Forte@Sun.COM * User context. 24167836SJohn.Forte@Sun.COM * 24177836SJohn.Forte@Sun.COM */ 24187836SJohn.Forte@Sun.COM /*ARGSUSED*/ 24197836SJohn.Forte@Sun.COM static int 24207836SJohn.Forte@Sun.COM ql_25xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc, 24217836SJohn.Forte@Sun.COM const mdb_arg_t *argv) 24227836SJohn.Forte@Sun.COM { 24237836SJohn.Forte@Sun.COM ql_25xx_fw_dump_t *fw; 24247836SJohn.Forte@Sun.COM uint32_t cnt = 0; 24257836SJohn.Forte@Sun.COM 24269156SDaniel.Beauregard@Sun.COM fw = (ql_25xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP); 24279156SDaniel.Beauregard@Sun.COM 24289156SDaniel.Beauregard@Sun.COM if (mdb_vread(fw, ha->ql_dump_size, 24299156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->ql_dump_ptr) == -1) { 24307836SJohn.Forte@Sun.COM mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)"); 24319156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 24327836SJohn.Forte@Sun.COM return (DCMD_OK); 24337836SJohn.Forte@Sun.COM } 24347836SJohn.Forte@Sun.COM 24359156SDaniel.Beauregard@Sun.COM mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n", 24367836SJohn.Forte@Sun.COM ha->fw_major_version, ha->fw_minor_version, 24377836SJohn.Forte@Sun.COM ha->fw_subminor_version, ha->fw_attributes); 24387836SJohn.Forte@Sun.COM 24397836SJohn.Forte@Sun.COM mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status); 24407836SJohn.Forte@Sun.COM 24419156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nHostRisc Registers"); 24427836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) { 24437836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24447836SJohn.Forte@Sun.COM mdb_printf("\n"); 24457836SJohn.Forte@Sun.COM } 24467836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->hostrisc_reg[cnt]); 24477836SJohn.Forte@Sun.COM } 24487836SJohn.Forte@Sun.COM 24499156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nPCIe Registers"); 24507836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) { 24517836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24527836SJohn.Forte@Sun.COM mdb_printf("\n"); 24537836SJohn.Forte@Sun.COM } 24547836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->pcie_reg[cnt]); 24557836SJohn.Forte@Sun.COM } 24567836SJohn.Forte@Sun.COM 24579156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nHost Interface Registers"); 24587836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) { 24597836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24607836SJohn.Forte@Sun.COM mdb_printf("\n"); 24617836SJohn.Forte@Sun.COM } 24627836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->host_reg[cnt]); 24637836SJohn.Forte@Sun.COM } 24647836SJohn.Forte@Sun.COM 24659156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nShadow Registers"); 24669156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) { 24679156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 24689156SDaniel.Beauregard@Sun.COM mdb_printf("\n"); 24699156SDaniel.Beauregard@Sun.COM } 24709156SDaniel.Beauregard@Sun.COM 24719156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->shadow_reg[cnt]); 24729156SDaniel.Beauregard@Sun.COM } 24739156SDaniel.Beauregard@Sun.COM 24747836SJohn.Forte@Sun.COM mdb_printf("\n\nMailbox Registers"); 24757836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 24767836SJohn.Forte@Sun.COM if (cnt % 16 == 0) { 24777836SJohn.Forte@Sun.COM mdb_printf("\n"); 24787836SJohn.Forte@Sun.COM } 24797836SJohn.Forte@Sun.COM mdb_printf("%04x ", fw->mailbox_reg[cnt]); 24807836SJohn.Forte@Sun.COM } 24817836SJohn.Forte@Sun.COM 24827836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ GP Registers"); 24837836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) { 24847836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24857836SJohn.Forte@Sun.COM mdb_printf("\n"); 24867836SJohn.Forte@Sun.COM } 24877836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_gp_reg[cnt]); 24887836SJohn.Forte@Sun.COM } 24897836SJohn.Forte@Sun.COM 24907836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-0 Registers"); 24917836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) { 24927836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 24937836SJohn.Forte@Sun.COM mdb_printf("\n"); 24947836SJohn.Forte@Sun.COM } 24957836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_0_reg[cnt]); 24967836SJohn.Forte@Sun.COM } 24977836SJohn.Forte@Sun.COM 24987836SJohn.Forte@Sun.COM mdb_printf("\n\nXSEQ-1 Registers"); 24997836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) { 25007836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25017836SJohn.Forte@Sun.COM mdb_printf("\n"); 25027836SJohn.Forte@Sun.COM } 25037836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xseq_1_reg[cnt]); 25047836SJohn.Forte@Sun.COM } 25057836SJohn.Forte@Sun.COM 25067836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ GP Registers"); 25077836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) { 25087836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25097836SJohn.Forte@Sun.COM mdb_printf("\n"); 25107836SJohn.Forte@Sun.COM } 25117836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_gp_reg[cnt]); 25127836SJohn.Forte@Sun.COM } 25137836SJohn.Forte@Sun.COM 25147836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-0 Registers"); 25157836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) { 25167836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25177836SJohn.Forte@Sun.COM mdb_printf("\n"); 25187836SJohn.Forte@Sun.COM } 25197836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_0_reg[cnt]); 25207836SJohn.Forte@Sun.COM } 25217836SJohn.Forte@Sun.COM 25227836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-1 Registers"); 25237836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) { 25247836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25257836SJohn.Forte@Sun.COM mdb_printf("\n"); 25267836SJohn.Forte@Sun.COM } 25277836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_1_reg[cnt]); 25287836SJohn.Forte@Sun.COM } 25297836SJohn.Forte@Sun.COM 25307836SJohn.Forte@Sun.COM mdb_printf("\n\nRSEQ-2 Registers"); 25317836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) { 25327836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25337836SJohn.Forte@Sun.COM mdb_printf("\n"); 25347836SJohn.Forte@Sun.COM } 25357836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rseq_2_reg[cnt]); 25367836SJohn.Forte@Sun.COM } 25377836SJohn.Forte@Sun.COM 25387836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ GP Registers"); 25397836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) { 25407836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25417836SJohn.Forte@Sun.COM mdb_printf("\n"); 25427836SJohn.Forte@Sun.COM } 25437836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_gp_reg[cnt]); 25447836SJohn.Forte@Sun.COM } 25457836SJohn.Forte@Sun.COM 25467836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-0 GP Registers"); 25477836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) { 25487836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25497836SJohn.Forte@Sun.COM mdb_printf("\n"); 25507836SJohn.Forte@Sun.COM } 25517836SJohn.Forte@Sun.COM 25527836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_0_reg[cnt]); 25537836SJohn.Forte@Sun.COM } 25547836SJohn.Forte@Sun.COM 25557836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-1 GP Registers"); 25567836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) { 25577836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25587836SJohn.Forte@Sun.COM mdb_printf("\n"); 25597836SJohn.Forte@Sun.COM } 25607836SJohn.Forte@Sun.COM 25617836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_1_reg[cnt]); 25627836SJohn.Forte@Sun.COM } 25637836SJohn.Forte@Sun.COM 25647836SJohn.Forte@Sun.COM mdb_printf("\n\nASEQ-2 GP Registers"); 25657836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) { 25667836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25677836SJohn.Forte@Sun.COM mdb_printf("\n"); 25687836SJohn.Forte@Sun.COM } 25697836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->aseq_2_reg[cnt]); 25707836SJohn.Forte@Sun.COM } 25717836SJohn.Forte@Sun.COM 25727836SJohn.Forte@Sun.COM mdb_printf("\n\nCommand DMA Registers"); 25737836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) { 25747836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25757836SJohn.Forte@Sun.COM mdb_printf("\n"); 25767836SJohn.Forte@Sun.COM } 25777836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->cmd_dma_reg[cnt]); 25787836SJohn.Forte@Sun.COM } 25797836SJohn.Forte@Sun.COM 25807836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest0 Queue DMA Channel Registers"); 25817836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) { 25827836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25837836SJohn.Forte@Sun.COM mdb_printf("\n"); 25847836SJohn.Forte@Sun.COM } 25857836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req0_dma_reg[cnt]); 25867836SJohn.Forte@Sun.COM } 25877836SJohn.Forte@Sun.COM 25887836SJohn.Forte@Sun.COM mdb_printf("\n\nResponse0 Queue DMA Channel Registers"); 25897836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) { 25907836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25917836SJohn.Forte@Sun.COM mdb_printf("\n"); 25927836SJohn.Forte@Sun.COM } 25937836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->resp0_dma_reg[cnt]); 25947836SJohn.Forte@Sun.COM } 25957836SJohn.Forte@Sun.COM 25967836SJohn.Forte@Sun.COM mdb_printf("\n\nRequest1 Queue DMA Channel Registers"); 25977836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) { 25987836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 25997836SJohn.Forte@Sun.COM mdb_printf("\n"); 26007836SJohn.Forte@Sun.COM } 26017836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->req1_dma_reg[cnt]); 26027836SJohn.Forte@Sun.COM } 26037836SJohn.Forte@Sun.COM 26047836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT0 Data DMA Registers"); 26057836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) { 26067836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26077836SJohn.Forte@Sun.COM mdb_printf("\n"); 26087836SJohn.Forte@Sun.COM } 26097836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]); 26107836SJohn.Forte@Sun.COM } 26117836SJohn.Forte@Sun.COM 26127836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT1 Data DMA Registers"); 26137836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) { 26147836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26157836SJohn.Forte@Sun.COM mdb_printf("\n"); 26167836SJohn.Forte@Sun.COM } 26177836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]); 26187836SJohn.Forte@Sun.COM } 26197836SJohn.Forte@Sun.COM 26207836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT2 Data DMA Registers"); 26217836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) { 26227836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26237836SJohn.Forte@Sun.COM mdb_printf("\n"); 26247836SJohn.Forte@Sun.COM } 26257836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]); 26267836SJohn.Forte@Sun.COM } 26277836SJohn.Forte@Sun.COM 26287836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT3 Data DMA Registers"); 26297836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) { 26307836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26317836SJohn.Forte@Sun.COM mdb_printf("\n"); 26327836SJohn.Forte@Sun.COM } 26337836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]); 26347836SJohn.Forte@Sun.COM } 26357836SJohn.Forte@Sun.COM 26367836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT4 Data DMA Registers"); 26377836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) { 26387836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26397836SJohn.Forte@Sun.COM mdb_printf("\n"); 26407836SJohn.Forte@Sun.COM } 26417836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]); 26427836SJohn.Forte@Sun.COM } 26437836SJohn.Forte@Sun.COM 26447836SJohn.Forte@Sun.COM mdb_printf("\n\nXMT Data DMA Common Registers"); 26457836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) { 26467836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26477836SJohn.Forte@Sun.COM mdb_printf("\n"); 26487836SJohn.Forte@Sun.COM } 26497836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]); 26507836SJohn.Forte@Sun.COM } 26517836SJohn.Forte@Sun.COM 26527836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 0 Data DMA Registers"); 26537836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) { 26547836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26557836SJohn.Forte@Sun.COM mdb_printf("\n"); 26567836SJohn.Forte@Sun.COM } 26577836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]); 26587836SJohn.Forte@Sun.COM } 26597836SJohn.Forte@Sun.COM 26607836SJohn.Forte@Sun.COM mdb_printf("\n\nRCV Thread 1 Data DMA Registers"); 26617836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) { 26627836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26637836SJohn.Forte@Sun.COM mdb_printf("\n"); 26647836SJohn.Forte@Sun.COM } 26657836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]); 26667836SJohn.Forte@Sun.COM } 26677836SJohn.Forte@Sun.COM 26687836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC GP Registers"); 26697836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) { 26707836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26717836SJohn.Forte@Sun.COM mdb_printf("\n"); 26727836SJohn.Forte@Sun.COM } 26737836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->risc_gp_reg[cnt]); 26747836SJohn.Forte@Sun.COM } 26757836SJohn.Forte@Sun.COM 26767836SJohn.Forte@Sun.COM mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io); 26777836SJohn.Forte@Sun.COM 26787836SJohn.Forte@Sun.COM mdb_printf("\n\nLMC Registers"); 26797836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) { 26807836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26817836SJohn.Forte@Sun.COM mdb_printf("\n"); 26827836SJohn.Forte@Sun.COM } 26837836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->lmc_reg[cnt]); 26847836SJohn.Forte@Sun.COM } 26857836SJohn.Forte@Sun.COM 26867836SJohn.Forte@Sun.COM mdb_printf("\n\nFPM Hardware Registers"); 26877836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) { 26887836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26897836SJohn.Forte@Sun.COM mdb_printf("\n"); 26907836SJohn.Forte@Sun.COM } 26917836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]); 26927836SJohn.Forte@Sun.COM } 26937836SJohn.Forte@Sun.COM 26947836SJohn.Forte@Sun.COM mdb_printf("\n\nFB Hardware Registers"); 26957836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) { 26967836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 26977836SJohn.Forte@Sun.COM mdb_printf("\n"); 26987836SJohn.Forte@Sun.COM } 26997836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->fb_hdw_reg[cnt]); 27007836SJohn.Forte@Sun.COM } 27017836SJohn.Forte@Sun.COM 27027836SJohn.Forte@Sun.COM mdb_printf("\n\nCode RAM"); 27037836SJohn.Forte@Sun.COM for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) { 27047836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 27057836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x20000); 27067836SJohn.Forte@Sun.COM } 27077836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->code_ram[cnt]); 27087836SJohn.Forte@Sun.COM } 27097836SJohn.Forte@Sun.COM 27107836SJohn.Forte@Sun.COM mdb_printf("\n\nExternal Memory"); 27117836SJohn.Forte@Sun.COM for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) { 27127836SJohn.Forte@Sun.COM if (cnt % 8 == 0) { 27137836SJohn.Forte@Sun.COM mdb_printf("\n%08x: ", cnt + 0x100000); 27147836SJohn.Forte@Sun.COM } 27157836SJohn.Forte@Sun.COM mdb_printf("%08x ", fw->ext_mem[cnt]); 27167836SJohn.Forte@Sun.COM } 27177836SJohn.Forte@Sun.COM 27187836SJohn.Forte@Sun.COM mdb_printf("\n[<==END] ISP Debug Dump"); 27197836SJohn.Forte@Sun.COM 27209156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nRequest Queue"); 27219156SDaniel.Beauregard@Sun.COM 27229156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) { 27239156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 27249156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 27259156SDaniel.Beauregard@Sun.COM } 27269156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->req_q[cnt]); 27279156SDaniel.Beauregard@Sun.COM } 27289156SDaniel.Beauregard@Sun.COM 27299156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nResponse Queue"); 27309156SDaniel.Beauregard@Sun.COM 27319156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) { 27329156SDaniel.Beauregard@Sun.COM if (cnt % 8 == 0) { 27339156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", cnt); 27349156SDaniel.Beauregard@Sun.COM } 27359156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->rsp_q[cnt]); 27369156SDaniel.Beauregard@Sun.COM } 27379156SDaniel.Beauregard@Sun.COM 27389156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) && 27399156SDaniel.Beauregard@Sun.COM (ha->fwexttracebuf.bp != NULL)) { 27409156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 27419156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwexttracebuf.bp; 27429156SDaniel.Beauregard@Sun.COM 27439156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nExtended Trace Buffer Memory"); 27449156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 27459156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) { 27469156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 27479156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 27489156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 27499156SDaniel.Beauregard@Sun.COM } 27509156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->ext_trace_buf[cnt]); 27519156SDaniel.Beauregard@Sun.COM } 27529156SDaniel.Beauregard@Sun.COM } 27539156SDaniel.Beauregard@Sun.COM 27549156SDaniel.Beauregard@Sun.COM if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) && 27559156SDaniel.Beauregard@Sun.COM (ha->fwfcetracebuf.bp != NULL)) { 27569156SDaniel.Beauregard@Sun.COM uint32_t cnt_b = 0; 27579156SDaniel.Beauregard@Sun.COM uint32_t *w32 = ha->fwfcetracebuf.bp; 27589156SDaniel.Beauregard@Sun.COM 27599156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nFC Event Trace Buffer Memory"); 27609156SDaniel.Beauregard@Sun.COM /* show data address as a byte address, data as long words */ 27619156SDaniel.Beauregard@Sun.COM for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) { 27629156SDaniel.Beauregard@Sun.COM cnt_b = cnt * 4; 27639156SDaniel.Beauregard@Sun.COM if (cnt_b % 32 == 0) { 27649156SDaniel.Beauregard@Sun.COM mdb_printf("\n%08x: ", w32 + cnt_b); 27659156SDaniel.Beauregard@Sun.COM } 27669156SDaniel.Beauregard@Sun.COM mdb_printf("%08x ", fw->fce_trace_buf[cnt]); 27679156SDaniel.Beauregard@Sun.COM } 27689156SDaniel.Beauregard@Sun.COM } 27699156SDaniel.Beauregard@Sun.COM 27709156SDaniel.Beauregard@Sun.COM mdb_free(fw, ha->ql_dump_size); 27719156SDaniel.Beauregard@Sun.COM 27729156SDaniel.Beauregard@Sun.COM mdb_printf("\n\nreturn exit\n"); 27737836SJohn.Forte@Sun.COM 27747836SJohn.Forte@Sun.COM return (DCMD_OK); 27757836SJohn.Forte@Sun.COM } 27767836SJohn.Forte@Sun.COM 27777836SJohn.Forte@Sun.COM /* 27789156SDaniel.Beauregard@Sun.COM * ql_gettrace_dcmd 27799156SDaniel.Beauregard@Sun.COM * prints out the Extended Logging trace buffer 27809156SDaniel.Beauregard@Sun.COM * 27819156SDaniel.Beauregard@Sun.COM * Input: 27829156SDaniel.Beauregard@Sun.COM * addr = User supplied address. (NB: must be an ha) 27839156SDaniel.Beauregard@Sun.COM * flags = mdb flags. 27849156SDaniel.Beauregard@Sun.COM * argc = Number of user supplied args. 27859156SDaniel.Beauregard@Sun.COM * argv = Arg array. 27869156SDaniel.Beauregard@Sun.COM * 27879156SDaniel.Beauregard@Sun.COM * Returns: 27889156SDaniel.Beauregard@Sun.COM * DCMD_OK or DCMD_ERR 27899156SDaniel.Beauregard@Sun.COM * 27909156SDaniel.Beauregard@Sun.COM * Context: 27919156SDaniel.Beauregard@Sun.COM * User context. 27929156SDaniel.Beauregard@Sun.COM * 27939156SDaniel.Beauregard@Sun.COM */ 27949156SDaniel.Beauregard@Sun.COM static int 27959156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 27969156SDaniel.Beauregard@Sun.COM { 27979156SDaniel.Beauregard@Sun.COM ql_adapter_state_t *ha; 27989156SDaniel.Beauregard@Sun.COM int verbose = 0; 27999156SDaniel.Beauregard@Sun.COM int wrapped = 0; 28009156SDaniel.Beauregard@Sun.COM char *trace_start; 28019156SDaniel.Beauregard@Sun.COM char *trace_end; 28029156SDaniel.Beauregard@Sun.COM char *dump_start = 0; 28039156SDaniel.Beauregard@Sun.COM char *trace_next = 0; 28049156SDaniel.Beauregard@Sun.COM char *dump_current = 0; 28059156SDaniel.Beauregard@Sun.COM el_trace_desc_t *trace_desc; 28069156SDaniel.Beauregard@Sun.COM 28079156SDaniel.Beauregard@Sun.COM if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) { 28089156SDaniel.Beauregard@Sun.COM mdb_warn("ql_adapter_state structure addr is required"); 28099156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 28109156SDaniel.Beauregard@Sun.COM } 28119156SDaniel.Beauregard@Sun.COM 28129156SDaniel.Beauregard@Sun.COM if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) != 28139156SDaniel.Beauregard@Sun.COM argc) { 28149156SDaniel.Beauregard@Sun.COM return (DCMD_USAGE); 28159156SDaniel.Beauregard@Sun.COM } 28169156SDaniel.Beauregard@Sun.COM 28179156SDaniel.Beauregard@Sun.COM /* 28189156SDaniel.Beauregard@Sun.COM * Get the adapter state struct which was passed 28199156SDaniel.Beauregard@Sun.COM */ 28209156SDaniel.Beauregard@Sun.COM if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t), 28219156SDaniel.Beauregard@Sun.COM UM_SLEEP)) == NULL) { 28229156SDaniel.Beauregard@Sun.COM mdb_warn("failed to allocate memory for ql_adapter_state\n"); 28239156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28249156SDaniel.Beauregard@Sun.COM } 28259156SDaniel.Beauregard@Sun.COM 28269156SDaniel.Beauregard@Sun.COM if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) { 28279156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", addr); 28289156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 28299156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28309156SDaniel.Beauregard@Sun.COM } 28319156SDaniel.Beauregard@Sun.COM 28329156SDaniel.Beauregard@Sun.COM /* 28339156SDaniel.Beauregard@Sun.COM * If its not a valid trace descriptor then bail out 28349156SDaniel.Beauregard@Sun.COM */ 28359156SDaniel.Beauregard@Sun.COM if (ha->el_trace_desc == NULL) { 28369156SDaniel.Beauregard@Sun.COM mdb_warn("trace descriptor does not exist for instance %d\n", 28379156SDaniel.Beauregard@Sun.COM ha->instance); 28389156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 28399156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28409156SDaniel.Beauregard@Sun.COM } else { 28419156SDaniel.Beauregard@Sun.COM trace_desc = (el_trace_desc_t *) 28429156SDaniel.Beauregard@Sun.COM mdb_alloc(sizeof (el_trace_desc_t), UM_SLEEP); 28439156SDaniel.Beauregard@Sun.COM if (mdb_vread(trace_desc, sizeof (el_trace_desc_t), 28449156SDaniel.Beauregard@Sun.COM (uintptr_t)ha->el_trace_desc) == -1) { 28459156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read ql_adapter_state at %p", 28469156SDaniel.Beauregard@Sun.COM addr); 28479156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 28489156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 28499156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28509156SDaniel.Beauregard@Sun.COM } 28519156SDaniel.Beauregard@Sun.COM if (trace_desc->trace_buffer == NULL) { 28529156SDaniel.Beauregard@Sun.COM mdb_warn("trace buffer does not exist for " 28539156SDaniel.Beauregard@Sun.COM "instance %d\n", ha->instance); 28549156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 28559156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 28569156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28579156SDaniel.Beauregard@Sun.COM } 28589156SDaniel.Beauregard@Sun.COM } 28599156SDaniel.Beauregard@Sun.COM 28609156SDaniel.Beauregard@Sun.COM /* Get the trace buffer */ 28619156SDaniel.Beauregard@Sun.COM 28629156SDaniel.Beauregard@Sun.COM trace_start = (char *) 28639156SDaniel.Beauregard@Sun.COM mdb_zalloc(trace_desc->trace_buffer_size, UM_SLEEP); 28649156SDaniel.Beauregard@Sun.COM 28659156SDaniel.Beauregard@Sun.COM if (mdb_vread(trace_start, trace_desc->trace_buffer_size, 28669156SDaniel.Beauregard@Sun.COM (uintptr_t)trace_desc->trace_buffer) == -1) { 28679156SDaniel.Beauregard@Sun.COM mdb_warn("failed to read trace buffer?)"); 28689156SDaniel.Beauregard@Sun.COM mdb_free(trace_start, trace_desc->trace_buffer_size); 28699156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 28709156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 28719156SDaniel.Beauregard@Sun.COM } 28729156SDaniel.Beauregard@Sun.COM 28739156SDaniel.Beauregard@Sun.COM /* set the end of the trace buffer. */ 28749156SDaniel.Beauregard@Sun.COM trace_end = trace_start + trace_desc->trace_buffer_size; 28759156SDaniel.Beauregard@Sun.COM 28769156SDaniel.Beauregard@Sun.COM /* Find the start point of trace. */ 28779156SDaniel.Beauregard@Sun.COM trace_next = trace_start + trace_desc->next; 28789156SDaniel.Beauregard@Sun.COM 28799156SDaniel.Beauregard@Sun.COM /* 28809156SDaniel.Beauregard@Sun.COM * If the buffer has not wrapped next will point at a null so 28819156SDaniel.Beauregard@Sun.COM * start is the begining of the buffer. If next points at a char 28829156SDaniel.Beauregard@Sun.COM * then we must traverse the buffer further until a null is detected. 28839156SDaniel.Beauregard@Sun.COM * The location after the null will be the beginning of the oldest 28849156SDaniel.Beauregard@Sun.COM * whole object in the buffer, which we use as the start. 28859156SDaniel.Beauregard@Sun.COM */ 28869156SDaniel.Beauregard@Sun.COM 28879156SDaniel.Beauregard@Sun.COM if ((trace_next + EL_BUFFER_RESERVE) >= trace_end) { 28889156SDaniel.Beauregard@Sun.COM dump_start = trace_start; 28899156SDaniel.Beauregard@Sun.COM } else if (*trace_next != NULL) { 28909156SDaniel.Beauregard@Sun.COM dump_start = trace_next + (strlen(trace_next) + 1); 28919156SDaniel.Beauregard@Sun.COM } else { 28929156SDaniel.Beauregard@Sun.COM dump_start = trace_start; 28939156SDaniel.Beauregard@Sun.COM } 28949156SDaniel.Beauregard@Sun.COM 28959156SDaniel.Beauregard@Sun.COM dump_current = dump_start; 28969156SDaniel.Beauregard@Sun.COM 28979156SDaniel.Beauregard@Sun.COM mdb_printf("\nExtended Logging trace buffer @%x, start @%x, " 28989156SDaniel.Beauregard@Sun.COM "size=%d\n\n", trace_start, dump_current, 28999156SDaniel.Beauregard@Sun.COM trace_desc->trace_buffer_size); 29009156SDaniel.Beauregard@Sun.COM 29019156SDaniel.Beauregard@Sun.COM /* Don't run off the end, no matter what. */ 29029156SDaniel.Beauregard@Sun.COM while (((uintptr_t)dump_current - (uintptr_t)trace_start) <= 29039156SDaniel.Beauregard@Sun.COM (uintptr_t)trace_desc->trace_buffer_size) { 29049156SDaniel.Beauregard@Sun.COM /* Show it... */ 29059156SDaniel.Beauregard@Sun.COM mdb_printf("%s", dump_current); 29069156SDaniel.Beauregard@Sun.COM /* Calculate the next and make it the current */ 29079156SDaniel.Beauregard@Sun.COM dump_current += (strlen(dump_current) + 1); 29089156SDaniel.Beauregard@Sun.COM /* check for wrap */ 29099156SDaniel.Beauregard@Sun.COM if ((dump_current + EL_BUFFER_RESERVE) >= trace_end) { 29109156SDaniel.Beauregard@Sun.COM mdb_printf("Wraping %x\n", dump_current); 29119156SDaniel.Beauregard@Sun.COM dump_current = trace_start; 29129156SDaniel.Beauregard@Sun.COM wrapped = 1; 29139156SDaniel.Beauregard@Sun.COM } else if (wrapped) { 29149156SDaniel.Beauregard@Sun.COM /* Don't go past next. */ 29159156SDaniel.Beauregard@Sun.COM if ((trace_start + trace_desc->next) <= dump_current) { 29169156SDaniel.Beauregard@Sun.COM mdb_printf("Done %x", dump_current); 29179156SDaniel.Beauregard@Sun.COM break; 29189156SDaniel.Beauregard@Sun.COM } 29199156SDaniel.Beauregard@Sun.COM } else if (*dump_current == NULL) { 29209156SDaniel.Beauregard@Sun.COM mdb_printf("Done %x(null)", dump_current); 29219156SDaniel.Beauregard@Sun.COM break; 29229156SDaniel.Beauregard@Sun.COM } 29239156SDaniel.Beauregard@Sun.COM } 29249156SDaniel.Beauregard@Sun.COM 29259156SDaniel.Beauregard@Sun.COM mdb_free(ha, sizeof (ql_adapter_state_t)); 29269156SDaniel.Beauregard@Sun.COM mdb_free(trace_start, trace_desc->trace_buffer_size); 29279156SDaniel.Beauregard@Sun.COM mdb_free(trace_desc, sizeof (el_trace_desc_t)); 29289156SDaniel.Beauregard@Sun.COM 29299156SDaniel.Beauregard@Sun.COM return (DCMD_OK); 29309156SDaniel.Beauregard@Sun.COM } 29319156SDaniel.Beauregard@Sun.COM /* 29327836SJohn.Forte@Sun.COM * ql_doprint 29337836SJohn.Forte@Sun.COM * ql generic function to call the print dcmd 29347836SJohn.Forte@Sun.COM * 29357836SJohn.Forte@Sun.COM * Input: 29367836SJohn.Forte@Sun.COM * addr - address to struct 29377836SJohn.Forte@Sun.COM * prtsting - address to string 29387836SJohn.Forte@Sun.COM * 29397836SJohn.Forte@Sun.COM * Returns: 29407836SJohn.Forte@Sun.COM * WALK_DONE 29417836SJohn.Forte@Sun.COM * 29427836SJohn.Forte@Sun.COM * Context: 29437836SJohn.Forte@Sun.COM * User context. 29447836SJohn.Forte@Sun.COM * 29457836SJohn.Forte@Sun.COM */ 29467836SJohn.Forte@Sun.COM static int32_t 29477836SJohn.Forte@Sun.COM ql_doprint(uintptr_t addr, int8_t *prtstring) 29487836SJohn.Forte@Sun.COM { 29497836SJohn.Forte@Sun.COM struct mdb_arg printarg; 29507836SJohn.Forte@Sun.COM 29517836SJohn.Forte@Sun.COM printarg.a_un.a_str = (int8_t *)(mdb_zalloc(strlen(prtstring), 29527836SJohn.Forte@Sun.COM UM_SLEEP)); 29537836SJohn.Forte@Sun.COM printarg.a_type = MDB_TYPE_STRING; 29547836SJohn.Forte@Sun.COM (void) strcpy((int8_t *)(printarg.a_un.a_str), prtstring); 29557836SJohn.Forte@Sun.COM 29567836SJohn.Forte@Sun.COM if ((mdb_call_dcmd("print", addr, DCMD_ADDRSPEC, 1, 29577836SJohn.Forte@Sun.COM &printarg)) == -1) { 29587836SJohn.Forte@Sun.COM mdb_warn("ql_doprint: failed print dcmd: %s" 29597836SJohn.Forte@Sun.COM "at addr: %llxh", prtstring, addr); 29607836SJohn.Forte@Sun.COM } 29617836SJohn.Forte@Sun.COM 29627836SJohn.Forte@Sun.COM mdb_free((void *)(printarg.a_un.a_str), strlen(prtstring)); 29637836SJohn.Forte@Sun.COM return (WALK_DONE); 29647836SJohn.Forte@Sun.COM } 29657836SJohn.Forte@Sun.COM 29667836SJohn.Forte@Sun.COM /* 29677836SJohn.Forte@Sun.COM * ql_dump_flags 29687836SJohn.Forte@Sun.COM * mdb utility to print the flag string 29697836SJohn.Forte@Sun.COM * 29707836SJohn.Forte@Sun.COM * Input: 29717836SJohn.Forte@Sun.COM * flags - flags to print 29727836SJohn.Forte@Sun.COM * strings - text to print when flag is set 29737836SJohn.Forte@Sun.COM * 29747836SJohn.Forte@Sun.COM * Returns: 29757836SJohn.Forte@Sun.COM * 29767836SJohn.Forte@Sun.COM * 29777836SJohn.Forte@Sun.COM * Context: 29787836SJohn.Forte@Sun.COM * User context. 29797836SJohn.Forte@Sun.COM * 29807836SJohn.Forte@Sun.COM */ 29817836SJohn.Forte@Sun.COM static void 29827836SJohn.Forte@Sun.COM ql_dump_flags(uint64_t flags, int8_t **strings) 29837836SJohn.Forte@Sun.COM { 29847836SJohn.Forte@Sun.COM int i, linel, first = 1; 29857836SJohn.Forte@Sun.COM uint64_t mask = 1; 29867836SJohn.Forte@Sun.COM 29877836SJohn.Forte@Sun.COM linel = 8; 29887836SJohn.Forte@Sun.COM mdb_printf("\t"); 29897836SJohn.Forte@Sun.COM for (i = 0; i < 64; i++) { 29907836SJohn.Forte@Sun.COM if (strings[i] == NULL) 29917836SJohn.Forte@Sun.COM break; 29927836SJohn.Forte@Sun.COM if (flags & mask) { 29937836SJohn.Forte@Sun.COM if (!first) { 29947836SJohn.Forte@Sun.COM mdb_printf(" | "); 29957836SJohn.Forte@Sun.COM } else { 29967836SJohn.Forte@Sun.COM first = 0; 29977836SJohn.Forte@Sun.COM } 29987836SJohn.Forte@Sun.COM linel += (int32_t)strlen(strings[i]) + 3; 29997836SJohn.Forte@Sun.COM if (linel > 80) { 30007836SJohn.Forte@Sun.COM mdb_printf("\n\t"); 30017836SJohn.Forte@Sun.COM linel = (int32_t)strlen(strings[i]) + 1 + 8; 30027836SJohn.Forte@Sun.COM } 30037836SJohn.Forte@Sun.COM mdb_printf("%s", strings[i]); 30047836SJohn.Forte@Sun.COM } 30057836SJohn.Forte@Sun.COM mask <<= 1; 30067836SJohn.Forte@Sun.COM } 30077836SJohn.Forte@Sun.COM mdb_printf("\n"); 30087836SJohn.Forte@Sun.COM } 30097836SJohn.Forte@Sun.COM 30107836SJohn.Forte@Sun.COM /* 30117836SJohn.Forte@Sun.COM * MDB module linkage information 30127836SJohn.Forte@Sun.COM * 30137836SJohn.Forte@Sun.COM * 30147836SJohn.Forte@Sun.COM * dcmd structures for the _mdb_init function 30157836SJohn.Forte@Sun.COM */ 30167836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = { 30177836SJohn.Forte@Sun.COM { "qlclinks", NULL, "Prints qlc link information", qlclinks_dcmd }, 30187836SJohn.Forte@Sun.COM { "qlcosc", NULL, "Prints outstanding cmd info", qlc_osc_dcmd }, 30197836SJohn.Forte@Sun.COM { "qlcver", NULL, "Prints driver/mdb version", qlcver_dcmd }, 30207836SJohn.Forte@Sun.COM { "qlc_elog", "[on|off] [<inst #>|all]", "Turns qlc extended logging " 30217836SJohn.Forte@Sun.COM "on / off", qlc_el_dcmd }, 30227836SJohn.Forte@Sun.COM { "qlcstate", ":[-v]", "Prints qlc adapter state information", 30237836SJohn.Forte@Sun.COM qlcstate_dcmd }, 30247836SJohn.Forte@Sun.COM { "qlctgtq", NULL, "Prints qlc target queues", qltgtq_dcmd }, 30257836SJohn.Forte@Sun.COM { "qlcwdog", NULL, "Prints out watchdog linked list", qlc_wdog_dcmd}, 30269156SDaniel.Beauregard@Sun.COM { "qlcgetdump", ":[-v]", "Retrieves the ASCII f/w dump", 30279156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd }, 30289156SDaniel.Beauregard@Sun.COM { "qlcgettrace", ":[-v]", "Retrieves the ASCII Extended Logging trace", 30299156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd }, 30307836SJohn.Forte@Sun.COM { NULL } 30317836SJohn.Forte@Sun.COM }; 30327836SJohn.Forte@Sun.COM 30337836SJohn.Forte@Sun.COM /* 30347836SJohn.Forte@Sun.COM * walker structures for the _mdb_init function 30357836SJohn.Forte@Sun.COM */ 30367836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = { 30377836SJohn.Forte@Sun.COM { "qlcstates", "walk list of qlc ql_state_t structures", 30387836SJohn.Forte@Sun.COM qlstates_walk_init, qlstates_walk_step, qlstates_walk_fini }, 30397836SJohn.Forte@Sun.COM { "qlcsrbs", "walk list of qlc ql_srb_t strctures", 30407836SJohn.Forte@Sun.COM qlsrb_walk_init, qlsrb_walk_step, qlsrb_walk_fini }, 30417836SJohn.Forte@Sun.COM { "qlclunq", "walk list of qlc ql_lun_t strctures", 30427836SJohn.Forte@Sun.COM qllunq_walk_init, qllunq_walk_step, qllunq_walk_fini }, 30437836SJohn.Forte@Sun.COM { NULL } 30447836SJohn.Forte@Sun.COM }; 30457836SJohn.Forte@Sun.COM 30467836SJohn.Forte@Sun.COM static const mdb_modinfo_t ql_mdb_modinfo = { 30477836SJohn.Forte@Sun.COM MDB_API_VERSION, dcmds, walkers 30487836SJohn.Forte@Sun.COM }; 30497836SJohn.Forte@Sun.COM 30507836SJohn.Forte@Sun.COM /* 30517836SJohn.Forte@Sun.COM * Registration function which lists the dcmds and walker structures 30527836SJohn.Forte@Sun.COM */ 30537836SJohn.Forte@Sun.COM const mdb_modinfo_t * 30547836SJohn.Forte@Sun.COM _mdb_init(void) 30557836SJohn.Forte@Sun.COM { 30567836SJohn.Forte@Sun.COM return (&ql_mdb_modinfo); 30577836SJohn.Forte@Sun.COM } 3058