miscellaneous update (enhance readability).

This commit is contained in:
Gatsby Van
2023-12-20 20:02:52 +08:00
parent 35ef220494
commit bfc1a14a50
+22 -20
View File
@@ -640,7 +640,7 @@ void L2_FrameStateUpdate(L2_INST* instPtr) {
int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType) { int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType) {
ASSERT(instPtr != NULL); ASSERT(instPtr != NULL);
PHY_INST* phyRef = instPtr->config.phyInstPtr; PHY_INST* phyRef = instPtr->config.phyInstPtr;
int32_t Status = SUCCESS; int32_t Status;
if (frameType < L2_INTER_SCAN_FRAME || frameType > L2_INTRA_SVC_FRAME) { if (frameType < L2_INTER_SCAN_FRAME || frameType > L2_INTRA_SVC_FRAME) {
return FAILURE; return FAILURE;
} }
@@ -714,7 +714,7 @@ int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
if(Status != SUCCESS){ if(Status != SUCCESS){
DBG_ERROR("Physical set pull time failed, with error code: %d\n", Status); DBG_ERROR("Physical set pull time failed, with error code: %d\n", Status);
} }
PHY_TOR_TYPE tor; PHY_TOR_TYPE tor;
switch(txrxMode) { switch(txrxMode) {
case L2_TOR_SUSPEND: case L2_TOR_SUSPEND:
@@ -905,6 +905,12 @@ int32_t Linklayer_Init(L2_INST** instPtr, const L2_CONFIG *config) {
(*instPtr)->isEnable = false; (*instPtr)->isEnable = false;
(*instPtr)->cxn2Net = false; (*instPtr)->cxn2Net = false;
(*instPtr)->dataAvail = false; (*instPtr)->dataAvail = false;
(*instPtr)->frameNum.last = 0;
(*instPtr)->frameNum.curr = 0;
(*instPtr)->frameNum.next = 0;
(*instPtr)->slotNum.last = 0;
(*instPtr)->slotNum.curr = 0;
(*instPtr)->slotNum.next = 0;
(*instPtr)->frame.last = L2_NONE_FRAME; (*instPtr)->frame.last = L2_NONE_FRAME;
(*instPtr)->frame.curr = L2_NONE_FRAME; (*instPtr)->frame.curr = L2_NONE_FRAME;
(*instPtr)->frame.next = L2_NONE_FRAME; (*instPtr)->frame.next = L2_NONE_FRAME;
@@ -915,15 +921,10 @@ int32_t Linklayer_Init(L2_INST** instPtr, const L2_CONFIG *config) {
(*instPtr)->rtneConfig.rtnePrd = ARRAY_SIZE(initTable); (*instPtr)->rtneConfig.rtnePrd = ARRAY_SIZE(initTable);
(*instPtr)->mainState = INIT_STATE; (*instPtr)->mainState = INIT_STATE;
(*instPtr)->nextState = INIT_STATE; (*instPtr)->nextState = INIT_STATE;
(*instPtr)->frameNum.last = 0;
(*instPtr)->frameNum.curr = 0;
(*instPtr)->frameNum.next = 0;
(*instPtr)->slotNum.last = 0;
(*instPtr)->slotNum.curr = 0;
(*instPtr)->slotNum.next = 0;
(*instPtr)->myInfo.nodeType = config->myType;
(*instPtr)->myInfo.nodeId = config->myId; (*instPtr)->myInfo.nodeId = config->myId;
(*instPtr)->myInfo.clustId = config->clustId; (*instPtr)->myInfo.clustId = config->clustId;
(*instPtr)->myInfo.headId = config->headId;
(*instPtr)->myInfo.nodeType = config->myType;
(*instPtr)->myInfo.pos.x = 0; (*instPtr)->myInfo.pos.x = 0;
(*instPtr)->myInfo.pos.y = 0; (*instPtr)->myInfo.pos.y = 0;
(*instPtr)->myInfo.pos.z = 0; (*instPtr)->myInfo.pos.z = 0;
@@ -989,6 +990,12 @@ int32_t Linklayer_Reconfig(L2_INST* instPtr, const L2_CONFIG *config) {
instPtr->rtneConfig.next = NULL; instPtr->rtneConfig.next = NULL;
instPtr->cxn2Net = false; instPtr->cxn2Net = false;
instPtr->dataAvail = false; instPtr->dataAvail = false;
instPtr->frameNum.last = 0;
instPtr->frameNum.curr = 0;
instPtr->frameNum.next = 0;
instPtr->slotNum.last = 0;
instPtr->slotNum.curr = 0;
instPtr->slotNum.next = 0;
instPtr->frame.last = L2_NONE_FRAME; instPtr->frame.last = L2_NONE_FRAME;
instPtr->frame.curr = L2_NONE_FRAME; instPtr->frame.curr = L2_NONE_FRAME;
instPtr->frame.next = L2_NONE_FRAME; instPtr->frame.next = L2_NONE_FRAME;
@@ -999,15 +1006,10 @@ int32_t Linklayer_Reconfig(L2_INST* instPtr, const L2_CONFIG *config) {
instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(initTable); instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(initTable);
instPtr->mainState = INIT_STATE; instPtr->mainState = INIT_STATE;
instPtr->nextState = INIT_STATE; instPtr->nextState = INIT_STATE;
instPtr->frameNum.last = 0;
instPtr->frameNum.curr = 0;
instPtr->frameNum.next = 0;
instPtr->slotNum.last = 0;
instPtr->slotNum.curr = 0;
instPtr->slotNum.next = 0;
instPtr->myInfo.nodeType = config->myType;
instPtr->myInfo.nodeId = config->myId; instPtr->myInfo.nodeId = config->myId;
instPtr->myInfo.clustId = config->clustId; instPtr->myInfo.clustId = config->clustId;
instPtr->myInfo.headId = config->headId;
instPtr->myInfo.nodeType = config->myType;
instPtr->myInfo.pos.x = 0; instPtr->myInfo.pos.x = 0;
instPtr->myInfo.pos.y = 0; instPtr->myInfo.pos.y = 0;
instPtr->myInfo.pos.z = 0; instPtr->myInfo.pos.z = 0;
@@ -1103,7 +1105,7 @@ int32_t Linklayer_EventHandler(L2_INST* instPtr, const L2_EVENT* l2Event) {
} }
case L2_EV_NET_SETUP_DONE: { case L2_EV_NET_SETUP_DONE: {
DBG_INFO("Event L2_EV_NETSETUP_DONE asserted....\n"); DBG_INFO("Event L2_EV_NETSETUP_DONE asserted....\n");
if(instPtr->myInfo.nodeType != HEAD_NODE){ if(L2_GetNodeType(instPtr) != HEAD_NODE){
instPtr->cxn2Net = true; instPtr->cxn2Net = true;
} }
else{ // Head node else{ // Head node
@@ -1121,7 +1123,7 @@ int32_t Linklayer_EventHandler(L2_INST* instPtr, const L2_EVENT* l2Event) {
} }
case L2_EV_LOST_CXN: { case L2_EV_LOST_CXN: {
DBG_INFO("Event L2_EV_LOST_CXN asserted....\n"); DBG_INFO("Event L2_EV_LOST_CXN asserted....\n");
DBG_WARNING("Lost connection with head node [%d].\n", instPtr->config.headId); DBG_WARNING("Lost connection with head node [%d].\n", L2_GetHeadId(instPtr));
instPtr->cxn2Net = false; instPtr->cxn2Net = false;
break; break;
} }
@@ -1355,11 +1357,11 @@ int32_t Linklayer_Proc(L2_INST* instPtr) {
// Handle frame received in last slot. // Handle frame received in last slot.
if(L2_isDataAvail(instPtr) == true){ if(L2_isDataAvail(instPtr) == true){
Linklayer_PktHandler(instPtr, L2_GetLastRcvFrameType(instPtr)); Linklayer_PktHandler(instPtr, L2_GetLastFrameType(instPtr));
} }
// Run Link layer routine, setup next slot procedure. // Run Link layer routine, setup next slot procedure.
if (instPtr->myInfo.nodeType == HEAD_NODE) { if (L2_GetNodeType(instPtr) == HEAD_NODE) {
Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL); Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL);
Status = Linklayer_Routine(instPtr); Status = Linklayer_Routine(instPtr);
} }