47#ifdef INITIATOR_DRIVER
56extern bit32 gDMDebugLevel;
69 TI_DBG1((
"tddmRotateQnumber: start\n"));
72 TI_DBG1((
"tddmRotateQnumber: agDevHandle is NULL!!!\n"));
76 if (oneDeviceData ==
agNULL)
78 TI_DBG1((
"tddmRotateQnumber: oneDeviceData is NULL!!!\n"));
84 TI_DBG1((
"tddmRotateQnumber: tdsaRoot is NULL\n"));
88 if (tdsaAllShared ==
agNULL)
90 TI_DBG1((
"tddmRotateQnumber: tdsaAllShared is NULL\n"));
96 TI_DBG1((
"tddmRotateQnumber: tiRoot is NULL\n"));
107 bit32 i, localMCN = 0;
109 TI_DBG2((
"tdsaFindLocalMCN: start\n"));
113 TI_DBG1((
"tdsaFindLocalMCN: invalid portcontext id %d\n", onePortContext->
id));
169 TI_DBG1((
"tddmDiscoverCB: start\n"));
173 TI_DBG1((
"tddmDiscoverCB: tdsaRoot is NULL\n"));
178 if (tdsaAllShared ==
agNULL)
180 TI_DBG1((
"tddmDiscoverCB: tdsaAllShared is NULL\n"));
187 TI_DBG1((
"tddmDiscoverCB: tiRoot is NULL\n"));
192 if (onePortContext ==
agNULL)
194 TI_DBG1((
"tddmDiscoverCB: onePortContext is NULL\n"));
202 TI_DBG1((
"tddmDiscoverCB: dmDiscCompleted\n"));
208 if ( onePortContext->UpdateMCN ==
agTRUE)
210 TI_DBG2((
"tddmDiscoverCB: calling tdsaUpdateMCN\n"));
211 onePortContext->UpdateMCN =
agFALSE;
212 tdsaUpdateMCN(dmRoot, onePortContext);
226 TI_DBG1((
"tddmDiscoverCB: dmDiscFailed \n"));
233 TI_DBG1((
"tddmDiscoverCB: agRoot is NULL\n"));
237 if (agPortContext ==
agNULL)
239 TI_DBG1((
"tddmDiscoverCB: agPortContext is NULL\n"));
245 tddmInvalidateDevicesInPort(
tiRoot, onePortContext);
267 TI_DBG1((
"tddmDiscoverCB: dmDiscAborted \n"));
272 TI_DBG1((
"tddmDiscoverCB: dmDiscAbortFailed \n"));
277 TI_DBG1((
"tddmDiscoverCB: dmDiscAbortInvalid \n"));
282 TI_DBG1((
"tddmDiscoverCB: dmDiscAbortInProgress \n"));
287 TI_DBG1((
"tddmDiscoverCB: undefined eventStatus 0x%x\n", eventStatus));
305 TI_DBG2((
"tddmQueryDiscoveryCB: start\n"));
307 if (onePortContext ==
agNULL)
309 TI_DBG1((
"tddmQueryDiscoveryCB: onePortContext is NULL\n"));
312 TI_DBG2((
"tddmQueryDiscoveryCB: discType %d discState %d\n", discType, discState));
314 onePortContext->DMDiscoveryState = discState;
319tddmInvalidateDevicesInPort(
329 TI_DBG1((
"tddmInvalidateDevicesInPort: start\n"));
336 if (oneDeviceData ==
agNULL)
338 TI_DBG1((
"tddmInvalidateDevicesInPort: oneDeviceData is NULL!!!\n"));
346 TI_DBG3((
"tddmInvalidateDevicesInPort: Found pid %d did %d\n", onePortContext->
id, oneDeviceData->
id));
351 TI_DBG1((
"tddmInvalidateDevicesInPort: keeping\n"));
362 DeviceListList = DeviceListList->
flink;
365 TI_DBG3((
"tddmInvalidateDevicesInPort: end\n"));
383 TI_DBG3((
"tddmNewSASorNot: start\n"));
390 if (oneDeviceData ==
agNULL)
392 TI_DBG1((
"tddmNewSASorNot: oneDeviceData is NULL!!!\n"));
401 TI_DBG3((
"tddmNewSASorNot: Found pid %d did %d\n", onePortContext->
id, oneDeviceData->
id));
405 DeviceListList = DeviceListList->
flink;
410 TI_DBG3((
"tddmNewSASorNot: end\n"));
416tddmPortSASDeviceFind(
428 TI_DBG2((
"tddmPortSASDeviceFind: start\n"));
440 if (oneDeviceData ==
agNULL)
442 TI_DBG1((
"tddmPortSASDeviceFind: oneDeviceData is NULL!!!\n"));
451 TI_DBG2((
"tddmPortSASDeviceFind: Found pid %d did %d\n", onePortContext->
id, oneDeviceData->
id));
454 RetDeviceData = oneDeviceData;
457 DeviceListList = DeviceListList->
flink;
462 return RetDeviceData;
467tddmAddToSharedcontext(
483 TI_DBG1((
"tddmAddToSharedcontext: start\n"));
485 TI_DBG1((
"tddmAddToSharedcontext: oneportContext ID %d\n", onePortContext->
id));
491 if (oneDeviceData ==
agNULL)
493 TI_DBG1((
"tddmAddToSharedcontext: oneDeviceData is NULL!!!\n"));
501 TI_DBG1((
"tddmAddToSharedcontext: pid %dtddmAddToSharedcontext did %d\n", onePortContext->
id, oneDeviceData->
id));
505 DeviceListList = DeviceListList->
flink;
511 TI_DBG1((
"tddmAddToSharedcontext: new device\n"));
516 TI_DBG1((
"tddmAddToSharedcontext: empty DeviceData FreeLink\n"));
524 TI_DBG1((
"tddmAddToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->
id));
526 onePortContext->
Count++;
527 oneDeviceData->
agRoot = agRoot;
544 oneDeviceData->
ExpDevice = oneExpDeviceData;
546 if (oneDeviceData->
phyID == 0xFF)
548 oneDeviceData->
phyID = phyID;
557 TI_DBG1((
"tddmAddToSharedcontext: one case pid %d did %d \n", onePortContext->
id, oneDeviceData->
id));
558 TI_DBG1((
"tddmAddToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->
id, oneDeviceData->
id, oneDeviceData->
phyID));
562 TI_DBG1((
"tddmAddToSharedcontext: old device\n"));
563 TI_DBG1((
"tddmAddToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->
id));
565 oneDeviceData->
agRoot = agRoot;
582 oneDeviceData->
ExpDevice = oneExpDeviceData;
584 if (oneDeviceData->
phyID == 0xFF)
586 oneDeviceData->
phyID = phyID;
590 TI_DBG1((
"tddmAddToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->
id, oneDeviceData->
id, oneDeviceData->
phyID));
593 return oneDeviceData;
618 TI_DBG2((
"tddmPortDeviceAdd: start\n"));
625 phyID = (dmDeviceInfo->
ext) & 0xFF;
628 if (
agFALSE == tdssNewSASorNot(
638 oneDeviceData = tdssNewAddSASToSharedcontext(
646 if (oneDeviceData ==
agNULL)
648 TI_DBG1((
"tddmPortDeviceAdd: no more device!!! oneDeviceData is null\n"));
652 if ( oneDeviceData !=
agNULL )
657 TI_DBG2((
"tddmPortDeviceAdd: phyID 0x%x\n", phyID));
679 return oneDeviceData;
687 oneDeviceData = tdssNewAddSASToSharedcontext(
695 if (oneDeviceData ==
agNULL)
697 TI_DBG1((
"tddmPortDeviceAdd: no more device!!! oneDeviceData is null\n"));
701 if ( oneDeviceData !=
agNULL )
706 TI_DBG2((
"tddmPortDeviceAdd: phyID 0x%x\n", phyID));
725 TI_DBG2((
"tddmPortDeviceAdd: did %d\n", oneDeviceData->
id));
735 TI_DBG1((
"tddmPortDeviceAdd: initiator. no add and registration\n"));
749 if( tdsaAllShared->
sflag )
753 TI_DBG1((
"tddmPortDeviceAdd: saRegisterNewDevice sflag %d\n", tdsaAllShared->
sflag));
769 return oneDeviceData;
808 bit32 sasAddressHi, sasAddressLo;
811 bit32 localMCN = 0, finalMCN = 0;
821 TI_DBG2((
"tddmReportDevice: start\n"));
825 TI_DBG1((
"tddmReportDevice: tdsaRoot is NULL\n"));
830 if (tdsaAllShared ==
agNULL)
832 TI_DBG1((
"tddmReportDevice: tdsaAllShared is NULL\n"));
839 TI_DBG1((
"tddmReportDevice: tiRoot is NULL\n"));
844 if (onePortContext ==
agNULL)
846 TI_DBG1((
"tddmReportDevice: onePortContext is NULL\n"));
851 smRoot = &(tdsaAllShared->smRoot);
854 TI_DBG2((
"tddmReportDevice: device addrHi 0x%08x addrLo 0x%08x\n",
857 if (dmExpDeviceInfo !=
agNULL)
859 TI_DBG2((
"tddmReportDevice: attached expander addrHi 0x%08x addrLo 0x%08x\n",
864 TI_DBG2((
"tddmReportDevice: No attached expander\n"));
872 TI_DBG3((
"tddmReportDevice: Initiators are not added\n"));
873 TI_DBG3((
"tddmReportDevice: device addrHi 0x%08x addrLo 0x%08x\n",
880 TI_DBG2((
"tddmReportDevice: arrival\n"));
881 if (dmExpDeviceInfo !=
agNULL)
886 oneExpDeviceData = tddmPortSASDeviceFind(
tiRoot, onePortContext, sasAddressLo, sasAddressHi);
889 tddmPortDeviceAdd(
tiRoot, onePortContext, dmDeviceInfo, oneExpDeviceData);
894 TI_DBG2((
"tddmReportDevice: removal\n"));
897 oneDeviceData = tddmPortSASDeviceFind(
tiRoot, onePortContext, sasAddressLo, sasAddressHi);
898 if (oneDeviceData ==
agNULL)
900 TI_DBG2((
"tddmReportDevice: oneDeviceData is NULL!!!\n"));
905 TI_DBG2((
"tddmReportDevice: invalidating\n"));
913 TI_DBG2((
"tddmReportDevice: agDevHandle->sdkData is NULL\n"));
917 agRoot = oneDeviceData->
agRoot;
930 TI_DBG2((
"tddmReportDevice: keeping\n"));
938 TI_DBG1((
"tddmReportDevice: agDevHandle->sdkData is NULL. Error!!! \n"));
947 TI_DBG2((
"tddmReportDevice: smDeregisterDevice\n"));
956 TI_DBG2((
"tddmReportDevice: no change; do nothing \n"));
960 oneDeviceData = tddmPortSASDeviceFind(
tiRoot, onePortContext, sasAddressLo, sasAddressHi);
961 if (oneDeviceData ==
agNULL)
963 TI_DBG2((
"tddmReportDevice: oneDeviceData is NULL!!!\n"));
967 agRoot = oneDeviceData->
agRoot;
972 tdIDStart(
tiRoot, agRoot, smRoot, oneDeviceData, onePortContext);
979 TI_DBG2((
"tddmReportDevice: dmDeviceMCNChange \n"));
982 TI_DBG2((
"tddmReportDevice: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
986 oneDeviceData = tddmPortSASDeviceFind(
tiRoot, onePortContext, sasAddressLo, sasAddressHi);
987 if (oneDeviceData ==
agNULL)
989 TI_DBG1((
"tddmReportDevice: oneDeviceData is NULL!!!\n"));
993 agRoot = oneDeviceData->
agRoot;
994 oneDeviceData->devMCN = devMCN;
995 TI_DBG2((
"tddmReportDevice: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", sasAddressHi, sasAddressLo));
999 TI_DBG2((
"tddmReportDevice: directlyAttached, Final MCN 0x%08x\n", finalMCN));
1003 finalMCN =
MIN(devMCN, localMCN);
1004 TI_DBG2((
"tddmReportDevice: Not directlyAttached, Final MCN 0x%08x\n", finalMCN));
1010 param = finalMCN << 24;
1011 TI_DBG2((
"tddmReportDevice: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1016 TI_DBG1((
"tddmReportDevice: oneDeviceData is not yet registered !!!\n"));
1018 oneDeviceData->finalMCN = finalMCN;
1023 TI_DBG1((
"tddmReportDevice: dmDeviceRateChange \n"));
1026 oneDeviceData = tddmPortSASDeviceFind(
tiRoot, onePortContext, sasAddressLo, sasAddressHi);
1027 if (oneDeviceData ==
agNULL)
1029 TI_DBG1((
"tddmReportDevice: oneDeviceData is NULL!!!\n"));
1033 agRoot = oneDeviceData->
agRoot;
1039 TI_DBG1((
"tddmReportDevice: option 0x%x param 0x%x DLR 0x%x\n", option, param, DLR));
1045 TI_DBG1((
"tddmReportDevice: oneDeviceData is not yet registered !!!\n"));
1052 TI_DBG1((
"tddmReportDevice: unknown flag 0x%x, wrong\n", flag));
1069 bit32 localMCN = 0, finalMCN = 0;
1074 TI_DBG3((
"tdsaUpdateMCN: start\n"));
1078 TI_DBG1((
"tdsaUpdateMCN: tdsaRoot is NULL\n"));
1083 if (tdsaAllShared ==
agNULL)
1085 TI_DBG1((
"tdsaUpdateMCN: tdsaAllShared is NULL\n"));
1092 TI_DBG1((
"tdsaUpdateMCN: tiRoot is NULL\n"));
1098 TI_DBG1((
"tdsaUpdateMCN: onePortContext is invalid\n"));
1102 TI_DBG3((
"tdsaUpdateMCN: pid %d\n", onePortContext->
id));
1108 TI_DBG1((
"tdsaUpdateMCN: empty device list\n"));
1117 if (oneDeviceData ==
agNULL)
1119 TI_DBG1((
"tdsaUpdateMCN: oneDeviceData is NULL!!!\n"));
1122 TI_DBG3((
"tdsaUpdateMCN: loop did %d\n", oneDeviceData->
id));
1124 devMCN = oneDeviceData->devMCN;
1129 TI_DBG3((
"tdsaUpdateMCN: found directly attached\n"));
1130 finalMCN = localMCN;
1131 TI_DBG3((
"tdsaUpdateMCN: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
1132 TI_DBG3((
"tdsaUpdateMCN: finalMCN 0x%08x\n", finalMCN));
1133 if (oneDeviceData->finalMCN != finalMCN)
1137 param = finalMCN << 24;
1138 TI_DBG3((
"tdsaUpdateMCN: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1140 oneDeviceData->finalMCN = finalMCN;
1146 TI_DBG3((
"tdsaUpdateMCN: found behind expander device\n"));
1147 finalMCN =
MIN(localMCN, devMCN);
1148 TI_DBG3((
"tdsaUpdateMCN: devMCN 0x%08x localMCN 0x%08x\n", devMCN, localMCN));
1149 TI_DBG3((
"tdsaUpdateMCN: finalMCN 0x%08x\n", finalMCN));
1150 if (oneDeviceData->finalMCN != finalMCN)
1154 param = finalMCN << 24;
1155 TI_DBG3((
"tdsaUpdateMCN: option 0x%x param 0x%x MCN 0x%x\n", option, param, finalMCN));
1157 oneDeviceData->finalMCN = finalMCN;
1161 DeviceListList = DeviceListList->
flink;
1167 TI_DBG3((
"tdsaUpdateMCN: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->
tdPortContext->
id, onePortContext->
id));
1171 TI_DBG3((
"tdsaUpdateMCN: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->
id));
1173 DeviceListList = DeviceListList->
flink;
1183 return (
bit8)tdssSATADeviceTypeDecode(pSignature);
1198 TI_DBG7((
"tddmSingleThreadedEnter: start\n"));
1203 TI_DBG1((
"tddmSingleThreadedEnter: tdsaRoot is NULL\n"));
1208 if (tdsaAllShared ==
agNULL)
1210 TI_DBG1((
"tddmSingleThreadedEnter: tdsaAllShared is NULL\n"));
1217 TI_DBG1((
"tddmSingleThreadedEnter: tiRoot is NULL\n"));
1237 TI_DBG7((
"tddmSingleThreadedLeave: start\n"));
1242 TI_DBG1((
"tddmSingleThreadedLeave: tdsaRoot is NULL\n"));
1247 if (tdsaAllShared ==
agNULL)
1249 TI_DBG1((
"tddmSingleThreadedLeave: tdsaAllShared is NULL\n"));
1256 TI_DBG1((
"tddmSingleThreadedLeave: tiRoot is NULL\n"));
1282 TI_DBG7((
"tddmGetTransportParam: start\n"));
#define DEVICE_IS_SATA_DEVICE(DeviceData)
#define DEVICE_IS_STP_INITIATOR(DeviceData)
#define DEVINFO_GET_EXT_MCN(devInfo)
#define DEVICE_IS_STP_TARGET(DeviceData)
#define MIN(a, b)
MIN macro.
#define DEVICE_IS_SSP_INITIATOR(DeviceData)
#define SATA_ATAPI_DEVICE
#define DEVICE_IS_SMP_TARGET(DeviceData)
#define DEVICE_IS_SMP_INITIATOR(DeviceData)
#define DEVINFO_GET_LINKRATE(devInfo)
#define DEVICE_IS_SSP_TARGET(DeviceData)
#define ATAPI_DEVICE_FLAG
#define ITD_DSTATE_COMPLETED
U32 ostiGetTransportParam(tiRoot_t *ptiRoot, S08 *key, S08 *subkey1, S08 *subkey2, S08 *subkey3, S08 *subkey4, S08 *subkey5, S08 *valueName, S08 *buffer, U32 bufferLen, U32 *lenReceived)
void ostiSingleThreadedLeave(tiRoot_t *ptiRoot, U32 queueId)
void ostiInitiatorEvent(tiRoot_t *ptiRoot, tiPortalContext_t *ptiPortalContext, tiDeviceHandle_t *ptiDevHandle, tiIntrEventType_t eventType, U32 eventStatus, void *parm)
void ostiSingleThreadedEnter(tiRoot_t *ptiRoot, U32 queueId)
#define osti_memcpy(des, src, n)
#define AGSA_PORT_IO_ABORT
GLOBAL bit32 saSetDeviceInfo(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDevHandle_t *agDevHandle, bit32 option, bit32 param, ossaSetDeviceInfoCB_t agCB)
Set Device Information.
GLOBAL bit32 saDeregisterDeviceHandle(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 queueNum)
Function for target to remove stale initiator device handle.
GLOBAL bit32 saPortControl(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaPortContext_t *agPortContext, bit32 portOperation, bit32 param0, bit32 param1)
Initiate a Port COntrol IOMB command.
GLOBAL bit32 saRegisterNewDevice(agsaRoot_t *agRoot, agsaContext_t *agContext, bit32 queueNum, agsaDeviceInfo_t *agDeviceInfo, agsaPortContext_t *agPortContext, bit16 hostAssignedDeviceId)
Register New Device from a specific local port.
GLOBAL void ossaSetDeviceInfoCB(agsaRoot_t *agRoot, agsaContext_t *agContext, agsaDevHandle_t *agDevHandle, bit32 status, bit32 option, bit32 param)
ossaSetDeviceInfoCB
osGLOBAL bit32 smDeregisterDevice(smRoot_t *smRoot, agsaDevHandle_t *agDevHandle, smDeviceHandle_t *smDeviceHandle)
data structure stores OS specific and LL specific context
bit8 initiator_ssp_stp_smp
data structure for SAS/SATA context at TD layer
struct tdsaRootOsData_s agRootOsDataForInt
data structure for SAS device list This structure maintains the device as a list and information abou...
agsaDevHandle_t * agDevHandle
bit8 initiator_ssp_stp_smp
struct tdsaPortContext_s * tdPortContext
TDSASAddressID_t SASAddressID
satDeviceData_t satDevData
agsaDeviceInfo_t agDeviceInfo
struct tdsaDeviceData_s * ExpDevice
data structure for TD port context This structure maintains information about the port such as ID add...
bit8 PhyIDList[TD_MAX_NUM_PHYS]
agsaPortContext_t * agPortContext
tiPortalContext_t * tiPortalContext
data structure OS root from the view of lower layer. TD Layer interrupt/non-interrupt context support...
the root data structure for TD layer
tdsaContext_t tdsaAllShared
bit8 initiator_ssp_stp_smp
#define TD_GET_SAS_ADDRESSHI(sasAddressHi)
#define TD_GET_SAS_ADDRESSLO(sasAddressLo)
#define TD_XFER_RDY_PRIORTY_DEVICE_FLAG
osGLOBAL void tddmReportDevice(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, dmDeviceInfo_t *dmDeviceInfo, dmDeviceInfo_t *dmExpDeviceInfo, bit32 flag)
osGLOBAL bit8 tddmSATADeviceTypeDecode(bit8 *pSignature)
osGLOBAL void tddmSingleThreadedLeave(dmRoot_t *dmRoot, bit32 syncLockId)
osGLOBAL void tddmDiscoverCB(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, bit32 eventStatus)
osGLOBAL bit32 tddmGetTransportParam(dmRoot_t *dmRoot, char *key, char *subkey1, char *subkey2, char *subkey3, char *subkey4, char *subkey5, char *valueName, char *buffer, bit32 bufferLen, bit32 *lenReceived)
osGLOBAL void tddmQueryDiscoveryCB(dmRoot_t *dmRoot, dmPortContext_t *dmPortContext, bit32 discType, bit32 discState)
osGLOBAL bit32 tddmRotateQnumber(dmRoot_t *dmRoot, agsaDevHandle_t *agDevHandle)
osGLOBAL void tddmSingleThreadedEnter(dmRoot_t *dmRoot, bit32 syncLockId)
#define TDLIST_OBJECT_BASE(baseType, fieldName, fieldPtr)
#define TDLIST_NOT_EMPTY(listHdr)
#define TDLIST_ENQUEUE_AT_TAIL(toAddHdr, listHdr)
#define TDLIST_EMPTY(listHdr)
#define TDLIST_DEQUEUE_FROM_HEAD(atHeadHdr, listHdr)
void tdsaSingleThreadedEnter(tiRoot_t *ptiRoot, bit32 queueId)
void tdsaSingleThreadedLeave(tiRoot_t *ptiRoot, bit32 queueId)
osGLOBAL bit32 tdsaAbortAll(tiRoot_t *tiRoot, agsaRoot_t *agRoot, tdsaDeviceData_t *oneDeviceData)
FORCEINLINE bit32 tdsaRotateQnumber(tiRoot_t *tiRoot, tdsaDeviceData_t *oneDeviceData)
osGLOBAL bit32 tdsaFindLocalMCN(tiRoot_t *tiRoot, tdsaPortContext_t *onePortContext)
@ tiIntrEventTypeDiscovery