/*
* 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.
*/
#include "cpqary3.h"
/*
* Local Functions Definitions
*/
/*
* Function : cpqary3_probe4targets
* Description : This routine detects all existing logical drives
* and updates per target structure.
* Called By : cpqary3_tgt_init()
* Parameters : per-controller
* Calls : cpqary3_probe4LVs(), cpqary3_probe4Tapes()
* Return Values: SUCCESS/ FAILURE
* [Shall fail only if Memory Constraints exist, the
*/
{
if (CPQARY3_FAILURE == rv) {
return (rv);
}
if (CPQARY3_FAILURE == rv) {
return (rv);
}
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_build_cmdlist
* Description : This routine builds the command list for the specific
* opcode.
* Called By : cpqary3_transport()
* Parameters : cmdlist pvt struct, target id as received by SA.
* Calls : None
* Return Values: SUCCESS : Build is successful
* FAILURE : Build has Failed
*/
{
int cntr;
return (CPQARY3_FAILURE);
if (!tgtp) {
return (CPQARY3_FAILURE);
}
/* Update Cmd Header */
sizeof (PhysDevAddr_t));
}
/* Cmd Request */
CommandList_t *, cmdlistp);
else
/*
* Looks like the above Direction is going for a toss in case of
* MSA20(perticularly for 0x0a-write) connected to SMART Array.
* If the above check fails, the below switch should take care.
*/
case 0x08:
case 0x28:
break;
case 0x0A:
case 0x2A:
break;
}
/*
* NEED to increase this TimeOut value when the concerned
* targets are tape devices(i.e., we need to do it here manually).
*/
}
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_send_abortcmd
* Description : Sends the Abort command to abort
* a set of cmds(on a target) or a cmdlist.
* Called By : cpqary3_abort
* Parameters : per controller, target_id, cmdlist to abort
* Calls : cpqary3_synccmd_alloc(), cpqary3_synccmd_send(),
* cpqary3_synccmd_free()
* Return Values: SUCCESS - abort cmd submit is successful.
* FAILURE - Could not submit the abort cmd.
*/
{
/*
* NOTE : DO NOT perform this operation for cmdlist2abortp.
* It may be NULL
*/
if (target_id == CTLR_SCSI_ID)
return (CPQARY3_FAILURE);
if (!cpqtgtp) {
return (CPQARY3_FAILURE);
}
/*
* Occupy the Command List
* Update the Command List accordingly
* Submit the command and wait for a signal
*/
/* BGB: CVFIX -> Introduced the call to cpqary3_synccmd_alloc */
if (cpqary3_cmdpvtp == NULL)
return (CPQARY3_FAILURE);
if (cmdlist2abortp) { /* Abort this Particular Task */
} else { /* Abort all tasks for this Target */
case CPQARY3_TARGET_LOG_VOL:
break;
case CPQARY3_TARGET_TAPE:
sizeof (PhysDevAddr_t));
}
}
/* PERF */
/* PERF */
/* BGB: CVFIX -> Introduced a call to cpqary3_synccmd_send */
CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
return (CPQARY3_FAILURE);
}
return (CPQARY3_FAILURE);
}
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_fulsh_cache
* Description : This routine flushes the controller cache.
* Called By : cpqary3_detach(), cpqary3_additional_cmd()
* Parameters : per controller
* Calls : cpqary3_synccmd_alloc(), cpqary3_synccmd_send()
* cpqary3_synccmd_free()
* Return Values: None
*/
void
{
/*
* Occupy the Command List
* Allocate Physically Contigous Memory for the FLUSH CACHE buffer
* Update the Command List accordingly
* Submit the command and wait for a signal
*/
/* grab a command and allocate a dma buffer */
sizeof (flushcache_buf_t));
if (cpqary3_cmdpvtp == NULL)
return;
/* PERF */
/* PERF */
CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
return;
}
}
/*
* Function : cpqary3_probe4LVs
* Description : This routine probes for the logical drives
* configured on the HP Smart Array controllers
* Called By : cpqary3_probe4targets()
* Parameters : per controller
* Calls : cpqary3_synccmd_alloc(), cpqary3_synccmd_send()
* cpqary3_synccmd_free()
* Return Values: None
*/
{
ulong_t i = 0;
/*
* Occupy the Command List
* Allocate Physically Contigous Memory
* Update the Command List for Report Logical LUNS (rll) Command
* This command detects all existing logical drives.
* Submit and Poll for completion
*/
/* Sync Changes */
if (cpqary3_cmdpvtp == NULL)
return (CPQARY3_FAILURE);
data_addr_len = sizeof (rll_data_t);
/* PERF */
/* PERF */
CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
return (CPQARY3_FAILURE);
}
"returned ERROR !");
return (CPQARY3_FAILURE);
}
/* Sync Changes */
/*
* The following is to restrict the maximum number of supported logical
* volumes to 32. This is very important as controller support upto 128
* logical volumes and this driver implementation supports only 32.
*/
if (log_lun_no > MAX_LOGDRV) {
}
/*
* Update per target structure with relevant information
* CPQARY#_TGT_ALLIGNMENT is 1 because of the following mapping:
* Target IDs 0-6 in the OS = Logical Drives 0 - 6 in the HBA
* Target ID 7 in the OS = none in the HBA
* Target IDs 8-32 in the OS = Logical Drives 7 - 31 in the HBA
* Everytime we reference a logical drive with ID > 6, we shall use
* the alignment.
*/
/*
* Depending upon the value of the variable legacy_mapping set in
* cpqary3_attach(),
* the target mapping algorithm to be used by the driver is decided.
*
* If the value of legacy_mapping is set to one, in the case of
* Logical Drives with holes,
* Targets will be renumbered by the driver as shown below
* Below example makes the mapping logic clear.
*
* Logical Drive 0 in the HBA -> Target ID 0 i.e., cXt0dXsx
* Logical Drive 2 in the HBA -> Target ID 1 i.e., cXt1dXsX
* Logical Drive 3 in the HBA -> Target ID 2 i.e., cXt2dXsX
*
* If the value of legacy_mapping is not one, then the Logical
* Drive numbers will
* not be renumbered in the case of holes, and the mapping
* will be done as shown below
* This will be the default mapping from 1.80 cpqary3 driver.
*
* Logical Drive 0 in the HBA -> Target ID 0 i.e. cXt0dXsx
* Logical Drive 2 in the HBA -> Target ID 2 i.e. cXt2dXsX
* Logical Drive 3 in the HBA -> Target ID 3 i.e. cXt3dXsX
*/
i = ((cntr < CTLR_SCSI_ID) ?
MEM_ZALLOC(sizeof (cpqary3_tgt_t)))) {
"targets, Memory Allocation Failure");
return (CPQARY3_FAILURE);
}
}
} else {
/*
* Fix for QXCR1000446657: Logical drives are re numbered after
* deleting a Logical drive.
* We are using new indexing mechanism to fill the
* cpqary3_tgtp[],
* Check given during memory allocation of cpqary3_tgtp
* elements, so that memory is not re-allocated each time the
* cpqary3_probe4LVs() is called.
* Check given while freeing the memory of the cpqary3_tgtp[]
* elements, when a hole is found in the Logical Drives
* configured.
*/
/* ensure that the loop will break for cntr = 32 in any case */
cntr++) {
i = ((cntr < CTLR_SCSI_ID) ?
if (cpqary3p->cpqary3_tgtp[i]) {
sizeof (cpqary3_tgt_t));
}
} else {
!(cpqary3p->cpqary3_tgtp[i] =
sizeof (cpqary3_tgt_t)))) {
"CPQary3 : Failed to Detect "
"targets, Memory Allocation "
"Failure");
/* Sync Changes */
/* Sync Changes */
return (CPQARY3_FAILURE);
}
/*
* Send "BMIC sense logical drive status
* command to set the target type to
* CPQARY3_TARGET_NONE in case of logical
* drive failure
*/
ld_count++;
}
}
}
/* HPQacucli Changes */
cpqary3_tgt_t *t;
i = ((cntr < CTLR_SCSI_ID) ?
t = cpqary3p->cpqary3_tgtp[i];
if (t) {
MEM_SFREE(t, sizeof (*t));
}
}
/* HPQacucli Changes */
/* Sync Changes */
/* Sync Changes */
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_probe4Tapes
* Description : This routine probes for the logical drives
* configured on the HP Smart Array controllers
* Called By : cpqary3_probe4targets()
* Parameters : per controller
* Calls : cpqary3_synccmd_alloc(), cpqary3_synccmd_send()
* cpqary3_synccmd_free()
* Return Values: None
*/
{
/*
* Occupy the Command List
* Allocate Physically Contigous Memory
* Update the Command List for Report Logical LUNS (rll) Command
* This command detects all existing logical drives.
* Submit and Poll for completion
*/
/* Sync Changes */
if (cpqary3_cmdpvtp == NULL)
return (CPQARY3_FAILURE);
/* Sync Changes */
data_addr_len = sizeof (rpl_data_t);
/* PERF */
/* PERF */
/* Sync Changes */
CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
return (CPQARY3_FAILURE);
}
"returned ERROR !");
return (CPQARY3_FAILURE);
}
/* Sync Changes */
/*
* Update per target structure with relevant information
* CPQARY3_TAPE_BASE is 33 because of the following mapping:
* Target IDs 0-6 in the OS = Logical Drives 0 - 6 in the HBA
* Target ID 7 in the OS = none in the HBA
* Target IDs 8-32 in the OS = Logical Drives 7 - 31 in the HBA
* Target IDs 33 and above are reserved for Tapes and hence we need
* the alignment.
*/
/*
* HP Smart Array SAS controllers with Firmware revsion 5.14 or
* later support
* 64 Logical drives. So we are checking
* if the controller is SAS or CISS and then assigning the value of the
* TAPE BASE accordingly
*/
} else {
}
(cpqary3_tgt_t *)
MEM_ZALLOC(sizeof (cpqary3_tgt_t)))) {
"targets, Memory Allocation Failure");
return (CPQARY3_FAILURE);
}
sizeof (PhysDevAddr_t));
ii++;
}
}
/* Sync Changes */
/* Sync Changes */
return (CPQARY3_SUCCESS);
}
/*
* Function : cpqary3_synccmd_complete
* Description : This routine processes the completed commands
* using the sync interface and
* initiates any callback that is needed.
* Called By : cpqary3_transport
* Parameters : per-command
* Calls : cpqary3_cmdlist_release, cpqary3_synccmd_cleanup
* Return Values: None
*/
void
{
return;
}
/*
* The submitter has abandoned this command, so we
* have to free the resources here.
*/
} else {
/* submitter is waiting; wake him up */
cpqary3_cmdpvtp->cmdpvt_flag = 0;
/*
* Fix for Flush Cache Operation Timed out issue:
* cv_signal() wakes up only one blocked thread.
* We need to use cv_broadcast which unblocks
* all the blocked threads()
*/
}
}