forked from gatsby/datalink_repo
miscellaneous update (and adapt to new node list api)
This commit is contained in:
@@ -27,7 +27,9 @@
|
|||||||
/************************** Constant Definitions *****************************/
|
/************************** Constant Definitions *****************************/
|
||||||
#define SQUENCE_MGMT_SLOTS 0
|
#define SQUENCE_MGMT_SLOTS 0
|
||||||
#define INTER_MGMT_SLOTS 2
|
#define INTER_MGMT_SLOTS 2
|
||||||
|
#define INTER_TSYNC_SLOTS 2
|
||||||
#define INTRA_MGMT_SLOTS 1
|
#define INTRA_MGMT_SLOTS 1
|
||||||
|
#define INTRA_TSYNC_SLOTS 1
|
||||||
#define NONE_MGMT_SLOTS -1
|
#define NONE_MGMT_SLOTS -1
|
||||||
#define CONX_LOST_TH 10 // 10 count of mgmt msg no response to delete
|
#define CONX_LOST_TH 10 // 10 count of mgmt msg no response to delete
|
||||||
#define TIME2QUIT 80 // time to send quit message
|
#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);
|
FrameGetChunk(mgmtMsg, NQT_MSG_CTRL_MUTE_OFFSET, NQT_MSG_CTRL_MUTE_LEN, &dataChunk);
|
||||||
mgmtMsgLog->quitCtrlWord = (uint8_t)(dataChunk & 0x7F);
|
mgmtMsgLog->quitCtrlWord = (uint8_t)(dataChunk & 0x7F);
|
||||||
if (mgmtMsgLog->quitCtrlWord == 0x01) {
|
if (mgmtMsgLog->quitCtrlWord == 0x01) {
|
||||||
DeletNode(instPtr->nodeList, mgmtMsgLog->quitNodeId);
|
L2_DeleteNodeById(instPtr->nodeList, mgmtMsgLog->quitNodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -731,7 +733,7 @@ int32_t MgmtNet_PktHandler(L2_INST* instPtr) {
|
|||||||
AssertL2Event(instPtr, &stateUpEvent);
|
AssertL2Event(instPtr, &stateUpEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
RstNodeTTL(instPtr->nodeList, mgmtMsgLog->srcNodeId);
|
L2_RstNodeTTL(instPtr->nodeList, mgmtMsgLog->srcNodeId);
|
||||||
// TODO: Check
|
// TODO: Check
|
||||||
if(mgmtMsgLog->srcNodeId == L2_GetHeadId(instPtr)){
|
if(mgmtMsgLog->srcNodeId == L2_GetHeadId(instPtr)){
|
||||||
L2_TimeAlign(instPtr, L2_GetCurrentFrameNum(instPtr), L2_GetCurrentSlotNum(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_INTER_TSYNC_FRAME:
|
||||||
case L2_INTRA_TSYNC_FRAME: {
|
case L2_INTRA_TSYNC_FRAME: {
|
||||||
L2_RTT_SATGE rttStage = L2_GetRttFsm(instPtr)->rttStatge;
|
if(L2_GetNodeType(instPtr) == HEAD_NODE){
|
||||||
if(rttStage == RTT_REQ1 || rttStage == RTT_REQ2){
|
|
||||||
for (int i = 0; i < ARRAY_SIZE(rttReqFrameMsgs); i++) {
|
for (int i = 0; i < ARRAY_SIZE(rttReqFrameMsgs); i++) {
|
||||||
memcpy(mgmtMsg->words,
|
memcpy(mgmtMsg->words,
|
||||||
instPtr->recvPktData + (size_t) (i * (RTT_MSG_LEN / 8)),
|
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++) {
|
for (int i = 0; i < ARRAY_SIZE(rttRspFrameMsgs); i++) {
|
||||||
memcpy(mgmtMsg->words,
|
memcpy(mgmtMsg->words,
|
||||||
instPtr->recvPktData + (size_t) (i * (RTT_MSG_LEN / 8)),
|
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
|
// TODO: Check
|
||||||
if((rttMsgRspLog->srcAddr&0x001F) == L2_GetHeadId(instPtr)){
|
if((rttMsgRspLog->srcAddr&0x001F) == L2_GetHeadId(instPtr)){
|
||||||
L2_TimeAlign(instPtr, L2_GetCurrentFrameNum(instPtr), L2_GetCurrentSlotNum(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.
|
// Check if there is any node exceeds the ttl threshold.
|
||||||
IterDeleteNode(instPtr->nodeList, IsTTLValid);
|
L2_IterDeleteNode(instPtr->nodeList, IsTTLValid);
|
||||||
|
|
||||||
// Determine next slot TOR state.
|
// Determine next slot TOR state.
|
||||||
L2_TOR_TYPE torState = L2_TOR_SUSPEND;
|
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,
|
.event = L2_EV_MAIN_STATE_UPDATE,
|
||||||
.msg = &newState
|
.msg = &newState
|
||||||
};
|
};
|
||||||
if (instPtr->nodeList->nodeNum < instPtr->config.netScale
|
if (L2_GetNodeListLen(instPtr->nodeList) < instPtr->config.netScale
|
||||||
&& L2_GetMainState(instPtr) != INTRA_SEEK_STATE) {
|
&& L2_GetMainState(instPtr) != INTRA_SEEK_STATE) {
|
||||||
newState = INTRA_SEEK_STATE;
|
newState = INTRA_SEEK_STATE;
|
||||||
AssertL2Event(instPtr, &stateEvent);
|
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){
|
L2_GetMainState(instPtr) != NORMAL_STATE){
|
||||||
newState = NORMAL_STATE;
|
newState = NORMAL_STATE;
|
||||||
AssertL2Event(instPtr, &stateEvent);
|
AssertL2Event(instPtr, &stateEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ // MEMBER_NODE or BACKUP_HEAD
|
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_NODE_STATE newState = INIT_STATE;
|
||||||
L2_EVENT stateEvent = {
|
L2_EVENT stateEvent = {
|
||||||
.event = L2_EV_MAIN_STATE_UPDATE,
|
.event = L2_EV_MAIN_STATE_UPDATE,
|
||||||
|
|||||||
Reference in New Issue
Block a user