#include <sys/cdefs.h>
#include <dev/pms/config.h>
#include <dev/pms/freebsd/driver/common/osenv.h>
#include <dev/pms/freebsd/driver/common/ostypes.h>
#include <dev/pms/freebsd/driver/common/osdebug.h>
#include <dev/pms/RefTisa/sallsdk/api/sa.h>
#include <dev/pms/RefTisa/sallsdk/api/saapi.h>
#include <dev/pms/RefTisa/sallsdk/spc/sadefs.h>
#include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
#include <dev/pms/RefTisa/tisa/api/titypes.h>
#include <dev/pms/RefTisa/tisa/api/ostiapi.h>
#include <dev/pms/RefTisa/tisa/api/tiapi.h>
#include <dev/pms/RefTisa/tisa/api/tiglobal.h>
#ifdef FDS_SM
#include <dev/pms/RefTisa/sat/api/sm.h>
#include <dev/pms/RefTisa/sat/api/smapi.h>
#include <dev/pms/RefTisa/sat/api/tdsmapi.h>
#endif
#ifdef FDS_DM
#include <dev/pms/RefTisa/discovery/api/dm.h>
#include <dev/pms/RefTisa/discovery/api/dmapi.h>
#include <dev/pms/RefTisa/discovery/api/tddmapi.h>
#endif
#include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
#include <dev/pms/freebsd/driver/common/osstring.h>
#include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
#ifdef INITIATOR_DRIVER
#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
#endif
#ifdef TARGET_DRIVER
#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
#endif
#include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
#include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
#ifndef TURN_OFF_HDA
#include <dev/pms/RefTisa/sallsdk/hda/64k/aap1img.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/ilaimg.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/iopimg.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/istrimg.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/aap18008.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/iop8008.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/ila8008.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/raae8070.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/iop8070.h>
#include <dev/pms/RefTisa/sallsdk/hda/64k/ila8070.h>
#endif
bit32 gSSC_Disable = 0;
bit32 volatile sgpioResponseSet = 0;
#ifdef ECHO_TESTING
bit8 gEcho;
#endif
bit32 tiCOMConfigureSgpio(
tiRoot_t *tiRoot,
bit8 enableSgpio
);
osGLOBAL void
tdsaGetSwConfigParams(
tiRoot_t *tiRoot
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
agsaSwConfig_t *SwConfig;
agsaQueueConfig_t *QueueConfig;
char *buffer;
bit32 buffLen;
bit32 lenRecv = 0;
char *pLastUsedChar = agNULL;
char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
char globalStr[] = "Global";
char iniParmsStr[] = "InitiatorParms";
char SwParmsStr[] = "SWParms";
char OBQueueProps[] = "OBQueueProps";
char IBQueueProps[] = "IBQueueProps";
char IBQueueSize[40];
char OBQueueSize[40];
char IBQueueEleSize[40];
char OBQueueEleSize[40];
char OBQueueInterruptCount[40];
char OBQueueInterruptDelay[40];
char OBQueueInterruptEnable[40];
char IBQueuePriority[40];
char *cardNum = tdsaAllShared->CardIDString;
bit32 i;
bit32 enableDIF;
bit32 enableEncryption;
#ifdef SA_CONFIG_MDFD_REGISTRY
bit32 disableMDF;
#endif
#ifdef FDS_DM
dmSwConfig_t *dmSwConfig;
#endif
#ifdef FDS_SM
smSwConfig_t *smSwConfig;
#endif
TI_DBG6(("tdsaGetSwConfigParams: start\n"));
TI_DBG6(("tdsaGetSwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
buffer = tmpBuffer;
buffLen = sizeof(tmpBuffer);
osti_memset(buffer, 0, buffLen);
SwConfig = (agsaSwConfig_t *)&(tdsaAllShared->SwConfig);
QueueConfig = (agsaQueueConfig_t *)&(tdsaAllShared->QueueConfig);
#ifdef FDS_DM
dmSwConfig = (dmSwConfig_t *)&(tdsaAllShared->dmSwConfig);
#endif
#ifdef FDS_SM
smSwConfig = (smSwConfig_t *)&(tdsaAllShared->smSwConfig);
#endif
SwConfig->numDevHandles = DEFAULT_MAX_DEV;
SwConfig->maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
SwConfig->smpReqTimeout = DEFAULT_SMP_TIMEOUT;
SwConfig->numberOfEventRegClients = DEFAULT_NUM_REG_CLIENTS;
SwConfig->sizefEventLog1 = HOST_EVENT_LOG_SIZE;
SwConfig->sizefEventLog2 = HOST_EVENT_LOG_SIZE;
SwConfig->eventLog1Option = DEFAULT_EVENT_LOG_OPTION;
SwConfig->eventLog2Option = DEFAULT_EVENT_LOG_OPTION;
SwConfig->fatalErrorInterruptEnable = 1;
SwConfig->fatalErrorInterruptVector = 0;
SwConfig->hostDirectAccessSupport = 0;
SwConfig->hostDirectAccessMode = 0;
SwConfig->FWConfig = 0;
SwConfig->enableDIF = agFALSE;
SwConfig->enableEncryption = agFALSE;
#ifdef SA_CONFIG_MDFD_REGISTRY
SwConfig->disableMDF = agFALSE;
#endif
SwConfig->param1 = tdsaAllShared->tdDeviceIdVendId;
SwConfig->param2 = tdsaAllShared->tdSubVendorId;
#if defined(SALLSDK_DEBUG)
SwConfig->sallDebugLevel = 1;
#endif
#if defined(DM_DEBUG)
dmSwConfig->DMDebugLevel = 1;
#endif
#if defined(SM_DEBUG)
smSwConfig->SMDebugLevel = 1;
#endif
tdsaAllShared->portTMO = PORT_RECOVERY_TIMEOUT;
tdsaAllShared->stp_idle_time = STP_IDLE_TIME;
tdsaAllShared->itNexusTimeout = IT_NEXUS_TIMEOUT;
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
iniParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MaxTargets",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: MaxTargets %d\n",SwConfig->numDevHandles ));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
QueueConfig->numInboundQueues = DEFAULT_NUM_INBOUND_QUEUE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"NumInboundQueues",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
}
if (QueueConfig->numInboundQueues > AGSA_MAX_INBOUND_Q)
{
QueueConfig->numInboundQueues = AGSA_MAX_INBOUND_Q;
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
QueueConfig->numOutboundQueues = DEFAULT_NUM_OUTBOUND_QUEUE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"NumOutboundQueues",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
}
if (QueueConfig->numOutboundQueues > AGSA_MAX_OUTBOUND_Q)
{
QueueConfig->numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->QueueOption = DEFAULT_QUEUE_OPTION;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"QueueOption",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MaxActiveIO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 0);
TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 1 !!!\n"));
}
else
{
SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 2 !!!\n"));
}
TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 3 !!!\n"));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SMPTO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"NumRegClients",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
#if defined(SALLSDK_DEBUG)
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"LLDebugLevel",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
#endif
#if defined(DM_DEBUG)
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"DMDebugLevel",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
#endif
#if defined(SM_DEBUG)
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SMDebugLevel",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
#endif
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<QueueConfig->numInboundQueues;i++)
{
osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->InboundQueueSize[i] = DEFAULT_INBOUND_QUEUE_SIZE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueueSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->InboundQueueEleSize[i] = DEFAULT_INBOUND_QUEUE_ELE_SIZE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueueEleSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->InboundQueuePriority[i] = DEFAULT_INBOUND_QUEUE_PRIORITY;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueuePriority,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d priority %d\n", i, tdsaAllShared->InboundQueuePriority[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<QueueConfig->numOutboundQueues;i++)
{
osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OutboundQueueSize[i] = DEFAULT_OUTBOUND_QUEUE_SIZE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OutboundQueueEleSize[i] = DEFAULT_OUTBOUND_QUEUE_ELE_SIZE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueEleSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OutboundQueueInterruptDelay[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_DELAY;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptDelay,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt delay %d\n", i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OutboundQueueInterruptCount[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_COUNT;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptCount,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt count %d\n", i, tdsaAllShared->OutboundQueueInterruptCount[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OutboundQueueInterruptEnable[i] = DEFAULT_OUTBOUND_INTERRUPT_ENABLE;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptEnable,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt enable %d\n", i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<QueueConfig->numInboundQueues;i++)
{
osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueueSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueueEleSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
IBQueuePriority,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d priority %d\n", cardNum, i, tdsaAllShared->InboundQueuePriority[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<QueueConfig->numOutboundQueues;i++)
{
osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueEleSize,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptDelay,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt delay %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptCount,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt count %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptCount[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
cardNum,
SwParmsStr,
OBQueueProps,
agNULL,
agNULL,
agNULL,
OBQueueInterruptEnable,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt enable %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"EventLogSize1",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"EventLogOption1",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"EventLogSize2",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"EventLogOption2",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"HDASupport",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"HDAMode",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"FWConfig",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
"IQNQDepth",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
IBQueueProps,
agNULL,
agNULL,
agNULL,
"IQHQDepth",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"PortTMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
#ifdef SA_ENABLE_TRACE_FUNCTIONS
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"TraceDestination",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceDestination %d\n",SwConfig->TraceDestination));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"TraceMask",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceMask %d %X\n",SwConfig->TraceMask,SwConfig->TraceMask));
}
#endif
#ifdef AGTIAPI_CTL
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->SASConnectTimeLimit = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SASCTL",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 0);
else
tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 10);
}
#endif
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->FCA = 1;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
"InitiatorParms",
agNULL,
agNULL,
agNULL,
agNULL,
"FCA",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->ResetInDiscovery = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
"InitiatorParms",
agNULL,
agNULL,
agNULL,
agNULL,
"ResetInDiscovery",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->MCN = 1;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MCN",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetSwConfigParams: MCN %d\n", tdsaAllShared->MCN));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->sflag = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"Sflag",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: sflag %d\n", tdsaAllShared->sflag));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"enableDIF",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
enableDIF = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
enableDIF = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetSwConfigParams: enableDIF %d\n", enableDIF));
if (enableDIF)
{
SwConfig->enableDIF = agTRUE;
}
else
{
SwConfig->enableDIF = agFALSE;
}
TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableDIF %d\n", SwConfig->enableDIF));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"enableEncryption",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetSwConfigParams: enableEncryption %d\n", enableEncryption));
if (enableEncryption)
{
SwConfig->enableEncryption = agTRUE;
}
else
{
SwConfig->enableEncryption = agFALSE;
}
TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableEncryption %d\n", SwConfig->enableEncryption));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->RateAdjust = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"RateAdjust",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetSwConfigParams: tdsaAllShared->RateAdjust %d\n", tdsaAllShared->RateAdjust));
}
#ifdef SA_CONFIG_MDFD_REGISTRY
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"disableMDF",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
disableMDF = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
disableMDF = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetSwConfigParams: disableMDF %d\n", disableMDF));
if (disableMDF)
{
SwConfig->disableMDF = agTRUE;
}
else
{
SwConfig->disableMDF = agFALSE;
}
TI_DBG6(("tdsaGetSwConfigParams: SwConfig->disableMDF %d\n", SwConfig->disableMDF));
}
#endif
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"IT_NEXUS_TIMEOUT",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: tdsaAllShared->itNexusTimeout %d\n", tdsaAllShared->itNexusTimeout));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"STPIdleTime",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: STPIdleTime %d\n", tdsaAllShared->stp_idle_time));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->STP_MCT_TMO = 32;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_STP_MCT_TMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: STP_MCT_TMO %d\n", tdsaAllShared->STP_MCT_TMO));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->SSP_MCT_TMO = 32;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_SSP_MCT_TMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: SSP_MCT_TMO %d\n", tdsaAllShared->SSP_MCT_TMO));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->MAX_OPEN_TIME = 5;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_MAX_OPEN_TIME",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: MAX_OPEN_TIME %d\n", tdsaAllShared->MAX_OPEN_TIME));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->SMP_MAX_CONN_TIMER = 0xFF;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_SMP_MAX_CONN_TIMER",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: SMP_MAX_CONN_TIMER %d\n", tdsaAllShared->SMP_MAX_CONN_TIMER));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->STP_FRM_TMO = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_STP_FRM_TMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: STP_FRM_TMO %d\n", tdsaAllShared->STP_FRM_TMO));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->MFD = 1;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_MFD",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: MFD %d\n", tdsaAllShared->MFD));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->OPNRJT_RTRY_INTVL = 2;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_OPNRJT_RTRY_INTVL",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: OPNRJT_RTRY_INTVL %d\n", tdsaAllShared->OPNRJT_RTRY_INTVL));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->DOPNRJT_RTRY_TMO = 128;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_DOPNRJT_RTRY_TMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_TMO %d\n", tdsaAllShared->DOPNRJT_RTRY_TMO));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->COPNRJT_RTRY_TMO = 128;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_COPNRJT_RTRY_TMO",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_TMO %d\n", tdsaAllShared->COPNRJT_RTRY_TMO));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->DOPNRJT_RTRY_THR = 23438;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_DOPNRJT_RTRY_THR",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_THR %d\n", tdsaAllShared->DOPNRJT_RTRY_THR));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->COPNRJT_RTRY_THR = 23438;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_COPNRJT_RTRY_THR",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_THR %d\n", tdsaAllShared->COPNRJT_RTRY_THR));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
tdsaAllShared->MAX_AIP = 0x200000;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"SAS_MAX_AIP",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG2(("tdsaGetSwConfigParams: MAX_AIP %d\n", tdsaAllShared->MAX_AIP));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
{
bit32 MpiContextvalue = 0;
SwConfig->mpiContextTable = agNULL;
SwConfig->mpiContextTablelen = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MpiContext",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 10);
}
if (MpiContextvalue == 0)
{
SwConfig->mpiContextTable = agNULL;
SwConfig->mpiContextTablelen = 0;
}
else
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
if(agNULL != tdsaRoot)
{
tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = 0xFF;
tdsaRoot->tdsaAllShared.MpiOverride.offset = 0;
tdsaRoot->tdsaAllShared.MpiOverride.value = 0;
SwConfig->mpiContextTable = &(tdsaRoot->tdsaAllShared.MpiOverride);
SwConfig->mpiContextTablelen = sizeof(agsaMPIContext_t);
}
TI_DBG1(("tdsaGetSwConfigParams: MpiContext %p Len %d\n", SwConfig->mpiContextTable, SwConfig->mpiContextTablelen));
}
}
if(SwConfig->mpiContextTable != agNULL )
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
if(agNULL != tdsaRoot)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MpiTableType",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.MPITableType 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.MPITableType ));
}
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MpiTableOffset",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.offset 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.offset ));
}
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MpiTableValue",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.value 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.value ));
}
}
}
}
#ifdef SA_ENABLE_PCI_TRIGGER
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
SwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"PciTrigger",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG1(("tdsaGetSwConfigParams: PciTrigger %d\n",SwConfig->PCI_trigger));
}
#endif
TI_DBG6(("tdsaGetSwConfigParams: $$$$$$$$$$$$$$$$$ merge $$$$$$$$$$$$$\n"));
#if defined(SALLSDK_DEBUG)
TI_DBG2(("tdsaGetSwConfigParams: SwConfig->sallDebugLevel %d\n", SwConfig->sallDebugLevel));
#endif
#ifdef SA_ENABLE_PCI_TRIGGER
TI_DBG1(("tdsaGetSwConfigParams: SwConfig->PCI_trigger 0x%x 0x%x\n",SwConfig->PCI_trigger, tdsaRoot->itdsaIni->tdsaAllShared->SwConfig.PCI_trigger));
#endif
#ifdef AGTIAPI_CTL
TI_DBG6(("tdsaLoLevelGetResource: SASConnectTimeLimit 0x%x\n",
tdsaAllShared->SASConnectTimeLimit));
#endif
return;
}
osGLOBAL void
tdsaParseLinkRateMode(
tiRoot_t *tiRoot,
bit32 index,
bit32 LinkRateRead,
bit32 ModeRead,
bit32 OpticalModeRead,
bit32 LinkRate,
bit32 Mode,
bit32 OpticalMode
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
TI_DBG3(("tdsaParseLinkRateMode: index 0x%X\n",index));
TI_DBG3(("tdsaParseLinkRateMode: LinkRateRead 0x%X LinkRate 0x%X\n",LinkRateRead,LinkRate));
TI_DBG3(("tdsaParseLinkRateMode: ModeRead 0x%X Mode 0x%X\n",ModeRead,Mode));
TI_DBG3(("tdsaParseLinkRateMode: OpticalModeRead 0x%X OpticalMode 0x%X\n",OpticalModeRead,OpticalMode));
if (LinkRateRead == agTRUE)
{
if (LinkRate & 0x1)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
}
if (LinkRate & 0x2)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x2;
}
if (LinkRate & 0x4)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x4;
}
if (LinkRate & 0x8)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x8;
}
if (LinkRate == 0 || LinkRate > 0xF )
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = 0;
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
TI_DBG1(("tdsaParseLinkRateMode: LinkRate == 0 || LinkRate >= 0x%x\n",tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
TI_DBG2(("tdsaParseLinkRateMode:A index 0x%x LinkRate 0x%x Mode 0x%x\n",index,LinkRate,Mode));
}
if ( ModeRead == agTRUE)
{
if (Mode & 0x1)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x10;
}
if (Mode & 0x2)
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x20;
}
if (Mode == 0 || Mode >= 4 )
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties & 0xf;
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x30;
}
TI_DBG2(("tdsaParseLinkRateMode:1 index 0x%x Mode 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
if ( OpticalModeRead == agTRUE)
{
agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
if (OpticalMode == 0)
{
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 0 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
else if(OpticalMode == 1)
{
if(tIsSPCV12or6G(agRoot))
{
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 1 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
}
else
{
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
tdsaAllShared->Ports[index].agPhyConfig.phyProperties &= 0xFFFFFFF0;
tdsaAllShared->Ports[index].agPhyConfig.phyProperties |= 0x4;
}
}
else if(OpticalMode == 2 )
{
if(tIsSPCV12or6G(agRoot))
{
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 2 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 20);
}
else
{
TD_ASSERT(0, "SPC optical mode 2");
}
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
else
{
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode unknown %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
}
else
{
TI_DBG1(("tdsaParseLinkRateMode: OpticalMode off phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
}
TI_DBG1(("tdsaParseLinkRateMode: phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
return;
}
osGLOBAL void
tdsaGetHwConfigParams(
tiRoot_t *tiRoot
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
agsaHwConfig_t *HwConfig;
char *buffer;
bit32 buffLen;
bit32 lenRecv = 0;
char *pLastUsedChar = agNULL;
char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
char globalStr[] = "Global";
char HwParmsStr[] = "HWParms";
char phyReg[10];
int i,j;
agsaPhyAnalogSetupTable_t *phyRegTable;
TI_DBG6(("tdsaGetHwConfigParams: start\n"));
TI_DBG6(("tdsaGetHwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
buffer = tmpBuffer;
buffLen = sizeof(tmpBuffer);
osti_memset(buffer, 0, buffLen);
HwConfig = (agsaHwConfig_t *)&(tdsaAllShared->HwConfig);
phyRegTable = (agsaPhyAnalogSetupTable_t *)&(HwConfig->phyAnalogConfig);
osti_memset(HwConfig, 0, sizeof(agsaHwConfig_t));
tdsaAllShared->FWMaxPorts = DEFAULT_FW_MAX_PORTS;
HwConfig->phyCount = TD_MAX_NUM_PHYS;
HwConfig->hwInterruptCoalescingTimer = 1;
HwConfig->hwInterruptCoalescingControl = 0;
tdsaAllShared->phyCalibration = 0;
HwConfig->hwOption = 0;
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"HwIntCoalTimer",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"HwIntCoalControl",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
if (HwConfig->hwInterruptCoalescingControl == 1 && HwConfig->hwInterruptCoalescingTimer == 0)
{
HwConfig->hwInterruptCoalescingTimer = 1;
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"IntReassertionOpt",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"HwOption",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"MaxFWPorts",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"phyCalibration",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<MAX_INDEX;i++)
{
for(j=0;j<10;j++)
{
osti_sprintf(phyReg,"spaReg%d%d",i,j);
TI_DBG6(("tdsaGetHwConfigParams: phyReg %s\n", phyReg));
if (j == 0)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 1)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 2)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 3)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 4)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 5)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 6)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 7)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 8)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
else if (j == 9)
{
if ((ostiGetTransportParam(
tiRoot,
globalStr,
HwParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
phyReg,
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 10);
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
}
}
}
return;
}
osGLOBAL void
tdsaGetCardPhyParams(
tiRoot_t *tiRoot
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
char *buffer;
bit32 buffLen;
bit32 lenRecv = 0;
char *pLastUsedChar = agNULL;
char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
char *globalStr = tdsaAllShared->CardIDString;
char phyParmsStr[12];
int i;
bit32 LinkRate = 15, Mode = 3, OpticalMode = 0;
bit32 LinkRateRead = agTRUE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
bit32 flag = agFALSE;
TI_DBG6(("tdsaGetCardPhyParams: start \n"));
TI_DBG6(("tdsaGetCardPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
if (tiIS_8PHY(agRoot))
{
TI_DBG6(("tdsaGetCardPhyParams: SPCv or SPCve \n"));
flag = agTRUE;
}
TI_DBG6(("tdsaGetCardPhyParams: flag %d\n", flag));
#ifdef REMOVED
#ifdef FPGA_CARD
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31;
}
#else
#ifdef INITIATOR_DRIVER
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37;
TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
#endif
#ifdef TARGET_DRIVER
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37;
TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
#endif
#endif
#endif
buffer = tmpBuffer;
buffLen = sizeof(tmpBuffer);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
if (flag == agFALSE)
{
osti_sprintf(phyParmsStr,"PhyParms%d", i);
}
else
{
if (i >= 4)
{
osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
}
else
{
osti_sprintf(phyParmsStr,"PhyParms%d", i);
}
}
TI_DBG6(("tdsaGetCardPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"AddrHi",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
TI_DBG6(("tdsaGetCardPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"AddrLow",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
TI_DBG6(("tdsaGetCardPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
TI_DBG6(("tdsaGetCardPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
}
TI_DBG6(("tdsaGetCardPhyParams: loop phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"Mode",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
ModeRead = agTRUE;
if (osti_strncmp(buffer, "0x", 2) == 0)
{
Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode 0x%x \n", i, Mode));
}
else
{
Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode %d \n", i, Mode));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"OpticalMode",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
OpticalModeRead = agTRUE;
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
}
else
{
OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
}
}
tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
LinkRateRead = agTRUE;
ModeRead = agFALSE;
OpticalModeRead = agFALSE;
}
return;
}
osGLOBAL void
tdsaGetGlobalPhyParams(
tiRoot_t *tiRoot
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
char *buffer;
bit32 buffLen;
bit32 lenRecv = 0;
char *pLastUsedChar = agNULL;
char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
char globalStr[] = "Global";
char phyParmsStr[12];
int i;
bit32 LinkRate = 15, Mode = 3, OpticalMode = 0;
bit32 LinkRateRead = agFALSE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
bit32 flag = agFALSE;
TI_DBG6(("tdsaGetGlobalPhyParams: start \n"));
TI_DBG6(("tdsaGetGlobalPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
if (tiIS_8PHY(agRoot) )
{
TI_DBG6(("tdsaGetGlobalPhyParams: SPCv or SPCve \n"));
flag = agTRUE;
}
TI_DBG6(("tdsaGetGlobalPhyParams: flag %d\n", flag));
#ifdef FPGA_CARD
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31;
}
#else
#ifdef INITIATOR_DRIVER
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
if (flag == agFALSE)
{
if (0 <= i && i <= 7)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
}
}
else
{
if (0 <= i && i <= 3)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
}
else if (4 <= i && i <= 7)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f);
}
}
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31;
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
#endif
#ifdef TARGET_DRIVER
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
if (tiIS_SPC(agRoot))
{
if (0 <= i && i <= 7)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
}
}
else if (tiIS_16PHY(agRoot))
{
if (0 <= i && i <= 7)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
}
}
else
{
if (0 <= i && i <= 3)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
}
else if (4 <= i && i <= 7)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f+i);
}
}
tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31;
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
#endif
#endif
buffer = tmpBuffer;
buffLen = sizeof(tmpBuffer);
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
for (i=0;i<TD_MAX_NUM_PHYS;i++)
{
if (flag == agFALSE)
{
osti_sprintf(phyParmsStr,"PhyParms%d", i);
}
else
{
if (i >= 4)
{
osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
}
else
{
osti_sprintf(phyParmsStr,"PhyParms%d", i);
}
}
TI_DBG6(("tdsaGetGlobalPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"AddrHi",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"AddrLow",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
else
{
OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
}
}
TI_DBG6(("tdsaGetGlobalPhyParams: loop phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"Mode",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
ModeRead = agTRUE;
if (osti_strncmp(buffer, "0x", 2) == 0)
{
Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode 0x%x \n", i, Mode));
}
else
{
Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode %d \n", i, Mode));
}
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
if ((ostiGetTransportParam (
tiRoot,
globalStr,
phyParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"OpticalMode",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
OpticalModeRead = agTRUE;
if (osti_strncmp(buffer, "0x", 2) == 0)
{
OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
}
else
{
OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
}
}
TI_DBG2(("tdsaGetGlobalPhyParams:A phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
TI_DBG2(("tdsaGetGlobalPhyParams:B phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
LinkRate = 15;
Mode = 3;
OpticalMode = 0;
LinkRateRead = agTRUE;
ModeRead = agFALSE;
OpticalModeRead = agFALSE;
}
return;
}
osGLOBAL void
tdsaGetPortParams(
tiRoot_t *tiRoot
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
char *buffer;
bit32 buffLen;
bit32 lenRecv = 0;
char *pLastUsedChar = agNULL;
char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
char globalStr[] = "Global";
char portParmsStr[] = "PortParms";
TI_DBG6(("tdsaGetPortParams: start \n"));
TI_DBG6(("tdsaGetPortParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
buffer = tmpBuffer;
buffLen = sizeof(tmpBuffer);
osti_memset(buffer, 0, buffLen);
if ((ostiGetTransportParam (
tiRoot,
globalStr,
portParmsStr,
agNULL,
agNULL,
agNULL,
agNULL,
"InterruptDelay",
buffer,
buffLen,
&lenRecv
) == tiSuccess) && (lenRecv != 0))
{
if (osti_strncmp(buffer, "0x", 2) == 0)
{
tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 0);
}
else
{
tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 10);
}
TI_DBG6(("tdsaGetPortParams: in \n"));
}
osti_memset(buffer, 0, buffLen);
lenRecv = 0;
TI_DBG6(("tdsaGetPortParams: out \n"));
return;
}
#ifdef FW_EVT_LOG_TST
void saLogDump(agsaRoot_t *agRoot,
U32 *eventLogSize,
U32 **eventLogAddress);
void tiLogDump(tiRoot_t *tiRoot, U32 *size, U32 **addr)
{
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
tdsaRoot = (tdsaRoot_t*)tiRoot->tdData;
tdsaAllShared = (tdsaContext_t*)&(tdsaRoot->tdsaAllShared);
saLogDump(&tdsaAllShared->agRootNonInt, size, addr);
}
#endif
osGLOBAL bit32
tiCOMPortInit(
tiRoot_t *tiRoot,
bit32 sysIntsActive
)
{
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
tiLoLevelResource_t *loResource;
bit32 status = tiError;
bit32 i;
agsaQueueConfig_t *QueueConfig;
#ifdef CONTROLLER_STATUS_TESTING
static agsaControllerStatus_t agcontrollerStatus;
#endif
#ifdef CONTROLLER_INFO_TESTING
static agsaControllerInfo_t agcontrollerInfo;
#endif
#ifdef CONTROLLER_ENCRYPT_TESTING
static agsaEncryptInfo_t agsaEncryptInfo;
#endif
static agsaMemoryRequirement_t agMemoryRequirement;
#ifdef ECHO_TESTING
static bit8 payload[56];
#endif
#if defined(FDS_DM) || defined(FDS_SM)
static agsaMemoryRequirement_t memRequirement;
bit32 maxQueueSets = 0;
bit32 LLMemCount = 0;
bit32 usecsPerTick = 0;
static agsaSwConfig_t tmpLLSwConfig;
#endif
#ifdef FDS_DM
static dmRoot_t *dmRoot = agNULL;
#ifdef FDS_SM
static dmSwConfig_t dmSwConfig;
#endif
static dmMemoryRequirement_t dmMemRequirement;
bit32 DMMemCount = 0;
#endif
#if defined(FDS_DM) && defined(FDS_SM)
bit32 dmUsecsPerTick = 0;
bit32 dmMaxNumLocks = 0;
#endif
#ifdef FDS_SM
smRoot_t *smRoot = agNULL;
static smMemoryRequirement_t smMemRequirement;
bit32 SMMemCount = 0;
#endif
#ifndef TURN_OFF_HDA
static agsaFwImg_t HDAImg;
#endif
TI_DBG3(("tiCOMPortInit: start\n"));
TI_DBG6(("tiCOMPortInit: sizeof agsaMemoryRequirement_t %d\n", (int)sizeof(agsaMemoryRequirement_t)));
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
osti_memset(&agMemoryRequirement, 0, sizeof(agsaMemoryRequirement_t));
if (tdsaAllShared->flags.resetInProgress == agTRUE)
{
TI_DBG1(("tiCOMPortInit: resetinProgress error\n"));
return tiError;
}
loResource = &(tdsaAllShared->loResource);
agRoot = &(tdsaAllShared->agRootNonInt);
tdsaAllShared->flags.sysIntsActive = sysIntsActive;
#ifdef CONTROLLER_STATUS_TESTING
TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
#endif
#ifdef CONTROLLER_INFO_TESTING
TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
#endif
#ifdef CONTROLLER_ENCRYPT_TESTING
TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo ) ));
#endif
tdsaGetSwConfigParams(tiRoot);
tdsaPrintSwConfig(&(tdsaAllShared->SwConfig));
tdsaAllShared->SwConfig.max_MSIX_InterruptVectors = loResource->loLevelOption.maxInterruptVectors;
tdsaAllShared->SwConfig.max_MSI_InterruptVectors = loResource->loLevelOption.max_MSI_InterruptVectors;
tdsaAllShared->SwConfig.legacyInt_X = loResource->loLevelOption.flag;
TI_DBG2(("tiCOMPortInit: got max_MSIX_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSIX_InterruptVectors));
TI_DBG2(("tiCOMPortInit: got max_MSI_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSI_InterruptVectors));
TI_DBG2(("tiCOMPortInit: got flag - legacyInt_X %d \n", tdsaAllShared->SwConfig.legacyInt_X));
if (
((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.legacyInt_X == 0))
||
((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0) &&
(tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.legacyInt_X == 0))
||
((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0) &&
(tdsaAllShared->SwConfig.legacyInt_X == 0))
||
((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
(tdsaAllShared->SwConfig.legacyInt_X != 0))
)
{
}
else
{
TI_DBG1(("tiCOMPortInit: incorrect interrupt\n"));
return tiError;
}
QueueConfig = &tdsaAllShared->QueueConfig;
for(i=0;i<QueueConfig->numInboundQueues;i++)
{
QueueConfig->inboundQueues[i].elementCount = tdsaAllShared->InboundQueueSize[i];
QueueConfig->inboundQueues[i].elementSize = tdsaAllShared->InboundQueueEleSize[i];
QueueConfig->inboundQueues[i].priority = tdsaAllShared->InboundQueuePriority[i];
QueueConfig->inboundQueues[i].reserved = 0;
TI_DBG6(("tiCOMPortInit: InboundQueuePriroity %d \n", tdsaAllShared->InboundQueuePriority[i]));
}
for(i=0;i<QueueConfig->numOutboundQueues;i++)
{
QueueConfig->outboundQueues[i].elementCount = tdsaAllShared->OutboundQueueSize[i];
QueueConfig->outboundQueues[i].elementSize = tdsaAllShared->OutboundQueueEleSize[i];
QueueConfig->outboundQueues[i].interruptDelay = tdsaAllShared->OutboundQueueInterruptDelay[i];
QueueConfig->outboundQueues[i].interruptCount = tdsaAllShared->OutboundQueueInterruptCount[i];
QueueConfig->outboundQueues[i].interruptEnable = tdsaAllShared->OutboundQueueInterruptEnable[i];
QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
if (tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0)
{
QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSIX_InterruptVectors;
}
else if (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)
{
QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSI_InterruptVectors;
}
else
{
QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
}
TI_DBG6(("tiCOMPortInit: OutboundQueueInterruptDelay %d OutboundQueueInterruptCount %d OutboundQueueInterruptEnable %d\n", tdsaAllShared->OutboundQueueInterruptDelay[i], tdsaAllShared->OutboundQueueInterruptCount[i], tdsaAllShared->OutboundQueueInterruptEnable[i]));
}
QueueConfig->queueOption = tdsaAllShared->QueueOption;
tdsaAllShared->SwConfig.param3 = (void *)QueueConfig;
tdsaAllShared->SwConfig.stallUsec = 10;
tdsaAllShared->SMPQNum = 0;
for(i=0;i<QueueConfig->numInboundQueues;i++)
{
if (QueueConfig->inboundQueues[i].priority != DEFAULT_INBOUND_QUEUE_PRIORITY)
{
tdsaAllShared->SMPQNum = i;
break;
}
}
tdsaGetHwConfigParams(tiRoot);
tdsaPrintHwConfig(&(tdsaAllShared->HwConfig));
#ifdef TARGET_DRIVER
if (tdsaAllShared->currentOperation & TD_OPERATION_TARGET)
{
ttdssGetTargetParams(tiRoot);
}
#endif
#if defined(FDS_DM) && defined(FDS_SM)
osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
saGetRequirements(agRoot,
&tmpLLSwConfig,
&memRequirement,
&usecsPerTick,
&maxQueueSets
);
TI_DBG1(("tiCOMPortInit: usecsPerTick %d\n", usecsPerTick));
TI_DBG1(("tiCOMPortInit: LL memRequirement.count %d\n", memRequirement.count));
TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
LLMemCount = memRequirement.count;
dmGetRequirements(dmRoot,
&dmSwConfig,
&dmMemRequirement,
&dmUsecsPerTick,
&dmMaxNumLocks
);
TI_DBG1(("tiCOMPortInit: DM dmmemRequirement.count %d\n", dmMemRequirement.count));
TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
DMMemCount = dmMemRequirement.count;
SMMemCount = loResource->loLevelMem.count - LLMemCount - DMMemCount;
agMemoryRequirement.count = LLMemCount;
TI_DBG1(("tiCOMPortInit: SMMemCount %d\n", SMMemCount));
#elif defined(FDS_DM)
osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
saGetRequirements(agRoot,
&tmpLLSwConfig,
&memRequirement,
&usecsPerTick,
&maxQueueSets
);
TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
LLMemCount = memRequirement.count;
DMMemCount = loResource->loLevelMem.count - LLMemCount;
agMemoryRequirement.count = LLMemCount;
#elif defined(FDS_SM)
osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
saGetRequirements(agRoot,
&tmpLLSwConfig,
&memRequirement,
&usecsPerTick,
&maxQueueSets
);
TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
LLMemCount = memRequirement.count;
SMMemCount = loResource->loLevelMem.count - LLMemCount;
agMemoryRequirement.count = LLMemCount;
#else
agMemoryRequirement.count = loResource->loLevelMem.count;
#endif
#if defined(FDS_DM) && defined(FDS_SM)
for(i=0;i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
{
TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
TI_DBG2(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
}
#endif
TI_DBG6(("tiCOMPortInit: AGSA_NUM_MEM_CHUNKS %d\n", AGSA_NUM_MEM_CHUNKS));
for(i=0;i<AGSA_NUM_MEM_CHUNKS;i++)
{
agMemoryRequirement.agMemory[i].virtPtr = agNULL;
agMemoryRequirement.agMemory[i].osHandle = agNULL;
agMemoryRequirement.agMemory[i].phyAddrUpper = 0;
agMemoryRequirement.agMemory[i].phyAddrLower = 0;
agMemoryRequirement.agMemory[i].totalLength = 0;
agMemoryRequirement.agMemory[i].numElements = 0;
agMemoryRequirement.agMemory[i].singleElementLength = 0;
agMemoryRequirement.agMemory[i].alignment = 0;
agMemoryRequirement.agMemory[i].type = 0;
agMemoryRequirement.agMemory[i].reserved = 0;
}
for(i=0;i<(int)agMemoryRequirement.count;i++)
{
TI_DBG2(("tiCOMPortInit: LL copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
agMemoryRequirement.agMemory[i].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
agMemoryRequirement.agMemory[i].osHandle = loResource->loLevelMem.mem[i].osHandle;
agMemoryRequirement.agMemory[i].phyAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
agMemoryRequirement.agMemory[i].phyAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
agMemoryRequirement.agMemory[i].totalLength = loResource->loLevelMem.mem[i].totalLength;
agMemoryRequirement.agMemory[i].numElements = loResource->loLevelMem.mem[i].numElements;
agMemoryRequirement.agMemory[i].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
agMemoryRequirement.agMemory[i].alignment = loResource->loLevelMem.mem[i].alignment;
if (loResource->loLevelMem.mem[i].type == TI_DMA_MEM)
{
agMemoryRequirement.agMemory[i].type = AGSA_DMA_MEM;
}
else if (loResource->loLevelMem.mem[i].type == TI_CACHED_MEM)
{
agMemoryRequirement.agMemory[i].type = AGSA_CACHED_MEM;
}
else if (loResource->loLevelMem.mem[i].type == TI_CACHED_DMA_MEM)
{
agMemoryRequirement.agMemory[i].type = AGSA_CACHED_DMA_MEM;
}
agMemoryRequirement.agMemory[i].reserved = loResource->loLevelMem.mem[i].reserved;
TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
loResource->loLevelMem.mem[i].physAddrUpper,
loResource->loLevelMem.mem[i].physAddrLower,
loResource->loLevelMem.mem[i].totalLength,
loResource->loLevelMem.mem[i].numElements));
TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
loResource->loLevelMem.mem[i].singleElementLength,
loResource->loLevelMem.mem[i].alignment,
loResource->loLevelMem.mem[i].type,
loResource->loLevelMem.mem[i].reserved));
}
osti_memset(&(tdsaAllShared->tdFWControlEx), 0, sizeof(tdFWControlEx_t));
TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdDeviceIdVendId %x\n",tdsaAllShared->tdDeviceIdVendId));
TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdSubVendorId= SUB_VEN_ID %x\n",tdsaAllShared->tdSubVendorId));
TI_DBG1(("tiCOMPortInit: swConfig->param1 hwDEVICE_ID_VENDID %x\n", tdsaAllShared->SwConfig.param1 ));
TI_DBG1(("tiCOMPortInit: swConfig->param2 hwSVID %x\n", tdsaAllShared->SwConfig.param2));
t_MacroCheck(agRoot);
#ifndef TURN_OFF_HDA
if (tdsaAllShared->SwConfig.hostDirectAccessSupport != 0)
{
osti_memset(&HDAImg, 0, sizeof(HDAImg));
if (tiIS_SPC(agRoot))
{
TI_DBG1(("tiCOMPortInit: SPC HDA\n"));
HDAImg.aap1Img = (bit8*)(&aap1array);
HDAImg.aap1Len = sizeof( aap1array);
HDAImg.iopImg = (bit8*)(&ioparray);
HDAImg.iopLen = sizeof( ioparray);
HDAImg.istrImg = (bit8*)(&istrarray);
HDAImg.istrLen = sizeof( istrarray);
HDAImg.ilaImg = (bit8*)(&ilaarray);
HDAImg.ilaLen = sizeof(ilaarray);
}
else if (tiIS_SPC6V(agRoot))
{
TI_DBG1(("tiCOMPortInit: SPCv HDA\n"));
HDAImg.aap1Img = (bit8*)(&spcv_aap1array);
HDAImg.aap1Len = sizeof( spcv_aap1array);
HDAImg.iopImg = (bit8*)(&spcv_ioparray);
HDAImg.iopLen = sizeof( spcv_ioparray);
HDAImg.ilaImg = (bit8*)(&spcv_ilaarray);
HDAImg.ilaLen = sizeof(spcv_ilaarray);
}
else if (tIsSPCV12G(agRoot))
{
TI_DBG1(("tiCOMPortInit: SPCv12G HDA\n"));
HDAImg.aap1Img = (bit8*)(&spcv12g_raaearray);
HDAImg.aap1Len = sizeof( spcv12g_raaearray);
HDAImg.iopImg = (bit8*)(&spcv12g_ioparray);
HDAImg.iopLen = sizeof( spcv12g_ioparray);
HDAImg.ilaImg = (bit8*)(&spcv12g_ilaarray);
HDAImg.ilaLen = sizeof(spcv12g_ilaarray);
}
else
{
TI_DBG1(("tiCOMPortInit: HDA Mode Unknown chip type 0x%08x\n",ossaHwRegReadConfig32(agRoot,0 )));
return tiError;
}
TI_DBG1(("tiCOMPortInit: HDA aap1Len 0x%08x iopLen 0x%08x ilaLen 0x%08x\n",HDAImg.aap1Len,HDAImg.iopLen,HDAImg.ilaLen ));
tdsaAllShared->SwConfig.param4 = &(HDAImg);
}
else
{
TI_DBG1(("tiCOMPortInit: HDA off\n"));
tdsaAllShared->SwConfig.param4 = agNULL;
}
#endif
if (tiIS_SPC(agRoot))
{
tdsaAllShared->SwConfig.FWConfig = 0;
tdsaAllShared->SwConfig.PortRecoveryResetTimer = 0x30032;
TI_DBG1(("tiCOMPortInit:only for SPC FWConfig set\n"));
}
tdsaAllShared->SwConfig.fatalErrorInterruptVector = loResource->loLevelOption.maxInterruptVectors > 31 ? 31 : loResource->loLevelOption.maxInterruptVectors -1;
TI_DBG1(("tiCOMPortInit: SwConfig->FWConfig 0x%x\n", tdsaAllShared->SwConfig.FWConfig));
TI_DBG1(("tiCOMPortInit: SwConfig->fatalErrorInterruptVector 0x%x\n", tdsaAllShared->SwConfig.fatalErrorInterruptVector));
TI_DBG1(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d\n", loResource->loLevelOption.usecsPerTick));
status = saInitialize(agRoot,
&agMemoryRequirement,
&(tdsaAllShared->HwConfig),
&(tdsaAllShared->SwConfig),
loResource->loLevelOption.usecsPerTick);
TI_DBG6(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d 0x%x\n", loResource->loLevelOption.usecsPerTick, loResource->loLevelOption.usecsPerTick));
if(status == AGSA_RC_FAILURE )
{
TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_FAILURE, status 0x%x\n", status));
return tiError;
}
if( status == AGSA_RC_VERSION_INCOMPATIBLE)
{
TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_VERSION_INCOMPATIBLE, status 0x%x\n", status));
return tiError;
}
tdsaAllShared->agRootInt.sdkData = tdsaAllShared->agRootNonInt.sdkData;
for(i=0;i<TD_MAX_NUM_PHYS;i++)
{
tdsaAllShared->Ports[i].flags.portInitialized = agTRUE;
}
#ifdef INITIATOR_DRIVER
TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device registration\n"));
status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED, (void *)ossaDeviceRegistrationCB);
if (status == AGSA_RC_FAILURE)
{
TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register failed\n"));
}
else
{
TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register succeeded\n"));
}
#endif
TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device de-registration\n"));
status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED, (void *)ossaDeregisterDeviceHandleCB);
if (status == AGSA_RC_FAILURE)
{
TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister failed\n"));
}
else
{
TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister succeeded\n"));
}
#ifdef ECHO_TESTING
payload[0] = gEcho;
payload[55] = gEcho;
TI_DBG2(("tiCOMPortInit: calling saEchoCommand gEcho %d\n", gEcho));
saEchoCommand(agRoot, agNULL, tdsaRotateQnumber(tiRoot, agNULL), (void *)&payload);
gEcho++;
#endif
#ifdef CONTROLLER_STATUS_TESTING
TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
#endif
#ifdef CONTROLLER_INFO_TESTING
TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
#endif
#ifdef CONTROLLER_ENCRYPT_TESTING
TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
#endif
#ifdef VPD_TESTING
tdsaVPDSet(tiRoot);
#endif
#if defined(FDS_DM) && defined(FDS_SM)
dmRoot = &(tdsaAllShared->dmRoot);
osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
dmMemRequirement.count = DMMemCount;
for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
{
TI_DBG2(("tiCOMPortInit: DM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
loResource->loLevelMem.mem[i].physAddrUpper,
loResource->loLevelMem.mem[i].physAddrLower,
loResource->loLevelMem.mem[i].totalLength,
loResource->loLevelMem.mem[i].numElements));
TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
loResource->loLevelMem.mem[i].singleElementLength,
loResource->loLevelMem.mem[i].alignment,
loResource->loLevelMem.mem[i].type,
loResource->loLevelMem.mem[i].reserved));
}
status = dmInitialize(dmRoot,
agRoot,
&dmMemRequirement,
&(tdsaAllShared->dmSwConfig),
loResource->loLevelOption.usecsPerTick);
if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
{
TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
return tiError;
}
smRoot = &(tdsaAllShared->smRoot);
osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
smMemRequirement.count = SMMemCount;
for(i=(LLMemCount + DMMemCount);i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
{
TI_DBG1(("tiCOMPortInit: SM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].type = loResource->loLevelMem.mem[i].type;
smMemRequirement.smMemory[i-LLMemCount-DMMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
loResource->loLevelMem.mem[i].physAddrUpper,
loResource->loLevelMem.mem[i].physAddrLower,
loResource->loLevelMem.mem[i].totalLength,
loResource->loLevelMem.mem[i].numElements));
TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
loResource->loLevelMem.mem[i].singleElementLength,
loResource->loLevelMem.mem[i].alignment,
loResource->loLevelMem.mem[i].type,
loResource->loLevelMem.mem[i].reserved));
}
status = smInitialize(smRoot,
agRoot,
&smMemRequirement,
&(tdsaAllShared->smSwConfig),
loResource->loLevelOption.usecsPerTick);
if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
{
TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
return tiError;
}
#elif defined(FDS_DM)
dmRoot = &(tdsaAllShared->dmRoot);
osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
dmMemRequirement.count = DMMemCount;
for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
{
TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
TI_DBG6(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
}
status = dmInitialize(dmRoot,
agRoot,
&dmMemRequirement,
&(tdsaAllShared->dmSwConfig),
loResource->loLevelOption.usecsPerTick);
if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
{
TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
return tiError;
}
#elif defined(FDS_SM)
smRoot = &(tdsaAllShared->smRoot);
osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
smMemRequirement.count = SMMemCount;
for(i=LLMemCount;i<(int)(LLMemCount + SMMemCount);i++)
{
TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
smMemRequirement.smMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
smMemRequirement.smMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
smMemRequirement.smMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
smMemRequirement.smMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
smMemRequirement.smMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
smMemRequirement.smMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
smMemRequirement.smMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
smMemRequirement.smMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
smMemRequirement.smMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
smMemRequirement.smMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
TI_DBG6(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
}
status = smInitialize(smRoot,
agRoot,
&smMemRequirement,
&(tdsaAllShared->smSwConfig),
loResource->loLevelOption.usecsPerTick);
if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
{
TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
return tiError;
}
#else
#endif
#ifdef CONTROLLER_STATUS_TESTING
TI_DBG1(("tiCOMPortInit:again saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
#endif
#ifdef CONTROLLER_INFO_TESTING
TI_DBG1(("tiCOMPortInit:again saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
#endif
#ifdef CONTROLLER_ENCRYPT_TESTING
TI_DBG1(("tiCOMPortInit:again saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
#endif
if (tiSuccess == tiCOMConfigureSgpio(tiRoot, agTRUE))
{
TI_DBG2(("tiCOMPortInit: Successfully sent request to enable SGPIO\n"));
}
else
{
TI_DBG1(("tiCOMPortInit: Failed to enable SGPIO\n"));
}
return tiSuccess;
}
static bit32 SendSgpioRequest(
tiRoot_t *tiRoot,
bit8 regType,
bit8 regIndex,
bit8 regCount,
bit32 *writeData
)
{
static bit32 buffer[128] = {0};
bit32 status = tiError;
bit32 retVal = IOCTL_CALL_FAIL;
tiIOCTLPayload_t *agIOCTLPayload = (tiIOCTLPayload_t *) buffer;
agsaSGpioReqResponse_t *pSGpioReq = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
agsaSGpioReqResponse_t *pSgpioResponse = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
do{
agIOCTLPayload->MajorFunction = IOCTL_MJ_SGPIO;
agIOCTLPayload->Length = sizeof(agsaSGpioReqResponse_t);
pSGpioReq->smpFrameType = SMP_REQUEST;
pSGpioReq->function = AGSA_WRITE_SGPIO_REGISTER;
pSGpioReq->registerType = regType;
pSGpioReq->registerIndex = regIndex;
pSGpioReq->registerCount = regCount;
memcpy(pSGpioReq->readWriteData, writeData, regCount * 4);
sgpioResponseSet = 0;
retVal = tdsaSGpioIoctlSetup(tiRoot, agNULL, agIOCTLPayload, agNULL, agNULL);
if (retVal != IOCTL_CALL_PENDING)
{
break;
}
while(!sgpioResponseSet)
{
tiCOMDelayedInterruptHandler(tiRoot, 0, 1, tiNonInterruptContext);
}
sgpioResponseSet = 0;
if(agIOCTLPayload->Status != IOCTL_ERR_STATUS_OK)
{
break;
}
if(pSgpioResponse->functionResult != 0x00)
{
break;
}
status = tiSuccess;
}while(0);
return status;
}
bit32 tiCOMConfigureSgpio(
tiRoot_t *tiRoot,
bit8 enableSgpio
)
{
bit32 status = tiError;
bit32 i;
bit8 regCount;
bit32 writeData[OSSA_SGPIO_MAX_READ_DATA_COUNT] = {0};
agsaSGpioCfg0_t *pCfg0 = (agsaSGpioCfg0_t *) &writeData[0];
agsaSGpioCfg1_t *pCfg1 = (agsaSGpioCfg1_t *) &writeData[1];
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *) &tdsaRoot->tdsaAllShared;
bit32 phyCount = tdsaAllShared->phyCount;
if (enableSgpio)
{
regCount = 2;
pCfg0->gpioEnable = 1;
pCfg1->maxActOn = 2;
pCfg1->forceActOff = 1;
}
else
{
regCount = 1;
pCfg0->gpioEnable = 0;
}
status = SendSgpioRequest(tiRoot, AGSA_SGPIO_CONFIG_REG, 0, regCount, writeData);
if((tiSuccess == status) && (enableSgpio))
{
regCount = phyCount / 4;
for(i = 0; i < regCount; i++)
{
writeData[i] = 0xA0A0A0A0;
}
status = SendSgpioRequest(tiRoot, AGSA_SGPIO_DRIVE_BY_DRIVE_TRANSMIT_REG, 0, regCount, writeData);
}
return status;
}
osGLOBAL bit32
tiCOMPortStart(
tiRoot_t * tiRoot,
bit32 portID,
tiPortalContext_t * portalContext,
bit32 option
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
agsaSASProtocolTimerConfigurationPage_t SASConfigPage;
bit32 status = AGSA_RC_FAILURE;
static bit32 IsSendSASConfigPage = agFALSE;
TI_DBG3(("tiCOMPortStart: start portID %d\n", portID));
if (tdsaAllShared->flags.resetInProgress == agTRUE)
{
TI_DBG1(("tiCOMPortStart: reset error\n"));
return tiError;
}
if (tdsaAllShared->Ports[portID].flags.portInitialized == agFALSE)
{
TI_DBG1(("tiCOMPortStart: not intialized error\n"));
return tiError;
}
if (portalContext->tdData != NULL)
{
if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
{
TI_DBG3 (("tiCOMPortStart : Cannot start port again: Port has already been started\n"));
ostiPortEvent (
tiRoot,
tiPortStarted,
tiSuccess,
(void *) tdsaAllShared->Ports[portID].tiPortalContext
);
return tiSuccess;
}
}
portalContext->tdData = &(tdsaAllShared->Ports[portID]);
TI_DBG4 (("tiCOMPortStart : saving portalconext portID %d tdsaAllShared %p\n", portID, tdsaAllShared));
tdsaAllShared->Ports[portID].tiPortalContext = portalContext;
TI_DBG4(("tiCOMPortStart : portID/phyID %d tiPortalContext %p\n", portID, tdsaAllShared->Ports[portID].tiPortalContext));
if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
{
TI_DBG1(("tiCOMPortStart: port already has been started \n"));
return tiSuccess;
}
#ifdef INITIATOR_DRIVER
tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = 0;
tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
= SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
#endif
#ifdef TARGET_DRIVER
tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp = 0;
tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
#endif
#if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
= SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
#endif
TI_DBG6(("tiCOMPortStart: before pid %d\n", portID));
tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
TI_DBG6(("tiCOMPortStart: sysIntsActive %s\n",
(tdsaAllShared->flags.sysIntsActive == agTRUE) ? "agTRUE" : "agFALSE"));
if ( tdsaAllShared->first_process == agFALSE)
{
tdsaGetGlobalPhyParams(tiRoot);
tdsaGetCardPhyParams(tiRoot);
tdsaAllShared->first_process = agTRUE;
}
TI_DBG6(("tiCOMPortStart: after pid %d\n", portID));
tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
if (tdsaAllShared->phyCalibration)
{
tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
(tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | 0x80;
tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
(tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | (portID << 8);
}
TI_DBG2(("tiCOMPortStart: tdsaAllShared->Ports[0x%x].agPhyConfig.phyProperties 0x%x\n",
portID, tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
if(gSSC_Disable)
{
tdsaAllShared->Ports[portID].agPhyConfig.phyProperties = tdsaAllShared->Ports[portID].agPhyConfig.phyProperties | 0x40000;
TI_DBG1(("tiCOMPortStart:gSSC_Disable tdsaAllShared->Ports[portID].agPhyConfig.phyProperties 0x%x\n", tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
}
if(tIsSPCV12or6G(agRoot) && !IsSendSASConfigPage)
{
osti_memset(&SASConfigPage, 0, sizeof(agsaSASProtocolTimerConfigurationPage_t));
SASConfigPage.pageCode = AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE;
SASConfigPage.MST_MSI = 3 << 15;
SASConfigPage.STP_SSP_MCT_TMO = (tdsaAllShared->STP_MCT_TMO << 16) | tdsaAllShared->SSP_MCT_TMO;
SASConfigPage.STP_FRM_TMO = (tdsaAllShared->MAX_OPEN_TIME << 24) | (tdsaAllShared->SMP_MAX_CONN_TIMER << 16) | tdsaAllShared->STP_FRM_TMO;
SASConfigPage.STP_IDLE_TMO = tdsaAllShared->stp_idle_time;
if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF)
{
SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF;
}
SASConfigPage.OPNRJT_RTRY_INTVL = (tdsaAllShared->MFD << 16) | tdsaAllShared->OPNRJT_RTRY_INTVL;
SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (tdsaAllShared->DOPNRJT_RTRY_TMO << 16) | tdsaAllShared->COPNRJT_RTRY_TMO;
SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (tdsaAllShared->DOPNRJT_RTRY_THR << 16) | tdsaAllShared->COPNRJT_RTRY_THR;
SASConfigPage.MAX_AIP = tdsaAllShared->MAX_AIP;
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.pageCode 0x%08x\n",SASConfigPage.pageCode));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MST_MSI 0x%08x\n",SASConfigPage.MST_MSI));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n",SASConfigPage.STP_SSP_MCT_TMO));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_FRM_TMO 0x%08x\n",SASConfigPage.STP_FRM_TMO));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_IDLE_TMO 0x%08x\n",SASConfigPage.STP_IDLE_TMO));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n",SASConfigPage.OPNRJT_RTRY_INTVL));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR));
TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MAX_AIP 0x%08x\n",SASConfigPage.MAX_AIP));
status = saSetControllerConfig(agRoot,
0,
AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE,
sizeof(agsaSASProtocolTimerConfigurationPage_t),
&SASConfigPage,
agNULL);
if (status != AGSA_RC_SUCCESS)
{
TI_DBG1(("tiCOMPortStart: calling saSetControllerConfig() failed\n"));
}
else
{
TI_DBG2(("tiCOMPortStart: calling saSetControllerConfig() is OK\n"));
}
IsSendSASConfigPage = agTRUE;
}
else
{
TI_DBG1(("tiCOMPortStart: saSetControllerConfig not called tIsSPCV12or6G %d IsSendSASConfigPage %d\n",tIsSPCV12or6G(agRoot),IsSendSASConfigPage));
}
status = saPhyStart(agRoot,
agNULL,
0,
portID,
&(tdsaAllShared->Ports[portID].agPhyConfig),
&(tdsaAllShared->Ports[portID].SASID)
);
TI_DBG6(("tiCOMPortStart: saPhyStart status %d\n", status));
if (status == AGSA_RC_SUCCESS)
{
TI_DBG3(("tiCOMPortStart : calling portstarted\n"));
ostiPortEvent(
tiRoot,
tiPortStarted,
tiSuccess,
(void *) tdsaAllShared->Ports[portID].tiPortalContext
);
return tiSuccess;
}
else
{
TI_DBG3(("tiCOMPortStart : cant' start port\n"));
return tiError;
}
}
osGLOBAL bit32
tiCOMPortStop (
tiRoot_t *tiRoot,
tiPortalContext_t *portalContext
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdList_t *PortContextList;
tdsaPortContext_t *onePortContext = agNULL;
agsaRoot_t *agRoot = agNULL;
bit32 i;
bit32 found = agFALSE;
#ifdef CONTROLLER_STATUS_TESTING
agsaControllerStatus_t agcontrollerStatus;
#endif
TI_DBG3(("tiCOMPortStop: start\n"));
agRoot = &(tdsaAllShared->agRootNonInt);
#ifdef CONTROLLER_STATUS_TESTING
TI_DBG1(("tiCOMPortStop: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
#endif
if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
{
TI_DBG1(("tiCOMPortStop: empty tdsaPortContext\n"));
return tiError;
}
PortContextList = tdsaAllShared->MainPortContextList.flink;
while (PortContextList != &(tdsaAllShared->MainPortContextList))
{
onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
if (onePortContext == agNULL)
{
TI_DBG1(("tiCOMPortStop: onePortContext is NULL!!!\n"));
return tiError;
}
if (onePortContext->tiPortalContext == portalContext)
{
TI_DBG6(("tiCOMPortStop: found; oneportContext ID %d\n", onePortContext->id));
found = agTRUE;
break;
}
PortContextList = PortContextList->flink;
}
if (found == agFALSE)
{
TI_DBG1(("tiCOMPortStop: No corressponding tdsaPortContext\n"));
return tiError;
}
#ifdef INITIATOR_DRIVER
onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED;
onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START;
#endif
onePortContext->Count = 0;
onePortContext->agContext.osData = onePortContext;
for(i=0;i<TD_MAX_NUM_PHYS;i++)
{
if (onePortContext->PhyIDList[i] == agTRUE)
{
tdsaAllShared->Ports[i].portContext = agNULL;
#ifdef CCFLAGS_PHYCONTROL_COUNTS
if( tiIS_SPC(agRoot) )
{
saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_ERROR_COUNTS, agNULL);
saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_CLEAR_ERROR_COUNTS, agNULL);
saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_BW_COUNTS, agNULL);
}
else
{
TI_DBG1(("\ntiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_PAGE, i);
saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_BW_COUNTERS_PAGE,i);
saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE,i);
saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_GENERAL_STATUS_PAGE,i);
saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE,i);
TI_DBG1(("tiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
}
#endif
saPhyStop(agRoot, &onePortContext->agContext, 0, i);
}
}
return tiSuccess;
}
osGLOBAL bit32 tiCOMGetPortInfo(
tiRoot_t *tiRoot,
tiPortalContext_t *portalContext,
tiPortInfo_t *tiPortInfo
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdList_t *PortContextList;
tdsaPortContext_t *onePortContext = agNULL;
bit32 found = agFALSE;
static bit8 localname[68], remotename[68];
TI_DBG6(("tiCOMGetPortInfo: start\n"));
tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
{
tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
TI_DBG1(("tiCOMGetPortInfo: No tdsaPortContext\n"));
return tiError;
}
else
{
tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
}
PortContextList = tdsaAllShared->MainPortContextList.flink;
while (PortContextList != &(tdsaAllShared->MainPortContextList))
{
onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
TI_DBG3(("tiCOMGetPortInfo: oneportContext pid %d\n", onePortContext->id));
if (onePortContext->tiPortalContext == portalContext && onePortContext->valid == agTRUE)
{
TI_DBG3(("tiCOMGetPortInfo: found; oneportContext pid %d\n", onePortContext->id));
found = agTRUE;
break;
}
PortContextList = PortContextList->flink;
}
if (found == agFALSE)
{
TI_DBG1(("tiCOMGetPortInfo: First, No corresponding tdsaPortContext\n"));
return tiError;
}
if (onePortContext == agNULL)
{
TI_DBG1(("tiCOMGetPortInfo: Second, No corressponding tdsaPortContext\n"));
return tiError;
}
osti_memset(localname, 0, sizeof(localname));
osti_memset(remotename, 0, sizeof(remotename));
if ( onePortContext->sasRemoteAddressHi == 0xFFFFFFFF && onePortContext->sasRemoteAddressLo == 0xFFFFFFFF)
{
osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
tiPortInfo->localNameLen = 8;
osti_memcpy(remotename, onePortContext->remoteName, 68);
tiPortInfo->remoteNameLen = 68;
}
else
{
osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
tiPortInfo->localNameLen = 8;
osti_memcpy(remotename, &(onePortContext->sasRemoteAddressHi), 4);
osti_memcpy(&(remotename[4]), &(onePortContext->sasRemoteAddressLo), 4);
tiPortInfo->remoteNameLen = 8;
}
tiPortInfo->localName = (char *)&localname;
tiPortInfo->remoteName = (char *)&remotename;
return tiSuccess;
}
osGLOBAL bit32 tiCOMSetControllerConfig (
tiRoot_t *tiRoot,
bit32 modePage,
bit32 length,
void *buffer,
void *context)
{
agsaRoot_t *agRoot;
bit32 returnCode = AGSA_RC_BUSY;
bit32 tiStatus = tiSuccess;
tdsaRoot_t *tdsaRoot ;
tdsaContext_t *tdsaAllShared ;
TD_ASSERT(tiRoot, "tiRoot");
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot, "tdsaRoot");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared, "tdsaAllShared");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot, "agRoot");
agRoot = &(tdsaAllShared->agRootNonInt);
TI_DBG1(("tiCOMSetControllerConfig:\n" ));
if ( ((modePage == TI_INTERRUPT_CONFIGURATION_PAGE) && (length != sizeof(tiInterruptConfigPage_t ))) ||
((modePage == TI_ENCRYPTION_GENERAL_CONFIG_PAGE) && (length != sizeof(tiEncryptGeneralPage_t ))) ||
((modePage == TI_ENCRYPTION_DEK_CONFIG_PAGE) && (length != sizeof(tiEncryptDekConfigPage_t))) ||
((modePage == TI_ENCRYPTION_CONTROL_PARM_PAGE) && (length != sizeof(tiEncryptControlParamPage_t ))) ||
((modePage == TI_ENCRYPTION_HMAC_CONFIG_PAGE) && (length != sizeof(tiEncryptHMACConfigPage_t ))) ||
((modePage == TI_SAS_PROTOCOL_TIMER_CONFIG_PAGE) && (length != sizeof(tiSASProtocolTimerConfigurationPage_t ))) )
{
tiStatus = tiError;
}
else
{
returnCode = saSetControllerConfig(agRoot, 0, modePage, length, buffer, context);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMGetControllerConfig (
tiRoot_t *tiRoot,
bit32 modePage,
bit32 flag,
void *context)
{
agsaRoot_t *agRoot;
bit32 returnCode = AGSA_RC_BUSY;
bit32 tiStatus = tiSuccess;
tdsaRoot_t *tdsaRoot ;
tdsaContext_t *tdsaAllShared ;
TD_ASSERT(tiRoot, "tiRoot");
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot, "tdsaRoot");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared, "tdsaAllShared");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot, "agRoot");
agRoot = &(tdsaAllShared->agRootNonInt);
TI_DBG1(("tiCOMGetControllerConfig: modePage 0x%x context %p\n",modePage,context ));
returnCode = saGetControllerConfig(agRoot, 0, modePage, flag, 0, context);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiSuccess\n",modePage ));
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiBusy\n",modePage ));
}
else
{
tiStatus = tiError;
TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiError\n",modePage ));
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptGetInfo(tiRoot_t *tiRoot)
{
tiEncryptInfo_t tiEncryptInfo;
agsaEncryptInfo_t agsaEncryptInfo;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agsaRoot_t *agRoot;
tiEncryptPort_t tiEncryptPort;
bit32 returnCode;
bit32 tiStatus;
agRoot = &(tdsaAllShared->agRootNonInt);
returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
TI_DBG1(("tiCOMEncryptGetInfo: returnCode 0x%x\n", returnCode));
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
osti_memset(&tiEncryptInfo, 0x0, sizeof(tiEncryptInfo_t));
if (agsaEncryptInfo.encryptionCipherMode == agsaEncryptCipherModeXTS)
{
tiEncryptInfo.securityCipherMode = TI_ENCRYPT_ATTRIB_CIPHER_XTS;
}
if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMF)
{
tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_FACT_INIT;
}
else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMA)
{
tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_A;
}
else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMB)
{
tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_B;
}
tiEncryptInfo.status = agsaEncryptInfo.status;
tiEncryptPort.pData = &tiEncryptInfo;
tiEncryptPort.encryptEvent = tiEncryptGetInfo;
tiEncryptPort.subEvent = 0;
ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
}
else
{
if (returnCode == AGSA_RC_NOT_SUPPORTED)
{
tiStatus = tiNotSupported;
TI_DBG1(("tiCOMEncryptGetInfo: tiNotSupported\n"));
}
else
{
TI_DBG1(("tiCOMEncryptGetInfo: tiError returnCode 0x%x\n",returnCode));
tiStatus = tiError;
}
tiEncryptPort.pData = NULL;
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptSetMode(tiRoot_t *tiRoot,
bit32 securityCipherMode)
{
bit32 returnCode;
bit32 tiStatus;
agsaEncryptInfo_t mode;
agsaEncryptInfo_t *pmode = &mode;
tdsaRoot_t *tdsaRoot ;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
TD_ASSERT(tiRoot, "tiRoot");
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot, "tdsaRoot");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared, "tdsaAllShared");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot, "agRoot");
pmode->encryptionSecurityMode = 0;
pmode->encryptionCipherMode = 0;
pmode->status = 0;
TI_DBG1(("tiCOMEncryptSetMode:\n"));
if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_A ) == TI_ENCRYPT_SEC_MODE_A)
{
pmode->encryptionSecurityMode = agsaEncryptSMA;
}
if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_B ) == TI_ENCRYPT_SEC_MODE_B)
{
pmode->encryptionSecurityMode = agsaEncryptSMB;
}
if( (securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_XTS) == TI_ENCRYPT_ATTRIB_CIPHER_XTS)
{
pmode->encryptionCipherMode |= agsaEncryptCipherModeXTS;
}
if(( securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_ECB) == TI_ENCRYPT_ATTRIB_CIPHER_ECB)
{
return tiError;
}
returnCode = saEncryptSetMode(agRoot,agNULL, 0, pmode );
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
TI_DBG1(("tiCOMEncryptSetMode:tiBusy\n"));
tiStatus = tiBusy;
}
else
{
TI_DBG1(("tiCOMEncryptSetMode:tiError\n"));
tiStatus = tiError;
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptDekAdd(tiRoot_t *tiRoot,
bit32 kekIndex,
bit32 dekTableSelect,
bit32 dekAddrHi,
bit32 dekAddrLo,
bit32 dekIndex,
bit32 dekNumberOfEntries,
bit32 dekBlobFormat,
bit32 dekTableKeyEntrySize
)
{
agsaRoot_t *agRoot;
bit32 returnCode;
bit32 tiStatus;
tdsaRoot_t *tdsaRoot ;
tdsaContext_t *tdsaAllShared ;
TD_ASSERT(tiRoot, "tiRoot");
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot, "tdsaRoot");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared, "tdsaAllShared");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot, "agRoot");
agRoot = &(tdsaAllShared->agRootNonInt);
TI_DBG1(("tiCOMEncryptDekAdd:\n" ));
returnCode = saEncryptDekCacheUpdate(agRoot,
agNULL,
0,
kekIndex,
dekTableSelect,
dekAddrHi,
dekAddrLo,
dekIndex,
dekNumberOfEntries,
dekBlobFormat,
dekTableKeyEntrySize
);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptDekInvalidate(tiRoot_t *tiRoot,
bit32 dekTable,
bit32 dekIndex)
{
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
tiEncryptPort_t tiEncryptPort;
tiEncryptDek_t tiEncryptDek;
bit32 returnCode;
bit32 tiStatus;
TD_ASSERT(tiRoot, "tiRoot");
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot, "tdsaRoot");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared, "tdsaAllShared");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot, "agRoot");
TI_DBG1(("tiCOMEncryptDekInvalidate:dekTable 0x%x dekIndex 0x%x\n", dekTable, dekIndex));
returnCode = saEncryptDekCacheInvalidate(agRoot, agNULL, 0, dekTable, dekIndex);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else
{
if (returnCode == AGSA_RC_NOT_SUPPORTED)
{
tiStatus = tiNotSupported;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
tiEncryptDek.dekTable = dekTable;
tiEncryptDek.dekIndex = dekIndex;
tiEncryptPort.encryptEvent = tiEncryptDekInvalidate;
tiEncryptPort.subEvent = 0;
tiEncryptPort.pData = (void *) &tiEncryptDek;
ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptKekAdd(tiRoot_t *tiRoot,
bit32 kekIndex,
bit32 wrapperKekIndex,
bit32 blobFormat,
tiEncryptKekBlob_t *encryptKekBlob)
{
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
bit32 returnCode= AGSA_RC_BUSY;
bit32 tiStatus= tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agRoot = &(tdsaAllShared->agRootNonInt);
TI_DBG1(("tiCOMEncryptDekInvalidate: kekIndex 0x%x wrapperKekIndex 0x%x\n", kekIndex , wrapperKekIndex));
returnCode = saEncryptKekUpdate(agRoot,
agNULL,
0,
AGSA_ENCRYPT_STORE_NVRAM,
kekIndex,
wrapperKekIndex,
blobFormat,
(agsaEncryptKekBlob_t *) encryptKekBlob);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
return(tiStatus);
}
#ifdef HIALEAH_ENCRYPTION
osGLOBAL bit32 tiCOMEncryptHilSet(tiRoot_t *tiRoot )
{
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
agsaEncryptInfo_t agsaEncryptInfo;
bit32 returnCode= tiBusy;
bit32 tiStatus= tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agRoot = &(tdsaAllShared->agRootNonInt);
returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
TI_DBG1(("tiCOMEncryptHilSet: saEncryptGetMode returnCode 0x%x agsaEncryptInfo status 0x%x Smode 0x%x CMode 0x%x\n",
returnCode,
agsaEncryptInfo.status,
agsaEncryptInfo.encryptionSecurityMode,
agsaEncryptInfo.encryptionCipherMode ));
if (returnCode == AGSA_RC_FAILURE)
{
TI_DBG1(("tiCOMEncryptHilSet:agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
if(agsaEncryptInfo.status == 0x81)
{
TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISMATCH agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
returnCode = saEncryptHilUpdate(agRoot,
agNULL,
0 );
if (returnCode == AGSA_RC_SUCCESS)
{
TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_SUCCESS\n"));
}
}
else if(agsaEncryptInfo.status == 0x80)
{
ostidisableEncryption(tiRoot);
TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISSING agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
returnCode = AGSA_RC_SUCCESS;
}
else
{
TI_DBG1(("tiCOMEncryptHilSet: not status 0x81 agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
returnCode = AGSA_RC_FAILURE;
}
}
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_BUSY\n"));
tiStatus = tiBusy;
}
else
{
TI_DBG1(("tiCOMEncryptHilSet:tiError\n"));
tiStatus = tiError;
}
return(tiStatus);
}
#endif
osGLOBAL bit32 tiCOMEncryptKekStore(tiRoot_t *tiRoot,
bit32 kekIndex)
{
#ifdef NOT_YET
tdsaRoot_t *tdsaRoot;
tdsaContext_t *tdsaAllShared;
agsaRoot_t *agRoot;
#endif
bit32 tiStatus = tiError;
#ifdef NOT_YET
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agRoot = &(tdsaAllShared->agRootNonInt);
#endif
TI_DBG1(("tiCOMEncryptKekStore: Needs code !!!! kekIndex 0x%x\n", kekIndex ));
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptKekLoad(tiRoot_t *tiRoot,
bit32 kekIndex)
{
#ifdef NOT_YET
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
agsaRoot_t *agRoot;
#endif
bit32 tiStatus = tiError;
#ifdef NOT_YET
agRoot = &(tdsaAllShared->agRootNonInt);
#endif
return(tiStatus);
}
osGLOBAL bit32 tiCOMEncryptSelfTest(
tiRoot_t *tiRoot,
bit32 type,
bit32 length,
void *TestDescriptor
)
{
tdsaRoot_t *tdsaRoot = agNULL;
tdsaContext_t *tdsaAllShared = agNULL;
agsaRoot_t *agRoot = agNULL;
bit32 returnCode = AGSA_RC_BUSY;
bit32 tiStatus = tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
TI_DBG1(("tiCOMEncryptSelfTest: type = 0x%x length = 0x%x\n", type, length));
if ( ((type == TI_ENCRYPTION_TEST_TYPE_BIST) && (length != sizeof(tiEncryptSelfTestDescriptor_t ))) ||
((type == TI_ENCRYPTION_TEST_TYPE_HMAC) && (length != sizeof(tiEncryptHMACTestDescriptor_t))) )
{
TI_DBG1(("tiCOMEncryptSelfTest: type or length error, type 0x%x length 0x%x\n", type, length));
tiStatus = tiError;
}
else
{
returnCode = saEncryptSelftestExecute(agRoot,
agNULL,
0,
type,
length,
TestDescriptor
);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMSetOperator(
tiRoot_t *tiRoot,
bit32 flag,
void *cert
)
{
tdsaRoot_t *tdsaRoot = agNULL;
tdsaContext_t *tdsaAllShared = agNULL;
agsaRoot_t *agRoot = agNULL;
bit32 returnCode = AGSA_RC_FAILURE;
bit32 tiStatus = tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
TI_DBG1(("tiCOMSetOperator: flag = 0x%x \n", flag));
returnCode = saSetOperator(agRoot,
agNULL,
0,
flag,
cert);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMGetOperator(
tiRoot_t *tiRoot,
bit32 option,
bit32 AddrHi,
bit32 AddrLo
)
{
tdsaRoot_t *tdsaRoot = agNULL;
tdsaContext_t *tdsaAllShared = agNULL;
agsaRoot_t *agRoot = agNULL;
bit32 returnCode = AGSA_RC_FAILURE;
bit32 tiStatus = tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
TI_DBG1(("tiCOMGetOperator: option = 0x%x \n", option));
returnCode = saGetOperator(agRoot,
agNULL,
0,
option,
AddrHi,
AddrLo);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
return(tiStatus);
}
osGLOBAL bit32 tiCOMOperatorManagement(
tiRoot_t *tiRoot,
bit32 flag,
bit8 role,
tiID_t *idString,
tiEncryptKekBlob_t *kekBlob
)
{
tdsaRoot_t *tdsaRoot = agNULL;
tdsaContext_t *tdsaAllShared = agNULL;
agsaRoot_t *agRoot = agNULL;
bit32 returnCode = AGSA_RC_BUSY;
bit32 tiStatus = tiError;
tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
agRoot = &(tdsaAllShared->agRootNonInt);
TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
TI_DBG1(("tiCOMOperatorManagement: flag = 0x%x role = 0x%x\n", flag, role));
returnCode = saOperatorManagement(agRoot,
agNULL,
0,
flag,
role,
(agsaID_t*)idString,
(agsaEncryptKekBlob_t *)kekBlob
);
if (returnCode == AGSA_RC_SUCCESS)
{
tiStatus = tiSuccess;
}
else if (returnCode == AGSA_RC_BUSY)
{
tiStatus = tiBusy;
}
else
{
tiStatus = tiError;
}
return(tiStatus);
}
#ifdef INITIATOR_DRIVER
osGLOBAL void
tdssRemoveSASSATAFromSharedcontext(
agsaRoot_t *agRoot,
tdsaPortContext_t *PortContext_Instance
)
{
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: start\n"));
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d\n", PortContext_Instance->id));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: oneDeviceData is NULL!!!\n"));
return;
}
if (oneDeviceData->tdPortContext == PortContext_Instance)
{
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d did %d\n", PortContext_Instance->id, oneDeviceData->id));
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
oneDeviceData->valid = agFALSE;
oneDeviceData->valid2 = agFALSE;
oneDeviceData->registered = agFALSE;
if ( DEVICE_IS_SSP_TARGET(oneDeviceData) ||
DEVICE_IS_STP_TARGET(oneDeviceData) ||
DEVICE_IS_SATA_DEVICE(oneDeviceData)
)
{
ostiInitiatorEvent(
tiRoot,
PortContext_Instance->tiPortalContext,
&(oneDeviceData->tiDeviceHandle),
tiIntrEventTypeDeviceChange,
tiDeviceRemoval,
agNULL
);
}
DeviceListList = DeviceListList->flink;
#ifdef REMOVED
TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
#endif
}
else
{
TI_DBG6(("tdssRemoveSASSATAFromSharedcontext: move to the next\n"));
DeviceListList = DeviceListList->flink;
}
}
return;
}
osGLOBAL void
tdssRemoveSASSATAFromSharedcontextByReset(
agsaRoot_t *agRoot
)
{
tdsaPortContext_t *onePortContext = agNULL;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *PortContextList;
tdList_t *DeviceListList;
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
#ifdef FDS_DM
dmRoot_t *dmRoot = agNULL;
dmPortContext_t *dmPortContext = agNULL;
dmPortInfo_t dmPortInfo;
#endif
#ifdef FDS_SM
smRoot_t *smRoot = &(tdsaAllShared->smRoot);
smDeviceHandle_t *smDeviceHandle = agNULL;
agsaDevHandle_t *agDevHandle = agNULL;
#endif
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: start\n"));
#ifdef FDS_DM
dmRoot = &(tdsaAllShared->dmRoot);
#endif
PortContextList = tdsaAllShared->MainPortContextList.flink;
while (PortContextList != &(tdsaAllShared->MainPortContextList))
{
onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
if (onePortContext == agNULL)
{
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: onePortContext is NULL!!!\n"));
return;
}
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneportContext pid %d\n", onePortContext->id));
TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", onePortContext->sasLocalAddressHi));
TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", onePortContext->sasLocalAddressLo));
#ifdef FDS_DM
if (onePortContext->UseDM == agTRUE)
{
dmPortContext = &(onePortContext->dmPortContext);
dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo);
}
#endif
tdsaPortContextReInit(tiRoot, onePortContext);
PortContextList = PortContextList->flink;
tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
}
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneDeviceData is NULL!!!\n"));
return;
}
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: did %d\n", oneDeviceData->id));
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
#ifdef FDS_SM
agDevHandle = oneDeviceData->agDevHandle;
smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
smDeregisterDevice(smRoot, agDevHandle, smDeviceHandle);
#endif
tdsaDeviceDataReInit(tiRoot, oneDeviceData);
DeviceListList = DeviceListList->flink;
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
}
return;
}
#endif
osGLOBAL void
tdssAddSASToSharedcontext(
tdsaPortContext_t *tdsaPortContext_Instance,
agsaRoot_t *agRoot,
agsaDevHandle_t *agDevHandle,
tdsaSASSubID_t *agSASSubID,
bit32 registered,
bit8 phyID,
bit32 flag
)
{
tdsaPortContext_t *onePortContext = agNULL;
tdList_t *PortContextList;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
bit32 new_device = agTRUE;
bit32 Indenom = tdsaAllShared->QueueConfig.numInboundQueues;
bit32 Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues;
bit8 dev_s_rate = 0;
bit8 sasorsata = 1;
bit8 connectionRate;
bit32 found = agFALSE;
TI_DBG3(("tdssAddSASToSharedcontext: start\n"));
PortContextList = tdsaAllShared->MainPortContextList.flink;
while (PortContextList != &(tdsaAllShared->MainPortContextList))
{
onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
if (onePortContext == tdsaPortContext_Instance)
{
TI_DBG3(("tdssAddSASToSharedContext: found; oneportContext ID %d\n", onePortContext->id));
found = agTRUE;
break;
}
PortContextList = PortContextList->flink;
}
if (found == agTRUE)
{
TI_DBG3(("tdssAddSASToSharedcontext: found pid %d\n", onePortContext->id));
}
else
{
TI_DBG1(("tdssAddSASToSharedcontext: Error!!! no portcontext found!!!\n"));
return;
}
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
return;
}
if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
(oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
(oneDeviceData->tdPortContext == onePortContext)
)
{
TI_DBG1(("tdssAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
new_device = agFALSE;
break;
}
DeviceListList = DeviceListList->flink;
}
if (new_device == agTRUE)
{
TI_DBG3(("tdssAddSASToSharedcontext: new device\n"));
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
{
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG1(("tdssAddSASToSharedContext: empty DeviceData FreeLink\n"));
return;
}
TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
onePortContext->Count++;
oneDeviceData->DeviceType = TD_SAS_DEVICE;
oneDeviceData->agRoot = agRoot;
if (flag == TD_OPERATION_TARGET)
{
oneDeviceData->agDevHandle = agDevHandle;
agDevHandle->osData = oneDeviceData;
}
oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
oneDeviceData->tdPortContext = onePortContext;
oneDeviceData->valid = agTRUE;
oneDeviceData->directlyAttached = agTRUE;
DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
sasorsata = SAS_DEVICE_TYPE;
connectionRate = onePortContext->LinkRate;
dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
dev_s_rate = (bit8)(dev_s_rate | connectionRate);
DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
DEVINFO_PUT_SAS_ADDRESSLO(
&oneDeviceData->agDeviceInfo,
agSASSubID->sasAddressLo
);
DEVINFO_PUT_SAS_ADDRESSHI(
&oneDeviceData->agDeviceInfo,
agSASSubID->sasAddressHi
);
oneDeviceData->agContext.osData = oneDeviceData;
oneDeviceData->agContext.sdkData = agNULL;
if (flag == TD_OPERATION_INITIATOR)
{
if (oneDeviceData->registered == agFALSE )
{
if( tdsaAllShared->sflag )
{
if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
{
TI_DBG1(("tdssAddSASToSharedcontext: First, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
}
}
saRegisterNewDevice(
agRoot,
&oneDeviceData->agContext,
0,
&oneDeviceData->agDeviceInfo,
onePortContext->agPortContext,
0
);
}
}
oneDeviceData->phyID = phyID;
oneDeviceData->InQID = oneDeviceData->id % Indenom;
#ifdef TARGET_DRIVER
{
bit32 localId = oneDeviceData->id;
localId += 1;
oneDeviceData->OutQID = localId % Outdenom;
TI_DBG1(("tdssAddSASToSharedcontext: OutQID %d\n", oneDeviceData->OutQID));
}
#endif
TI_DBG4(("tdssAddSASToSharedcontext: SSP target %d STP target %d SATA device %d\n", DEVICE_IS_SSP_TARGET(oneDeviceData), DEVICE_IS_STP_TARGET(oneDeviceData), DEVICE_IS_SATA_DEVICE(oneDeviceData)));
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG4(("tdssAddSASToSharedContext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
TI_DBG4(("tdssAddSASToSharedContext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
}
else
{
TI_DBG3(("tdssAddSASToSharedcontext: old device\n"));
TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
oneDeviceData->DeviceType = TD_SAS_DEVICE;
oneDeviceData->agRoot = agRoot;
if (flag == TD_OPERATION_TARGET)
{
oneDeviceData->agDevHandle = agDevHandle;
agDevHandle->osData = oneDeviceData;
}
oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
oneDeviceData->tdPortContext = onePortContext;
oneDeviceData->valid = agTRUE;
oneDeviceData->directlyAttached = agTRUE;
if (oneDeviceData->registered == agFALSE)
{
TI_DBG1(("tdssAddSASToSharedcontext: registering\n"));
DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
sasorsata = SAS_DEVICE_TYPE;
connectionRate = onePortContext->LinkRate;
dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
dev_s_rate = (bit8)(dev_s_rate | connectionRate);
DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
DEVINFO_PUT_SAS_ADDRESSLO(
&oneDeviceData->agDeviceInfo,
agSASSubID->sasAddressLo
);
DEVINFO_PUT_SAS_ADDRESSHI(
&oneDeviceData->agDeviceInfo,
agSASSubID->sasAddressHi
);
oneDeviceData->agContext.osData = oneDeviceData;
oneDeviceData->agContext.sdkData = agNULL;
if (flag == TD_OPERATION_INITIATOR)
{
if( tdsaAllShared->sflag )
{
if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
{
TI_DBG1(("tdssAddSASToSharedcontext: Second, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
}
}
saRegisterNewDevice(
agRoot,
&oneDeviceData->agContext,
0,
&oneDeviceData->agDeviceInfo,
onePortContext->agPortContext,
0
);
}
}
oneDeviceData->phyID = phyID;
oneDeviceData->InQID = oneDeviceData->id % Indenom;
oneDeviceData->OutQID = oneDeviceData->id % Outdenom;
TI_DBG1(("tdssAddSASToSharedcontext: A OutQID %d\n", oneDeviceData->OutQID));
TI_DBG4(("tdssAddSASToSharedcontext: SSP target %d STP target %d SATA device %d\n", DEVICE_IS_SSP_TARGET(oneDeviceData), DEVICE_IS_STP_TARGET(oneDeviceData), DEVICE_IS_SATA_DEVICE(oneDeviceData)));
TI_DBG4(("tdssAddSASToSharedContext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
}
return;
}
osGLOBAL void
tdssRemoveSASFromSharedcontext(
tdsaPortContext_t *tdsaPortContext_Ins,
tdsaDeviceData_t *tdsaDeviceData_Ins,
agsaRoot_t *agRoot
)
{
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdsaPortContext_t *onePortContext = agNULL;
tdList_t *PortContextList;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
bit32 found = agTRUE;
TI_DBG3(("tdssRemoveSASFromSharedcontext: start\n"));
PortContextList = tdsaAllShared->MainPortContextList.flink;
while (PortContextList != &(tdsaAllShared->MainPortContextList))
{
onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
if (onePortContext == agNULL)
{
TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: onePortContext is NULL!!!\n"));
return;
}
if (onePortContext == tdsaPortContext_Ins)
{
TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: found; oneportContext ID %d\n", onePortContext->id));
break;
}
PortContextList = PortContextList->flink;
}
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: oneDeviceData is NULL!!!\n"));
return;
}
if ((oneDeviceData->SASAddressID.sasAddressHi
== SA_DEVINFO_GET_SAS_ADDRESSHI(&tdsaDeviceData_Ins->agDeviceInfo))
&&
(oneDeviceData->SASAddressID.sasAddressLo ==
SA_DEVINFO_GET_SAS_ADDRESSLO(&tdsaDeviceData_Ins->agDeviceInfo)))
{
TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
found = agFALSE;
break;
}
DeviceListList = DeviceListList->flink;
}
if (found == agFALSE)
{
TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: can't find the right devicedata in MainLink\n"));
return;
}
TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: removing ... pid %d did %d\n", onePortContext->id, oneDeviceData->id));
oneDeviceData->valid = agFALSE;
return;
}
osGLOBAL void
tdssRemoveAllDevicelistFromPortcontext(
tdsaPortContext_t *PortContext_Ins,
agsaRoot_t *agRoot
)
{
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
TI_DBG6(("tdssRemoveAllDevicedataFromPortcontext: start\n"));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssRemoveAllDevicelistFromPortcontext: oneDeviceData is NULL!!!\n"));
return;
}
if (oneDeviceData->tdPortContext == PortContext_Ins)
{
TI_DBG4(("tdssRemoveAllDevicelistFromPortcontext: pid %d did %d\n", PortContext_Ins->id, oneDeviceData->id));
PortContext_Ins->Count--;
oneDeviceData->valid = agFALSE;
}
DeviceListList = DeviceListList->flink;
}
return;
}
#ifdef INITIATOR_DRIVER
#ifdef TD_DISCOVER
osGLOBAL tdsaDeviceData_t *
tdssNewAddSASToSharedcontext(
agsaRoot_t *agRoot,
tdsaPortContext_t *onePortContext,
tdsaSASSubID_t *agSASSubID,
tdsaDeviceData_t *oneExpDeviceData,
bit8 phyID
)
{
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
bit32 new_device = agTRUE;
TI_DBG3(("tdssNewAddSASToSharedcontext: start\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: oneportContext ID %d\n", onePortContext->id));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdssNewAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
return agNULL;
}
if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
(oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
(oneDeviceData->tdPortContext == onePortContext)
)
{
TI_DBG3(("tdssNewAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
new_device = agFALSE;
break;
}
DeviceListList = DeviceListList->flink;
}
if (new_device == agTRUE)
{
TI_DBG3(("tdssNewAddSASToSharedcontext: new device\n"));
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
{
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG1(("tdssNewAddSASToSharedcontext: empty DeviceData FreeLink\n"));
return agNULL;
}
TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
onePortContext->Count++;
oneDeviceData->agRoot = agRoot;
oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
oneDeviceData->tdPortContext = onePortContext;
if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
{
oneDeviceData->DeviceType = TD_SAS_DEVICE;
}
else
{
oneDeviceData->DeviceType = TD_SATA_DEVICE;
}
oneDeviceData->ExpDevice = oneExpDeviceData;
if (oneDeviceData->phyID == 0xFF)
{
oneDeviceData->phyID = phyID;
}
#ifdef FDS_DM
oneDeviceData->valid = agTRUE;
#else
if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
{
TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
oneDeviceData->valid2 = agTRUE;
}
else
{
TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
oneDeviceData->valid = agTRUE;
}
#endif
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG4(("tdssNewAddSASToSharedcontext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
TI_DBG4(("tdssNewAddSASToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
}
else
{
TI_DBG3(("tdssNewAddSASToSharedcontext: old device\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
oneDeviceData->agRoot = agRoot;
oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
oneDeviceData->tdPortContext = onePortContext;
if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
{
oneDeviceData->DeviceType = TD_SAS_DEVICE;
}
else
{
oneDeviceData->DeviceType = TD_SATA_DEVICE;
}
oneDeviceData->ExpDevice = oneExpDeviceData;
if (oneDeviceData->phyID == 0xFF)
{
oneDeviceData->phyID = phyID;
}
#ifdef FDS_DM
oneDeviceData->valid = agTRUE;
#else
if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
{
TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
oneDeviceData->valid2 = agTRUE;
}
else
{
TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
oneDeviceData->valid = agTRUE;
}
#endif
TI_DBG4(("tdssNewAddSASToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
}
return oneDeviceData;
}
osGLOBAL tdsaDeviceData_t *
tdsaFindRegNValid(
agsaRoot_t *agRoot,
tdsaPortContext_t *onePortContext,
tdsaSASSubID_t *agSASSubID
)
{
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
bit32 found = agFALSE;
TI_DBG3(("tdsaFindRegNValid: start\n"));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_FULL_START)
{
TI_DBG3(("tdsaFindRegNValid: Full discovery\n"));
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
return agNULL;
}
if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
(oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
(oneDeviceData->registered == agTRUE) &&
(oneDeviceData->valid == agTRUE) &&
(oneDeviceData->tdPortContext == onePortContext)
)
{
TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
found = agTRUE;
break;
}
DeviceListList = DeviceListList->flink;
}
}
else
{
TI_DBG3(("tdsaFindRegNValid: Incremental discovery\n"));
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if (oneDeviceData == agNULL)
{
TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
return agNULL;
}
if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
(oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
(oneDeviceData->registered == agTRUE) &&
(oneDeviceData->valid2 == agTRUE) &&
(oneDeviceData->tdPortContext == onePortContext)
)
{
TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
found = agTRUE;
break;
}
DeviceListList = DeviceListList->flink;
}
}
if (found == agFALSE)
{
TI_DBG3(("tdsaFindRegNValid: end returning NULL\n"));
return agNULL;
}
else
{
TI_DBG3(("tdsaFindRegNValid: end returning NOT NULL\n"));
return oneDeviceData;
}
}
bit32
tdssNewSASorNot(
agsaRoot_t *agRoot,
tdsaPortContext_t *onePortContext,
tdsaSASSubID_t *agSASSubID
)
{
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
bit32 ret = agTRUE;
TI_DBG3(("tdssNewSASorNot: start\n"));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
(oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
(oneDeviceData->registered == agTRUE) &&
(oneDeviceData->tdPortContext == onePortContext)
)
{
TI_DBG3(("tdssNewSASorNot: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
ret = agFALSE;
break;
}
DeviceListList = DeviceListList->flink;
}
TI_DBG3(("tdssNewSASorNot: end\n"));
return ret;
}
osGLOBAL tdsaExpander_t *
tdssSASDiscoveringExpanderAlloc(
tiRoot_t *tiRoot,
tdsaPortContext_t *onePortContext,
tdsaDeviceData_t *oneDeviceData
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
tdsaExpander_t *oneExpander = agNULL;
tdList_t *ExpanderList;
TI_DBG3(("tdssSASDiscoveringExpanderAlloc: start\n"));
TI_DBG3(("tdssSASDiscoveringExpanderAlloc: did %d\n", oneDeviceData->id));
TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
if (onePortContext->valid == agFALSE)
{
TI_DBG1(("tdssSASDiscoveringExpanderAlloc: aborting discovery\n"));
tdsaSASDiscoverAbort(tiRoot, onePortContext);
return agNULL;
}
tdsaDumpAllFreeExp(tiRoot);
if (TDLIST_EMPTY(&(tdsaAllShared->freeExpanderList)))
{
TI_DBG1(("tdssSASDiscoveringExpanderAlloc: no free expanders\n"));
return agNULL;
}
tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
TDLIST_DEQUEUE_FROM_HEAD(&ExpanderList, &(tdsaAllShared->freeExpanderList));
tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
oneExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
if (oneExpander != agNULL)
{
TI_DBG3(("tdssSASDiscoveringExpanderAlloc: expander id %d\n", oneExpander->id));
tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
oneExpander->tdDevice = oneDeviceData;
oneExpander->tdUpStreamExpander = agNULL;
oneExpander->tdCurrentDownStreamExpander = agNULL;
oneExpander->tdReturnginExpander = agNULL;
oneExpander->hasUpStreamDevice = agFALSE;
oneExpander->numOfUpStreamPhys = 0;
oneExpander->currentUpStreamPhyIndex = 0;
oneExpander->discoveringPhyId = 0;
oneExpander->underDiscovering = agFALSE;
osti_memset( &(oneExpander->currentIndex), 0, sizeof(oneExpander->currentIndex));
oneDeviceData->tdExpander = oneExpander;
}
return oneExpander;
}
osGLOBAL void
tdssSASDiscoveringExpanderAdd(
tiRoot_t *tiRoot,
tdsaPortContext_t *onePortContext,
tdsaExpander_t *oneExpander
)
{
#ifdef TD_INTERNAL_DEBUG
tdList_t *ExpanderList;
tdsaExpander_t *tempExpander;
#endif
TI_DBG3(("tdssSASDiscoveringExpanderAdd: start\n"));
TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", oneExpander->id));
TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
if (onePortContext->valid == agFALSE)
{
TI_DBG1(("tdssSASDiscoveringExpanderAdd: aborting discovery\n"));
tdsaSASDiscoverAbort(tiRoot, onePortContext);
return;
}
if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
{
TI_DBG3(("tdssSASDiscoveringExpanderAdd: UPSTREAM\n"));
}
else if (onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
{
TI_DBG3(("tdssSASDiscoveringExpanderAdd: DOWNSTREAM\n"));
}
else
{
TI_DBG3(("tdssSASDiscoveringExpanderAdd: status %d\n", onePortContext->discovery.status));
}
TI_DBG3(("tdssSASDiscoveringExpanderAdd: BEFORE\n"));
tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
if ( oneExpander->underDiscovering == agFALSE)
{
TI_DBG3(("tdssSASDiscoveringExpanderAdd: ADDED \n"));
oneExpander->underDiscovering = agTRUE;
tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(onePortContext->discovery.discoveringExpanderList));
tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
}
TI_DBG3(("tdssSASDiscoveringExpanderAdd: AFTER\n"));
tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
#ifdef TD_INTERNAL_DEBUG
if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
{
TI_DBG3(("tdssSASDiscoveringExpanderAdd: empty discoveringExpanderList\n"));
return;
}
ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
{
tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", tempExpander->id));
ExpanderList = ExpanderList->flink;
}
#endif
return;
}
osGLOBAL bit32
tdssSASFindDiscoveringExpander(
tiRoot_t *tiRoot,
tdsaPortContext_t *onePortContext,
tdsaExpander_t *oneExpander
)
{
tdList_t *ExpanderList;
tdsaExpander_t *tempExpander;
tdsaPortContext_t *tmpOnePortContext = onePortContext;
bit32 ret = agFALSE;
TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
if (TDLIST_EMPTY(&(tmpOnePortContext->discovery.discoveringExpanderList)))
{
TI_DBG1(("tdssSASFindDiscoveringExpander: empty discoveringExpanderList\n"));
return ret;
}
ExpanderList = tmpOnePortContext->discovery.discoveringExpanderList.flink;
while (ExpanderList != &(tmpOnePortContext->discovery.discoveringExpanderList))
{
tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
if (tempExpander == oneExpander)
{
TI_DBG3(("tdssSASFindDiscoveringExpander: match!!! expander id %d\n", tempExpander->id));
TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressHi));
TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressLo));
ret = agTRUE;
break;
}
ExpanderList = ExpanderList->flink;
}
return ret;
}
osGLOBAL void
tdssSASDiscoveringExpanderRemove(
tiRoot_t *tiRoot,
tdsaPortContext_t *onePortContext,
tdsaExpander_t *oneExpander
)
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
#ifdef TD_INTERNAL_DEBUG
tdList_t *ExpanderList;
tdsaExpander_t *tempExpander;
#endif
TI_DBG3(("tdssSASDiscoveringExpanderRemove: start\n"));
TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", oneExpander->id));
TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
tdsaDumpAllFreeExp(tiRoot);
#ifdef TD_INTERNAL_DEBUG
TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
{
TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
}
ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
{
tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
ExpanderList = ExpanderList->flink;
}
#endif
if (tdssSASFindDiscoveringExpander(tiRoot, onePortContext, oneExpander) == agTRUE)
{
oneExpander->underDiscovering = agFALSE;
oneExpander->discoveringPhyId = 0;
tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
{
TI_DBG3(("tdssSASDiscoveringExpanderRemove: DISCOVERY_UP_STREAM\n"));
TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->upNode), &(onePortContext->discovery.UpdiscoveringExpanderList));
onePortContext->discovery.NumOfUpExp++;
}
else
{
TI_DBG3(("tdssSASDiscoveringExpanderRemove: Status %d\n", onePortContext->discovery.status));
TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(tdsaAllShared->freeExpanderList));
}
tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
}
else
{
TI_DBG1(("tdssSASDiscoveringExpanderRemove: !!! problem !!!\n"));
}
TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
tdsaDumpAllFreeExp(tiRoot);
#ifdef TD_INTERNAL_DEBUG
TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
{
TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
}
ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
{
tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
ExpanderList = ExpanderList->flink;
}
#endif
return;
}
#ifdef SATA_ENABLE
osGLOBAL tdsaDeviceData_t *
tdssNewAddSATAToSharedcontext(tiRoot_t *tiRoot,
agsaRoot_t *agRoot,
tdsaPortContext_t *onePortContext,
agsaSATADeviceInfo_t *agSATADeviceInfo,
bit8 *Signature,
bit8 pm,
bit8 pmField,
bit32 connectionRate,
tdsaDeviceData_t *oneExpDeviceData,
bit8 phyID
)
{
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
int new_device = agTRUE;
TI_DBG5(("tdssNewAddSATAToSharedcontext: start\n"));
TI_DBG5(("tdssNewAddSATAToSharedcontext: oneportContext ID %d\n", onePortContext->id));
#ifdef RPM_SOC
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if ((osti_memcmp (((char *)&oneDeviceData->satDevData.satIdentifyData),
((char *)&agSATADeviceInfo->sataIdentifyData),
sizeof(agsaSATAIdentifyData_t)) == 0))
{
TI_DBG5(("tdssNewAddSATAToSharedcontext: pid %d did %d\n",
onePortContext->id, oneDeviceData->id));
new_device = agFALSE;
break;
}
DeviceListList = DeviceListList->flink;
}
#else
#endif
if (new_device == agTRUE)
{
TI_DBG5(("tdssNewAddSATAToSharedcontext: new device\n"));
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
{
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG1(("tdssNewAddSATAToSharedcontext: ERROR empty DeviceData FreeLink\n"));
return oneDeviceData;
}
TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
onePortContext->Count++;
oneDeviceData->DeviceType = TD_SATA_DEVICE;
oneDeviceData->agRoot = agRoot;
TI_DBG5(("tdssNewAddSATAToSharedcontext: oneDeviceData %p\n", oneDeviceData));
TI_DBG5(("tdssNewAddSATAToSharedcontext: pSatDevData=%p\n", &oneDeviceData->satDevData));
oneDeviceData->satDevData.satPMField = pmField;
osti_memcpy(&(oneDeviceData->satDevData.satSignature), Signature, 8);
oneDeviceData->satDevData.satDeviceType = tdssSATADeviceTypeDecode(agSATADeviceInfo->signature);
TI_DBG3(("tdssNewAddSATAToSharedcontext: device type %d\n", oneDeviceData->satDevData.satDeviceType));
#ifdef RPM_SOC_REMOVED
TI_DBG3(("tdssNewAddSATAToSharedcontext: Word8 %x signature: %x %x %x %x %x %x %x %x\n",
agSATADeviceInfo->sataIdentifyData.word1_9[7],
agSATADeviceInfo->signature[0], agSATADeviceInfo->signature[1],
agSATADeviceInfo->signature[2], agSATADeviceInfo->signature[3],
agSATADeviceInfo->signature[4], agSATADeviceInfo->signature[5],
agSATADeviceInfo->signature[6], agSATADeviceInfo->signature[7] ));
#endif
oneDeviceData->tdPortContext = onePortContext;
oneDeviceData->valid = agTRUE;
oneDeviceData->ExpDevice = oneExpDeviceData;
oneDeviceData->phyID = phyID;
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
TI_DBG5(("tdssNewAddSATAToSharedcontext: one case pid %d did %d \n",
onePortContext->id, oneDeviceData->id));
}
else
{
TI_DBG5(("tdssNewAddSATAToSharedcontext: old device\n"));
onePortContext->Count++;
oneDeviceData->DeviceType = TD_SATA_DEVICE;
oneDeviceData->agRoot = agRoot;
oneDeviceData->tdPortContext = onePortContext;
oneDeviceData->valid = agTRUE;
oneDeviceData->ExpDevice = oneExpDeviceData;
oneDeviceData->phyID = phyID;
}
return oneDeviceData;
}
#endif
#endif
#endif
#ifdef TARGET_DRIVER
osGLOBAL void
ttdssReportRemovals(
agsaRoot_t *agRoot,
tdsaPortContext_t *onePortContext,
bit32 flag
)
{
tdsaDeviceData_t *oneDeviceData = agNULL;
tdList_t *DeviceListList;
tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
bit32 removed = agFALSE;
agsaEventSource_t *eventSource;
bit32 PhyID;
bit32 HwAckSatus;
tdsaDeviceData_t *tmpDeviceData = agNULL;
TI_DBG1(("ttdssReportRemovals: start\n"));
PhyID = onePortContext->eventPhyID;
if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE &&
onePortContext->RegisteredDevNums == 0 &&
PhyID != 0xFF
)
{
TI_DBG1(("ttdssReportRemovals: calling saHwEventAck\n"));
eventSource = &(tdsaAllShared->eventSource[PhyID].Source);
HwAckSatus = saHwEventAck(
agRoot,
agNULL,
0,
eventSource,
0,
0
);
if ( HwAckSatus != AGSA_RC_SUCCESS)
{
TI_DBG1(("ttdssReportRemovals: failing in saHwEventAck; status %d\n", HwAckSatus));
}
tdsaAllShared->eventSource[PhyID].EventValid = agFALSE;
if (onePortContext->valid == agFALSE)
{
tdsaPortContextReInit(tiRoot, onePortContext);
tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
}
}
else
{
if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
{
TI_DBG1(("ttdssReportRemovals: empty device list\n"));
return;
}
DeviceListList = tdsaAllShared->MainDeviceList.flink;
while (DeviceListList != &(tdsaAllShared->MainDeviceList))
{
oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
if( oneDeviceData == agNULL )
{
break;
}
TI_DBG1(("ttdssReportRemovals: loop did %d\n", oneDeviceData->id));
TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
TI_DBG1(("ttdssReportRemovals: valid %d valid2 %d\n", oneDeviceData->valid, oneDeviceData->valid2));
TI_DBG1(("ttdssReportRemovals: directlyAttached %d registered %d\n", oneDeviceData->directlyAttached, oneDeviceData->registered));
if ( oneDeviceData->tdPortContext == onePortContext)
{
TI_DBG1(("ttdssReportRemovals: right portcontext pid %d\n", onePortContext->id));
if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE)
{
TI_DBG1(("ttdssReportRemovals: removing\n"));
removed = agTRUE;
TI_DBG1(("ttdssReportRemovals: calling tdsaAbortAll\n"));
TI_DBG1(("ttdssReportRemovals: did %d\n", oneDeviceData->id));
TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
tmpDeviceData = oneDeviceData;
ttdsaAbortAll(tiRoot, agRoot, oneDeviceData);
oneDeviceData->valid = agFALSE;
oneDeviceData->valid2 = agFALSE;
oneDeviceData->registered = agFALSE;
}
if (flag == agTRUE)
{
oneDeviceData->tdPortContext = agNULL;
}
#ifdef REMOVED
if (oneDeviceData->DeviceType == TD_SATA_DEVICE &&
oneDeviceData->directlyAttached == agTRUE)
{
TI_DBG1(("ttdssReportRemovals: device did %d\n", oneDeviceData->id));
tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceLis));
DeviceListList = tdsaAllShared->MainDeviceList.flink;
if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
{
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
break;
}
else
{
tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
}
}
else
{
DeviceListList = DeviceListList->flink;
}
#endif
DeviceListList = DeviceListList->flink;
}
else
{
if (oneDeviceData->tdPortContext != agNULL)
{
TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->tdPortContext->id, onePortContext->id));
}
else
{
TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->id));
}
DeviceListList = DeviceListList->flink;
}
}
if (removed == agTRUE)
{
TI_DBG1(("ttdssReportRemovals: removed at the end\n"));
ostiTargetEvent(
tiRoot,
onePortContext->tiPortalContext,
&(tmpDeviceData->tiDeviceHandle),
tiTgtEventTypeDeviceChange,
tiDeviceRemoval,
agNULL
);
}
}
return;
}
#endif
FORCEINLINE bit32
tdsaRotateQnumber(tiRoot_t *tiRoot,
tdsaDeviceData_t *oneDeviceData )
{
bit32 ret = 0;
TI_DBG6(("tdsaRotateQnumber: start\n"));
if (oneDeviceData == agNULL)
{
return 0;
}
ret = (oneDeviceData->OutQID << 16) | oneDeviceData->InQID;
return ret;
}
osGLOBAL bit32
tdsaRotateQnumber1(tiRoot_t *tiRoot,
tdsaDeviceData_t *oneDeviceData )
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
bit32 ret = 0;
if (oneDeviceData == agNULL)
{
return 0;
}
ret = ((tdsaAllShared->QueueConfig.numOutboundQueues-1) << 16) | (tdsaAllShared->QueueConfig.numInboundQueues-1);
return(ret);
}
#ifdef REMOVED
osGLOBAL bit32
tdsaRotateQnumber(tiRoot_t *tiRoot,
tdsaDeviceData_t *oneDeviceData )
{
tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
bit32 denom = tdsaAllShared->QueueConfig.numInboundQueues;
bit32 ret = 0;
tdsaAllShared->IBQnumber++;
if (tdsaAllShared->IBQnumber % denom == 0)
{
tdsaAllShared->IBQnumber = 0;
}
TI_DBG6(("tdsaRotateQnumber: IBQnumber %d\n", tdsaAllShared->IBQnumber));
tdsaAllShared->OBQnumber++;
denom = tdsaAllShared->QueueConfig.numOutboundQueues;
if (tdsaAllShared->OBQnumber % denom == 0)
{
tdsaAllShared->OBQnumber = 0;
}
TI_DBG6(("tdsaRotateQnumber: OBQnumber %d\n", tdsaAllShared->OBQnumber));
ret = (tdsaAllShared->OBQnumber << 16) | tdsaAllShared->IBQnumber;
return ret;
}
#endif
void t_MacroCheck( agsaRoot_t *agRoot)
{
TI_DBG1(("t_MacroCheck:tIsSPC %d\n",tIsSPC(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCHIL %d\n",tIsSPCHIL(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCv %d\n",tIsSPCv(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCve %d\n",tIsSPCve(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCvplus %d\n",tIsSPCvplus(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCveplus %d\n",tIsSPCveplus(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCADAPvplus %d\n",tIsSPCADAPvplus(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPCADAPveplus %d\n",tIsSPCADAPveplus(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPC12Gv %d\n",tIsSPC12Gv(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPC12Gve %d\n",tIsSPC12Gve(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPC12Gvplus %d\n",tIsSPC12Gvplus(agRoot)));
TI_DBG1(("t_MacroCheck:tIsSPC12Gveplus %d\n",tIsSPC12Gveplus(agRoot)));
TI_DBG1(("t_MacroCheck:tiIS_SPC %d\n",tiIS_SPC(agRoot) ));
TI_DBG1(("t_MacroCheck:tiIS_HIL %d\n",tiIS_HIL(agRoot) ));
TI_DBG1(("t_MacroCheck:tiIS_SPC6V %d\n",tiIS_SPC6V(agRoot) ));
TI_DBG1(("t_MacroCheck:tiIS_SPC_ENC %d\n",tiIS_SPC_ENC(agRoot) ));
TI_DBG1(("t_MacroCheck:tIsSPCV12G %d\n",tIsSPCV12G(agRoot) ));
}