#include <sys/cdefs.h>
#include <dev/pms/config.h>
#include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
#ifdef SA_ENABLE_TRACE_FUNCTIONS
#ifdef siTraceFileID
#undef siTraceFileID
#endif
#define siTraceFileID 'C'
#endif
GLOBAL bit32 saDiscover(
agsaRoot_t *agRoot,
agsaPortContext_t *agPortContext,
bit32 type,
bit32 option
)
{
return AGSA_RC_FAILURE;
}
GLOBAL bit32 saDeregisterDeviceHandle(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
agsaDevHandle_t *agDevHandle,
bit32 queueNum
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
agsaDeviceDesc_t *pDevice;
agsaPort_t *pPort;
bit32 ret = AGSA_RC_SUCCESS;
bit32 deviceid, portid;
bit32 deviceIdx;
OS_ASSERT(agDevHandle != agNULL, "saDeregisterDeviceHandle agDevHandle is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD, "za");
if(agNULL == agDevHandle)
{
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "za");
return AGSA_RC_FAILURE;
}
pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
OS_ASSERT(pDevice != agNULL, "saDeregisterDeviceHandle pDevice is NULL");
if(pDevice == agNULL)
{
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "za");
return AGSA_RC_FAILURE;
}
deviceid = pDevice->DeviceMapIndex;
deviceIdx = deviceid & DEVICE_ID_BITS;
OS_ASSERT(deviceIdx < MAX_IO_DEVICE_ENTRIES, "deviceIdx MAX_IO_DEVICE_ENTRIES");
pPort = pDevice->pPort;
portid = pPort->portId;
SA_DBG3(("saDeregisterDeviceHandle: start DeviceHandle %p\n", agDevHandle));
SA_DBG1(("saDeregisterDeviceHandle: deviceId 0x%x Device Context %p\n", deviceid, pDevice));
if ((deviceid != saRoot->DeviceMap[deviceIdx].DeviceIdFromFW) ||
(pDevice != saRoot->DeviceMap[deviceIdx].DeviceHandle))
{
SA_DBG1(("saDeregisterDeviceHandle: Not match failure\n"));
ret = AGSA_RC_FAILURE;
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "za");
return ret;
}
ret = mpiDeregDevHandleCmd(agRoot, agContext, pDevice, deviceid, portid, queueNum);
smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "za");
return ret;
}
GLOBAL bit32 siRemoveDevHandle(
agsaRoot_t *agRoot,
agsaDevHandle_t *agDevHandle
)
{
agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
agsaPort_t *pPort;
bit32 ret = AGSA_RC_SUCCESS;
OS_ASSERT(pDevice != agNULL, "siRemoveDevHandle is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zb");
if (pDevice == agNULL)
{
SA_DBG1(("siRemoveDevHandle: pDevice is NULL \n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zb");
return AGSA_RC_FAILURE;
}
if ( &(pDevice->initiatorDevHandle) == agDevHandle )
{
(pDevice->initiatorDevHandle).sdkData = agNULL;
}
else if ( &(pDevice->targetDevHandle) == agDevHandle )
{
(pDevice->targetDevHandle).sdkData = agNULL;
}
else
{
SA_ASSERT(agFALSE, "");
}
if ( (agNULL == (pDevice->initiatorDevHandle).sdkData)
&& (agNULL == (pDevice->targetDevHandle).sdkData) )
{
pPort = pDevice->pPort;
switch ( pDevice->deviceType )
{
case STP_DEVICE:
case SSP_SMP_DEVICE:
case DIRECT_SATA_DEVICE:
{
SA_DBG3(("siRemoveDevHandle: remove device context %p\n", pDevice));
siPortDeviceRemove(agRoot, pPort, pDevice, agTRUE);
break;
}
default:
{
SA_DBG1(("siRemoveDevHandle: switch. Not calling siPortDeviceRemove %d\n", pDevice->deviceType));
break;
}
}
}
else
{
SA_DBG1(("siRemoveDevHandle: else. Not caling siPortDeviceRemove\n"));
}
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zb");
return ret;
}
GLOBAL bit32 saGetDeviceHandles(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 queueNum,
agsaPortContext_t *agPortContext,
bit32 flags,
agsaDevHandle_t *agDev[],
bit32 skipCount,
bit32 MaxDevs
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
agsaPort_t *pPort = (agsaPort_t *) (agPortContext->sdkData);
bit32 portIndex, i;
bit32 ret = AGSA_RC_SUCCESS;
OS_ASSERT(pPort != agNULL, "saGetDeviceHandles is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zc");
if (pPort == agNULL)
{
SA_DBG1(("saGetDeviceHandles: pPort is NULL \n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zc");
return AGSA_RC_FAILURE;
}
SA_DBG1(("saGetDeviceHandles: start portId %d\n", pPort->portId));
for (i = 0; i < MaxDevs; i ++)
{
saRoot->DeviceHandle[i] = agDev[i];
}
portIndex = pPort->portId;
mpiGetDeviceHandleCmd(agRoot, agContext, portIndex, flags, MaxDevs, queueNum, skipCount);
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zc");
return ret;
}
GLOBAL bit32 saRegisterNewDevice(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 queueNum,
agsaDeviceInfo_t *agDeviceInfo,
agsaPortContext_t *agPortContext,
bit16 hostAssignedDeviceId
)
{
bit32 ret = AGSA_RC_SUCCESS;
agsaRegDevCmd_t payload;
agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
agsaIORequestDesc_t *pRequest;
agsaPort_t *pPort = (agsaPort_t *) (agPortContext->sdkData);
agsaSASIdentify_t remoteIdentify;
bit32 i, phyId, sDTypeRate;
agsaDeviceDesc_t *pDevice = agNULL;
OS_ASSERT(pPort != agNULL, "saRegisterNewDevice is NULL");
OS_ASSERT(saRoot != agNULL, "saRoot is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zd");
if(saRoot == agNULL)
{
SA_DBG1(("saRegisterNewDevice: saRoot == agNULL\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zd");
return(AGSA_RC_FAILURE);
}
if (pPort == agNULL)
{
SA_DBG1(("saRegisterNewDevice: pPort is NULL \n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zd");
return AGSA_RC_FAILURE;
}
SA_DBG2(("saRegisterNewDevice: start portId %d Port Context %p\n", pPort->portId, agPortContext));
SA_DBG2(("saRegisterNewDevice: smpTimeout 0x%x\n", agDeviceInfo->smpTimeout));
SA_DBG2(("saRegisterNewDevice: it_NexusTimeout 0x%x\n", agDeviceInfo->it_NexusTimeout));
SA_DBG2(("saRegisterNewDevice: firstBurstSize 0x%x\n", agDeviceInfo->firstBurstSize));
SA_DBG2(("saRegisterNewDevice: devType_S_Rate 0x%x\n", agDeviceInfo->devType_S_Rate));
SA_DBG2(("saRegisterNewDevice: flag 0x%x\n", agDeviceInfo->flag));
SA_DBG2(("saRegisterNewDevice: hostAssignedDeviceId 0x%x\n",hostAssignedDeviceId ));
SA_DBG2(("saRegisterNewDevice: Addr 0x%02x%02x%02x%02x 0x%02x%02x%02x%02x\n",
agDeviceInfo->sasAddressHi[0],agDeviceInfo->sasAddressHi[1],agDeviceInfo->sasAddressHi[2],agDeviceInfo->sasAddressHi[3],
agDeviceInfo->sasAddressLo[0],agDeviceInfo->sasAddressLo[1],agDeviceInfo->sasAddressLo[2],agDeviceInfo->sasAddressLo[3] ));
agDeviceInfo->devType_S_Rate &= DEV_LINK_RATE;
si_memset(&remoteIdentify, 0, sizeof(agsaSASIdentify_t));
for (i=0;i<4;i++)
{
remoteIdentify.sasAddressHi[i] = agDeviceInfo->sasAddressHi[i];
remoteIdentify.sasAddressLo[i] = agDeviceInfo->sasAddressLo[i];
}
remoteIdentify.deviceType_addressFrameType = (bit8)(agDeviceInfo->devType_S_Rate & 0xC0);
ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
if ( agNULL == pRequest )
{
pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeReservedRequests));
if(agNULL != pRequest)
{
saLlistIORemove(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
SA_DBG1(("saRegisterNewDevice, using saRoot->freeReservedRequests\n"));
}
else
{
SA_DBG1(("saRegisterNewDevice, No request from free list Not using saRoot->freeReservedRequests\n"));
ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zd");
return AGSA_RC_BUSY;
}
}
else
{
saLlistIORemove(&(saRoot->freeIORequests), &(pRequest->linkNode));
}
saRoot->IOMap[pRequest->HTag].Tag = pRequest->HTag;
saRoot->IOMap[pRequest->HTag].IORequest = (void *)pRequest;
saRoot->IOMap[pRequest->HTag].agContext = agContext;
pRequest->valid = agTRUE;
ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
if (!(agDeviceInfo->devType_S_Rate & 0x20))
{
pDevice = siPortSASDeviceAdd(agRoot,
pPort,
remoteIdentify,
agFALSE,
agDeviceInfo->smpTimeout,
agDeviceInfo->it_NexusTimeout,
agDeviceInfo->firstBurstSize,
agDeviceInfo->devType_S_Rate,
(agDeviceInfo->flag & DEV_INFO_MASK));
}
else
{
pDevice = siPortSATADeviceAdd(agRoot,
pPort,
agNULL,
agNULL,
agFALSE,
0,
agDeviceInfo->smpTimeout,
agDeviceInfo->it_NexusTimeout,
agDeviceInfo->firstBurstSize,
agDeviceInfo->devType_S_Rate,
(agDeviceInfo->flag & DEV_INFO_MASK));
}
SA_DBG1(("saRegisterNewDevice: Device Context %p, TypeRate 0x%x\n", pDevice, agDeviceInfo->devType_S_Rate));
pRequest->pDevice = pDevice;
sDTypeRate = agDeviceInfo->devType_S_Rate << SHIFT24;
sDTypeRate |= (agDeviceInfo->flag & 0x01);
sDTypeRate |= (agDeviceInfo->flag & 0x02) << 1;
if ( hostAssignedDeviceId != 0 )
{
sDTypeRate |= 2;
SA_DBG3(("saRegisterNewDevice:hostAssignedDeviceId 0x%x sDTypeRate 0x%x\n",hostAssignedDeviceId,sDTypeRate ));
}
sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_MCN_SHIFT) & 0xf) << 4;
sDTypeRate |= ((agDeviceInfo->flag >> DEV_INFO_IR_SHIFT) & 0x1) << 3;
sDTypeRate |= ((agDeviceInfo->flag & ATAPI_DEVICE_FLAG) << SHIFT9 );
sDTypeRate |= (agDeviceInfo->flag & AWT_DEVICE_FLAG) ? (1 << SHIFT2) : 0;
sDTypeRate |= (agDeviceInfo->flag & XFER_RDY_PRIORTY_DEVICE_FLAG) ? (1 << SHIFT31) : 0;
if(agDeviceInfo->flag & XFER_RDY_PRIORTY_DEVICE_FLAG)
{
SA_DBG1(("saRegisterNewDevice: sflag XFER_RDY_PRIORTY_DEVICE_FLAG sDTypeRate 0x%x\n",sDTypeRate ));
}
#ifdef CCFLAG_FORCE_AWT_ON
sDTypeRate |= (1 << SHIFT2);
SA_DBG1(("saRegisterNewDevice: Force AWT_DEVICE_FLAG sDTypeRate 0x%x\n",sDTypeRate ));
#endif
si_memset(&payload, 0, sizeof(agsaRegDevCmd_t));
SA_DBG2(("saRegisterNewDevice,flag 0x%08X\n",agDeviceInfo->flag));
if ((agDeviceInfo->devType_S_Rate & 0x30) == 0x20)
{
if(smIS_SPC(agRoot))
{
phyId = (agDeviceInfo->flag & 0xF0);
}
else
{
phyId = (agDeviceInfo->flag & 0xF0) << SHIFT4;
}
}
else
{
phyId = 0;
}
smTrace(hpDBG_VERY_LOUD,"QQ",phyId);
smTrace(hpDBG_VERY_LOUD,"QR",pPort->portId);
smTrace(hpDBG_VERY_LOUD,"QS",sDTypeRate);
smTrace(hpDBG_VERY_LOUD,"QT",agDeviceInfo->it_NexusTimeout);
OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, phyIdportId), (bit32)(pPort->portId & PORTID_MASK) | phyId);
OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, dTypeLRateAwtHa), sDTypeRate);
OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, ITNexusTimeOut), (agDeviceInfo->it_NexusTimeout));
smTrace(hpDBG_VERY_LOUD,"QT",(bit32)(pPort->portId & PORTID_MASK) | phyId);
payload.sasAddrHi = *(bit32*)agDeviceInfo->sasAddressHi;
payload.sasAddrLo = *(bit32*)agDeviceInfo->sasAddressLo;
OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, tag), pRequest->HTag);
OSSA_WRITE_LE_32(agRoot, &payload, OSSA_OFFSET_OF(agsaRegDevCmd_t, DeviceId), ((bit32)hostAssignedDeviceId) << 16);
if(smIS_SPC(agRoot))
{
ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_SPC_REG_DEV, IOMB_SIZE64, queueNum);
}
else
{
ret = mpiBuildCmd(agRoot, (bit32 *)&payload, MPI_CATEGORY_SAS_SATA, OPC_INB_REG_DEV, IOMB_SIZE64, queueNum);
}
if (AGSA_RC_SUCCESS != ret)
{
ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
saRoot->IOMap[pRequest->HTag].Tag = MARK_OFF;
saRoot->IOMap[pRequest->HTag].IORequest = agNULL;
saRoot->IOMap[pRequest->HTag].agContext = agNULL;
pRequest->valid = agFALSE;
if(saLlistIOGetCount(&(saRoot->freeReservedRequests)) < SA_RESERVED_REQUEST_COUNT)
{
SA_DBG1(("saRegisterNewDevice: saving pRequest (%p) for later use\n", pRequest));
saLlistIOAdd(&(saRoot->freeReservedRequests), &(pRequest->linkNode));
}
else
{
saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
}
ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
SA_DBG1(("saRegisterNewDevice, sending IOMB failed\n" ));
}
SA_DBG3(("saRegisterNewDevice: end\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "zd");
return ret;
}
GLOBAL bit32 saRegisterEventCallback(
agsaRoot_t *agRoot,
bit32 eventSourceType,
ossaGenericCB_t callbackPtr
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
bit32 ret = AGSA_RC_FAILURE;
SA_DBG3(("saRegisterEventCallback: start\n"));
switch (eventSourceType)
{
case OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED:
saRoot->DeviceRegistrationCB = (ossaDeviceRegistrationCB_t)callbackPtr;
ret = AGSA_RC_SUCCESS;
break;
case OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED:
saRoot->DeviceDeregistrationCB = (ossaDeregisterDeviceHandleCB_t) callbackPtr;
ret = AGSA_RC_SUCCESS;
break;
default:
SA_DBG1(("saRegisterEventCallback: not allowed case %d\n", eventSourceType));
ret = AGSA_RC_FAILURE;
break;
}
return ret;
}
GLOBAL bit32 saGetDeviceInfo(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 option,
bit32 queueNum,
agsaDevHandle_t *agDevHandle
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
bit32 deviceid;
bit32 ret = AGSA_RC_FAILURE;
OS_ASSERT(pDevice != agNULL, "saGetDeviceInfo is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"ze");
if (pDevice == agNULL)
{
SA_DBG1(("saGetDeviceInfo: pDevice is NULL \n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "ze");
return AGSA_RC_FAILURE;
}
deviceid = pDevice->DeviceMapIndex;
SA_DBG3(("saGetDeviceInfo: start pDevice %p, deviceId %d\n", pDevice, deviceid));
if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
(pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
{
SA_DBG1(("saGetDeviceInfo: Not match failure or device not exist\n"));
ret = AGSA_RC_FAILURE;
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "ze");
return ret;
}
ret = mpiGetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum);
SA_DBG3(("saGetDeviceInfo: end\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "ze");
return ret;
}
GLOBAL bit32 saSetDeviceInfo(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 queueNum,
agsaDevHandle_t *agDevHandle,
bit32 option,
bit32 param,
ossaSetDeviceInfoCB_t agCB
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
bit32 deviceid;
bit32 ret = AGSA_RC_FAILURE;
OS_ASSERT(pDevice != agNULL, "saSetDeviceInfo is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zf");
SA_DBG2(("saSetDeviceInfo: start pDevice %p, option=0x%x param=0x0%x\n", pDevice, option, param));
if(agNULL == pDevice )
{
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zf");
return ret;
}
deviceid = pDevice->DeviceMapIndex;
pDevice->option = option;
pDevice->param = param;
SA_DBG3(("saSetDeviceInfo: deviceId %d\n", deviceid));
if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
(pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
{
SA_DBG1(("saSetDeviceInfo: Not match failure or device not exist\n"));
ret = AGSA_RC_FAILURE;
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zf");
return ret;
}
ret = mpiSetDeviceInfoCmd(agRoot, agContext, deviceid, option, queueNum, param, agCB);
SA_DBG3(("saSetDeviceInfo: end\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zf");
return ret;
}
GLOBAL bit32 saGetDeviceState(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 queueNum,
agsaDevHandle_t *agDevHandle
)
{
agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
agsaDeviceDesc_t *pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
bit32 deviceid;
bit32 ret = AGSA_RC_FAILURE;
OS_ASSERT(pDevice != agNULL, "saGetDeviceState is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zg");
if (pDevice == agNULL)
{
SA_DBG1(("saGetDeviceState: pDevice is NULL \n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zg");
return AGSA_RC_FAILURE;
}
SA_DBG3(("saGetDeviceState: start pDevice %p\n", pDevice));
deviceid = pDevice->DeviceMapIndex;
if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
(pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
{
SA_DBG1(("saGetDeviceState: Not match failure or device not exist\n"));
ret = AGSA_RC_FAILURE;
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zg");
return ret;
}
ret = mpiGetDeviceStateCmd(agRoot, agContext, deviceid, queueNum);
SA_DBG3(("saGetDeviceState: end\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zg");
return ret;
}
GLOBAL bit32 saSetDeviceState(
agsaRoot_t *agRoot,
agsaContext_t *agContext,
bit32 queueNum,
agsaDevHandle_t *agDevHandle,
bit32 newDeviceState
)
{
agsaLLRoot_t *saRoot;
agsaDeviceDesc_t *pDevice;
bit32 deviceid;
bit32 ret = AGSA_RC_FAILURE;
saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
OS_ASSERT(saRoot != agNULL, "saSetDeviceState saRoot");
if(saRoot == agNULL )
{
SA_DBG1(("saSetDeviceState: saRoot is NULL\n"));
return ret;
}
OS_ASSERT(agDevHandle != agNULL, "saSetDeviceState agDevHandle is NULL");
smTraceFuncEnter(hpDBG_VERY_LOUD,"zh");
if(agDevHandle == agNULL )
{
SA_DBG1(("saSetDeviceState: agDevHandle is NULL\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "zh");
return ret;
}
pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
OS_ASSERT(pDevice != agNULL, "saSetDeviceState pDevice is NULL");
SA_DBG3(("saSetDeviceState: start pDevice %p\n", pDevice));
if(pDevice == agNULL )
{
SA_DBG1(("saSetDeviceState: pDevice is NULL\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "zh");
return ret;
}
deviceid = pDevice->DeviceMapIndex;
if ((deviceid != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceIdFromFW) ||
(pDevice != saRoot->DeviceMap[deviceid & DEVICE_ID_BITS].DeviceHandle))
{
SA_DBG1(("saSetDeviceState: Not match failure or device not exist\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "zh");
return ret;
}
ret = mpiSetDeviceStateCmd(agRoot, agContext, deviceid, newDeviceState, queueNum);
SA_DBG3(("saSetDeviceState: end\n"));
smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "zh");
return ret;
}