Skip to content

Commit 07b203f

Browse files
Add configuration option to prevent configASSERT checks on ipBUFFER_PADDING (#1271)
* Added ipconfigSUPPRESS_BUFFER_PADDING_CHECK to eliminate configASSERT checks on ipBUFFER_PADDING in FreeRTOS_IP_Utils.c/vPreCheckConfigs( void ) * Defaults to ipconfigDISABLE to build with configASSERT checks in place. * User settable to ipconfigENABLE to eliminate configASSERT checks. * Fix formatting --------- Co-authored-by: Dave Skok <[email protected]> Co-authored-by: Tony Josi <[email protected]>
1 parent 16dcb1f commit 07b203f

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

source/FreeRTOS_IP_Utils.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,26 +1004,29 @@ void vPreCheckConfigs( void )
10041004
{
10051005
size_t uxSize;
10061006

1007-
/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
1008-
* See FreeRTOS_IP.h for more details. */
1009-
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
1007+
#if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 )
1008+
1009+
/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
1010+
* See FreeRTOS_IP.h for more details. */
1011+
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
1012+
1013+
/*
1014+
* This is a 64-bit platform, make sure there is enough space in
1015+
* pucEthernetBuffer to store a pointer.
1016+
*/
1017+
configASSERT( ipBUFFER_PADDING >= 14U );
1018+
#else
1019+
/* This is a 32-bit platform. */
1020+
configASSERT( ipBUFFER_PADDING >= 10U );
1021+
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */
10101022

10111023
/*
1012-
* This is a 64-bit platform, make sure there is enough space in
1013-
* pucEthernetBuffer to store a pointer.
1024+
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
1025+
* multiple of 32 bits, in order to get aligned access to all uint32_t
1026+
* fields in the protocol headers.
10141027
*/
1015-
configASSERT( ipBUFFER_PADDING >= 14U );
1016-
#else
1017-
/* This is a 32-bit platform. */
1018-
configASSERT( ipBUFFER_PADDING >= 10U );
1019-
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */
1020-
1021-
/*
1022-
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
1023-
* multiple of 32 bits, in order to get aligned access to all uint32_t
1024-
* fields in the protocol headers.
1025-
*/
1026-
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
1028+
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
1029+
#endif /* if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 ) */
10271030

10281031
/* LCOV_EXCL_BR_START */
10291032
uxSize = ipconfigNETWORK_MTU;

source/include/FreeRTOSIPConfigDefaults.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3403,6 +3403,24 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY );
34033403

34043404
/*---------------------------------------------------------------------------*/
34053405

3406+
/*
3407+
* ipconfigSUPPRESS_BUFFER_PADDING_CHECK
3408+
*
3409+
* Type: BaseType_t ( ipconfigENABLE | ipconfigDISABLE )
3410+
*
3411+
* Suppress configuration check when user configuration
3412+
* for ipconfigPACKET_FILLER_SIZE or ipconfigBUFFER_PADDING is
3413+
* sub optimal. Useful when porting to a MAC that does not include
3414+
* the option to pad received packets ipconfigPACKET_FILLER_SIZE
3415+
* within a word boundary.
3416+
*/
3417+
3418+
#ifndef ipconfigSUPPRESS_BUFFER_PADDING_CHECK
3419+
#define ipconfigSUPPRESS_BUFFER_PADDING_CHECK ipconfigDISABLE
3420+
#endif
3421+
3422+
/*---------------------------------------------------------------------------*/
3423+
34063424
/*
34073425
* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS
34083426
*

0 commit comments

Comments
 (0)