2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Table to validate log pages 2N/A "informational-exceptions",
2N/A * Given an extended sense page, retrieves the sense key, as well as the 2N/A * additional sense code information. 2N/A * Get asc, ascq and info field from sense data. There are two 2N/A * possible formats (fixed sense data and descriptor sense data) 2N/A * depending on the value of es_code. 2N/A * Routines built atop the bare uscsi commands, which take into account the 2N/A * command length, automatically translate any scsi errors, and transparently 2N/A * call into the simulator if active. 2N/A /* The following fields are reserved during mode select: */ 2N/A /* The following fields are reserved during mode select: */ 2N/A * Given a list of supported mode pages, determine if the given page is present. 2N/A * The mode page list contains all mode pages supported by the device, 2N/A * one after the other. 2N/A * Load mode pages and check that the appropriate pages are supported. 2N/A * As part of this process, we determine which form of the MODE SENSE / MODE 2N/A * SELECT command to use (the 6-byte or 10-byte version) by executing a MODE 2N/A * SENSE command for a page that should be implemented by the device. 2N/A * Attempt a mode sense(6). If that fails, try a mode sense(10) 2N/A * allpages is allocated to be of the maximum size for either a mode 2N/A * sense(6) or mode sense(10) MODEPAGE_ALLPAGES response. 2N/A * Note that the length passed into uscsi_mode_sense should be set to 2N/A * the maximum size of the parameter response, which in this case is 2N/A * Compute the data length of the page that contains all mode 2N/A * sense pages. This is a bit tricky because the format of the 2N/A * response from the lun is: 2N/A * header: <length> <medium type byte> <dev specific byte> 2N/A * <block descriptor length> 2N/A * [<optional block descriptor>] 2N/A * data: [<mode page data> <mode page data> ...] 2N/A * Since the length field in the header describes the length of 2N/A * the entire response. This includes the header, but NOT 2N/A * the length field itself, which is 1 or 2 bytes depending on 2N/A * which mode sense type (6- or 10- byte) is being executed. 2N/A * So, the data length equals the length value in the header 2N/A * plus 1 (because the length byte was not included in the 2N/A * length count), minus [[the sum of the length of the header 2N/A * and the length of the block descriptor]]. 2N/A * Fallback and try the 10-byte version of the command. 2N/A * One of the sets of the commands (above) succeeded, so now 2N/A * look for the mode pages we need and record them appropriately 2N/A * Specifically, we are looking to see if the disk supports 2N/A * MODEPAGE_INFO_EXCPT. If so, we will mark it as supported. 2N/A * Note that examining this mode page for data will occur only 2N/A * if the LOGPAGE for IE (SMART) data is not supported. 2N/A "informational-exceptions",
nvl) != 0) {
2N/A * If the device failed to respond to one of the basic commands, 2N/A * then assume it's not a SCSI device or otherwise doesn't 2N/A * support the necessary transport. 2N/A dprintf(
"command returned invalid data length (%d)\n",
2N/A * Verify a single logpage. This will do some generic validation and then call 2N/A * the logpage-specific function for further verification. 2N/A * Load log pages and determine which pages are supported. 2N/A * Only add a page to the supported mask if it is 2N/A * returned from the disk, is one of the three supported 2N/A * by this code, and the test mask (tmask) calls for it 2N/A * Validate the logpage contents. 2N/A * verify_logpage will clear the supported bit if 2N/A * verification fails. 2N/A * We always return 0 here, even if the required log pages aren't 2N/A * Verify that the IE log page is sane. This log page is potentially chock-full 2N/A * of vendor specific information that we do not know how to access. All we can 2N/A * do is check for the generic predictive failure bit. If this log page is not 2N/A * well-formed, then bail out. 2N/A * Verify the contents of the temperature log page. The temperature log page 2N/A * contains two log parameters: the current temperature, and (optionally) the 2N/A * reference temperature. For the verification phase, we check that the two 2N/A * parameters we care about are well-formed. If there is no reference 2N/A * temperature, then we cannot use the page for monitoring purposes. 2N/A dprintf(
"temperature logpage validation failed\n");
2N/A * Verify the contents of the self test log page. The log supports a maximum of 2N/A * 20 entries, where each entry's parameter code is its index in the log. We 2N/A * check that the parameter codes fall within this range, and that the size of 2N/A * each page is what we expect. It's perfectly acceptable for there to be no 2N/A * entries in this log, so we must also be sure to validate the contents as part 2N/A * of the analysis phase. 2N/A * Load the current IE mode pages 2N/A * Enable IE reporting. We prefer the following settings: 2N/A * (3) MRIE = 6 (IE_REPORT_ON_REQUEST) 2N/A * (6) REPORT COUNT = 0x00000001 2N/A * However, not all drives support changing these values, and the current state 2N/A * may be useful enough as-is. For example, some drives support IE logging, but 2N/A * don't support changing the MRIE. In this case, we can still use the 2N/A * information provided by the log page. 2N/A /* A previous enable attempt failed on this drive, don't retry. */ 2N/A * We only want to enable warning reporting if we are able to change the 2N/A * mrie to report on request. Otherwise, we risk unnecessarily 2N/A * interrupting normal SCSI commands with a CHECK CONDITION code. 2N/A * Now compare the new mode page with the existing one. 2N/A * if there's no difference, there's no need for a mode select 2N/A /* This drive can be skipped in the future. */ 2N/A * Clear the GLTSD bit, indicating log pages should be saved to non-volatile 2N/A dprintf(
"failed to read Control mode page (KEY=0x%x " 2N/A dprintf(
"SCSI-3 control mode page not supported\n");
2N/A dprintf(
"failed to read changeable Control mode page (KEY=0x%x " 2N/A * Fetch the contents of the logpage, and then call the logpage-specific 2N/A * analysis function. The analysis function is responsible for detecting any 2N/A * faults and filling in the details. 2N/A * Analyze the IE logpage. If we find an IE log record with a non-zero 'asc', 2N/A * then we have a fault. 2N/A * Even though we validated the length during the initial phase, 2N/A * never trust the device. 2N/A * We always log the last result, or the result of the 2N/A * last completed test. 2N/A * Analyze the IE mode sense page explicitly. This is only needed if the IE log 2N/A * page is not supported. 2N/A * Don't bother checking if we weren't able to set our MRIE correctly. 2N/A dprintf(
"failed to request IE page (KEY=0x%x ASC=0x%x " 2N/A * Clean up the scsi-specific information structure. 2N/A * Initialize a single disk. Initialization consists of: 2N/A * 1. Check to see if the IE mechanism is enabled via MODE SENSE for the IE 2N/A * Control page (page 0x1C). 2N/A * 2. If the IE page is available, try to set the following parameters: 2N/A * DEXCPT 0 Enable exceptions 2N/A * MRIE 6 Only report IE information on request 2N/A * EWASC 1 Enable warning reporting 2N/A * REPORT COUNT 1 Only report an IE exception once 2N/A * LOGERR 1 Enable logging of errors 2N/A * The remaining fields are left as-is, preserving the current values. If we 2N/A * cannot set some of these fields, then we do our best. Some drives may 2N/A * have a static configuration which still allows for some monitoring. 2N/A * 3. Check to see if the IE log page (page 0x2F) is supported by issuing a 2N/A * LOG SENSE command. 2N/A * 4. Check to see if the self-test log page (page 0x10) is supported. 2N/A * 5. Check to see if the temperature log page (page 0x0D) is supported, and 2N/A * contains a reference temperature. 2N/A * 6. Clear the GLTSD bit in control mode page 0xA. This will allow the drive 2N/A * to save each of the log pages described above to nonvolatile storage. 2N/A * This is essential if the drive is to remember its failures across 2N/A /* Load and validate mode pages */ 2N/A /* Load and validate log pages */ 2N/A * Load IE state, but only if the IE logpage is not supported. 2N/A * The ie_modepage is only used in the read phase if the logpage 2N/A * is not supported so save the effort here. 2N/A /* Clear the GLTSD bit in the control page */ 2N/A * Scan for any faults. The following steps are performed: 2N/A * 1. If the temperature log page is supported, check the current temperature 2N/A * and threshold. If the current temperature exceeds the threshold, report 2N/A * and overtemp fault. 2N/A * 2. If the selftest log page is supported, check to the last completed self 2N/A * test. If the last completed test resulted in failure, report a selftest 2N/A * 3. If the IE log page is supported, check to see if failure is predicted. If 2N/A * so, indicate a predictive failure fault. 2N/A * 4. If the IE log page is not supported, but the mode page supports report on 2N/A * request mode, then issue a REQUEST SENSE for the mode page. Indicate a 2N/A * predictive failure fault if necessary.