After porting existing K65 code from SDKv2.7.0 to SDKv2.9.0 (verified the issue with SDKv2.8.2 as well), I now am seeing asserts when operating my device on an extremely busy network. The assert being seen (ENET_GetRxBuffer() status != kStatus_Success) is found in the new function ethernetif_drop_frame() of enet_ethernetif_kinetis.c:
static void ethernetif_drop_frame(struct ethernetif *ethernetif)
{
status_t status;
void *buffer;
uint32_t len;
uint32_t ts;
bool isLastBuff;
do
{
#if 0 /* Error statisctics */
enet_data_error_stats_t eErrStatic;
/* Get the error information of the received g_frame. */
ENET_GetRxErrBeforeReadFrame(ðernetif->handle, &eErrStatic);
#endif
status = ENET_GetRxBuffer(ethernetif->base, ðernetif->handle, &buffer, &len, 0, &isLastBuff, &ts);
LWIP_UNUSED_ARG(status); /* for LWIP_NOASSERT */
LWIP_ASSERT("ENET_GetRxBuffer() status != kStatus_Success", status == kStatus_Success);
ENET_ReleaseRxBuffer(ethernetif->base, ðernetif->handle, buffer, 0);
} while (!isLastBuff);
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_linkinput: RxFrameError\n"));
LINK_STATS_INC(link.drop);
MIB2_STATS_NETIF_INC(netif, ifindiscards);
}
The asserts occur when receive descriptors are being dropped because of frame errors found by ENET_GetRxFrameSize when the length of the descriptor buffer is zero:
/* Add check for abnormal case. */
if (curBuffDescrip->length == 0U)
{
isReturn = true;
result = kStatus_ENET_RxFrameError;
break;
}
When this is the case, it seems that the last flag (ENET_BUFFDESCRIPTOR_RX_LAST_MASK) on the descriptor in error is not set, resulting in the ethernetif_drop_frame() function attempting to drop multiple descriptors. It is when this function is attempting to drop the second descriptor that this error/assert occurs.
Setting the last flag in the descriptor in error seems to solve the issue as this stops the drop frame function from dropping multiple descriptors. Though I am unsure if this is the correct solution.
Does anyone have any thoughts on what is going on here and what the proper solution might be?