enhance coherence.
This commit is contained in:
@@ -106,21 +106,21 @@ static int32_t MgmtMsg_Packing(L2_INST* instPtr, BIT_ARRAY* bitarr, L2_MSG_TYPE
|
||||
FrameInsertChunk(bitarr, TK_MSG_INI_OFFSET, TK_MSG_INI_LEN, dataChunk);
|
||||
|
||||
// Next net stage
|
||||
if (L2_GetNodeType(instPtr) == HEAD_NODE) {
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD) {
|
||||
switch (instPtr->nextState) {
|
||||
case INIT_STATE:
|
||||
case L2_INIT_STATE:
|
||||
dataChunk = NET_INI_STAGE;
|
||||
break;
|
||||
case NORMAL_STATE:
|
||||
case L2_NORMAL_STATE:
|
||||
dataChunk = NET_NORMAL_STAGE;
|
||||
break;
|
||||
case INTRA_SEEK_STATE:
|
||||
case L2_INTRA_SEEK_STATE:
|
||||
dataChunk = NET_INTRA_SEEK_STAGE;
|
||||
break;
|
||||
case INTER_SEEK_STATE:
|
||||
case L2_INTER_SEEK_STATE:
|
||||
dataChunk = NET_INTER_SEEK_STAGE;
|
||||
break;
|
||||
case SEEK_STATE:
|
||||
case L2_SEEK_STATE:
|
||||
dataChunk = NET_SEEK_STAGE;
|
||||
break;
|
||||
default:
|
||||
@@ -405,7 +405,7 @@ static int32_t MgmtMsg_Packing(L2_INST* instPtr, BIT_ARRAY* bitarr, L2_MSG_TYPE
|
||||
// // Quit object
|
||||
// dataChunk = (L2_GetNodeId(instPtr) & 0x1F) | (((uint16_t)(L2_GetClusterId(instPtr) & 0x1F)) << 5);
|
||||
// FrameInsertChunk(bitarr, NQT_MSG_OBJ_OFFSET, NQT_MSG_OBJ_LEN, dataChunk);
|
||||
// L2_NODE_STATE newState = INIT_STATE;
|
||||
// L2_NODE_STATE newState = L2_INIT_STATE;
|
||||
// L2_EVENT stateEvent = {
|
||||
// .event = L2_EV_MAIN_STATE_UPDATE,
|
||||
// .msg = &newState
|
||||
@@ -451,7 +451,7 @@ static int32_t MgmtPkt_Packing(L2_INST* instPtr, MGMTPKT_TYPE pktType) {
|
||||
BIT_ARRAY* mgmtPkt = bit_array_create(L2_MSG_MAX);
|
||||
if (mgmtPkt == NULL) {
|
||||
DBG_ERROR("Failed to allocate memory for scanMsg.\n");
|
||||
return NUM_SLOTS_NONE;
|
||||
return FAILURE;
|
||||
}
|
||||
switch (pktType) {
|
||||
case MGMTPKT_INTRA_MGMT:
|
||||
@@ -551,7 +551,7 @@ void MgmtNet_Reset(L2_MGMT_FSM* mgmtFSM) {
|
||||
mgmtFSM->isPendSlotAlloc = false;
|
||||
mgmtFSM->isPendTimeAlloc = false;
|
||||
|
||||
mgmtFSM->mgmtMsgLog.nextNetState = NONE_STATE;
|
||||
mgmtFSM->mgmtMsgLog.nextNetState = L2_NONE_STATE;
|
||||
mgmtFSM->mgmtMsgLog.isValid = false;
|
||||
mgmtFSM->mgmtMsgLog.quitCtrlWord = 0;
|
||||
mgmtFSM->mgmtMsgLog.quitNodeId = 0;
|
||||
@@ -569,8 +569,8 @@ void MgmtNet_Reset(L2_MGMT_FSM* mgmtFSM) {
|
||||
mgmtFSM->mgmtMsgLog.Latitude = 0 ;
|
||||
|
||||
// clear buffer.
|
||||
memset(&(mgmtFSM->rttMsgRspLog), 0x00, sizeof(RTT_MSG_RECORD));
|
||||
memset(&(mgmtFSM->rttMsgReqLog), 0x00, sizeof(RTT_MSG_RECORD));
|
||||
memset(&(mgmtFSM->rttMsgRspLog), 0x00, sizeof(L2_RTT_MSG_RECORD));
|
||||
memset(&(mgmtFSM->rttMsgReqLog), 0x00, sizeof(L2_RTT_MSG_RECORD));
|
||||
}
|
||||
|
||||
|
||||
@@ -603,9 +603,9 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
|
||||
int32_t Status;
|
||||
uint32_t filedSize = 0;
|
||||
uint64_t dataChunk = 0;
|
||||
MGMT_MSG_RECORD *mgmtMsgLog = &(instPtr->mgmtNetFSM->mgmtMsgLog);
|
||||
RTT_MSG_RECORD *rttMsgRspLog = &(instPtr->mgmtNetFSM->rttMsgRspLog);
|
||||
RTT_MSG_RECORD *rttMsgReqLog = &(instPtr->mgmtNetFSM->rttMsgReqLog);
|
||||
L2_MGMT_MSG_RECORD *mgmtMsgLog = &(instPtr->mgmtNetFSM->mgmtMsgLog);
|
||||
L2_RTT_MSG_RECORD *rttMsgRspLog = &(instPtr->mgmtNetFSM->rttMsgRspLog);
|
||||
L2_RTT_MSG_RECORD *rttMsgReqLog = &(instPtr->mgmtNetFSM->rttMsgReqLog);
|
||||
|
||||
BIT_ARRAY* mgmtMsg = bit_array_create(L2_MSG_MAX);
|
||||
if (mgmtMsg == NULL) {
|
||||
@@ -702,24 +702,24 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
|
||||
}
|
||||
}
|
||||
// Member Node update state with received message
|
||||
if(L2_GetNodeId(instPtr) != HEAD_NODE && mgmtMsgLog->isValid == true ){
|
||||
L2_NODE_STATE newState = NONE_STATE;
|
||||
if(L2_GetNodeId(instPtr) != L2_NODE_HEAD && mgmtMsgLog->isValid == true ){
|
||||
L2_NODE_STATE newState = L2_NONE_STATE;
|
||||
// FIXME :
|
||||
switch (mgmtMsgLog->nextNetState) {
|
||||
case NET_INI_STAGE:
|
||||
newState = INIT_STATE;
|
||||
newState = L2_INIT_STATE;
|
||||
break;
|
||||
case NET_NORMAL_STAGE:
|
||||
newState = NORMAL_STATE;
|
||||
newState = L2_NORMAL_STATE;
|
||||
break;
|
||||
case NET_INTRA_SEEK_STAGE:
|
||||
newState = INTRA_SEEK_STATE;
|
||||
newState = L2_INTRA_SEEK_STATE;
|
||||
break;
|
||||
case NET_INTER_SEEK_STAGE:
|
||||
newState = INTER_SEEK_STATE;
|
||||
newState = L2_INTER_SEEK_STATE;
|
||||
break;
|
||||
case NET_SEEK_STAGE:
|
||||
newState = SEEK_STATE;
|
||||
newState = L2_SEEK_STATE;
|
||||
break;
|
||||
default:
|
||||
DBG_WARNING("Unknown Head node state [%d].\n", mgmtMsgLog->nextNetState);
|
||||
@@ -742,7 +742,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
|
||||
}
|
||||
case L2_INTER_TSYNC_FRAME:
|
||||
case L2_INTRA_TSYNC_FRAME: {
|
||||
if(L2_GetNodeType(instPtr) == HEAD_NODE){
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD){
|
||||
for (int i = 0; i < ARRAY_SIZE(rttReqFrameMsgs); i++) {
|
||||
memcpy(mgmtMsg->words,
|
||||
instPtr->recvPktData + (size_t) (i * (RTT_MSG_LEN / 8)),
|
||||
@@ -919,7 +919,7 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
|
||||
if (L2_GetLastFrameType(instPtr) == L2_INTRA_TSYNC_FRAME && L2_GetLastTor(instPtr) == L2_TOR_RX) {
|
||||
RTT_FsmUpdate(instPtr, L2_TOR_RX);
|
||||
}
|
||||
if (rtneEntry->slotType == SLOT_INTRA_TSYNC) {
|
||||
if (rtneEntry->slotType == L2_SLOT_INTRA_TSYNC) {
|
||||
if(torState == L2_TOR_TX) {
|
||||
RTT_FsmUpdate(instPtr, L2_TOR_TX);
|
||||
}
|
||||
@@ -934,11 +934,11 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
|
||||
}
|
||||
|
||||
switch (rtneEntry->slotType) {
|
||||
case SLOT_INTER_MGMT:
|
||||
case L2_SLOT_INTER_MGMT:
|
||||
// TODO:
|
||||
L2_SetupNextSlot(instPtr, torState, L2_INTER_MGMT_FRAME);
|
||||
break;
|
||||
case SLOT_INTRA_MGMT:
|
||||
case L2_SLOT_INTRA_MGMT:
|
||||
memset(instPtr->sendPktData, 0xAA, INTRA_MGMT_FRAME_LENGTH_MAX);
|
||||
if (torState == L2_TOR_TX) {
|
||||
if(MgmtPkt_Packing(instPtr, MGMTPKT_INTRA_MGMT) != SUCCESS) {
|
||||
@@ -948,14 +948,14 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
|
||||
}
|
||||
L2_SetupNextSlot(instPtr, torState, L2_INTRA_MGMT_FRAME);
|
||||
break;
|
||||
case SLOT_INTER_TSYNC:
|
||||
case L2_SLOT_INTER_TSYNC:
|
||||
// TODO:
|
||||
L2_SetupNextSlot(instPtr, torState, L2_INTER_TSYNC_FRAME);
|
||||
break;
|
||||
case SLOT_INTRA_TSYNC:
|
||||
case L2_SLOT_INTRA_TSYNC:
|
||||
if (torState == L2_TOR_TX) {
|
||||
memset(instPtr->sendPktData, 0xAA, INTRA_RTT_FRAME_LENGTH_MAX);
|
||||
if(L2_GetNodeType(instPtr) == HEAD_NODE){
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD){
|
||||
if(MgmtPkt_Packing(instPtr, MGMTPKT_INTRA_RTTREQ) != SUCCESS) {
|
||||
Status = FAILURE;
|
||||
goto routine_err;
|
||||
@@ -978,26 +978,26 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
|
||||
|
||||
/*************************************************/
|
||||
// Update link layer state...
|
||||
if (L2_GetNodeType(instPtr) == HEAD_NODE) {
|
||||
L2_NODE_STATE newState = NONE_STATE;
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD) {
|
||||
L2_NODE_STATE newState = L2_NONE_STATE;
|
||||
L2_EVENT stateEvent = {
|
||||
.event = L2_EV_MAIN_STATE_UPDATE,
|
||||
.msg = &newState
|
||||
};
|
||||
if (L2_GetNodeListLen(instPtr->nodeList) < instPtr->config.netScale
|
||||
&& L2_GetMainState(instPtr) != INTRA_SEEK_STATE) {
|
||||
newState = INTRA_SEEK_STATE;
|
||||
&& L2_GetMainState(instPtr) != L2_INTRA_SEEK_STATE) {
|
||||
newState = L2_INTRA_SEEK_STATE;
|
||||
AssertL2Event(instPtr, &stateEvent);
|
||||
}
|
||||
else if(L2_GetNodeListLen(instPtr->nodeList) >= instPtr->config.netScale &&
|
||||
L2_GetMainState(instPtr) != NORMAL_STATE){
|
||||
newState = NORMAL_STATE;
|
||||
L2_GetMainState(instPtr) != L2_NORMAL_STATE){
|
||||
newState = L2_NORMAL_STATE;
|
||||
AssertL2Event(instPtr, &stateEvent);
|
||||
}
|
||||
}
|
||||
else{ // MEMBER_NODE or BACKUP_HEAD
|
||||
else{ // L2_NODE_MEMBER or BACKUP_HEAD
|
||||
if(L2_isNodeInList(instPtr->nodeList, L2_GetHeadId(instPtr)) == false){
|
||||
L2_NODE_STATE newState = INIT_STATE;
|
||||
L2_NODE_STATE newState = L2_INIT_STATE;
|
||||
L2_EVENT stateEvent = {
|
||||
.event = L2_EV_MAIN_STATE_UPDATE,
|
||||
.msg = &newState
|
||||
|
||||
Reference in New Issue
Block a user