Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 42 additions & 13 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,13 +1016,28 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
{
static StaticTask_t xIPTaskBuffer;
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
"IP-Task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
xIPTaskStack,
&xIPTaskBuffer );
#if ( ipconfigIP_TASK_AFFINITY > 0 )
{
xIPTaskHandle = xTaskCreateStaticAffinitySet( &prvIPTask,
"IP-Task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
xIPTaskStack,
&xIPTaskBuffer,
ipconfigIP_TASK_AFFINITY );
}
#else /* if ( ipconfigIP_TASK_AFFINITY ) */
{
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
"IP-Task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
xIPTaskStack,
&xIPTaskBuffer );
}
#endif /* ipconfigIP_TASK_AFFINITY */

if( xIPTaskHandle != NULL )
{
Expand All @@ -1031,12 +1046,26 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
}
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
{
xReturn = xTaskCreate( &prvIPTask,
"IP-task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
&( xIPTaskHandle ) );
#if ( ipconfigIP_TASK_AFFINITY > 0 )
{
xReturn = xTaskCreateAffinitySet( &prvIPTask,
"IP-task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
ipconfigIP_TASK_AFFINITY,
&( xIPTaskHandle ) );
}
#else /* if ( ipconfigIP_TASK_AFFINITY ) */
{
xReturn = xTaskCreate( &prvIPTask,
"IP-task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
ipconfigIP_TASK_PRIORITY,
&( xIPTaskHandle ) );
}
#endif /* ipconfigIP_TASK_AFFINITY */
}
#endif /* configSUPPORT_STATIC_ALLOCATION */
}
Expand Down
40 changes: 40 additions & 0 deletions source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,46 @@ STATIC_ASSERT( pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ) <= portMAX_DELA

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

/*
* ipconfigIP_TASK_AFFINITY
*
* https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigIP_TASK_AFFINITY
*
* Type: UBaseType_t
* Unit: task affinity
* Minimum: 0
* Maximum: (2 ^ configNUMBER_OF_CORES) - 1
*
* When running using a SMP kernel, task affinity can be used to prevent
* concurrent execution of code that does not fully support SMP. Until
* the TCP library and ports fully supports SMP, it is necessary to set
* the affinity of all tasks which use TCP functions to the same core in
* order to prevent concurrent execution.
*
* An alternative to setting task affinity is to set configRUN_MULTIPLE_PRIORITIES
* to 0.
*
* Task affinity is defined as shifting a bit by the core number.
*
* Example:
* (1U << 0U) //run only on core 0
* (1U << 1U) //run only on core 1
*/

#ifndef ipconfigIP_TASK_AFFINITY
#define ipconfigIP_TASK_AFFINITY ( 0 )
#endif

#if ( ipconfigIP_TASK_AFFINITY < 0 )
#error ipconfigIP_TASK_AFFINITY must be at least 0
#endif

#if ( ipconfigIP_TASK_AFFINITY > 0 && configUSE_CORE_AFFINITY == 0 )
#error configUSE_CORE_AFFINITY must be 1 in order to use ipconfigIP_TASK_AFFINITY
#endif

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

/*
* ipconfigIP_TASK_STACK_SIZE_WORDS
*
Expand Down