bugfix: fix frame type inference.

This commit is contained in:
Gatsby Van
2024-01-05 16:39:54 +08:00
parent 7f852e9ddc
commit a3fd398729
+30 -1
View File
@@ -40,6 +40,7 @@ static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum);
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum); static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum);
static void L2_UpdateSlotNum(L2_INST *instPtr); static void L2_UpdateSlotNum(L2_INST *instPtr);
static void L2_DataAvailUpdate(L2_INST *instPtr, bool status); static void L2_DataAvailUpdate(L2_INST *instPtr, bool status);
static L2_FRAME_TYPE L2_GetReceiveFrameType(L2_INST *instPtr);
/** /**
* @brief helper function to update linkelayer state * @brief helper function to update linkelayer state
@@ -296,6 +297,34 @@ inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
rcd->next = netxVal; rcd->next = netxVal;
} }
/*****************************************************************************/
/**
* @brief Infer last received frame type.
*
* @param instPtr A pointer to physical layer control instance.
*
* @return L2_FRAME_TYPE.
*
******************************************************************************/
static L2_FRAME_TYPE L2_GetReceiveFrameType(L2_INST *instPtr)
{
if (instPtr->myInfo.nodeType == L2_NODE_HEAD || L2_isCxn2Net(instPtr))
{
return instPtr->frame.curr;
}
switch (instPtr->scanNetFSM->scanStage)
{
case L2_SCAN_INIT_STAGE:
case L2_SCAN_BMADVT_STAGE:
return L2_INTRA_BM_FRAME;
case L2_SCANT_2WAYACQ_STAGE:
return L2_INTRA_W2_ACQ_FRAME;
default:
return L2_NONE_FRAME;
}
}
/*****************************************************************************/ /*****************************************************************************/
/** /**
* @brief Update L2 frame state, check if there is any valid L2 frame data in * @brief Update L2 frame state, check if there is any valid L2 frame data in
@@ -322,7 +351,7 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
Phy_RetrieveRecvData(phyRef, instPtr->recvPktData); Phy_RetrieveRecvData(phyRef, instPtr->recvPktData);
instPtr->log.frameRecv++; instPtr->log.frameRecv++;
switch (instPtr->frame.last) switch (L2_GetReceiveFrameType(instPtr))
{ {
case L2_INTRA_SCAN_FRAME: case L2_INTRA_SCAN_FRAME:
// INTRA_BM_FRAME could be received if current frame type is INTRA_BM_FRAME // INTRA_BM_FRAME could be received if current frame type is INTRA_BM_FRAME