Hello again,
I have some news to share. I’ve created a function to check within vReleaseNetworkBufferAndDescriptor if the UDP network buffers that I allocate at startup through FreeRTOS_GetUDPPayloadBuffer are being released. It is actually the case:
Below you can see the check:
void vReleaseNetworkBufferAndDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer )
{
BaseType_t xListItemAlreadyInFreeList;
bool houstonWeHaveAProblem = false;
if(ext_adc_check_buff_add_reserved(&( pxNetworkBuffer->pucEthernetBuffer[ sizeof( UDPPacket_t ) ] ))) {
houstonWeHaveAProblem = true;
}
This part of the code is triggered wich eventually releases the allocated UDP buffers for Zero-Copy:
/* When a packet has been transmitted, the descriptor must be
* prepared for a next transmission.
* When using zero-copy, the network buffer must be released
* ( i.e. returned to the pool of network buffers ). */
if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0U )
{
vClearOptionBit( &( ulISREvents ), EMAC_IF_TX_EVENT );
if( xSemaphoreTake( xTransmissionMutex, 10000U ) != pdFAIL )
{
ETH_Clear_Tx_Descriptors( &( xEthHandle ) );
xSemaphoreGive( xTransmissionMutex );
}
}
and then:
#if ( ipconfigZERO_COPY_TX_DRIVER != 0 )
{
NetworkBufferDescriptor_t * pxNetworkBuffer;
uint8_t * ucPayLoad;
ucPayLoad = ( uint8_t * ) xDMATxDescriptor->DESC0;
if( ucPayLoad == NULL )
{
/* No buffer is assigned or DMA still OWNs this descriptor. */
break;
}
pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad );
if( pxNetworkBuffer != NULL )
{
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
}
}
#endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */
From the comment I understand that this behavior is indeed wanted. It seems that the buffers allocated when in ZERO-Copy need to be released after each transmission. This is quite a killer for my application as I use the buffers in an ISR continuously and I can not call every time I send a packet FreeRTOS_GetUDPPayloadBuffer to allocate a new one, as it is not permitted in the ISR.
Is there a fundamental reason behind releasing the allocated buffers when in ZERO-Copy always after each transmission?, or would be ok to modify this?