/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
*/
/*
* This File has Modules that handle the NOE functionality for
* this driver.
* It builds and submits the NOE command to the adapter. It also
* processes a completed NOE command.
* A study of the FirmWare specifications would be neccessary to relate
* coding in this module to the hardware functionality.
*/
#include "cpqary3.h"
/*
* Local Functions Definitions
*/
/*
* Last reason a drive at this position was failed by the
* controller firmware (saved in the RIS).
*/
char *ascii_failure_reason[] = {
"NONE",
"TOO_SMALL_IN_LOAD_CONFIG",
"ERROR_ERASING_RIS",
"ERROR_SAVING_RIS",
"FAIL_DRIVE_COMMAND",
"MARK_BAD_FAILED",
"MARK_BAD_FAILED_IN_FINISH_REMAP",
"TIMEOUT",
"AUTOSENSE_FAILED",
"MEDIUM_ERROR_1",
"MEDIUM_ERROR_2",
"NOT_READY_BAD_SENSE",
"NOT_READY",
"HARDWARE_ERROR",
"ABORTED_COMMAND",
"WRITE_PROTECTED",
"SPIN_UP_FAILURE_IN_RECOVER",
"REBUILD_WRITE_ERROR",
"TOO_SMALL_IN_HOT_PLUG",
"RESET_RECOVERY_ABORT",
"REMOVED_IN_HOT_PLUG",
"INIT_REQUEST_SENSE_FAILED",
"INIT_START_UNIT_FAILED",
"GDP_INQUIRY_FAILED",
"GDP_NON_DISK_DEVICE",
"GDP_READ_CAPACITY_FAILED",
"GDP_INVALID_BLOCK_SIZE",
"HOTP_REQUEST_SENSE_FAILED",
"HOTP_START_UNIT_FAILED",
"WRITE_ERROR_AFTER_REMAP",
"INIT_RESET_RECOVERY_ABORTED"
};
/*
* All Possible Logical Volume Status
*/
char *log_vol_status[] = {
"OK",
"Failed",
"Not Configured",
"Regenerating",
"Needs Rebuild Permission",
"Rebuilding",
"Wrong Drive Replaced",
"Bad Drive Connection",
"Box Overheating",
"Box Overheated",
"Volume Expanding",
"Not Yet Available",
"Volume Needs to Expand",
"Unknown"
};
/*
* Function : cpqary3_send_NOE_command
* Description : This routine builds and submits the NOE Command
* to the Controller.
* Called By : cpqary3_attach(), cpqary3_NOE_handler()
* Parameters : per-controller, per-command,
* Flag to signify first time or otherwise
* Calls : cpqary3_alloc_phyctgs_mem(), cpqary3_cmdlist_occupy(),
* cpqary3_submit(), cpqary3_add2submitted_cmdq(),
* cpqary3_free_phyctgs_mem()
* Return Values: SUCCESS / FAILURE
* [Shall fail only if memory allocation issues exist]
*/
{
int rv;
/*
* NOTE : DO NOT perform this operation for memp. Shall result in a
* failure of submission of the NOE command as it shall be NULL for
* the very first time
*/
/*
* Allocate Memory for Return data
* if failure, RETURN.
* Allocate Memory for CommandList
* If error, RETURN.
* get the Request Block from the CommandList
* Fill in the Request Packet with the corresponding values
* Special Information can be filled in the "bno" field of
* the request structure.
* Here, the "bno" field is filled for Asynchronous Mode.
* Submit the Command.
* If Failure, WARN and RETURN.
*/
if (CPQARY3_NOE_RESUBMIT == flag) {
"Re-Use Not possible; CommandList NULL");
return (CPQARY3_FAILURE);
}
} else if (CPQARY3_NOE_INIT == flag) {
if (!phys_handle)
return (CPQARY3_FAILURE);
if (!databuf) {
return (CPQARY3_FAILURE);
}
return (CPQARY3_FAILURE);
}
MEM_ZALLOC(sizeof (cpqary3_private_t));
return (CPQARY3_FAILURE);
}
}
/* PERF */
if (rv != 0)
return (CPQARY3_FAILURE);
/* PERF */
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_disable_NOE_command
* Description : This routine disables the Event Notifier
* for the specified Controller.
* Called By : cpqary3_cleanup()
* Parameters : Per Controller Structure
* Calls : cpqary3_cmdlist_occupy(), cpqary3_submit(),
* cpqary3_add2submitted_cmdq()
* Return Values: SUCCESS / FAILURE
* [Shall fail only if Memory Constraints exist]
*/
{
int rv;
/*
* Allocate Memory for CommandList
* If error, RETURN.
* get the Request Block from the CommandList
* Fill in the Request Packet with the corresponding values
* Submit the Command.
* If Failure, WARN and RETURN.
*/
return (CPQARY3_FAILURE);
}
/* PERF */
if (rv != 0)
return (CPQARY3_FAILURE);
/* PERF */
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_NOE_handler
* Description : This routine handles all those NOEs tabulated at the
* begining of this code.
* Called By : cpqary3_process_pkt()
* Parameters : Pointer to the Command List
* Calls : cpqary3_send_NOE_command(),
* cpqary3_display_spare_status()
* cpqary3_free_phyctgs_mem(), cpqary3_cmdlist_release()
* Return Values: None
*/
void
{
/*
* This should never happen....
* If the pointer passed as argument is NULL, Panic the System.
*/
/* Don't display more than 79 characters */
switch (evt->event_class_code) {
case CLASS_PROTOCOL:
/*
* the following cases are not handled:
* 000 : This is for Synchronous NOE.
* CPQary3 follows asynchronous NOE.
* 002 : Asynchronous NOE time out.
* CPQary3 does not implement time
* outs for NOE. It shall always reside in the HBA.
*/
"CPQary3 : Event Notifier Disabled \n");
return;
} else if ((evt->event_subclass_code ==
}
break;
case CLASS_HOT_PLUG:
/*
* Fix for QUIX 1000440284: Display the Physical
* Drive Num info only for CISS Controllers
*/
driveId =
/* LINTED: alignment */
if (driveId & 0x80) {
driveId -= 0x80;
"....... SCSI Port %u, "
"Drive Id %u\n",
(driveId % 16));
} else {
"....... SCSI Port %u, "
"Drive Id %u\n",
}
}
"............. %s\n",
}
" Storage Enclosure cable or %s\n",
evt->ascii_message);
} else if (evt->event_detail_code ==
" Storage Enclosure Cable or %s\n",
evt->ascii_message);
} else {
}
} else {
}
break;
case CLASS_HARDWARE:
case CLASS_ENVIRONMENT:
break;
case CLASS_PHYSICAL_DRIVE:
/*
* Fix for QUIX 1000440284: Display the Physical Drive
* Num info only for CISS Controllers
*/
/* LINTED: alignment */
if (driveId & 0x80) {
driveId -= 0x80;
"SCSI Port %u, Drive Id %u\n",
} else {
"SCSI Port %u, Drive Id %u\n",
}
}
} else {
" Failure Reason............ UNKNOWN \n");
}
break;
case CLASS_LOGICAL_DRIVE:
/*
* Fix for QXCR1000717274 - We are appending the logical
* voulme number by one to be in sync with logical volume
* details given by HPQacucli
*/
/* LINTED: alignment */
/*
* If the Logical drive has FAILED or it was
* NOT CONFIGURED, in the corresponding target
* structure, set flag as NONE to suggest that no
* target exists at this id.
*/
/* LINTED: alignment */
(&evt->event_specific_data[0]);
}
}
"Data is rebuilding on spare drive\n",
/* LINTED: alignment */
(*(uint16_t *)
}
" Logical Drive %d: Rebuild complete. "
"Spare is now active\n",
/* LINTED: alignment */
(*(uint16_t *)
}
"logical drive %u\n",
/* LINTED: alignment */
(*(uint16_t *)
} else {
}
break;
default:
break;
}
/*
* Here, we reuse this command block to resubmit the NOE
* command.
* Ideally speaking, the resubmit should never fail
*/
if (CPQARY3_FAILURE ==
"NOTIFY OF EVENT");
}
}
/* PERF */
/*
* Function : cpqary3_noe_complete
* Description : This routine processes the completed
* NOE commands and
* initiates any callback that is needed.
* Called By : cpqary3_send_NOE_command,
* cpqary3_disable_NOE_command
* Parameters : per-command
* Calls : cpqary3_NOE_handler, cpqary3_cmdlist_release
* Return Values: None
*/
void
{
return;
}
} else {
}
}
/* PERF */