miscellaneous update (and adapt to new node list api)

This commit is contained in:
Gatsby Van
2023-12-22 01:25:54 +08:00
parent c1e26fa20b
commit b76a4cd776
+11 -10
View File
@@ -27,7 +27,9 @@
/************************** Constant Definitions *****************************/
#define SQUENCE_MGMT_SLOTS 0
#define INTER_MGMT_SLOTS 2
#define INTER_TSYNC_SLOTS 2
#define INTRA_MGMT_SLOTS 1
#define INTRA_TSYNC_SLOTS 1
#define NONE_MGMT_SLOTS -1
#define CONX_LOST_TH 10 // 10 count of mgmt msg no response to delete
#define TIME2QUIT 80 // time to send quit message
@@ -680,7 +682,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
FrameGetChunk(mgmtMsg, NQT_MSG_CTRL_MUTE_OFFSET, NQT_MSG_CTRL_MUTE_LEN, &dataChunk);
mgmtMsgLog->quitCtrlWord = (uint8_t)(dataChunk & 0x7F);
if (mgmtMsgLog->quitCtrlWord == 0x01) {
DeletNode(instPtr->nodeList, mgmtMsgLog->quitNodeId);
L2_DeleteNodeById(instPtr->nodeList, mgmtMsgLog->quitNodeId);
}
}
else {
@@ -731,7 +733,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
AssertL2Event(instPtr, &stateUpEvent);
}
RstNodeTTL(instPtr->nodeList, mgmtMsgLog->srcNodeId);
L2_RstNodeTTL(instPtr->nodeList, mgmtMsgLog->srcNodeId);
// TODO: Check
if(mgmtMsgLog->srcNodeId == L2_GetHeadId(instPtr)){
L2_TimeAlign(instPtr, L2_GetCurrentFrameNum(instPtr), L2_GetCurrentSlotNum(instPtr));
@@ -740,8 +742,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
}
case L2_INTER_TSYNC_FRAME:
case L2_INTRA_TSYNC_FRAME: {
L2_RTT_SATGE rttStage = L2_GetRttFsm(instPtr)->rttStatge;
if(rttStage == RTT_REQ1 || rttStage == RTT_REQ2){
if(L2_GetNodeType(instPtr) == HEAD_NODE){
for (int i = 0; i < ARRAY_SIZE(rttReqFrameMsgs); i++) {
memcpy(mgmtMsg->words,
instPtr->recvPktData + (size_t) (i * (RTT_MSG_LEN / 8)),
@@ -793,7 +794,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
}
}
}
else if(rttStage == RTT_RSP1 || rttStage == RTT_RSP2){
else {
for (int i = 0; i < ARRAY_SIZE(rttRspFrameMsgs); i++) {
memcpy(mgmtMsg->words,
instPtr->recvPktData + (size_t) (i * (RTT_MSG_LEN / 8)),
@@ -847,7 +848,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
}
}
RstNodeTTL(instPtr->nodeList, rttMsgRspLog->srcAddr & 0x001F);
L2_RstNodeTTL(instPtr->nodeList, rttMsgRspLog->srcAddr & 0x001F);
// TODO: Check
if((rttMsgRspLog->srcAddr&0x001F) == L2_GetHeadId(instPtr)){
L2_TimeAlign(instPtr, L2_GetCurrentFrameNum(instPtr), L2_GetCurrentSlotNum(instPtr));
@@ -898,7 +899,7 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
}
// Check if there is any node exceeds the ttl threshold.
IterDeleteNode(instPtr->nodeList, IsTTLValid);
L2_IterDeleteNode(instPtr->nodeList, IsTTLValid);
// Determine next slot TOR state.
L2_TOR_TYPE torState = L2_TOR_SUSPEND;
@@ -983,19 +984,19 @@ int32_t MgmtNet_Routine(L2_INST* instPtr, const L2_RTNE_TABLE_ENTRY* rtneEntry){
.event = L2_EV_MAIN_STATE_UPDATE,
.msg = &newState
};
if (instPtr->nodeList->nodeNum < instPtr->config.netScale
if (L2_GetNodeListLen(instPtr->nodeList) < instPtr->config.netScale
&& L2_GetMainState(instPtr) != INTRA_SEEK_STATE) {
newState = INTRA_SEEK_STATE;
AssertL2Event(instPtr, &stateEvent);
}
else if(instPtr->nodeList->nodeNum >= instPtr->config.netScale &&
else if(L2_GetNodeListLen(instPtr->nodeList) >= instPtr->config.netScale &&
L2_GetMainState(instPtr) != NORMAL_STATE){
newState = NORMAL_STATE;
AssertL2Event(instPtr, &stateEvent);
}
}
else{ // MEMBER_NODE or BACKUP_HEAD
if(IsNodeInList(instPtr->nodeList, L2_GetHeadId(instPtr)) == false){
if(L2_isNodeInList(instPtr->nodeList, L2_GetHeadId(instPtr)) == false){
L2_NODE_STATE newState = INIT_STATE;
L2_EVENT stateEvent = {
.event = L2_EV_MAIN_STATE_UPDATE,