Skip to content

Commit

Permalink
adding queue initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws committed Oct 31, 2023
1 parent 81e9ecf commit 28bb905
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
79 changes: 67 additions & 12 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,13 @@ static eFrameProcessingResult_t prvProcessUDPPacket( NetworkBufferDescriptor_t *

/*-----------------------------------------------------------*/

/** @brief The queue used to pass events into the IP-task for processing. */
QueueHandle_t xNetworkEventQueue = NULL;
#if ( ipconfigMULTI_PRIORITY_EVENT_QUEUES == 1 )
/** @brief Multi priority event queues for TX and RX, and their mapping.
*/
QueueHandle_t xNetworkTxRxEventQueues[ ipconfigEVENT_QUEUES ][ 2 ] = { { NULL } };
uint8_t xQueueMapping[ ipconfigEVENT_QUEUES ] = ipconfigPACKET_PRIORITY_QUEUE_MAPPING;
#else
/** @brief The queue used to pass events into the IP-task for processing. */
QueueHandle_t xNetworkEventQueue = NULL;
#endif

/** @brief The IP packet ID. */
Expand Down Expand Up @@ -1028,6 +1027,11 @@ void * FreeRTOS_GetUDPPayloadBuffer_Multi( size_t uxRequestedSizeBytes,
BaseType_t FreeRTOS_IPInit_Multi( void )
{
BaseType_t xReturn = pdFALSE;
BaseType_t xQueueCreateStatus = pdFALSE;

#if ( ipconfigEVENT_QUEUES > 1 )
BaseType_t xIndex;
#endif

/* There must be at least one interface and one end-point. */
configASSERT( FreeRTOS_FirstNetworkInterface() != NULL );
Expand All @@ -1039,21 +1043,72 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
/* Attempt to create the queue used to communicate with the IP task. */
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{
static StaticQueue_t xNetworkEventStaticQueue;
static uint8_t ucNetworkEventQueueStorageArea[ ipconfigEVENT_QUEUE_LENGTH * sizeof( IPStackEvent_t ) ];
xNetworkEventQueue = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH,
sizeof( IPStackEvent_t ),
ucNetworkEventQueueStorageArea,
&xNetworkEventStaticQueue );
#if ( ipconfigMULTI_PRIORITY_EVENT_QUEUES == 1 )
static StaticQueue_t xNetworkEventStaticQueue[ ipconfigEVENT_QUEUES ][ 2 ];
static uint8_t ucNetworkEventQueueStorageArea[ ipconfigEVENT_QUEUES ][ 2 ][ ipconfigEVENT_QUEUE_LENGTH * sizeof( IPStackEvent_t ) ];

xQueueCreateStatus = pdTRUE;

for( xIndex = 0; xIndex < ipconfigEVENT_QUEUES; xIndex++ )
{
xNetworkTxRxEventQueues[ xIndex ][ 0 ] = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH,
sizeof( IPStackEvent_t ),
ucNetworkEventQueueStorageArea[ xIndex ][ 0 ],
&xNetworkEventStaticQueue[ xIndex ][ 0 ] );
xQueueCreateStatus &= ( xNetworkTxRxEventQueues[ xIndex ][ 0 ] != NULL );

xNetworkTxRxEventQueues[ xIndex ][ 1 ] = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH,
sizeof( IPStackEvent_t ),
ucNetworkEventQueueStorageArea[ xIndex ][ 1 ],
&xNetworkEventStaticQueue[ xIndex ][ 1 ] );
xQueueCreateStatus &= ( xNetworkTxRxEventQueues[ xIndex ][ 1 ] != NULL );

}

xNetworkEventQueue = xNetworkTxRxEventQueues[ ipconfigEVENT_QUEUES - 1 ][ 0 ];

#else
static StaticQueue_t xNetworkEventStaticQueue;
static uint8_t ucNetworkEventQueueStorageArea[ ipconfigEVENT_QUEUE_LENGTH * sizeof( IPStackEvent_t ) ];

xNetworkEventQueue = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH,
sizeof( IPStackEvent_t ),
ucNetworkEventQueueStorageArea,
&xNetworkEventStaticQueue );

xQueueCreateStatus = ( xNetworkEventQueue != NULL );

#endif
}
#else
{
xNetworkEventQueue = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) );
configASSERT( xNetworkEventQueue != NULL );
#if ( ipconfigMULTI_PRIORITY_EVENT_QUEUES == 1 )
xQueueCreateStatus = pdTRUE;

for( xIndex = 0; xIndex < ipconfigEVENT_QUEUES; xIndex++ )
{
xNetworkTxRxEventQueues[ xIndex ][ 0 ] = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) );
configASSERT( xNetworkTxRxEventQueues[ xIndex ][ 0 ] != NULL );
xQueueCreateStatus &= ( xNetworkTxRxEventQueues[ xIndex ][ 0 ] != NULL );

xNetworkTxRxEventQueues[ xIndex ][ 1 ] = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) );
configASSERT( xNetworkTxRxEventQueues[ xIndex ][ 1 ] != NULL );
xQueueCreateStatus &= ( xNetworkTxRxEventQueues[ xIndex ][ 1 ] != NULL );
}

xNetworkEventQueue = xNetworkTxRxEventQueues[ ipconfigEVENT_QUEUES - 1 ][ 0 ];

#else

xNetworkEventQueue = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) );
configASSERT( xNetworkEventQueue != NULL );
xQueueCreateStatus = ( xNetworkEventQueue != NULL );

#endif
}
#endif /* configSUPPORT_STATIC_ALLOCATION */

if( xNetworkEventQueue != NULL )
if( xQueueCreateStatus != pdFALSE )
{
#if ( configQUEUE_REGISTRY_SIZE > 0 )
{
Expand Down
2 changes: 1 addition & 1 deletion source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@

#ifndef ipconfigPACKET_PRIORITY_QUEUE_MAPPING
#if ( ipconfigEVENT_QUEUES == 8 )
#define ipconfigPACKET_PRIORITY_QUEUE_MAPPING { 7, 6, 5, 4, 3, 2, 1, 0 }
#define ipconfigPACKET_PRIORITY_QUEUE_MAPPING { 0, 1, 2, 3, 4, 5, 6, 7 }
#endif
#endif

Expand Down

0 comments on commit 28bb905

Please sign in to comment.