From e4e236a6c1df6b2d95fc71c6c597e1df89dd0cd6 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu, 13 Oct 2022 18:41:14 -0700 Subject: [PATCH 01/44] Update mainline to reflect changes after the release. (#563) * Update README.md * Update History.txt * Update version number macros * Update manifest.yml --- History.txt | 5 +++++ README.md | 2 +- manifest.yml | 2 +- source/include/FreeRTOS_IP.h | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/History.txt b/History.txt index 441587adb1..9837b7d4d7 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,8 @@ +Changes between V3.0.0 and V3.1.0 releases: + + Fixed a bug in the Connect function where multiple SYN and RST packet combinations can + lead to orphaned sockets. + + Added network interface support for NetifSlirp. + Changes between V3.0.0 and V2.4.0 releases: + Split the source files according to the function the code performs. This makes the code modular making test coverage easier. diff --git a/README.md b/README.md index d6c84f02d6..7c6ee16c6e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The easiest way to use FreeRTOS-Plus-TCP is to start with the pre-configured dem Additionally, for FreeRTOS-Plus-TCP source code organization refer to the [Documentation](http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial.html), and [API Reference](https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html). -FreeRTOS-Plus-TCP V2.3.2-LTS-Patch-2 [source code](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/tree/V2.3.2-LTS-Patch-2)(.c .h) is part of the [FreeRTOS 202012.04 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.04-LTS) release. +**FreeRTOS-Plus-TCP V3.1.0 [source code](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/tree/V3.1.0)(.c .h) is part of the [FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS) release.** ### Getting help If you have any questions or need assistance troubleshooting your FreeRTOS project, we have an active community that can help on the [FreeRTOS Community Support Forum](https://forums.freertos.org). Please also refer to [FAQ](http://www.freertos.org/FAQHelp.html) for frequently asked questions. diff --git a/manifest.yml b/manifest.yml index 8e85092f39..2960e74170 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,5 +1,5 @@ name : "FreeRTOS-Plus-TCP" -version: "V3.0.0" +version: "V3.1.0" description: "Thread safe FreeRTOS TCP/IP stack working on top of the FreeRTOS-Kernel to implement the TCP/IP protocol. Suitable for microcontrollers." license: "MIT" dependencies: diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index 805b880fbb..d8cdf2be1e 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -44,9 +44,9 @@ /* Constants defining the current version of the FreeRTOS+TCP * network stack. */ -#define ipFR_TCP_VERSION_NUMBER "V3.0.999" +#define ipFR_TCP_VERSION_NUMBER "V3.1.999" #define ipFR_TCP_VERSION_MAJOR 3 -#define ipFR_TCP_VERSION_MINOR 0 +#define ipFR_TCP_VERSION_MINOR 1 /* Development builds are always version 999. */ #define ipFR_TCP_VERSION_BUILD 999 From b33224bde761a456b2661934561a932324f24d20 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Fri, 4 Nov 2022 04:25:31 +0800 Subject: [PATCH 02/44] IPv4/single SAME70 emac race condition (#567) * Implemented Maty's solution * Added a new statistic 'tx_write_fail' * Uncrustify: triggered by comment. Co-authored-by: Hein Tibosch Co-authored-by: GitHub Action --- .../DriverSAM/NetworkInterface.c | 112 ++++++++++-------- .../NetworkInterface/DriverSAM/gmac_SAM.c | 65 ++++++---- .../NetworkInterface/DriverSAM/gmac_SAM.h | 27 ++++- 3 files changed, 130 insertions(+), 74 deletions(-) diff --git a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c index 402865aaf7..7bbbc81425 100644 --- a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c +++ b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c @@ -53,6 +53,15 @@ /* This file is included to see if 'CONF_BOARD_ENABLE_CACHE' is defined. */ #include "conf_board.h" +/* The SAME70 family has the possibility of caching RAM. + * 'NETWORK_BUFFERS_CACHED' can be defined in either "conf_eth.h" + * or in "FreeRTOSIPConfig.h". + * For now, NETWORK_BUFFERS_CACHED should be defined as zero. + * D-cache may be enabled. + */ +#if ( NETWORK_BUFFERS_CACHED != 0 ) + #error please define this macro as zero +#endif /* Interrupt events to process. Currently only the Rx event is processed * although code for other events is included to allow for possible future @@ -95,10 +104,9 @@ #define niEMAC_HANDLER_TASK_PRIORITY configMAX_PRIORITIES - 1 #endif -#if ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) +#if ( NETWORK_BUFFERS_CACHED != 0 ) && ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) #include "core_cm7.h" #warning This driver assumes the presence of DCACHE - #define NETWORK_BUFFERS_CACHED 1 #define CACHE_LINE_SIZE 32 #define NETWORK_BUFFER_HEADER_SIZE ( ipconfigPACKET_FILLER_SIZE + 8 ) @@ -113,26 +121,24 @@ uint32_t size ) { /* SAME70 does not have clean/invalidate per area. */ - /* SCB_CleanInvalidateDCache_by_Addr( ( uint32_t * )addr, size); */ - SCB_CleanInvalidateDCache(); + SCB_CleanInvalidateDCache_by_Addr( ( uint32_t * ) addr, size ); } /*-----------------------------------------------------------*/ - static void cache_invalidate_by_addr( addr, - size ) \ + static void cache_invalidate_by_addr( uint32_t addr, + uint32_t size ) { /* SAME70 does not have clean/invalidate per area. */ - /* SCB_InvalidateDCache_by_Addr( ( uint32_t * )addr, size); */ - SCB_InvalidateDCache(); + SCB_InvalidateDCache_by_Addr( ( uint32_t * ) addr, size ); } /*-----------------------------------------------------------*/ -#else /* if ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) */ +#else /* The DMA buffers are located in non-cached RAM. */ #warning Sure there is no caching? #define cache_clean_invalidate() do {} while( 0 ) #define cache_clean_invalidate_by_addr( addr, size ) do {} while( 0 ) #define cache_invalidate_by_addr( addr, size ) do {} while( 0 ) -#endif /* if ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) */ +#endif /* if ( NETWORK_BUFFERS_CACHED != 0 ) && ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) */ /*-----------------------------------------------------------*/ @@ -186,13 +192,8 @@ static void hand_tx_errors( void ); /*-----------------------------------------------------------*/ -/* Bit map of outstanding ETH interrupt events for processing. Currently only - * the Rx interrupt is handled, although code is included for other events to - * enable future expansion. */ -static volatile uint32_t ulISREvents; - /* A copy of PHY register 1: 'PHY_REG_01_BMSR' */ -static volatile BaseType_t xGMACSwitchRequired; +static BaseType_t xGMACSwitchRequired; /* LLMNR multicast address. */ static const uint8_t llmnr_mac_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; @@ -205,8 +206,9 @@ static gmac_device_t gs_gmac_dev; * related interrupts. */ TaskHandle_t xEMACTaskHandle = NULL; +/* TX buffers that have been sent must be returned to the driver + * using this queue. */ static QueueHandle_t xTxBufferQueue; -int tx_release_count[ 4 ]; /* xTXDescriptorSemaphore is a counting semaphore with * a maximum count of GMAC_TX_BUFFERS, which is the number of @@ -271,21 +273,21 @@ void xRxCallback( uint32_t ulStatus ) if( ( ( ulStatus & GMAC_RSR_REC ) != 0 ) && ( xEMACTaskHandle != NULL ) ) { /* let the prvEMACHandlerTask know that there was an RX event. */ - ulISREvents |= EMAC_IF_RX_EVENT; - /* Only an RX interrupt can wakeup prvEMACHandlerTask. */ - vTaskNotifyGiveFromISR( xEMACTaskHandle, ( BaseType_t * ) &xGMACSwitchRequired ); + xTaskNotifyFromISR( xEMACTaskHandle, EMAC_IF_RX_EVENT, eSetBits, &( xGMACSwitchRequired ) ); } } /*-----------------------------------------------------------*/ +/* The following function can be called by gmac_reset_tx_mem(). + */ void returnTxBuffer( uint8_t * puc_buffer ) { /* Called from a non-ISR context. */ if( xTxBufferQueue != NULL ) { + /* return 'puc_buffer' to the pool of transmission buffers. */ xQueueSend( xTxBufferQueue, &puc_buffer, 0 ); - xTaskNotifyGive( xEMACTaskHandle ); - ulISREvents |= EMAC_IF_TX_EVENT; + xTaskNotify( xEMACTaskHandle, EMAC_IF_TX_EVENT, eSetBits ); } } @@ -295,11 +297,21 @@ void xTxCallback( uint32_t ulStatus, if( ( xTxBufferQueue != NULL ) && ( xEMACTaskHandle != NULL ) ) { /* let the prvEMACHandlerTask know that there was an TX event. */ - ulISREvents |= EMAC_IF_TX_EVENT; /* Wakeup prvEMACHandlerTask. */ - vTaskNotifyGiveFromISR( xEMACTaskHandle, ( BaseType_t * ) &xGMACSwitchRequired ); - xQueueSendFromISR( xTxBufferQueue, &puc_buffer, ( BaseType_t * ) &xGMACSwitchRequired ); - tx_release_count[ 2 ]++; + if( puc_buffer == NULL ) + { + /* (GMAC_TSR) Retry Limit Exceeded */ + /* Can not send logging, we're in an ISR. */ + } + else + { + xQueueSendFromISR( xTxBufferQueue, &puc_buffer, ( BaseType_t * ) &xGMACSwitchRequired ); + xTaskNotifyFromISR( xEMACTaskHandle, EMAC_IF_TX_EVENT, eSetBits, &( xGMACSwitchRequired ) ); + + /* TX statistics. Only works when 'GMAC_STATS' + * is defined as 1. See gmac_SAM.h for more information. */ + TX_STAT_INCREMENT( tx_callback ); + } } } /*-----------------------------------------------------------*/ @@ -445,7 +457,9 @@ BaseType_t xNetworkInterfaceInitialise( void ) if( xTXDescriptorSemaphore == NULL ) { - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) GMAC_TX_BUFFERS, ( UBaseType_t ) GMAC_TX_BUFFERS ); + /* When there are N TX descriptors, we want to use + * at most "N-1" simultaneously. */ + xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) GMAC_TX_BUFFERS - 1U, ( UBaseType_t ) GMAC_TX_BUFFERS - 1U ); configASSERT( xTXDescriptorSemaphore ); } @@ -483,7 +497,6 @@ static void hand_tx_errors( void ) gmac_enable_transmit( GMAC, false ); /* Reinit TX descriptors. */ -/* gmac_tx_init(ps_gmac_dev); */ gmac_reset_tx_mem( &gs_gmac_dev ); /* Clear error status. */ gmac_clear_tx_status( GMAC, GMAC_TX_ERRORS ); @@ -498,7 +511,7 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript BaseType_t bReleaseAfterSend ) { /* Do not wait too long for a free TX DMA buffer. */ - const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u ); + const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50U ); uint32_t ulTransmitSize; ulTransmitSize = pxDescriptor->xDataLength; @@ -514,6 +527,8 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript * statement. */ do { + uint32_t ulResult; + if( xPhyObject.ulLinkStatusMask == 0ul ) { /* Do not attempt to send packets as long as the Link Status is low. */ @@ -531,10 +546,11 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) { /* Time-out waiting for a free TX descriptor. */ - tx_release_count[ 3 ]++; + TX_STAT_INCREMENT( tx_enqueue_fail ); break; } + TX_STAT_INCREMENT( tx_enqueue_ok ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) { /* Confirm that the pxDescriptor may be kept by the driver. */ @@ -550,7 +566,12 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript } #endif - gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); + ulResult = gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); + + if( ulResult != GMAC_OK ) + { + TX_STAT_INCREMENT( tx_write_fail ); + } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) { @@ -594,7 +615,7 @@ static BaseType_t prvGMACInit( void ) { /* Set MDC clock divider. */ - gmac_set_mdc_clock( GMAC, sysclk_get_cpu_hz() ); + gmac_set_mdc_clock( GMAC, sysclk_get_peripheral_hz() ); vPhyInitialise( &xPhyObject, xPHY_Read, xPHY_Write ); xPhyDiscover( &xPhyObject ); @@ -840,7 +861,7 @@ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkB static void prvEMACHandlerTask( void * pvParameters ) { UBaseType_t uxCount; - UBaseType_t uxLowestSemCount = 0; + UBaseType_t uxLowestSemCount = GMAC_TX_BUFFERS + 1; #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) NetworkBufferDescriptor_t * pxBuffer; @@ -849,6 +870,7 @@ static void prvEMACHandlerTask( void * pvParameters ) BaseType_t xResult = 0; uint32_t xStatus; const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( EMAC_MAX_BLOCK_TIME_MS ); + uint32_t ulISREvents = 0U; /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; @@ -879,16 +901,14 @@ static void prvEMACHandlerTask( void * pvParameters ) } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ - if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); - } + /* Wait for a new event or a time-out. */ + xTaskNotifyWait( 0U, /* ulBitsToClearOnEntry */ + EMAC_IF_ALL_EVENT, /* ulBitsToClearOnExit */ + &( ulISREvents ), /* pulNotificationValue */ + ulMaxBlockTime ); if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) { - ulISREvents &= ~EMAC_IF_RX_EVENT; - /* Wait for the EMAC interrupt to indicate that another packet has been * received. */ xResult = prvEMACRxPoll(); @@ -896,9 +916,6 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) { - /* Future extension: code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - while( xQueueReceive( xTxBufferQueue, &pucBuffer, 0 ) != pdFALSE ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) @@ -908,21 +925,21 @@ static void prvEMACHandlerTask( void * pvParameters ) if( pxBuffer != NULL ) { vReleaseNetworkBufferAndDescriptor( pxBuffer ); - tx_release_count[ 0 ]++; + TX_STAT_INCREMENT( tx_release_ok ); } else { - tx_release_count[ 1 ]++; + TX_STAT_INCREMENT( tx_release_bad ); } } #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ { - tx_release_count[ 0 ]++; + TX_STAT_INCREMENT( tx_release_ok ); } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ uxCount = uxQueueMessagesWaiting( ( QueueHandle_t ) xTXDescriptorSemaphore ); - if( uxCount < GMAC_TX_BUFFERS ) + if( uxCount < ( GMAC_TX_BUFFERS - 1 ) ) { /* Tell the counting semaphore that one more TX descriptor is available. */ xSemaphoreGive( xTXDescriptorSemaphore ); @@ -933,7 +950,6 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulISREvents & EMAC_IF_ERR_EVENT ) != 0 ) { /* Future extension: logging about errors that occurred. */ - ulISREvents &= ~EMAC_IF_ERR_EVENT; } gmac_enable_management( GMAC, true ); diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c index 7b2d445f7c..17222dc8ac 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c @@ -89,11 +89,20 @@ #endif #if ( GMAC_RX_BUFFERS <= 1 ) - #error Configuration error + #error Configuration error, GMAC_RX_BUFFERS must be at least 2 #endif #if ( GMAC_TX_BUFFERS <= 1 ) - #error Configuration error + #error Configuration error, GMAC_TX_BUFFERS must be at least 2 +#endif + +/* Interesting bits in the Transmission Status Register. */ +#define TSR_TSR_BITS ( GMAC_TSR_TXCOMP | GMAC_TSR_COL | GMAC_TSR_RLE | GMAC_TSR_UND ) + +#if ( GMAC_STATS != 0 ) + #warning Statistics are enabled + struct SGmacStats gmacStats; + TransmitStats_t xTransmitStats; #endif /** @@ -488,12 +497,6 @@ static uint32_t gmac_dev_poll( gmac_device_t * p_gmac_dev ) int32_t ulIndex = p_gmac_dev->ul_rx_idx; gmac_rx_descriptor_t * pxHead = &gs_rx_desc[ ulIndex ]; -/* #warning Just for debugging */ -/* if((pxHead->addr.val & GMAC_RXD_OWNERSHIP) != 0) */ -/* { */ -/* NVIC_DisableIRQ( GMAC_IRQn ); */ -/* } */ - #if ( ipconfigZERO_COPY_RX_DRIVER == 0 ) { /* Discard any incomplete frames */ @@ -616,7 +619,7 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev, /* Read +2 bytes because buffers are aligned at -2 bytes */ bytesLeft = min( bytesLeft + 2, ( int32_t ) ul_frame_size ); - #if ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) + #if ( NETWORK_BUFFERS_CACHED != 0 ) && ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE ) SCB_InvalidateDCache(); #endif @@ -670,20 +673,25 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev, pxHead = &gs_rx_desc[ nextIdx ]; pxHead->addr.val &= ~( GMAC_RXD_OWNERSHIP ); circ_inc32( &nextIdx, GMAC_RX_BUFFERS ); + + if( pxHead->addr.val ) + { + /* Just read it back to make sure that + * it was written to SRAM. */ + } } while( ( pxHead->status.val & GMAC_RXD_EOF ) == 0 ); p_gmac_dev->ul_rx_idx = nextIdx; *p_rcv_size = bytesLeft; -/* #warning Just for debugging */ -/* NVIC_EnableIRQ( GMAC_IRQn ); */ - return GMAC_OK; } -extern void vGMACGenerateChecksum( uint8_t * apBuffer, - size_t uxLength ); +#if ( SAME70 == 0 ) + extern void vGMACGenerateChecksum( uint8_t * apBuffer, + size_t uxLength ); +#endif /** * \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the @@ -705,6 +713,8 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, Gmac * p_hw = p_gmac_dev->p_hw; + configASSERT( p_buffer != NULL ); + configASSERT( ul_size >= ipconfigETHERNET_MINIMUM_PACKET_BYTES ); /* Check parameter */ if( ul_size > GMAC_TX_UNITSIZE ) @@ -739,12 +749,15 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); } #endif /* ipconfigZERO_COPY_TX_DRIVER */ - vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size ); + #if ( SAME70 == 0 ) + { + #warning Is this a SAM4E? + /* Needs to be called for SAM4E series only. */ + vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size ); + } + #endif } - /*#warning Trying out */ - gmac_start_transmission( p_hw ); - /* Update transmit descriptor status */ /* The buffer size defined is the length of ethernet frame, @@ -763,6 +776,12 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, ul_size | GMAC_TXD_LAST; } + if( p_tx_td->status.val ) + { + /* Just read it back to make sure that + * it was written to SRAM. */ + } + circ_inc32( &p_gmac_dev->l_tx_head, GMAC_TX_BUFFERS ); /* Now start to transmit if it is still not done */ @@ -862,9 +881,6 @@ void gmac_dev_halt( Gmac * p_gmac ) */ #if ( GMAC_STATS != 0 ) - extern int logPrintf( const char * pcFormat, - ... ); - void gmac_show_irq_counts() { int index; @@ -873,7 +889,7 @@ void gmac_dev_halt( Gmac * p_gmac ) { if( gmacStats.intStatus[ intPairs[ index ].index ] ) { - logPrintf( "%s : %6u\n", intPairs[ index ].name, gmacStats.intStatus[ intPairs[ index ].index ] ); + FreeRTOS_printf( ( "%s : %6u\n", intPairs[ index ].name, gmacStats.intStatus[ intPairs[ index ].index ] ) ); } } } @@ -922,7 +938,7 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) } /* TX packet */ - if( ( ul_isr & GMAC_ISR_TCOMP ) || ( ul_tsr & ( GMAC_TSR_TXCOMP | GMAC_TSR_COL | GMAC_TSR_RLE | GMAC_TSR_UND ) ) ) + if( ( ul_isr & GMAC_ISR_TCOMP ) || ( ( ul_tsr & TSR_TSR_BITS ) != 0U ) ) { ul_tx_status_flag = GMAC_TSR_TXCOMP; /* A frame transmitted */ @@ -968,7 +984,8 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) if( ul_tsr & GMAC_TSR_RLE ) { - /* Notify upper layer RLE */ + /* Notify upper layer RLE + * (GMAC_TSR) Retry Limit Exceeded */ xTxCallback( ul_tx_status_flag, NULL ); } diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h index 212e25ea3c..414300b875 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h @@ -1544,10 +1544,15 @@ /**INDENT-ON**/ /*/ @endcond */ + #ifndef GMAC_STATS + #define GMAC_STATS 0 + #endif + + #if ( GMAC_STATS == 0 ) - #define GMAC_STATS 0 + #define TX_STAT_INCREMENT( field ) do {} while( ipFALSE_BOOL ) - #if ( GMAC_STATS != 0 ) + #else /* Here below some code to study the types and * frequencies of GMAC interrupts. */ @@ -1599,6 +1604,24 @@ void gmac_show_irq_counts(); +/* + * The following struct replaces the earlier: + * int tx_release_count[ 4 ]; + * The purpose of this struct is to describe the TX events. + */ + typedef struct STransmitStats + { + unsigned tx_enqueue_ok; /* xNetworkInterfaceOutput() success. */ + unsigned tx_enqueue_fail; /* xNetworkInterfaceOutput() failed, no slot available. */ + unsigned tx_write_fail; /* gmac_dev_write() did not return GMAC-OK. */ + unsigned tx_callback; /* Transmission ready, buffer returned to driver. */ + unsigned tx_release_ok; /* Buffer released. */ + unsigned tx_release_bad; /* Buffer corruption. */ + } TransmitStats_t; + + extern TransmitStats_t xTransmitStats; + #define TX_STAT_INCREMENT( field ) xTransmitStats.field++ + #endif /* if ( GMAC_STATS != 0 ) */ #endif /* GMAC_H_INCLUDED */ From ed04dc76ab2a8a5f69fce8fae155c5a554bb640d Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Fri, 4 Nov 2022 04:58:23 +0800 Subject: [PATCH 03/44] IPv4/Single: Add a SocketID to a socket (#546) * IPv4/Single: Add a SocketID to a socket * Change in comment * Applied uncrustify to format the source code * Added a few entries to lexicon.txt * Removed the 'ipconfigUSE_SetSocketID' option * Change to lexicon.txt * Add unit tests for the newly added API Co-authored-by: Hein Tibosch Co-authored-by: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- .github/lexicon.txt | 5 ++ source/FreeRTOS_Sockets.c | 43 ++++++++++ source/include/FreeRTOS_IP_Private.h | 7 ++ source/include/FreeRTOS_Sockets.h | 8 ++ .../FreeRTOS_Sockets_GenericAPI_utest.c | 83 +++++++++++++++++++ 5 files changed, 146 insertions(+) diff --git a/.github/lexicon.txt b/.github/lexicon.txt index d7caa6248e..3e6d4d913d 100644 --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -230,6 +230,7 @@ egetlinklayeraddress ehertype einitialwait einprogress +einval einvalidchecksum einvaliddata eleasedaddress @@ -785,6 +786,7 @@ pvparameters pvportmalloc pvportmallocsocket pvsearchid +pvsocketid pvsource pxackmessage pxaddr @@ -981,6 +983,7 @@ skipnamefield snd snprintf sockaddr +socketid socketset sockopt sof @@ -1392,8 +1395,10 @@ vrxfaultinjection vsocketbind vsocketclose vsocketclosenexttime +vsocketgetsocketid vsocketlistennexttime vsocketselect +vsocketsetsocketid vsocketwakeupuser vtasklist vtasknotifygivefromisr diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 504016726b..a782304fea 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -4797,6 +4797,49 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) #endif /* ipconfigUSE_TCP */ /*-----------------------------------------------------------*/ +/** + * @brief Set the value of the SocketID of a socket. + * @param[in] xSocket: The socket whose ID should be set. + * @param[in] pvSocketID: The new value for the SocketID. + * @return Zero if the socket was valid, otherwise -EINVAL. + */ +BaseType_t xSocketSetSocketID( const Socket_t xSocket, + void * pvSocketID ) +{ + FreeRTOS_Socket_t * pxSocket = ( FreeRTOS_Socket_t * ) xSocket; + BaseType_t xReturn = -pdFREERTOS_ERRNO_EINVAL; + + if( xSocketValid( pxSocket ) ) + { + xReturn = 0; + pxSocket->pvSocketID = pvSocketID; + } + + return xReturn; +} +/*-----------------------------------------------------------*/ + +/** + * @brief Retrieve the SocketID that is associated with a socket. + * @param[in] xSocket: The socket whose ID should be returned. + * @return The current value of pvSocketID, or NULL in case + * the socket pointer is not valid or when the ID was not + * yet set. + */ +void * pvSocketGetSocketID( const ConstSocket_t xSocket ) +{ + const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) xSocket; + void * pvReturn = NULL; + + if( xSocketValid( pxSocket ) ) + { + pvReturn = pxSocket->pvSocketID; + } + + return pvReturn; +} +/*-----------------------------------------------------------*/ + #if ( ( ipconfigHAS_PRINTF != 0 ) && ( ipconfigUSE_TCP == 1 ) ) /** diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index 4a347f02dc..411cf9cb1b 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -680,6 +680,13 @@ typedef struct xSOCKET EventBits_t xSocketBits; /**< These bits indicate the events which have actually occurred. * They are maintained by the IP-task */ #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ + + /* This field is only only by the user, and can be accessed with + * vSocketSetSocketID() / vSocketGetSocketID(). + * All fields of a socket will be cleared by memset() in FreeRTOS_socket(). + */ + void * pvSocketID; + /* TCP/UDP specific fields: */ /* Before accessing any member of this structure, it should be confirmed */ /* that the protocol corresponds with the type of structure */ diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index f3095268d1..cf3a20c57e 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -366,6 +366,14 @@ void FreeRTOS_netstat( void ); +/* This option adds the possibility to have a user-ID attached to a socket. + * The type of this ID is a void *. Both UDP and TCP sockets have + * this ID. It has a default value of NULL. + */ + BaseType_t xSocketSetSocketID( const Socket_t xSocket, + void * pvSocketID ); + + void * pvSocketGetSocketID( const ConstSocket_t xSocket ); /* End TCP Socket Attributes. */ diff --git a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_GenericAPI_utest.c b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_GenericAPI_utest.c index 4dbd0f4cf0..f93ce1626a 100644 --- a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_GenericAPI_utest.c +++ b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_GenericAPI_utest.c @@ -2903,6 +2903,89 @@ void test_FreeRTOS_maywrite_HappyPath( void ) TEST_ASSERT_EQUAL( 0x3344, xReturn ); } +/* + * @brief Test setting socket ID when the socket is NULL. + */ +void test_xSocketSetSocketID_NULLSocket( void ) +{ + BaseType_t xReturn; + + xReturn = xSocketSetSocketID( NULL, NULL ); + + TEST_ASSERT_EQUAL( -pdFREERTOS_ERRNO_EINVAL, xReturn ); +} + +/* + * @brief Test setting socket ID when the socket is invalid. + */ +void test_xSocketSetSocketID_InvalidSocket( void ) +{ + BaseType_t xReturn; + + xReturn = xSocketSetSocketID( FREERTOS_INVALID_SOCKET, NULL ); + + TEST_ASSERT_EQUAL( -pdFREERTOS_ERRNO_EINVAL, xReturn ); +} + +/* + * @brief Test setting socket ID when the socket is Valid. + */ +void test_xSocketSetSocketID_ValidSocket( void ) +{ + BaseType_t xReturn; + FreeRTOS_Socket_t xSocket; + BaseType_t AnchorVariable; + + memset( &xSocket, 0, sizeof( xSocket ) ); + + xReturn = xSocketSetSocketID( &xSocket, &AnchorVariable ); + + TEST_ASSERT_EQUAL( 0, xReturn ); + TEST_ASSERT_EQUAL( &AnchorVariable, xSocket.pvSocketID ); +} + +/* + * @brief Test setting socket ID when the socket is NULL. + */ +void test_pvSocketGetSocketID_NULLSocket( void ) +{ + void * pvReturn; + + pvReturn = pvSocketGetSocketID( NULL ); + + TEST_ASSERT_EQUAL( NULL, pvReturn ); +} + +/* + * @brief Test setting socket ID when the socket is invalid. + */ +void test_pvSocketGetSocketID_InvalidSocket( void ) +{ + void * pvReturn; + + pvReturn = pvSocketGetSocketID( FREERTOS_INVALID_SOCKET ); + + TEST_ASSERT_EQUAL( NULL, pvReturn ); +} + +/* + * @brief Test setting socket ID when the socket is Valid. + */ +void test_pvSocketGetSocketID_ValidSocket( void ) +{ + BaseType_t pvReturn; + FreeRTOS_Socket_t xSocket; + BaseType_t AnchorVariable; + + memset( &xSocket, 0, sizeof( xSocket ) ); + + xSocket.pvSocketID = &AnchorVariable; + + pvReturn = pvSocketGetSocketID( &xSocket ); + + TEST_ASSERT_EQUAL( &AnchorVariable, pvReturn ); +} + /* * @brief This function just prints out some data. It is expected to make calls to the * below functions when IP stack is not initialised. From 9bd9d28ced6aac194049aa2e516feefb5b4223e6 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Tue, 8 Nov 2022 01:37:53 +0800 Subject: [PATCH 04/44] IPv4/single: SAME70 EMAC buffer sizes (#568) * Implemented Maty's solution * Added a new statistic 'tx_write_fail' * Uncrustify: triggered by comment. * Increase NETWORK_BUFFER_SIZE in order to include the 'ipBUFFER_PADDING' bytes * ICMP checksum calculated manually * Uncrustify: triggered by comment. * Update gmac_SAM.c Co-authored-by: Hein Tibosch Co-authored-by: GitHub Action Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- .../DriverSAM/NetworkInterface.c | 42 +++++++++-------- .../NetworkInterface/DriverSAM/gmac_SAM.c | 34 +++++++------- .../NetworkInterface/DriverSAM/gmac_SAM.h | 46 +++++++++++-------- 3 files changed, 68 insertions(+), 54 deletions(-) diff --git a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c index 7bbbc81425..7974b72a49 100644 --- a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c +++ b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c @@ -71,12 +71,6 @@ #define EMAC_IF_ERR_EVENT 4UL #define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) -/* 1536 bytes is more than needed, 1524 would be enough. - * But 1536 is a multiple of 32, which gives a great alignment for - * cached memories. */ - -#define NETWORK_BUFFER_SIZE 1536 - #ifndef EMAC_MAX_BLOCK_TIME_MS /* The task 'prvEMACHandlerTask()' will wake-up every 100 ms, to see @@ -518,9 +512,10 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript pxSendPacket = ( IPPacket_t * ) pxDescriptor->pucEthernetBuffer; - if( ulTransmitSize > NETWORK_BUFFER_SIZE ) + /* 'GMAC_TX_UNITSIZE' is the netto size of a transmission buffer. */ + if( ulTransmitSize > GMAC_TX_UNITSIZE ) { - ulTransmitSize = NETWORK_BUFFER_SIZE; + ulTransmitSize = GMAC_TX_UNITSIZE; } /* A do{}while(0) loop is introduced to allow the use of multiple break @@ -566,7 +561,7 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript } #endif - ulResult = gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); + ulResult = gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, ulTransmitSize ); if( ulResult != GMAC_OK ) { @@ -742,17 +737,26 @@ void vGMACGenerateChecksum( uint8_t * pucBuffer, { ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) pucBuffer; - if( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) + /* The SAM4E has problems offloading checksums for transmission. + * The SAME70 does not set the CRC for ICMP packets (ping). */ + + if( xProtPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) { - IPHeader_t * pxIPHeader = &( xProtPacket->xTCPPacket.xIPHeader ); + #if ( SAME70 != 0 ) + if( ( xProtPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_UDP ) && + ( xProtPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_TCP ) ) + #endif + { + IPHeader_t * pxIPHeader = &( xProtPacket->xTCPPacket.xIPHeader ); - /* Calculate the IP header checksum. */ - pxIPHeader->usHeaderChecksum = 0x00; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); - pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); + /* Calculate the IP header checksum. */ + pxIPHeader->usHeaderChecksum = 0x00; + pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); + pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - /* Calculate the TCP checksum for an outgoing packet. */ - usGenerateProtocolChecksum( pucBuffer, uxLength, pdTRUE ); + /* Calculate the TCP checksum for an outgoing packet. */ + usGenerateProtocolChecksum( pucBuffer, uxLength, pdTRUE ); + } } } /*-----------------------------------------------------------*/ @@ -773,7 +777,7 @@ static uint32_t prvEMACRxPoll( void ) * descriptor then allocate one now. */ if( ( pxNextNetworkBufferDescriptor == NULL ) && ( uxGetNumberOfFreeNetworkBuffers() > xMinDescriptorsToLeave ) ) { - pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, xBlockTime ); + pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor( GMAC_RX_UNITSIZE, xBlockTime ); } if( pxNextNetworkBufferDescriptor != NULL ) @@ -789,7 +793,7 @@ static uint32_t prvEMACRxPoll( void ) } /* Read the next packet from the hardware into pucUseBuffer. */ - ulResult = gmac_dev_read( &gs_gmac_dev, pucUseBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, &ulReceiveCount, &pucDMABuffer ); + ulResult = gmac_dev_read( &gs_gmac_dev, pucUseBuffer, GMAC_RX_UNITSIZE, &ulReceiveCount, &pucDMABuffer ); if( ( ulResult != GMAC_OK ) || ( ulReceiveCount == 0 ) ) { diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c index 17222dc8ac..e864e1be72 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c @@ -111,8 +111,8 @@ * See \ref gmac_quickstart. * * Driver for the GMAC (Ethernet Media Access Controller). - * This file contains basic functions for the GMAC, with support for all modes, settings - * and clock speeds. + * This file contains basic functions for the GMAC, with support for all modes, + * settings and clock speeds. * * \section dependencies Dependencies * This driver does not depend on other modules. @@ -120,8 +120,18 @@ * @{ */ -#define NETWORK_BUFFER_SIZE 1536 - +/* + * When BufferAllocation_1.c is used, the network buffer space + * is declared statically as 'ucNetworkPackets[]'. + * Like the DMA descriptors, this array is located in a non-cached area. + * Here an example of the total size: + * + * #define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 24 + * #define GMAC_FRAME_LENTGH_MAX 1536 + * Hidden space for back-pointer and IP-type 16 + * + * Total size: 24 * ( 1536 + 16 ) = 37248 bytes + */ __attribute__( ( aligned( 32 ) ) ) __attribute__( ( section( ".first_data" ) ) ) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * NETWORK_BUFFER_SIZE ]; @@ -688,11 +698,6 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev, return GMAC_OK; } -#if ( SAME70 == 0 ) - extern void vGMACGenerateChecksum( uint8_t * apBuffer, - size_t uxLength ); -#endif - /** * \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the * GMAC Tx buffers, and then indicates to the GMAC that the buffer is ready. @@ -749,13 +754,10 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); } #endif /* ipconfigZERO_COPY_TX_DRIVER */ - #if ( SAME70 == 0 ) - { - #warning Is this a SAM4E? - /* Needs to be called for SAM4E series only. */ - vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size ); - } - #endif + { + /* Needs to be called for SAM4E series only. */ + vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size ); + } } /* Update transmit descriptor status */ diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h index 414300b875..d59965f0d9 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h @@ -96,42 +96,45 @@ /** The MAC can support frame lengths up to 1536 bytes */ #define GMAC_FRAME_LENTGH_MAX 1536 + #define GMAC_RX_UNITSIZE GMAC_FRAME_LENTGH_MAX /**< Maximum size for RX buffer */ + #define GMAC_TX_UNITSIZE GMAC_FRAME_LENTGH_MAX /**< Maximum size for TX buffer */ -/*#define GMAC_RX_UNITSIZE 128 / **< Fixed size for RX buffer * / */ - #define GMAC_RX_UNITSIZE 1536 /**< Fixed size for RX buffer */ +/* A network buffer starts with 10 hidden bytes (ipBUFFER_PADDING) + * in which a pointer is stored. Round up this extra size to a multiple of 16, + * in order to get well-aligned buffers. */ -/*#define GMAC_TX_UNITSIZE 1518 / **< Size for ETH frame length * / */ - #define GMAC_TX_UNITSIZE 1536 /**< Size for ETH frame length */ + #define BUFFER_PADDING ( ( ipBUFFER_PADDING + 16U ) & ~0x0FU ) + #define NETWORK_BUFFER_SIZE ( GMAC_FRAME_LENTGH_MAX + BUFFER_PADDING ) /** GMAC clock speed */ - #define GMAC_MCK_SPEED_240MHZ ( 240 * 1000 * 1000 ) - #define GMAC_MCK_SPEED_160MHZ ( 160 * 1000 * 1000 ) - #define GMAC_MCK_SPEED_120MHZ ( 120 * 1000 * 1000 ) - #define GMAC_MCK_SPEED_80MHZ ( 80 * 1000 * 1000 ) - #define GMAC_MCK_SPEED_40MHZ ( 40 * 1000 * 1000 ) - #define GMAC_MCK_SPEED_20MHZ ( 20 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_240MHZ ( 240 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_160MHZ ( 160 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_120MHZ ( 120 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_80MHZ ( 80 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_40MHZ ( 40 * 1000 * 1000 ) + #define GMAC_MCK_SPEED_20MHZ ( 20 * 1000 * 1000 ) /** GMAC maintain code default value*/ - #define GMAC_MAN_CODE_VALUE ( 10 ) + #define GMAC_MAN_CODE_VALUE ( 10 ) /** GMAC maintain start of frame default value*/ - #define GMAC_MAN_SOF_VALUE ( 1 ) + #define GMAC_MAN_SOF_VALUE ( 1 ) /** GMAC maintain read/write*/ - #define GMAC_MAN_RW_TYPE ( 2 ) + #define GMAC_MAN_RW_TYPE ( 2 ) /** GMAC maintain read only*/ - #define GMAC_MAN_READ_ONLY ( 1 ) + #define GMAC_MAN_READ_ONLY ( 1 ) /** GMAC address length */ - #define GMAC_ADDR_LENGTH ( 6 ) + #define GMAC_ADDR_LENGTH ( 6 ) - #define GMAC_DUPLEX_HALF 0 - #define GMAC_DUPLEX_FULL 1 + #define GMAC_DUPLEX_HALF 0 + #define GMAC_DUPLEX_FULL 1 - #define GMAC_SPEED_10M 0 - #define GMAC_SPEED_100M 1 + #define GMAC_SPEED_10M 0 + #define GMAC_SPEED_100M 1 /** * \brief Return codes for GMAC APIs. @@ -1536,6 +1539,11 @@ void gmac_reset_tx_mem( gmac_device_t * p_dev ); +/* The SAM4E has problems offloading checksums for transmission. + * The SAME70 does not set the CRC for ICMP packets (ping). */ + extern void vGMACGenerateChecksum( uint8_t * apBuffer, + size_t uxLength ); + /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus From fc71939d54051e3b77f2faacfed8ca41325dcf56 Mon Sep 17 00:00:00 2001 From: Pete Bone Date: Wed, 16 Nov 2022 23:20:39 +0100 Subject: [PATCH 05/44] Eliminate some warnings (#578) * Eliminate some warnings related to print statements Authored-by: Pete Bone --- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_IP_Utils.c | 4 ++-- source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 9add500e51..b2b05c5655 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1563,7 +1563,7 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP if( xCount < 5 ) /* LCOV_EXCL_BR_LINE */ { FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %xip without CRC dropped\n", - FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); + ( unsigned ) FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); xCount++; } } diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 4919d6f744..1b521e3b2a 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -640,7 +640,7 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, if( xCount < 5 ) /* LCOV_EXCL_BR_LINE */ { FreeRTOS_printf( ( "usGenerateProtocolChecksum: UDP packet from %xip without CRC dropped\n", - FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); + ( unsigned ) FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); xCount++; } } @@ -1050,7 +1050,7 @@ uint16_t usGenerateChecksum( uint16_t usSum, else if( ( uxMinLastSize * ipMONITOR_PERCENTAGE_90 ) > ( uxMinSize * ipMONITOR_PERCENTAGE_100 ) ) { uxMinLastSize = uxMinSize; - FreeRTOS_printf( ( "Heap: current %lu lowest %lu\n", xPortGetFreeHeapSize(), uxMinSize ) ); + FreeRTOS_printf( ( "Heap: current %u lowest %u\n", xPortGetFreeHeapSize(), uxMinSize ) ); } else { diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c index a023e6c867..1718c4ed6c 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c @@ -178,7 +178,7 @@ static int detect_phy( XEmacPs * xemacpsp ) { XEmacPs_PhyRead( xemacpsp, phy_addr, IEEE_PHYSID2_OFFSET, &id_upper ); id = ( ( ( uint32_t ) id_upper ) << 16 ) | ( id_lower & 0xFFF0 ); - FreeRTOS_printf( ( "XEmacPs detect_phy: %04lX at address %d.\n", id, phy_addr ) ); + FreeRTOS_printf( ( "XEmacPs detect_phy: %04lX at address %u.\n", id, ( unsigned ) phy_addr ) ); phy_detected = phy_addr; return phy_addr; } From 115702138311a8f09dcea791dcbb6b80c7175bc3 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri, 18 Nov 2022 13:34:54 +0530 Subject: [PATCH 06/44] Add MISRA justification for use of dynamic memory (#581) --- MISRA.md | 12 ++++++++++++ source/FreeRTOS_DNS_Callback.c | 4 ++++ source/FreeRTOS_Sockets.c | 16 +++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/MISRA.md b/MISRA.md index 7df2ce4c91..7a4f1ac519 100644 --- a/MISRA.md +++ b/MISRA.md @@ -14,6 +14,18 @@ with ( Assuming rule 11.4 violation; with justification in point 2 ): ``` grep 'MISRA Ref 11.4.2' . -rI ``` +#### Directive 4.12 + +_Ref 4.12.1_ + +- MISRA C:2012 Directive 4.12: Dynamic memory allocation shall not be used. + MISRA warns against the use of dynamic memory allocation as it might + lead to undefined behavior if not used properly. However, the + FreeRTOS-Plus-TCP library only uses the memory allocation primitives + defined by the FreeRTOS-Kernel, which are deterministic. Additionally, + proper care is taken in the code to not use free'd pointers and to check + the validity of malloc'd memory before it is dereferenced or used. + #### Rule 2.2 _Ref 2.2.1_ diff --git a/source/FreeRTOS_DNS_Callback.c b/source/FreeRTOS_DNS_Callback.c index 260d42b908..2e4e87f903 100644 --- a/source/FreeRTOS_DNS_Callback.c +++ b/source/FreeRTOS_DNS_Callback.c @@ -110,6 +110,10 @@ TickType_t uxIdentifier ) { size_t lLength = strlen( pcHostName ); + + /* MISRA Ref 4.12.1 [Use of dynamic memory]. */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#directive-412. */ + /* coverity[misra_c_2012_directive_4_12_violation] */ DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) pvPortMalloc( sizeof( *pxCallback ) + lLength ) ); /* Translate from ms to number of clock ticks. */ diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index a782304fea..9a297817db 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -404,7 +404,7 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, if( prvDetermineSocketSize( xDomain, xType, xProtocolCpy, &uxSocketSize ) == pdFAIL ) { /* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */ -/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ /* coverity[misra_c_2012_rule_11_4_violation] */ xReturn = FREERTOS_INVALID_SOCKET; } @@ -414,12 +414,16 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * size depends on the type of socket: UDP sockets need less space. A * define 'pvPortMallocSocket' will used to allocate the necessary space. * By default it points to the FreeRTOS function 'pvPortMalloc()'. */ + + /* MISRA Ref 4.12.1 [Use of dynamic memory]. */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#directive-412. */ + /* coverity[misra_c_2012_directive_4_12_violation] */ pxSocket = ( ( FreeRTOS_Socket_t * ) pvPortMallocSocket( uxSocketSize ) ); if( pxSocket == NULL ) { /* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */ -/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ /* coverity[misra_c_2012_rule_11_4_violation] */ xReturn = FREERTOS_INVALID_SOCKET; iptraceFAILED_TO_CREATE_SOCKET(); @@ -433,7 +437,7 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, vPortFreeSocket( pxSocket ); /* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */ -/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ /* coverity[misra_c_2012_rule_11_4_violation] */ xReturn = FREERTOS_INVALID_SOCKET; iptraceFAILED_TO_CREATE_EVENT_GROUP(); @@ -528,6 +532,9 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, { SocketSelect_t * pxSocketSet; + /* MISRA Ref 4.12.1 [Use of dynamic memory]. */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#directive-412. */ + /* coverity[misra_c_2012_directive_4_12_violation] */ pxSocketSet = ( ( SocketSelect_t * ) pvPortMalloc( sizeof( *pxSocketSet ) ) ); if( pxSocketSet != NULL ) @@ -4235,6 +4242,9 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) uxSize = ( sizeof( *pxBuffer ) + uxLength ) - sizeof( pxBuffer->ucArray ); + /* MISRA Ref 4.12.1 [Use of dynamic memory]. */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#directive-412. */ + /* coverity[misra_c_2012_directive_4_12_violation] */ pxBuffer = ( ( StreamBuffer_t * ) pvPortMallocLarge( uxSize ) ); if( pxBuffer == NULL ) From 7d8299d7942e86d3d29721fabb31bfe18c9e372a Mon Sep 17 00:00:00 2001 From: Pete Bone Date: Tue, 22 Nov 2022 11:31:09 +0100 Subject: [PATCH 07/44] Update deprecated macros in network driver files (#579) * Update deprecated macros in network driver files * Fix typo in RX driver. * Replace #warning with #error on test for deprecated macro. * Fix doxygen check Co-authored-by: PeterB Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- docs/doxygen/config.doxyfile | 270 +++++++++++++----- .../ATSAM4E/NetworkInterface.c | 24 +- .../NetworkInterface/Common/phyHandling.c | 2 +- .../LPC18xx/NetworkInterface.c | 25 +- .../NetworkInterface/RX/NetworkInterface.c | 25 +- .../NetworkInterface/Zynq/NetworkInterface.c | 25 +- .../ksz8851snl/NetworkInterface.c | 25 +- .../xilinx_ultrascale/NetworkInterface.c | 25 +- 9 files changed, 284 insertions(+), 139 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f8ecdc683..6bce7f8d73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,7 +99,7 @@ jobs: fi doxygen: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Run doxygen build diff --git a/docs/doxygen/config.doxyfile b/docs/doxygen/config.doxyfile index 7792e2cb85..ba5aad883d 100644 --- a/docs/doxygen/config.doxyfile +++ b/docs/doxygen/config.doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.9.2 +# Doxyfile 1.9.5 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -12,6 +12,16 @@ # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] #--------------------------------------------------------------------------- # Project related configuration options @@ -60,16 +70,28 @@ PROJECT_LOGO = OUTPUT_DIRECTORY = docs/doxygen/output/ -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes -# performance problems for the file system. +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. # The default value is: NO. CREATE_SUBDIRS = NO +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# numer of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode @@ -81,14 +103,14 @@ ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English @@ -452,7 +474,7 @@ TYPEDEF_HIDES_STRUCT = YES LOOKUP_CACHE_SIZE = 0 -# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use # during processing. When set to 0 doxygen will based this on the number of # cores available in the system. You can set it explicitly to a value larger # than 0 to get more control over the balance between CPU load and processing @@ -528,6 +550,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -570,14 +599,15 @@ INTERNAL_DOCS = NO # filesystem is case sensitive (i.e. it supports files in the same directory # whose names only differ in casing), the option must be set to YES to properly # deal with such files in case they appear in the input. For filesystems that -# are not case sensitive the option should be be set to NO to properly deal with +# are not case sensitive the option should be set to NO to properly deal with # output files written for symbols that only differ in casing, such as for two # classes, one named CLASS and the other named Class, and to also support # references to files without having to specify the exact matching casing. On # Windows (including Cygwin) and MacOS, users should typically set this option # to NO, whereas on Linux or other Unix flavors it should typically be set to # YES. -# The default value is: system dependent. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. CASE_SENSE_NAMES = NO @@ -844,13 +874,27 @@ WARN_AS_ERROR = NO # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard -# error (stderr). +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). WARN_LOGFILE = @@ -885,10 +929,21 @@ INPUT = ./ \ # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: # https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING # The default value is: UTF-8. INPUT_ENCODING = UTF-8 +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. @@ -946,7 +1001,7 @@ EXCLUDE_PATTERNS = # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test +# ANamespace::AClass, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* @@ -994,6 +1049,11 @@ IMAGE_PATH = # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. @@ -1035,6 +1095,15 @@ FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- @@ -1269,6 +1338,23 @@ HTML_EXTRA_STYLESHEET = ./docs/doxygen/style.css HTML_EXTRA_FILES = +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. Default setting AUTO_LIGHT +# enables light output unless the user preference is dark output. Other options +# are DARK to always use dark mode, LIGHT to always use light mode, AUTO_DARK to +# default to dark mode unless the user prefers light mode, and TOGGLE to let the +# user toggle between dark and light mode via a button. +# Possible values are: LIGHT Always generate light output., DARK Always generate +# dark output., AUTO_LIGHT Automatically set the mode according to the user +# preference, use light mode if no preference is set (the default)., AUTO_DARK +# Automatically set the mode according to the user preference, use dark mode if +# no preference is set. and TOGGLE Allow to user to switch between light and +# dark mode via a button.. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a color-wheel, see @@ -1363,6 +1449,13 @@ GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. @@ -1567,7 +1660,7 @@ GENERATE_TREEVIEW = YES # area (value NO) or if it should extend to the full height of the window (value # YES). Setting this to YES gives a layout similar to # https://docs.readthedocs.io with more room for contents, but less room for the -# project logo, title, and description. If either GENERATOR_TREEVIEW or +# project logo, title, and description. If either GENERATE_TREEVIEW or # DISABLE_INDEX is set to NO, this option has no effect. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1598,6 +1691,13 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + # If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg # tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see # https://inkscape.org) to generate formulas as SVG images instead of PNGs for @@ -1618,17 +1718,6 @@ HTML_FORMULA_FORMAT = png FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANSPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. @@ -1690,8 +1779,8 @@ MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example -# for MathJax version 2 (see -# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# for MathJax version 2 (see https://docs.mathjax.org/en/v2.7-latest/tex.html +# #tex-and-latex-extensions): # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # For example for MathJax version 3 (see # http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): @@ -2219,7 +2308,8 @@ SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by the -# preprocessor. +# preprocessor. Note that the INCLUDE_PATH is not recursive, so the setting of +# RECURSIVE has no effect here. # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = @@ -2319,15 +2409,6 @@ EXTERNAL_PAGES = NO # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2360,35 +2441,50 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 -# When you want a differently looking font in the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. +# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of +# subgraphs. When you want a differently looking font in the dot files that +# doxygen generates you can specify fontname, fontcolor and fontsize attributes. +# For details please see Node, +# Edge and Graph Attributes specification You need to make sure dot is able +# to find the font, which can be done by putting it in a standard location or by +# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. Default graphviz fontsize is 14. +# The default value is: fontname=Helvetica,fontsize=10. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" + +# DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can +# add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. Complete documentation about +# arrows shapes. +# The default value is: labelfontname=Helvetica,labelfontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTNAME = Helvetica +DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. +# DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes +# around nodes set 'shape=plain' or 'shape=plaintext' Shapes specification +# The default value is: shape=box,height=0.2,width=0.4. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTSIZE = 10 +DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. +# You can set the path where dot can find font specified with fontname in +# DOT_COMMON_ATTR and others dot attributes. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTPATH = -# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for -# each documented class showing the direct and indirect inheritance relations. -# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. +# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a +# graph for each documented class showing the direct and indirect inheritance +# relations. In case HAVE_DOT is set as well dot will be used to draw the graph, +# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set +# to TEXT the direct and indirect inheritance relations will be shown as texts / +# links. +# Possible values are: NO, YES, TEXT and GRAPH. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. CLASS_GRAPH = YES @@ -2402,7 +2498,8 @@ CLASS_GRAPH = YES COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for -# groups, showing the direct groups dependencies. +# groups, showing the direct groups dependencies. See also the chapter Grouping +# in the manual. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2429,6 +2526,28 @@ UML_LOOK = NO UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2495,6 +2614,13 @@ GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES +# The DIR_GRAPH_MAX_DEPTH tag can be used to limit the maximum number of levels +# of child directories generated in directory dependency graphs by dot. +# Minimum value: 1, maximum value: 25, default value: 1. +# This tag requires that the tag DIRECTORY_GRAPH is set to YES. + +DIR_GRAPH_MAX_DEPTH = 1 + # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. For an explanation of the image formats see the section # output formats in the documentation of the dot tool (Graphviz (see: @@ -2548,10 +2674,10 @@ MSCFILE_DIRS = DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the -# path where java can find the plantuml.jar file. If left blank, it is assumed -# PlantUML is not used or called during a preprocessing step. Doxygen will -# generate a warning when it encounters a \startuml command in this case and -# will not generate output for the diagram. +# path where java can find the plantuml.jar file or to the filename of jar file +# to be used. If left blank, it is assumed PlantUML is not used or called during +# a preprocessing step. Doxygen will generate a warning when it encounters a +# \startuml command in this case and will not generate output for the diagram. PLANTUML_JAR_PATH = @@ -2589,18 +2715,6 @@ DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support @@ -2613,6 +2727,8 @@ DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated # graphs. +# Note: This tag requires that UML_LOOK isn't set, i.e. the doxygen internal +# graphical representation for inheritance and collaboration diagrams is used. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. diff --git a/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c b/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c index 93a400914b..474ff6fed5 100644 --- a/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c +++ b/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c @@ -53,16 +53,20 @@ #define BMSR_LINK_STATUS 0x0004 /*!< Link status */ #endif -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not +/* Check if the LinkStatus in the PHY is still high after 15 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif /* Interrupt events to process. Currently only the Rx event is processed @@ -533,7 +537,7 @@ static void prvEMACHandlerTask( void * pvParameters ) configASSERT( xEMACTaskHandle != NULL ); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); for( ; ; ) { @@ -624,7 +628,7 @@ static void prvEMACHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); xResult = 0; } else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) @@ -642,11 +646,11 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } diff --git a/source/portable/NetworkInterface/Common/phyHandling.c b/source/portable/NetworkInterface/Common/phyHandling.c index e3cf2c4d34..50e879fcea 100644 --- a/source/portable/NetworkInterface/Common/phyHandling.c +++ b/source/portable/NetworkInterface/Common/phyHandling.c @@ -56,7 +56,7 @@ #define phyMAX_PHY_ADDRESS 31 #if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) - #warning please use the new defines with 'ipconfig' prefix + #error please use the new defines with 'ipconfig' prefix #endif #ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS diff --git a/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c b/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c index a4cfeb93df..8354368823 100644 --- a/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c +++ b/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c @@ -50,18 +50,23 @@ /* The size of the stack allocated to the task that handles Rx packets. */ #define nwRX_TASK_STACK_SIZE 140 -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not +/* Check if the LinkStatus in the PHY is still high after 15 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif + #ifndef configUSE_RMII #define configUSE_RMII 1 #endif @@ -1000,7 +1005,7 @@ static void prvEMACHandlerTask( void * pvParameters ) iptraceEMAC_TASK_STARTING(); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); for( ; ; ) { @@ -1064,7 +1069,7 @@ static void prvEMACHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); xResult = 0; } else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) @@ -1081,11 +1086,11 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } diff --git a/source/portable/NetworkInterface/RX/NetworkInterface.c b/source/portable/NetworkInterface/RX/NetworkInterface.c index 118deb924c..204588abdb 100644 --- a/source/portable/NetworkInterface/RX/NetworkInterface.c +++ b/source/portable/NetworkInterface/RX/NetworkInterface.c @@ -67,18 +67,23 @@ #endif #endif /* if defined( BSP_MCU_RX65N ) || defined( BSP_MCU_RX64M ) || defined( BSP_MCU_RX71M ) */ -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 2 seconds of not +/* Check if the LinkStatus in the PHY is still high after 2 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 2000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 2000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif + /*********************************************************************************************************************** * Private global variables and functions **********************************************************************************************************************/ @@ -225,7 +230,7 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters ) const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL ); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); FreeRTOS_printf( ( "Deferred Interrupt Handler Task started\n" ) ); xTaskToNotify = ether_receive_check_task_handle; @@ -334,7 +339,7 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); /* Indicate that the Link Status is high, so that * xNetworkInterfaceOutput() can send packets. */ @@ -358,11 +363,11 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters ) if( xPHYLinkStatus != 0 ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } diff --git a/source/portable/NetworkInterface/Zynq/NetworkInterface.c b/source/portable/NetworkInterface/Zynq/NetworkInterface.c index 49bb833e18..787d64aa1a 100644 --- a/source/portable/NetworkInterface/Zynq/NetworkInterface.c +++ b/source/portable/NetworkInterface/Zynq/NetworkInterface.c @@ -60,18 +60,23 @@ #define niBMSR_LINK_STATUS 0x0004uL -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not +/* Check if the LinkStatus in the PHY is still high after 15 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif + /* The size of each buffer when BufferAllocation_1 is used: * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html */ #define niBUFFER_1_PACKET_SIZE 1536 @@ -344,7 +349,7 @@ static void prvEMACHandlerTask( void * pvParameters ) iptraceEMAC_TASK_STARTING(); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); for( ; ; ) { @@ -386,7 +391,7 @@ static void prvEMACHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); xResult = 0; if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) == 0uL ) @@ -411,11 +416,11 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0uL ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } diff --git a/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c b/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c index 41be99f937..31d680435e 100644 --- a/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c +++ b/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c @@ -193,18 +193,23 @@ #define BMSR_LINK_STATUS 0x0004 /*!< Link status */ -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not +/* Check if the LinkStatus in the PHY is still high after 15 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif + /* Interrupt events to process. Currently only the Rx event is processed * although code for other events is included to allow for possible future * expansion. */ @@ -1225,7 +1230,7 @@ static void prvEMACHandlerTask( void * pvParameters ) configASSERT( xEMACTaskHandle != NULL ); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); xLoggingTime = xTaskGetTickCount(); for( ; ; ) @@ -1301,7 +1306,7 @@ static void prvEMACHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); xResult = 0; } else if( ( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) && @@ -1320,11 +1325,11 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c b/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c index 93bf236cf6..0016f4b3bb 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c @@ -60,18 +60,23 @@ #define niBMSR_LINK_STATUS 0x0004uL -#ifndef PHY_LS_HIGH_CHECK_TIME_MS +#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) + #error please use the new defines with 'ipconfig' prefix +#endif + +#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS -/* Check if the LinkSStatus in the PHY is still high after 15 seconds of not +/* Check if the LinkStatus in the PHY is still high after 15 seconds of not * receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 + #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000U #endif -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 +#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS + /* Check if the LinkStatus in the PHY is still low every second. */ + #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000U #endif + #if ( ipconfigNETWORK_MTU > 1526 ) #warning the use of Jumbo Frames has not been tested sufficiently yet. #define USE_JUMBO_FRAMES 1 @@ -470,7 +475,7 @@ static void prvEMACHandlerTask( void * pvParameters ) iptraceEMAC_TASK_STARTING(); vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); for( ; ; ) { @@ -512,7 +517,7 @@ static void prvEMACHandlerTask( void * pvParameters ) /* A packet was received. No need to check for the PHY status now, * but set a timer to check it later on. */ vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); xResult = 0; if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) == 0uL ) @@ -537,11 +542,11 @@ static void prvEMACHandlerTask( void * pvParameters ) if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0uL ) { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); } else { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); + xPhyRemTime = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); } } } From 1279a3f7ab2d3d7fb238f60a725017321600a291 Mon Sep 17 00:00:00 2001 From: ChristosZosi <76208460+ChristosZosi@users.noreply.github.com> Date: Mon, 28 Nov 2022 06:43:31 +0100 Subject: [PATCH 08/44] Fix Network-interface of the Xilinx UltraScale port (#588) The underlying issue was when the port would be used with Jumbo frames. During receives of Jumbo packets the data length was always set incorrectly, which then would cause buffer allocation issues and subsequently corrupted data would be sent to the IP-task. After some inspection in the Xilinx UltraScale port, I found out that when the data length would be set, the wrong mask from the Xilinx Ethernet MAC driver would be used. By using the right mask (XEMACPS_RXBUF_LEN_JUMBO_MASK) when Jumbo Frame support is enabled the issue was resolved --- .../xilinx_ultrascale/x_emacpsif_dma.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c index 3b38fa90c5..0c86df68f6 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c @@ -79,13 +79,13 @@ #if ( ipconfigNETWORK_MTU > 1526 ) #warning the use of Jumbo Frames has not been tested sufficiently yet. #define USE_JUMBO_FRAMES 1 -#endif +#endif /* ( ipconfigNETWORK_MTU > 1526 ) */ #if ( USE_JUMBO_FRAMES == 1 ) #define dmaRX_TX_BUFFER_SIZE 10240 #else #define dmaRX_TX_BUFFER_SIZE 1536 -#endif +#endif /* ( USE_JUMBO_FRAMES == 1 ) */ #if ( ipconfigULTRASCALE == 1 ) extern XScuGic xInterruptController; @@ -430,8 +430,19 @@ int emacps_check_rx( xemacpsif_s * xemacpsif ) /* * Adjust the buffer size to the actual number of bytes received. + * If port is built with Jumbo Frame support, then the XEMACPS_RXBUF_LEN_JUMBO_MASK + * should be used to obtain the size of the buffer. Otherwise the mask + * XEMACPS_RXBUF_LEN_MASK can be used. */ - rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; + #if ( USE_JUMBO_FRAMES == 1 ) + { + rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_JUMBO_MASK; + } + #else + { + rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; + } + #endif /* ( USE_JUMBO_FRAMES == 1 ) */ pxBuffer->xDataLength = rx_bytes; From 3ec7aa93a4ae2b96e2aec45f1e64e4abb042e665 Mon Sep 17 00:00:00 2001 From: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> Date: Tue, 29 Nov 2022 12:24:48 -0800 Subject: [PATCH 09/44] Fix Windows thread calling vTaskSuspendAll / xTaskResumeAll. (#592) Co-authored-by: Jason Carroll --- .../WinPCap/NetworkInterface.c | 79 ++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c index 737a5ce835..6e543a3bde 100644 --- a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c +++ b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c @@ -103,6 +103,20 @@ static void prvInterruptSimulatorTask( void * pvParameters ); */ static void prvCreateThreadSafeBuffers( void ); +/* + * This function is equivalent to uxStreamBufferAdd from + * FreeRTOS_Stream_Buffer.c in the case that the stream buffer is being used + * as a normal circular buffer (i.e. only the tail and head pointers are + * needed). Thus, this function does not take the offset argument, and does not + * update the front pointer of the stream buffer. This allows the removal of + * the calls to vTaskSuspendAll and xTaskResumeAll, as the head and front + * pointer no longer need to be atomically updated, allowing this function to be + * safely used by a Windows thread. + */ +static size_t prvStreamBufferAdd( StreamBuffer_t * pxBuffer, + const uint8_t * pucData, + size_t uxByteCount ); + /* * Utility function used to format print messages only. */ @@ -189,6 +203,59 @@ static void prvCreateThreadSafeBuffers( void ) xRecvBuffer->LENGTH = xRECV_BUFFER_SIZE + 1; } } + +/*-----------------------------------------------------------*/ + +static size_t prvStreamBufferAdd( StreamBuffer_t * pxBuffer, + const uint8_t * pucData, + size_t uxByteCount ) +{ + size_t uxSpace, uxNextHead, uxFirst; + size_t uxCount = uxByteCount; + + uxSpace = uxStreamBufferGetSpace( pxBuffer ); + + /* The number of bytes that can be written is the minimum of the number of + * bytes requested and the number available. */ + uxCount = FreeRTOS_min_size_t( uxSpace, uxCount ); + + if( uxCount != 0U ) + { + uxNextHead = pxBuffer->uxHead; + + if( pucData != NULL ) + { + /* Calculate the number of bytes that can be added in the first + * write - which may be less than the total number of bytes that need + * to be added if the buffer will wrap back to the beginning. */ + uxFirst = FreeRTOS_min_size_t( pxBuffer->LENGTH - uxNextHead, uxCount ); + + /* Write as many bytes as can be written in the first write. */ + ( void ) memcpy( &( pxBuffer->ucArray[ uxNextHead ] ), pucData, uxFirst ); + + /* If the number of bytes written was less than the number that + * could be written in the first write... */ + if( uxCount > uxFirst ) + { + /* ...then write the remaining bytes to the start of the + * buffer. */ + ( void ) memcpy( pxBuffer->ucArray, &( pucData[ uxFirst ] ), uxCount - uxFirst ); + } + } + + uxNextHead += uxCount; + + if( uxNextHead >= pxBuffer->LENGTH ) + { + uxNextHead -= pxBuffer->LENGTH; + } + + pxBuffer->uxHead = uxNextHead; + } + + return uxCount; +} + /*-----------------------------------------------------------*/ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, @@ -459,8 +526,16 @@ void pcap_callback( u_char * user, * Otherwise, there is no action. */ iptraceDUMP_PACKET( ( const uint8_t * ) pkt_data, ( size_t ) pkt_header->caplen, pdTRUE ); - uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t * ) pkt_header, sizeof( *pkt_header ) ); - uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t * ) pkt_data, ( size_t ) pkt_header->caplen ); + /* NOTE. The prvStreamBufferAdd function is used here in place of + * uxStreamBufferAdd since the uxStreamBufferAdd call will suspend + * the FreeRTOS scheduler to atomically update the head and front + * of the stream buffer. Since xRecvBuffer is being used as a regular + * circular buffer (i.e. only the head and tail are needed), this call + * only updates the head of the buffer, removing the need to suspend + * the scheduler, and allowing this function to be safely called from + * a Windows thread. */ + prvStreamBufferAdd( xRecvBuffer, ( const uint8_t * ) pkt_header, sizeof( *pkt_header ) ); + prvStreamBufferAdd( xRecvBuffer, ( const uint8_t * ) pkt_data, ( size_t ) pkt_header->caplen ); } } /*-----------------------------------------------------------*/ From 702eea65c190fb1b2efc074e19367e1a640a10f4 Mon Sep 17 00:00:00 2001 From: Tony Josi <117763118+tony-josi-aws@users.noreply.github.com> Date: Fri, 9 Dec 2022 16:09:13 +0530 Subject: [PATCH 10/44] Updated comments for FreeRTOS_select return value (#596) * Updated comments for FreeRTOS_select return value * Updated the function brief for FreeRTOS_select * Uncrustify: triggered by comment. * Updating FreeRTOS_select function @brief * Updated function brief for FreeRTOS_SignalSocket * Uncrustify: triggered by comment. * Update source/FreeRTOS_Sockets.c Co-authored-by: Ubuntu Co-authored-by: GitHub Action Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- source/FreeRTOS_Sockets.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 9a297817db..af1248ad24 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -704,7 +704,7 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, /** * @brief The select() statement: wait for an event to occur on any of the sockets - * included in a socket set. + * included in a socket set and return its event bits when the event occurs. * * @param[in] xSocketSet: The socket set including the sockets on which we are * waiting for an event to occur. @@ -712,7 +712,11 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * If the value is 'portMAX_DELAY' then the function will wait * indefinitely for an event to occur. * - * @return The socket which might have triggered the event bit. + * @return The event bits (event flags) value for the socket set in which an + * event occurred. If any socket is signalled during the call, using + * FreeRTOS_SignalSocket() or FreeRTOS_SignalSocketFromISR(), then eSELECT_INTR + * is returned. + * */ BaseType_t FreeRTOS_select( SocketSet_t xSocketSet, TickType_t xBlockTimeTicks ) @@ -5133,6 +5137,10 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) * and return the value -pdFREERTOS_ERRNO_EINTR ( -4 ). * * @param[in] xSocket: The socket that will be signalled. + * + * @return If xSocket is an invalid socket (NULL) or if the socket set is invalid (NULL) + * and/or if event group is invalid/not created, then, -pdFREERTOS_ERRNO_EINVAL + * is returned. On successful sending of a signal, 0 is returned. */ BaseType_t FreeRTOS_SignalSocket( Socket_t xSocket ) { From cb0f4ef0b100f45f91050570b129491112f679cf Mon Sep 17 00:00:00 2001 From: Tony Josi <117763118+tony-josi-aws@users.noreply.github.com> Date: Thu, 22 Dec 2022 01:52:41 +0530 Subject: [PATCH 11/44] Fixed readme script to build and run unit tests (#644) --- test/unit-test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit-test/README.md b/test/unit-test/README.md index 95f2517c71..f3dd7e8ef0 100644 --- a/test/unit-test/README.md +++ b/test/unit-test/README.md @@ -33,7 +33,7 @@ Go to the root directory of the FreeRTOS+TCP repo and run the following script: #!/bin/bash # This script should be run from the root directory of the FreeRTOS+TCP repo. -if [[ ! -f FreeRTOS_IP.c ]]; then +if [[ ! -d source ]]; then echo "Please run this script from the root directory of the FreeRTOS+TCP repo." exit 1 fi From 1615f72135dcd33700f7ba9a3e68bc47c8df17b2 Mon Sep 17 00:00:00 2001 From: ChristosZosi <76208460+ChristosZosi@users.noreply.github.com> Date: Wed, 4 Jan 2023 01:53:26 +0100 Subject: [PATCH 12/44] Minor warning fixes (#589) * Eliminate compiler unused parameter warning * Eliminate compiler unused variable warnings * Eliminate compiler unused function warning The function pcGetPHIName(...) would be called only in the FreeRTOS_printf message, however FreeRTOS_printf maybe be defined to nothing e.g. release builds, which then the warning would come up * Rework callback setups in the EMAC-driver of the Xilinx UltraScale port The calls to the function XEmacPs_SetHandler would trigger the pedantic warning: "ISO C forbids conversion of object pointer to function pointer type" The reason for this, is that the second parameter of the function XEmacPS_SetHandler is declared as pointer to a void type, but the function "expects" a function pointer, which in setup_isr rightly happens. However IMHO, this is just bad code from the side of Xilinx, as not on all architectures the size of a data pointer is identical to the size of a function pointer, which also is correctly recognised by the compiler. Instead of using the "bad" function XEmacPs_SetHandler, we can set the handlers manually to the EmacPS-instance. * Uncrustify: triggered by comment. * Update source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c Co-authored-by: Paul Bartell * Apply suggestions from code review Co-authored-by: Paul Bartell * Address comments from reviews Co-authored-by: GitHub Action Co-authored-by: Paul Bartell --- source/FreeRTOS_ICMP.c | 3 + .../xilinx_ultrascale/x_emacpsif_dma.c | 3 + .../xilinx_ultrascale/x_emacpsif_hw.c | 17 +++--- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 61 +++---------------- 4 files changed, 22 insertions(+), 62 deletions(-) diff --git a/source/FreeRTOS_ICMP.c b/source/FreeRTOS_ICMP.c index d507d629c5..660786dda7 100644 --- a/source/FreeRTOS_ICMP.c +++ b/source/FreeRTOS_ICMP.c @@ -177,6 +177,9 @@ } #else { + /* Just to prevent compiler warnings about unused parameters. */ + ( void ) pxNetworkBuffer; + /* Many EMAC peripherals will only calculate the ICMP checksum * correctly if the field is nulled beforehand. */ pxICMPHeader->usChecksum = 0U; diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c index 0c86df68f6..0dd90c4835 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c @@ -126,6 +126,9 @@ int is_tx_space_available( xemacpsif_s * xemacpsif ) { size_t uxCount; + /* Just to prevent compiler warnings about unused parameters. */ + ( void ) xemacpsif; + if( xTXDescriptorSemaphore != NULL ) { uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index 183f82810b..80b9386735 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -47,17 +47,16 @@ void setup_isr( xemacpsif_s * xemacpsif ) /* * Setup callbacks */ - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_DMASEND, - ( void * ) emacps_send_handler, - ( void * ) xemacpsif ); + XEmacPs * xInstancePtr = &( xemacpsif->emacps ); - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_DMARECV, - ( void * ) emacps_recv_handler, - ( void * ) xemacpsif ); + xInstancePtr->SendHandler = emacps_send_handler; + xInstancePtr->SendRef = ( void * ) xemacpsif; - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_ERROR, - ( void * ) emacps_error_handler, - ( void * ) xemacpsif ); + xInstancePtr->RecvHandler = emacps_recv_handler; + xInstancePtr->RecvRef = ( void * ) xemacpsif; + + xInstancePtr->ErrorHandler = emacps_error_handler; + xInstancePtr->ErrorRef = ( void * ) xemacpsif; } void start_emacps( xemacpsif_s * xemacps ) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 658a46d86d..039cef5dfc 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -245,18 +245,10 @@ void my_sleep( uint32_t uxTicks ) u32 phymapemac0[ 32 ]; u32 phymapemac1[ 32 ]; -static uint16_t prvAR803x_debug_reg_read( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg ); static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, uint32_t phy_addr, u16 reg, u16 value ); -static int prvAR803x_debug_reg_mask( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg, - u16 clear, - u16 set ); static void prvSET_AR803x_TX_Timing( XEmacPs * xemacpsp, uint32_t phy_addr ); @@ -832,29 +824,8 @@ static uint32_t get_AR8035_phy_speed( XEmacPs * xemacpsp, } } -static void ar8035Tick( XEmacPs * xemacpsp, - uint32_t phy_addr ) -{ - uint16_t value; - BaseType_t linkState; - - /*Read basic status register */ - value = XEmacPs_PhyRead2( xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET ); - /*Retrieve current link state */ - linkState = ( value & IEEE_STAT_LINK_STATUS ) ? TRUE : FALSE; -} - #define AR803X_DEBUG_ADDR 0x1D #define AR803X_DEBUG_DATA 0x1E -static uint16_t prvAR803x_debug_reg_read( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg ) -{ - XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_ADDR, reg ); - - return XEmacPs_PhyRead2( xemacpsp, phy_addr, AR803X_DEBUG_DATA ); -} - static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, uint32_t phy_addr, u16 reg, @@ -865,29 +836,6 @@ static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, return XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_DATA, value ); } -static int prvAR803x_debug_reg_mask( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg, - u16 clear, - u16 set ) -{ - u16 val; - int ret; - - ret = prvAR803x_debug_reg_read( xemacpsp, phy_addr, reg ); - - if( ret < 0 ) - { - return ret; - } - - val = ret & 0xffff; - val &= ~clear; - val |= set; - - return XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_DATA, val ); -} - static uint32_t ar8035CheckStatus( XEmacPs * xemacpsp, uint32_t phy_addr ) { @@ -970,6 +918,9 @@ static uint32_t ar8035CheckStatus( XEmacPs * xemacpsp, /* nicNotifyLinkChange(interface); */ } + /* Just to prevent compiler warnings about unused variable. */ + ( void ) linkState; + return linkSpeed; } @@ -1015,7 +966,11 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, XEmacPs_PhyRead( xemacpsp, phy_addr, PHY_IDENTIFIER_1_REG, &phy_identity ); - FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcGetPHIName( phy_identity ), phy_identity ) ); + const char * pcPHYName = pcGetPHIName( phy_identity ); + FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHYName, phy_identity ) ); + + /* Just to prevent compiler warnings about unused variablies. */ + ( void ) pcPHYName; switch( phy_identity ) { From b65c139a4ebffdcdf8d92cee68c5a7aa8777aade Mon Sep 17 00:00:00 2001 From: Kareem Khazem Date: Fri, 13 Jan 2023 17:42:24 +0000 Subject: [PATCH 13/44] Use CBMC XML output to enable VSCode debugger (#673) Prior to this commit, CBMC would emit logging information in plain text format, which does not contain information required for the CBMC VSCode debugger. This commit makes CBMC use XML instead of plain text. Co-authored-by: Mark Tuttle --- test/cbmc/proofs/Makefile.template | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/test/cbmc/proofs/Makefile.template b/test/cbmc/proofs/Makefile.template index 375c15c120..094fd560c1 100644 --- a/test/cbmc/proofs/Makefile.template +++ b/test/cbmc/proofs/Makefile.template @@ -119,8 +119,8 @@ goto: # Ignore the return code for CBMC, so that we can still generate the # report if the proof failed. If the proof failed, we separately fail # the entire job using the check-cbmc-result rule. -cbmc.txt: $(ENTRY).goto - -cbmc $(CBMCFLAGS) $(SOLVER) --unwinding-assertions --trace @RULE_INPUT@ > $@ 2>&1 +cbmc.xml: $(ENTRY).goto + -cbmc $(CBMCFLAGS) $(SOLVER) --unwinding-assertions --trace --xml-ui @RULE_INPUT@ > $@ 2>&1 property.xml: $(ENTRY).goto cbmc $(CBMCFLAGS) --unwinding-assertions --show-properties --xml-ui @RULE_INPUT@ > $@ 2>&1 @@ -128,29 +128,27 @@ property.xml: $(ENTRY).goto coverage.xml: $(ENTRY).goto cbmc $(CBMCFLAGS) --cover location --xml-ui @RULE_INPUT@ > $@ 2>&1 -cbmc: cbmc.txt +cbmc: cbmc.xml property: property.xml coverage: coverage.xml -report: cbmc.txt property.xml coverage.xml +report: cbmc.xml property.xml coverage.xml $(VIEWER) \ --goto $(ENTRY).goto \ --srcdir $(FREERTOS_PLUS_TCP) \ - --blddir $(FREERTOS_PLUS_TCP) \ - --htmldir html \ - --srcexclude "(.@FORWARD_SLASH@doc|.@FORWARD_SLASH@tests|.@FORWARD_SLASH@vendors)" \ - --result cbmc.txt \ + --reportdir report \ + --result cbmc.xml \ --property property.xml \ - --block coverage.xml + --coverage coverage.xml -# This rule depends only on cbmc.txt and has no dependents, so it will +# This rule depends only on cbmc.xml and has no dependents, so it will # not block the report from being generated if it fails. This rule is # intended to fail if and only if the CBMC safety check that emits -# cbmc.txt yielded a proof failure. -check-cbmc-result: cbmc.txt - grep -e "^VERIFICATION SUCCESSFUL" $^ +# cbmc.xml yielded a proof failure. +check-cbmc-result: cbmc.xml + grep 'SUCCESS' $^ # ____________________________________________________________________ # Rules @@ -160,7 +158,7 @@ check-cbmc-result: cbmc.txt clean: @RM@ $(OBJS) $(ENTRY).goto @RM@ $(ENTRY)[0-9].goto $(ENTRY)[0-9].txt - @RM@ cbmc.txt property.xml coverage.xml TAGS TAGS-* + @RM@ cbmc.xml property.xml coverage.xml TAGS TAGS-* @RM@ *~ \#* @RM@ queue_datastructure.h From 68c70a3a76f7cb9be141f471843a3972b3f8116e Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri, 20 Jan 2023 14:40:05 -0800 Subject: [PATCH 14/44] Remove need of token --- .github/workflows/uncrustify.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml index 31ab98b57a..01bf905be4 100644 --- a/.github/workflows/uncrustify.yml +++ b/.github/workflows/uncrustify.yml @@ -31,7 +31,6 @@ jobs: - name: Checkout upstream repo uses: actions/checkout@v2 with: - token: ${{ secrets.PAT }} repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} ref: ${{ steps.upstreambranch.outputs.branchname }} - name: Install Uncrustify From a9f7c9a317c37499de17014216c550a559bc505c Mon Sep 17 00:00:00 2001 From: ChristosZosi <76208460+ChristosZosi@users.noreply.github.com> Date: Fri, 3 Feb 2023 19:02:13 +0100 Subject: [PATCH 15/44] Use vTaskDelay for sleep in the network-interface of xilinx_ultrascale (#698) The issue here is that, the FreeRTOS IP-task would block all other tasks during PHY-link speed negotiations, as it was using busy waiting. However this is not really ideal. A much more suitable function for such a task would be `vTaskDelay`. --- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 039cef5dfc..a23fdf9708 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -71,26 +71,10 @@ #include "FreeRTOS_IP_Private.h" #include "NetworkBufferManagement.h" -#define NOP() asm ( "nop" ); - #define phyMIN_PHY_ADDRESS 0 #define phyMAX_PHY_ADDRESS 31 -void test_sleep( uint32_t uxTicks ) -{ - for( uint32_t j = 0U; j < uxTicks; j++ ) - { - for( uint32_t i = 0U; i < 100000000U; i++ ) - { - NOP(); - } - } -} - -void my_sleep( uint32_t uxTicks ) -{ - sleep( uxTicks ); -} +#define MINIMUM_SLEEP_TIME ( ( TickType_t ) 1 * configTICK_RATE_HZ ) /*** IMPORTANT: Define PEEP in xemacpsif.h and sys_arch_raw.c *** to run it on a PEEP board @@ -474,7 +458,7 @@ static uint32_t get_TI_phy_speed( XEmacPs * xemacpsp, while( !( status & IEEE_STAT_AUTONEGOTIATE_COMPLETE ) ) { - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); timeout_counter++; if( timeout_counter == 30 ) @@ -572,7 +556,7 @@ static uint32_t get_Marvell_phy_speed( XEmacPs * xemacpsp, while( !( status & IEEE_STAT_AUTONEGOTIATE_COMPLETE ) ) { - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); XEmacPs_PhyRead( xemacpsp, phy_addr, IEEE_COPPER_SPECIFIC_STATUS_REG_2, &temp ); timeout_counter++; @@ -663,7 +647,7 @@ static uint32_t get_Realtek_phy_speed( XEmacPs * xemacpsp, while( !( status & IEEE_STAT_AUTONEGOTIATE_COMPLETE ) ) { - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); timeout_counter++; if( timeout_counter == 30 ) @@ -804,7 +788,7 @@ static uint32_t get_AR8035_phy_speed( XEmacPs * xemacpsp, while( pdTRUE ) { uint32_t status; - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); timeout_counter++; @@ -967,6 +951,7 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, &phy_identity ); const char * pcPHYName = pcGetPHIName( phy_identity ); + FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHYName, phy_identity ) ); /* Just to prevent compiler warnings about unused variablies. */ @@ -1377,19 +1362,19 @@ u32 Phy_Setup_US( XEmacPs * xemacpsp, link_speed = 1000; configure_IEEE_phy_speed_US( xemacpsp, link_speed ); convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED1000_FD; - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); #elif defined( ipconfigNIC_LINKSPEED100 ) SetUpSLCRDivisors( xemacpsp->Config.BaseAddress, 100 ); link_speed = 100; configure_IEEE_phy_speed_US( xemacpsp, link_speed, phy_addr ); convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED100_FD; - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); #elif defined( ipconfigNIC_LINKSPEED10 ) SetUpSLCRDivisors( xemacpsp->Config.BaseAddress, 10 ); link_speed = 10; configure_IEEE_phy_speed_US( xemacpsp, link_speed, , phy_addr ); convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED10_FD; - my_sleep( 1 ); + vTaskDelay( MINIMUM_SLEEP_TIME ); #endif /* ifdef ipconfigNIC_LINKSPEED_AUTODETECT */ if( conv_present ) From aef286a1a0b1a8ba1f42ba02899a915c2f81c299 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 10 Feb 2023 21:34:55 +0530 Subject: [PATCH 16/44] Make sure that a TCP socket is closed only once (#707) * Make sure that a TCP socket is closed only once * Fix failing test cases for FreeRTOS_TCP_IP unit test modules post PR#705 changes * Uncrustify: triggered by comment. * Fix failing test cases for FreeRTOS_TCP_IP unit test modules post PR - 705 changes --------- Co-authored-by: Hein Tibosch Co-authored-by: GitHub Action --- source/FreeRTOS_TCP_IP.c | 33 ++++++++++++----- source/include/FreeRTOS_IP_Private.h | 20 ++++++++--- .../FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c | 35 +++++++++++++++++++ .../FreeRTOS_TCP_IP_DiffConfig_utest.c | 2 ++ 4 files changed, 77 insertions(+), 13 deletions(-) diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 7db7737267..995173573d 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -445,27 +445,42 @@ } } + /* Fill in the new state. */ + pxSocket->u.xTCP.eTCPState = eTCPState; + if( ( eTCPState == eCLOSED ) || ( eTCPState == eCLOSE_WAIT ) ) { /* Socket goes to status eCLOSED because of a RST. * When nobody owns the socket yet, delete it. */ - if( ( pxSocket->u.xTCP.bits.bPassQueued != pdFALSE_UNSIGNED ) || - ( pxSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) + vTaskSuspendAll(); { - FreeRTOS_debug_printf( ( "vTCPStateChange: Closing socket\n" ) ); + if( ( pxSocket->u.xTCP.bits.bPassQueued != pdFALSE_UNSIGNED ) || + ( pxSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) + { + if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) + { + pxSocket->u.xTCP.bits.bPassQueued = pdFALSE_UNSIGNED; + pxSocket->u.xTCP.bits.bPassAccept = pdFALSE_UNSIGNED; + } - if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) + xTaskResumeAll(); + + FreeRTOS_printf( ( "vTCPStateChange: Closing socket\n" ) ); + + if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) + { + configASSERT( xIsCallingFromIPTask() != pdFALSE ); + vSocketCloseNextTime( pxSocket ); + } + } + else { - configASSERT( xIsCallingFromIPTask() != pdFALSE ); - vSocketCloseNextTime( pxSocket ); + xTaskResumeAll(); } } } - /* Fill in the new state. */ - pxSocket->u.xTCP.eTCPState = eTCPState; - if( ( eTCPState == eCLOSE_WAIT ) && ( pxSocket->u.xTCP.bits.bReuseSocket == pdTRUE_UNSIGNED ) ) { switch( xPreviousState ) diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index 411cf9cb1b..542c28b247 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -508,6 +508,20 @@ BaseType_t xIPIsNetworkTaskReady( void ); */ TickType_t xTCPTimerCheck( BaseType_t xWillSleep ); +/** + * About the TCP flags 'bPassQueued' and 'bPassAccept': + * + * When a new TCP connection request is received on a listening socket, the bPassQueued and + * bPassAccept members of the newly created socket are updated as follows: + * + * 1. bPassQueued is set to indicate that the 3-way TCP handshake is in progress. + * 2. When the 3-way TCP handshake is complete, bPassQueued is cleared. At the same time, + * bPassAccept is set to indicate that the socket is ready to be picked up by the task + * that called FreeRTOS_accept(). + * 3. When the socket is picked up by the task that called FreeRTOS_accept, the bPassAccept + * is cleared. + */ + /** * Every TCP socket has a buffer space just big enough to store * the last TCP header received. @@ -544,10 +558,8 @@ BaseType_t xIPIsNetworkTaskReady( void ); /* Most compilers do like bit-flags */ uint32_t bMssChange : 1, /**< This socket has seen a change in MSS */ - bPassAccept : 1, /**< when true, this socket may be returned in a call to accept() */ - bPassQueued : 1, /**< when true, this socket is an orphan until it gets connected - * Why an orphan? Because it may not be returned in a accept() call until it - * gets the state eESTABLISHED */ + bPassAccept : 1, /**< See comment here above. */ + bPassQueued : 1, /**< See comment here above. */ bReuseSocket : 1, /**< When a listening socket gets a connection, do not create a new instance but keep on using it */ bCloseAfterSend : 1, /**< As soon as the last byte has been transmitted, finalise the connection * Useful in e.g. FTP connections, where the last data bytes are sent along with the FIN flag */ diff --git a/test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c b/test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c index d3afc4ac48..dbee39fd2c 100644 --- a/test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c +++ b/test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c @@ -587,6 +587,8 @@ void test_vTCPStateChange_ClosedState( void ) memset( &xSocket, 0, sizeof( xSocket ) ); eTCPState = eCLOSED; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -617,6 +619,8 @@ void test_vTCPStateChange_ClosedWaitState_PrvStateSyn( void ) xSocket.u.xTCP.eTCPState = eCONNECT_SYN; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -647,6 +651,8 @@ void test_vTCPStateChange_ClosedWaitState_PrvStateSynFirst( void ) xSocket.u.xTCP.eTCPState = eSYN_FIRST; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -680,6 +686,8 @@ void test_vTCPStateChange_ClosedWaitState_CurrentStateSynFirstNextStateCloseWait xSocket.u.xTCP.bits.bReuseSocket = pdTRUE_UNSIGNED; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -711,6 +719,8 @@ void test_vTCPStateChange_ClosedWaitState_PrvStateSynRecvd( void ) xSocket.u.xTCP.eTCPState = eSYN_RECEIVED; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -738,6 +748,8 @@ void test_vTCPStateChange_ClosedWaitState( void ) memset( &xSocket, 0, sizeof( xSocket ) ); eTCPState = eCLOSE_WAIT; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -769,6 +781,9 @@ void test_vTCPStateChange_ClosedWaitState_CallingFromIPTask( void ) xSocket.u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; + + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); @@ -801,6 +816,8 @@ void test_vTCPStateChange_ClosedWaitState_NotCallingFromIPTask( void ) xSocket.u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); catch_assert( vTCPStateChange( &xSocket, eTCPState ) ); @@ -821,6 +838,8 @@ void test_vTCPStateChange_ClosedWaitState_CallingFromIPTask1( void ) xSocket.u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); @@ -851,6 +870,8 @@ void test_vTCPStateChange_ClosedWaitState_NotCallingFromIPTask1( void ) xSocket.u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); catch_assert( vTCPStateChange( &xSocket, eTCPState ) ); @@ -872,6 +893,8 @@ void test_vTCPStateChange_ClosedWaitState_ReuseSocket( void ) xSocket.u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; xSocket.u.xTCP.bits.bReuseSocket = pdTRUE_UNSIGNED; + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -946,6 +969,8 @@ void test_vTCPStateChange_EstablishedToClosedState_SocketInactive( void ) xTCPWindowLoggingLevel = 2; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, 0 ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -991,6 +1016,8 @@ void test_vTCPStateChange_EstablishedToClosedState_SocketActive( void ) xHandleConnectedLength = 0; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -1036,6 +1063,8 @@ void test_vTCPStateChange_EstablishedToClosedState_SocketActive_SelectExcept( vo xHandleConnectedLength = 0; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); @@ -1685,6 +1714,9 @@ void test_xProcessReceivedTCPPacket_ConnectSyn_State_Rst_Change_State( void ) pxTCPSocketLookup_ExpectAnyArgsAndReturn( pxSocket ); prvTCPSocketIsActive_ExpectAnyArgsAndReturn( pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); + xTaskGetTickCount_ExpectAndReturn( 1000 ); xTaskGetTickCount_ExpectAndReturn( 1500 ); @@ -1768,6 +1800,9 @@ void test_xProcessReceivedTCPPacket_Establish_State_Rst_Change_State( void ) pxTCPSocketLookup_ExpectAnyArgsAndReturn( pxSocket ); prvTCPSocketIsActive_ExpectAnyArgsAndReturn( pdTRUE ); prvTCPSocketIsActive_ExpectAnyArgsAndReturn( pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); + xTaskGetTickCount_ExpectAndReturn( 1000 ); xTaskGetTickCount_ExpectAndReturn( 1500 ); diff --git a/test/unit-test/FreeRTOS_TCP_IP_DiffConfig/FreeRTOS_TCP_IP_DiffConfig_utest.c b/test/unit-test/FreeRTOS_TCP_IP_DiffConfig/FreeRTOS_TCP_IP_DiffConfig_utest.c index f8a5babebb..84f62cfad8 100644 --- a/test/unit-test/FreeRTOS_TCP_IP_DiffConfig/FreeRTOS_TCP_IP_DiffConfig_utest.c +++ b/test/unit-test/FreeRTOS_TCP_IP_DiffConfig/FreeRTOS_TCP_IP_DiffConfig_utest.c @@ -163,6 +163,8 @@ void test_vTCPStateChange_ClosedWaitState_CurrentStateSynFirstNextStateCloseWait xSocket.u.xTCP.bits.bReuseSocket = pdTRUE_UNSIGNED; prvTCPSocketIsActive_ExpectAndReturn( xSocket.u.xTCP.eTCPState, pdTRUE ); + vTaskSuspendAll_Expect(); + xTaskResumeAll_ExpectAndReturn( 0 ); xTaskGetTickCount_ExpectAndReturn( xTickCountAck ); xTaskGetTickCount_ExpectAndReturn( xTickCountAlive ); From cb592e939cf388e1157e0141441b62b2f03ab983 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 16 Feb 2023 10:33:27 +0800 Subject: [PATCH 17/44] Remove Dup function HAL_ETH_SetMDIOClockRange. (#711) --- .../STM32Hxx/NetworkInterface.c | 3 -- .../STM32Hxx/stm32hxx_hal_eth.c | 50 ------------------- .../STM32Hxx/stm32hxx_hal_eth.h | 1 - 3 files changed, 54 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 926effa1d8..af8b3684f7 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -278,9 +278,6 @@ BaseType_t xNetworkInterfaceInitialise( void ) HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } - /* Configure the MDIO Clock */ - HAL_ETH_SetMDIOClockRange( &( xEthHandle ) ); - /* Initialize the MACB and set all PHY properties */ prvMACBProbePhy(); diff --git a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c index 460168623d..0a44278bb2 100644 --- a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c +++ b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c @@ -2171,56 +2171,6 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; } } -/** - * @brief Configures the Clock range of ETH MDIO interface. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ - void HAL_ETH_SetMDIOClockRange( ETH_HandleTypeDef * heth ) - { - uint32_t tmpreg, hclk; - - /* Get the ETHERNET MACMDIOAR value */ - tmpreg = ( heth->Instance )->MACMDIOAR; - - /* Clear CSR Clock Range bits */ - tmpreg &= ~ETH_MACMDIOAR_CR; - - /* Get hclk frequency value */ - hclk = HAL_RCC_GetHCLKFreq(); - - /* Set CR bits depending on hclk value */ - if( ( hclk >= 20000000U ) && ( hclk < 35000000U ) ) - { - /* CSR Clock Range between 20-35 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV16; - } - else if( ( hclk >= 35000000U ) && ( hclk < 60000000U ) ) - { - /* CSR Clock Range between 35-60 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV26; - } - else if( ( hclk >= 60000000U ) && ( hclk < 100000000U ) ) - { - /* CSR Clock Range between 60-100 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV42; - } - else if( ( hclk >= 100000000U ) && ( hclk < 150000000U ) ) - { - /* CSR Clock Range between 100-150 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV62; - } - else /* (hclk >= 150000000)&&(hclk <= 200000000) */ - { - /* CSR Clock Range between 150-200 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV102; - } - - /* Configure the CSR Clock Range */ - ( heth->Instance )->MACMDIOAR = ( uint32_t ) tmpreg; - } - /** * @brief Set the ETH MAC (L2) Filters configuration. * @param heth: pointer to a ETH_HandleTypeDef structure that contains diff --git a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h index 749dd261d9..519d8c659a 100644 --- a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h +++ b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h @@ -1808,7 +1808,6 @@ ETH_MACConfigTypeDef * macconf ); HAL_StatusTypeDef HAL_ETH_SetDMAConfig( ETH_HandleTypeDef * heth, ETH_DMAConfigTypeDef * dmaconf ); - void HAL_ETH_SetMDIOClockRange( ETH_HandleTypeDef * heth ); /* MAC VLAN Processing APIs ************************************************/ void HAL_ETH_SetRxVLANIdentifier( ETH_HandleTypeDef * heth, From 1a29e5b72b21b199d43679cdf95d789187f9dbe0 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Sat, 18 Feb 2023 13:41:52 -0800 Subject: [PATCH 18/44] Update PR template to include checkbox for ut change (#734) --- .github/pull_request_template.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c3c8607fbd..a39aa2bfa3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,6 +8,13 @@ Test Steps ----------- +Checklist: +---------- + + +- [ ] I have tested my changes. No regression in existing tests. +- [ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request. + Related Issue ----------- From 14cf915805b03f71fe9092fcbadb8c587b42858d Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Sun, 19 Feb 2023 16:32:23 +0800 Subject: [PATCH 19/44] Main/TCP4 : ACK number in TCP RESET reply to SYN packet (#724) * Main/TCP4 : ACK number in TCP RESET reply to SYN packet * Typo fix * Add unit-test for coverage; Fix ntohl to htonl * Fix unit-test --------- Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- source/FreeRTOS_TCP_Transmission.c | 12 ++++++++- .../FreeRTOS_TCP_Transmission_utest.c | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index 154d0ac5b3..bf1be23700 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -1463,10 +1463,20 @@ TCPPacket_t * pxTCPPacket = ( ( TCPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); const uint32_t ulSendLength = ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ); /* Plus 0 options. */ - + uint8_t ucFlagsReceived = pxTCPPacket->xTCPHeader.ucTCPFlags; pxTCPPacket->xTCPHeader.ucTCPFlags = ucTCPFlags; pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER ) << 2; + if( ( ucFlagsReceived & tcpTCP_FLAG_SYN ) != 0U ) + { + /* A synchronize packet is received. It counts as 1 pseudo byte of data, + * so increase the variable with 1. Before sending a reply, the values of + * 'ulSequenceNumber' and 'ulAckNr' will be swapped. */ + uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); + ulSequenceNumber++; + pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); + } + prvTCPReturnPacket( NULL, pxNetworkBuffer, ulSendLength, pdFALSE ); } #endif /* !ipconfigIGNORE_UNKNOWN_PACKETS */ diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index a99d102e09..fdefe06894 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -1867,6 +1867,33 @@ void test_prvTCPSendSpecialPacketHelper( void ) TEST_ASSERT_EQUAL( 0x50, pxTCPPacket->xTCPHeader.ucTCPOffset ); } +/* test prvTCPSendSpecialPacketHelper function */ +void test_prvTCPSendSpecialPacketHelper_flagSYN( void ) +{ + BaseType_t Return = pdTRUE; + const uint32_t ulSequenceNumber = 0xABC12300; + + pxSocket = &xSocket; + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + TCPPacket_t * pxTCPPacket = ( ( const TCPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + + pxTCPPacket->xTCPHeader.ucTCPFlags = tcpTCP_FLAG_SYN; + pxTCPPacket->xTCPHeader.ucTCPOffset = 0; + pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); + + usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); + usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + xNetworkInterfaceOutput_ExpectAnyArgsAndReturn( pdTRUE ); + + Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); + TEST_ASSERT_EQUAL( pdFALSE, Return ); + TEST_ASSERT_EQUAL( tcpTCP_FLAG_ACK, pxTCPPacket->xTCPHeader.ucTCPFlags ); + TEST_ASSERT_EQUAL( 0x50, pxTCPPacket->xTCPHeader.ucTCPOffset ); + TEST_ASSERT_EQUAL( ulSequenceNumber + 1, FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulAckNr ) ); +} + /* test prvTCPSendChallengeAck function */ void test_prvTCPSendChallengeAck( void ) { From dcd6e58cec5676231c329e9645590d90eb4c5cba Mon Sep 17 00:00:00 2001 From: phelter Date: Thu, 23 Feb 2023 19:09:25 -0800 Subject: [PATCH 20/44] #556 Initial Cmake Module definition. (#557) * #556 Initial Cmake Module definition. * Fixing CI builds, rely on pcap. (#556) * Updating tested configurations and minor clean-up of missing network interfaces (#555) * Further clean-up based on testing with build environment. (#555) * Using single definition for libraries everywhere. (#555) * Fixing A_CUSTOM_NETWORK_IF compile option. * Identifying and fixing compile issues. * Adding in additional warnings for GNU to ignore for now. * Fixing formatting issues with uncrustify. * More warnings for GNU used by CI/CD pipeline. * Assuming custom for build tests and using latest freertos-kernel code. Updated readme for how to consume at project level. * Fixing up issues identified in the PR. Making the build_test EXCLUDE_FROM_ALL so only compiled if requested. * Changing to support C89 instead of C99. Renaming tcp_tools to tcp_utilities to mimic the directory. * Using C90 ISO. Fixing compiler warnings. * Fixing non C90 compliant declaration after statement * Separating out CMakeLists so each port is independent. * Updating warning list in code. * Fixed formatting with uncrustify. * Fix failing tests * Fix failing unit-test * Fix a typo. --------- Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- .github/workflows/ci.yml | 24 +- CMakeLists.txt | 236 ++++++++++++++++++ README.md | 35 ++- cmake_modules/FindPCAP.cmake | 75 ++++++ source/CMakeLists.txt | 93 +++++++ source/FreeRTOS_ARP.c | 4 +- source/FreeRTOS_DNS.c | 4 +- source/FreeRTOS_IP.c | 4 + source/FreeRTOS_Sockets.c | 4 + source/portable/CMakeLists.txt | 36 +++ .../NetworkInterface/ATSAM4E/CMakeLists.txt | 26 ++ .../NetworkInterface/ATSAME5x/CMakeLists.txt | 20 ++ .../portable/NetworkInterface/CMakeLists.txt | 54 ++++ .../NetworkInterface/DriverSAM/CMakeLists.txt | 22 ++ .../NetworkInterface/LPC17xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC18xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC54018/CMakeLists.txt | 28 +++ .../NetworkInterface/M487/CMakeLists.txt | 22 ++ .../MPS2_AN385/CMakeLists.txt | 29 +++ .../NetworkInterface/RX/CMakeLists.txt | 22 ++ .../NetworkInterface/SH2A/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Fxx/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Hxx/CMakeLists.txt | 23 ++ .../NetworkInterface/TM4C/CMakeLists.txt | 20 ++ .../ThirdParty/MSP432/CMakeLists.txt | 23 ++ .../NetworkInterface/WinPCap/CMakeLists.txt | 25 ++ .../NetworkInterface/Zynq/CMakeLists.txt | 73 ++++++ .../board_family/CMakeLists.txt | 20 ++ .../NetworkInterface/esp32/CMakeLists.txt | 28 +++ .../ksz8851snl/CMakeLists.txt | 23 ++ .../NetworkInterface/libslirp/CMakeLists.txt | 29 +++ .../NetworkInterface/linux/CMakeLists.txt | 39 +++ .../NetworkInterface/linux/NetworkInterface.c | 8 +- .../NetworkInterface/mw300_rd/CMakeLists.txt | 20 ++ .../NetworkInterface/pic32mzef/CMakeLists.txt | 23 ++ .../xilinx_ultrascale/CMakeLists.txt | 70 ++++++ test/CMakeLists.txt | 8 + test/build-combination/CMakeLists.txt | 144 +++++------ .../build-combination/Common/FreeRTOSConfig.h | 9 +- test/build-combination/Common/main.c | 56 +++-- .../DefaultConf/FreeRTOSIPConfig.h | 8 +- test/build-combination/README.md | 18 +- tools/CMakeLists.txt | 37 +++ 43 files changed, 1405 insertions(+), 143 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake_modules/FindPCAP.cmake create mode 100644 source/CMakeLists.txt create mode 100644 source/portable/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/DriverSAM/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC17xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC18xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC54018/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/M487/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/RX/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/SH2A/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/TM4C/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/WinPCap/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/Zynq/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/board_family/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/esp32/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/libslirp/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/linux/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/mw300_rd/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/pic32mzef/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt create mode 100644 test/CMakeLists.txt create mode 100644 tools/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bce7f8d73..4fe0b79fdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Clone This Repo uses: actions/checkout@v2 with: - path: ./tcp + path: ./tcp - name: Install spell run: | sudo apt-get install spell @@ -111,23 +111,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Update submodules - run: git submodule update --init --checkout + - name: Build Install Dependencies + run: | + sudo apt-get install -y libpcap-dev - name: Build checks (Enable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=ENABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Disable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DISABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Default configuration) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DEFAULT_CONF - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test complexity: runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..71d0b56d0b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,236 @@ + +cmake_minimum_required(VERSION 3.15) +cmake_policy(SET CMP0048 NEW) # project version +cmake_policy(SET CMP0076 NEW) # full paths + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") + +######################################################################## +# Project Details +project(FreeRTOS-Plus-TCP + VERSION 3.1.0 + DESCRIPTION "FreeRTOS TCP/UDP Network Layer" + HOMEPAGE_URL https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html + LANGUAGES C) + +# Do not allow in-source build. +if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) +message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) +endif() + +# Options +option(FREERTOS_PLUS_TCP_BUILD_TEST "Build the test for FreeRTOS Plus TCP" OFF) + +# Configuration +# Override these at project level with: +# Optional: set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "1" CACHE STRING "" FORCE) +# Optional: set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "" FORCE) +# Required: set(FREERTOS_PLUS_TCP_NETWORK_IF "POSIX" CACHE STRING "" FORCE) + +# Select the appropriate buffer allocaiton method. +# See: https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html +if (NOT FREERTOS_PLUS_TCP_BUFFER_ALLOCATION) + message(STATUS "Using default FREERTOS_PLUS_TCP_BUFFER_ALLOCATION = 2") + set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.") +endif() + +# Select the Compiler - if left blank will detect using CMake +# Note relies on CMake to detect over any setting here. +# Valid options are: +# FREERTOS_PLUS_TCP_COMPILER | Detected | CMake +# ------------------------------------------------- +# CCS | No | ?TBD? +# GCC | Yes | GNU +# IAR | Yes | IAR +# Keil | Yes | ARMCC +# MSVC | Yes | MSVC # Note only for MinGW +# Renesas | No | ?TBD? +# Will always a attempt to detect and if detectable double checks that the compiler is set correctly. +set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "FreeRTOS Plus TCP Compiler Selection") + + +# Select the appropriate network interface +# This will fail the CMake preparation step if not set to one of those values. +set(FREERTOS_PLUS_TCP_NETWORK_IF "" CACHE STRING "FreeRTOS Plus TCP Network Interface selection") +set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST + A_CUSTOM_NETWORK_IF + ATSAM43 ATSAME5x # AT + DRIVER_SAM + ESP32 + KSZ8851SNL + LPC17xx LPC18xx LPC54018 + M487 + MPS2_AN385 + MW300_RD + PIC32MZEF_ETH PIC32MZEF_WIFI + POSIX WIN_PCAP # Native Linux & Windows respectively + RX + SH2A + STM32FXX STM32HXX # ST Micro + MSP432 + TM4C + XILINX_ULTRASCALE ZYNQ # AMD/Xilinx +) +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF) + # Attempt to detect the system. + if(UNIX) + message(STATUS "Detected UNIX/Posix system setting FREERTOS_PLUS_TCP_NETWORK_IF = POSIX") + set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX) + elseif(MINGW) + message(STATUS "Detected Windows MinGW system setting FREERTOS_PLUS_TCP_NETWORK_IF = WIN_PCAP") + set(FREERTOS_PLUS_TCP_NETWORK_IF WIN_PCAP) + endif() +endif() + +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF IN_LIST FREERTOS_PLUS_TCP_NETWORK_IF_LIST ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is '${FREERTOS_PLUS_TCP_NETWORK_IF}'.\n" + " Please specify it from top-level CMake file (example):\n" + " set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX CACHE STRING \"\")\n" + " or from CMake command line option:\n" + " -DFREERTOS_PLUS_TCP_NETWORK_IF=POSIX\n" + " \n" + " Available port options: (Tested means compiled with that variant)\n" + " A_CUSTOM_NETWORK_IF Target: User Defined\n" + " ATSAM4E Target: ATSAM4E Tested: TODO\n" + " ATSAME5x Target: ATSAME5x Tested: TODO\n" + " DRIVER_SAM Target: Driver SAM Tested: TODO\n" + " ESP32 Target: ESP-32 Tested: TODO\n" + " KSZ8851SNL Target: ksz8851snl Tested: TODO\n" + " POSIX Target: linux/Posix\n" + " LPC17xx Target: LPC17xx Tested: TODO\n" + " LPC18xx Target: LPC18xx Tested: TODO\n" + " LPC54018 Target: LPC54018 Tested: TODO\n" + " M487 Target: M487 Tested: TODO\n" + " MPS2_AN385 Target: MPS2_AN385 Tested: TODO\n" + " MW300_RD Target: mw300_rd Tested: TODO\n" + " PIC32MZEF_ETH Target: pic32mzef ethernet Tested: TODO\n" + " PIC32MZEF_WIFI Target: pic32mzef Wifi Tested: TODO\n" + " RX Target: RX Tested: TODO\n" + " SH2A Target: SH2A Tested: TODO\n" + " STM32FXX Target: STM32Fxx Tested: TODO\n" + " STM32HXX Target: STM32Hxx Tested: TODO\n" + " MSP432 Target: MSP432 Tested: TODO\n" + " TM4C Target: TM4C Tested: TODO\n" + " WIN_PCAP Target: Windows Tested: TODO\n" + " XILINX_ULTRASCALE Target: Xilinx Ultrascale Tested: TODO\n" + " ZYNQ Target: Xilinx Zynq") +elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is set to A_CUSTOM_NETWORK_IF.\n" + " Please specify the custom network interface target with all necessary files.\n" + " For example, assuming a directory of:\n" + " FreeRTOSCustomNetworkInterface/\n" + " CMakeLists.txt\n" + " NetworkInterface.c\n\n" + " Where FreeRTOSCustomNetworkInterface/CMakeLists.txt is a modified version of:\n" + " add_library(freertos_plus_tcp_network_if STATIC)\n\n" + " target_sources(freertos_plus_tcp_network_if\n" + " PRIVATE\n" + " NetworkInterface.c)\n\n" + " target_include_directories(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " .)\n\n" + " taget_link_libraries(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " freertos_plus_tcp_port\n" + " freertos_plus_tcp_network_if_common\n" + " PRIVATE\n" + " freertos_kernel)") +endif() + +# There is also the need to add a target - typically an interface library that describes the +# Configuration for FreeRTOS-Kernel and FreeRTOS-Plus-TCP. +# This is called freertos_config +# If not defined will be default compile with one of the test build combinations AllEnable. + +# Select the appropriate Build Test configuration +# This is only used when freertos_config is not defined, otherwise the build test will be performed +# on the config defined in the freertos_config +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION "CUSTOM" CACHE STRING "FreeRTOS Plus TCP Build Test configuration") +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST + CUSTOM # Custom (external) configuration -eg from a top-level project + ENABLE_ALL # Enable all configuration settings + DISABLE_ALL # Disable all configuration settings + DEFAULT_CONF # Default (typical) configuration +) +if(NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION IN_LIST FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST) + message(FATAL_ERROR "Invalid FREERTOS_PLUS_TCP_TEST_CONFIGURATION value '${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}' should be one of: ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST}") +else() + message(STATUS "Using FreeRTOS-Plus-TCP Test Configuration : ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}") + if (NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM") + message(WARNING "FreeRTOS-Kernel configuration settings are configured by FreeRTOS-Plus-TCP") + endif() +endif() + +######################################################################## +# Requirements +set(CMAKE_C_STANDARD 90) # Note FreeRTOS-Kernel uses C99 constructs. +set(CMAKE_C_STANDARD_REQUIRED ON) + +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. +# +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# For the ?TBD? - Suggest trying GNU-based and adding the appropriate toolchain file. +# For Toolchain examples see _deps/cmake-src/toolchain/arm-none-eabil-gcc.toolchain.cmake +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? + +add_compile_options( + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Weverything> + + # TODO: Add in other Compilers here. +) + +######################################################################## +# External Dependencies +# Note: For backwards compatibility - still have .gitmodules defining submodules +# To support fetching content in a higher level project see +# README.md `Consume with CMake` +# This will allow you to upgrade submodules and have one common submodule for +# all your builds despite multiple submodules having different versions. +include(FetchContent) + +FetchContent_Declare( freertos_kernel + GIT_REPOSITORY https://github.com/phelter/FreeRTOS-Kernel.git #https://github.com/FreeRTOS/FreeRTOS-Kernel.git + GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master +) + +FetchContent_Declare( cmock + GIT_REPOSITORY https://github.com/ThrowTheSwitch/CMock + GIT_TAG v2.5.3 +) + +add_subdirectory(source) +add_subdirectory(tools) +add_subdirectory(test) + +FetchContent_MakeAvailable(freertos_kernel cmock) + +# Note following are can be removed once FreeRTOS-Kernel v10.5.0 + fixes their issues. +# To ignore header specific issues - change all of the headers to SYSTEM +set(_freertos_kernel_targets freertos_kernel freertos_kernel_port) +# foreach (_target ${_freertos_kernel_targets} ) +# get_target_property( interface_directories ${_target} INTERFACE_INCLUDE_DIRECTORIES ) +# set_target_properties(${_target} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${interface_directories}" ) +# endforeach() diff --git a/README.md b/README.md index 7c6ee16c6e..07971fe2d7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,40 @@ Once python is downloaded and installed, you can verify the version from your te To run the script, you should switch to the FreeRTOS-Plus-TCP directory that was created using the [Cloning this repository](#cloning-this-repository) step above. And then run `python /GenerateOriginalFiles.py`. -## Cloning this repository +## To consume FreeRTOS+TCP + +### Consume with CMake +If using CMake, it is recommended to use this repository using FetchContent. +Add the following into your project's main or a subdirectory's `CMakeLists.txt`: + +- Define the source and version/tag you want to use: + +```cmake +FetchContent_Declare( freertos_plus_tcp + GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git + GIT_TAG master #Note: Best practice to use specific git-hash or tagged version + GIT_SUBMODULES "" # Don't grab any submodules since not latest +) +``` + +- Configure the FreeRTOS-Kernel and make it available + - this particular example supports a native and cross-compiled build option. + +```cmake +set( FREERTOS_PLUS_FAT_DEV_SUPPORT OFF CACHE BOOL "" FORCE) +# Select the native compile PORT +set( FREERTOS_PLUS_FAT_PORT "POSIX" CACHE STRING "" FORCE) +# Select the cross-compile PORT +if (CMAKE_CROSSCOMPILING) + # Eg. Zynq 2019_3 version of port + set(FREERTOS_PLUS_FAT_PORT "ZYNQ_2019_3" CACHE STRING "" FORCE) +endif() + +FetchContent_MakeAvailable(freertos_plus_tcp) +``` + +### Consuming stand-alone + This repository uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to bring in dependent components. Note: If you download the ZIP file provided by GitHub UI, you will not get the contents of the submodules. (The ZIP file is also not a valid Git repository) diff --git a/cmake_modules/FindPCAP.cmake b/cmake_modules/FindPCAP.cmake new file mode 100644 index 0000000000..4f3c7b6412 --- /dev/null +++ b/cmake_modules/FindPCAP.cmake @@ -0,0 +1,75 @@ +# - Try to find libpcap include dirs and libraries +# +# Usage of this module as follows: +# +# find_package(PCAP) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# PCAP_ROOT_DIR Set this variable to the root installation of +# libpcap if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# PCAP_FOUND System has libpcap, include and library dirs found +# PCAP_INCLUDE_DIR The libpcap include directories. +# PCAP_LIBRARY The libpcap library (possibly includes a thread +# library e.g. required by pf_ring's libpcap) +# HAVE_PF_RING If a found version of libpcap supports PF_RING + +find_path(PCAP_ROOT_DIR + NAMES include/pcap.h +) + +find_path(PCAP_INCLUDE_DIR + NAMES pcap.h + HINTS ${PCAP_ROOT_DIR}/include +) + +find_library(PCAP_LIBRARY + NAMES pcap + HINTS ${PCAP_ROOT_DIR}/lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCAP DEFAULT_MSG + PCAP_LIBRARY + PCAP_INCLUDE_DIR +) + +include(CheckCSourceCompiles) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO) +set(CMAKE_REQUIRED_LIBRARIES) + +# check if linking against libpcap also needs to link against a thread library +if (NOT PCAP_LINKS_SOLO) + find_package(Threads) + if (THREADS_FOUND) + set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS) + set(CMAKE_REQUIRED_LIBRARIES) + endif () + if (THREADS_FOUND AND PCAP_NEEDS_THREADS) + set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + list(REMOVE_DUPLICATES _tmp) + set(PCAP_LIBRARY ${_tmp} + CACHE STRING "Libraries needed to link against libpcap" FORCE) + else () + message(FATAL_ERROR "Couldn't determine how to link against libpcap") + endif () +endif () + +include(CheckFunctionExists) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_function_exists(pcap_get_pfring_id HAVE_PF_RING) +check_function_exists(pcap_dump_open_append HAVE_PCAP_DUMP_OPEN_APPEND) +set(CMAKE_REQUIRED_LIBRARIES) + +mark_as_advanced( + PCAP_ROOT_DIR + PCAP_INCLUDE_DIR + PCAP_LIBRARY +) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt new file mode 100644 index 0000000000..a990fe9478 --- /dev/null +++ b/source/CMakeLists.txt @@ -0,0 +1,93 @@ +add_library( freertos_plus_tcp STATIC ) + +target_sources( freertos_plus_tcp + PRIVATE + include/FreeRTOS_ARP.h + include/FreeRTOS_DHCP.h + include/FreeRTOS_DNS_Cache.h + include/FreeRTOS_DNS_Callback.h + include/FreeRTOS_DNS_Globals.h + include/FreeRTOS_DNS_Networking.h + include/FreeRTOS_DNS_Parser.h + include/FreeRTOS_DNS.h + include/FreeRTOS_errno_TCP.h + include/FreeRTOS_ICMP.h + include/FreeRTOS_IP_Private.h + include/FreeRTOS_IP_Timers.h + include/FreeRTOS_IP_Utils.h + include/FreeRTOS_IP.h + include/FreeRTOS_Sockets.h + include/FreeRTOS_Stream_Buffer.h + include/FreeRTOS_TCP_IP.h + include/FreeRTOS_TCP_Reception.h + include/FreeRTOS_TCP_State_Handling.h + include/FreeRTOS_TCP_Transmission.h + include/FreeRTOS_TCP_Utils.h + include/FreeRTOS_TCP_WIN.h + include/FreeRTOS_UDP_IP.h + include/FreeRTOSIPConfigDefaults.h + include/IPTraceMacroDefaults.h + include/NetworkBufferManagement.h + include/NetworkInterface.h + + FreeRTOS_ARP.c + FreeRTOS_DHCP.c + FreeRTOS_DNS_Cache.c + FreeRTOS_DNS_Callback.c + FreeRTOS_DNS_Networking.c + FreeRTOS_DNS_Parser.c + FreeRTOS_DNS.c + FreeRTOS_ICMP.c + FreeRTOS_IP_Timers.c + FreeRTOS_IP_Utils.c + FreeRTOS_IP.c + FreeRTOS_Sockets.c + FreeRTOS_Stream_Buffer.c + FreeRTOS_TCP_IP.c + FreeRTOS_TCP_Reception.c + FreeRTOS_TCP_State_Handling.c + FreeRTOS_TCP_Transmission.c + FreeRTOS_TCP_Utils.c + FreeRTOS_TCP_WIN.c + FreeRTOS_Tiny_TCP.c + FreeRTOS_UDP_IP.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp SYSTEM + PUBLIC + include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp + PRIVATE + $<$:-Wno-bad-function-cast> + $<$:-Wno-cast-qual> + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-covered-switch-default> + $<$:-Wno-documentation> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-missing-noreturn> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-variable> + $<$:-Wno-pedantic> +) + +target_link_libraries( freertos_plus_tcp + PUBLIC + freertos_config + freertos_plus_tcp_port # for pack_struct_start.h + PRIVATE + freertos_kernel + freertos_plus_tcp_network_if + freertos_plus_tcp_utilities +) + +add_subdirectory(portable) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index dab7aaecd5..453127dd1c 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -168,6 +168,8 @@ eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame ) /* Introduce a do while loop to allow use of breaks. */ do { + uint32_t ulHostEndianProtocolAddr; + /* Only Ethernet hardware type is supported. * Only IPv4 address can be present in the ARP packet. * The hardware length (the MAC address) must be 6 bytes. And, @@ -193,7 +195,7 @@ eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame ) break; } - uint32_t ulHostEndianProtocolAddr = FreeRTOS_ntohl( ulSenderProtocolAddress ); + ulHostEndianProtocolAddr = FreeRTOS_ntohl( ulSenderProtocolAddress ); if( ( ipFIRST_LOOPBACK_IPv4 <= ulHostEndianProtocolAddr ) && ( ulHostEndianProtocolAddr < ipLAST_LOOPBACK_IPv4 ) ) diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index d856862ff5..3844001f4d 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -395,9 +395,7 @@ /* Obtain the DNS server address. */ FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulIPAddress ); #if ( ipconfigUSE_LLMNR == 1 ) - BaseType_t bHasDot = llmnr_has_dot( pcHostName ); - - if( bHasDot == pdFALSE ) + if( llmnr_has_dot( pcHostName ) == pdFALSE ) { /* Use LLMNR addressing. */ pxAddress->sin_addr = ipLLMNR_IP_ADDR; /* Is in network byte order. */ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index b2b05c5655..9e7fdf0901 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -55,6 +55,10 @@ #include "NetworkBufferManagement.h" #include "FreeRTOS_DNS.h" +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif + /* IPv4 multi-cast addresses range from 224.0.0.0.0 to 240.0.0.0. */ #define ipFIRST_MULTI_CAST_IPv4 0xE0000000U /**< Lower bound of the IPv4 multicast address. */ #define ipLAST_MULTI_CAST_IPv4 0xF0000000U /**< Higher bound of the IPv4 multicast address. */ diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index af1248ad24..972cb18c9d 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -50,6 +50,10 @@ #include "FreeRTOS_DNS.h" #include "NetworkBufferManagement.h" +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif + /* The ItemValue of the sockets xBoundSocketListItem member holds the socket's * port number. */ /** @brief Set the port number for the socket in the xBoundSocketListItem. */ diff --git a/source/portable/CMakeLists.txt b/source/portable/CMakeLists.txt new file mode 100644 index 0000000000..c3aede2013 --- /dev/null +++ b/source/portable/CMakeLists.txt @@ -0,0 +1,36 @@ +add_library( freertos_plus_tcp_port STATIC ) + +target_sources( freertos_plus_tcp_port + PRIVATE + BufferManagement/BufferAllocation_${FREERTOS_PLUS_TCP_BUFFER_ALLOCATION}.c + # TODO: There's NetworkInterface/pic32mzef that has it's own BufferAllocation_2.c +) + +target_include_directories( freertos_plus_tcp_port + PUBLIC + # Using Cmake to detect except for unknown compilers. + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/GCC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/IAR> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Keil> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/MSVC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Renesas> +) + +target_compile_options( freertos_plus_tcp_port + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-pedantic> # Strange definition for STATIC_ASSERT +) + +target_link_libraries( freertos_plus_tcp_port + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if +) + +#------------------------------------------------------------------------------ +add_subdirectory(NetworkInterface) diff --git a/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt new file mode 100644 index 0000000000..22bacf3789 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt @@ -0,0 +1,26 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAM4E") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + component/gmac.h + instance/gmac.h + ethernet_phy.c + ethernet_phy.h + gmac.c + gmac.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt new file mode 100644 index 0000000000..7fe7b5dd01 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAME5x") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/CMakeLists.txt b/source/portable/NetworkInterface/CMakeLists.txt new file mode 100644 index 0000000000..dcf98604dd --- /dev/null +++ b/source/portable/NetworkInterface/CMakeLists.txt @@ -0,0 +1,54 @@ +add_library( freertos_plus_tcp_network_if_common STATIC ) + +target_sources( freertos_plus_tcp_network_if_common + PRIVATE + Common/phyHandling.c + include/phyHandling.h +) + +target_include_directories( freertos_plus_tcp_network_if_common + PUBLIC + include +) + +target_compile_options( freertos_plus_tcp_network_if_common + PRIVATE + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-padded> + $<$:-Wno-uninitialized> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-macros> +) + +target_link_libraries( freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) + +#------------------------------------------------------------------------------ +add_subdirectory(ATSAM4E) +add_subdirectory(ATSAME5x) +#add_subdirectory(board_family) - This is only an example. +add_subdirectory(DriverSAM) +add_subdirectory(esp32) +add_subdirectory(ksz8851snl) +add_subdirectory(libslirp) +add_subdirectory(linux) +add_subdirectory(LPC17xx) +add_subdirectory(LPC18xx) +add_subdirectory(LPC54018) +add_subdirectory(M487) +add_subdirectory(MPS2_AN385) +add_subdirectory(mw300_rd) +add_subdirectory(pic32mzef) +add_subdirectory(RX) +add_subdirectory(SH2A) +add_subdirectory(STM32Fxx) +add_subdirectory(STM32Hxx) +add_subdirectory(ThirdParty/MSP432) +add_subdirectory(TM4C) +add_subdirectory(WinPCap) +add_subdirectory(xilinx_ultrascale) +add_subdirectory(Zynq) diff --git a/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt new file mode 100644 index 0000000000..d142a9cd05 --- /dev/null +++ b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "DRIVER_SAM") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + gmac_SAM.c + gmac_SAM.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt new file mode 100644 index 0000000000..1e6ca4f1b2 --- /dev/null +++ b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC17xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC17xx must have a target for the lpc17xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc17xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt new file mode 100644 index 0000000000..480acf5725 --- /dev/null +++ b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC18xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC18xx must have a target for the lpc18xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc18xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC54018/CMakeLists.txt b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt new file mode 100644 index 0000000000..6d444220ed --- /dev/null +++ b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC54018") ) + return() +endif() + +if(NOT TARGET fsl_enet_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC54018 must have a target for the fsl_enet_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc54018_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/M487/CMakeLists.txt b/source/portable/NetworkInterface/M487/CMakeLists.txt new file mode 100644 index 0000000000..8400bc6bb8 --- /dev/null +++ b/source/portable/NetworkInterface/M487/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "M487") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + m480_eth.c + m480_eth.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt new file mode 100644 index 0000000000..231b4aaada --- /dev/null +++ b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MPS2_AN385") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118/SMM_MPS2.h + ether_lan9118/smsc9220_emac_config.h + ether_lan9118/smsc9220_eth_drv.c + ether_lan9118/smsc9220_eth_drv.h + NetworkInterface.c +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118 +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/RX/CMakeLists.txt b/source/portable/NetworkInterface/RX/CMakeLists.txt new file mode 100644 index 0000000000..9fed7027f0 --- /dev/null +++ b/source/portable/NetworkInterface/RX/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "RX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_callback.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/SH2A/CMakeLists.txt b/source/portable/NetworkInterface/SH2A/CMakeLists.txt new file mode 100644 index 0000000000..54f704c0de --- /dev/null +++ b/source/portable/NetworkInterface/SH2A/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "SH2A") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +# target_link_libraries( freertos_plus_tcp_network_if +# PRIVATE +# hwEthernetLib # Todo where is hwEthernet.h? +# ) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt new file mode 100644 index 0000000000..cfe8f1c1f1 --- /dev/null +++ b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32FXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + # stm32f2xx_hal_eth.h + # stm32f4xx_hal_eth.h + stm32f7xx_hal_eth.h #TODO: Only one of these ? + stm32fxx_hal_eth.c + stm32fxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt new file mode 100644 index 0000000000..016f1b927c --- /dev/null +++ b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32HXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + stm32h7xx_hal_eth.h + stm32hxx_hal_eth.c + stm32hxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/TM4C/CMakeLists.txt b/source/portable/NetworkInterface/TM4C/CMakeLists.txt new file mode 100644 index 0000000000..b019e71a4c --- /dev/null +++ b/source/portable/NetworkInterface/TM4C/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "TM4C") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt new file mode 100644 index 0000000000..fdbcc425b2 --- /dev/null +++ b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MSP432") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + NetworkInterface.h + NetworkMiddleware.c + NetworkMiddleware.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/WinPCap/CMakeLists.txt b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt new file mode 100644 index 0000000000..eb5f37573a --- /dev/null +++ b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "WIN_PCAP") ) ) + return() +endif() + +find_package(PCAP REQUIRED) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + FaultInjection.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} +) + diff --git a/source/portable/NetworkInterface/Zynq/CMakeLists.txt b/source/portable/NetworkInterface/Zynq/CMakeLists.txt new file mode 100644 index 0000000000..2f27c5125e --- /dev/null +++ b/source/portable/NetworkInterface/Zynq/CMakeLists.txt @@ -0,0 +1,73 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ZYNQ") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ZYNQ must have a target for the xil_bsp") +endif() + +# ZYNQ port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) +set_property(TARGET freertos_plus_tcp_network_if PROPERTY C_STANDARD 99) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> + $<$:-Wno-pedantic> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/source/portable/NetworkInterface/board_family/CMakeLists.txt b/source/portable/NetworkInterface/board_family/CMakeLists.txt new file mode 100644 index 0000000000..03f46e4051 --- /dev/null +++ b/source/portable/NetworkInterface/board_family/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/esp32/CMakeLists.txt b/source/portable/NetworkInterface/esp32/CMakeLists.txt new file mode 100644 index 0000000000..899f711cca --- /dev/null +++ b/source/portable/NetworkInterface/esp32/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ESP32") ) + return() +endif() + +if(NOT TARGET esp32_lib) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ESP32 must have a target for the esp32_lib") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PRIVATE + esp32_lib # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt new file mode 100644 index 0000000000..0ab28dfa81 --- /dev/null +++ b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "KSZ8851SNL") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ksz8851snl_reg.h + ksz8851snl.c + ksz8851snl.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/libslirp/CMakeLists.txt b/source/portable/NetworkInterface/libslirp/CMakeLists.txt new file mode 100644 index 0000000000..3c4a94dbf6 --- /dev/null +++ b/source/portable/NetworkInterface/libslirp/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LIBSLIRP") ) + return() +endif() + +if(NOT TARGET slirp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LIBSLIRP must have a target for the slirp") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + MBuffNetifBackendLibslirp.c + MBuffNetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + slirp # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/linux/CMakeLists.txt b/source/portable/NetworkInterface/linux/CMakeLists.txt new file mode 100644 index 0000000000..0b2e44cbd6 --- /dev/null +++ b/source/portable/NetworkInterface/linux/CMakeLists.txt @@ -0,0 +1,39 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "POSIX") ) + return() +endif() + +find_package(PCAP REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-documentation> + $<$:-Wno-missing-noreturn> + $<$:-Wno-padded> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-undef> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} + Threads::Threads +) diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index 30203f86a3..230b90d5c8 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -650,14 +650,14 @@ static void * prvLinuxPcapRecvThread( void * pvParam ) { int ret; - ( void ) pvParam; - /* Disable signals to this thread since this is a Linux pthread to be able to * printf and other blocking operations without being interrupted and put in * suspension mode by the linux port signals */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); @@ -689,12 +689,12 @@ static void * prvLinuxPcapSendThread( void * pvParam ) uint8_t ucBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ]; const time_t xMaxMSToWait = 1000; - ( void ) pvParam; - /* disable signals to avoid treating this thread as a FreeRTOS task and putting * it to sleep by the scheduler */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); diff --git a/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt new file mode 100644 index 0000000000..974008c93e --- /dev/null +++ b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MW300_RD") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt new file mode 100644 index 0000000000..31f5ff6ea3 --- /dev/null +++ b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_ETH") OR + (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_WIFI") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + $<$:NetworkInterface_eth.c> + $<$:NetworkInterface_wifi.c> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt new file mode 100644 index 0000000000..674a1dc506 --- /dev/null +++ b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt @@ -0,0 +1,70 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "XILINX_ULTRASCALE") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=XILINX_ULTRASCALE must have a target for the xil_bsp") +endif() + +# XILINX_ULTRASCALE port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..97d4459107 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(build-combination) + +if(FREERTOS_PLUS_TCP_BUILD_TEST) + add_subdirectory(cbmc) + add_subdirectory(Coverity) + add_subdirectory(unit-test) +endif() + diff --git a/test/build-combination/CMakeLists.txt b/test/build-combination/CMakeLists.txt index c695073309..9c77788cb3 100644 --- a/test/build-combination/CMakeLists.txt +++ b/test/build-combination/CMakeLists.txt @@ -1,89 +1,61 @@ -cmake_minimum_required ( VERSION 3.13.0 ) -project ( "FreeRTOS-Plus-TCP Build Combination" - VERSION 1.0.0 - LANGUAGES C ) - -# Allow the project to be organized into folders. -set_property( GLOBAL PROPERTY USE_FOLDERS ON ) - -# Use C90. -set( CMAKE_C_STANDARD 90 ) -set( CMAKE_C_STANDARD_REQUIRED ON ) - -# Do not allow in-source build. -if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) - message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) -endif() - -# Set global path variables. -get_filename_component(__MODULE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) -set(MODULE_ROOT_DIR ${__MODULE_ROOT_DIR} CACHE INTERNAL "FreeRTOS-Plus-TCP repository root.") - -# Configure options to always show in CMake GUI. -option( BUILD_CLONE_SUBMODULES - "Set this to ON to automatically clone any required Git submodules. When OFF, submodules must be manually cloned." - ON ) - - -option(TEST_CONFIGURATION "Configuration All Enable/Disable or default" ENABLE_ALL) - -message( STATUS "Argument: ${TEST_CONFIGURATION}") - -# Set output directories. -set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) - - -set( FREERTOS_KERNEL_DIR ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel ) -set( TEST_DIR ${MODULE_ROOT_DIR}/test/build-combination ) - -include_directories( ${MODULE_ROOT_DIR}/source/include ) -include_directories( ${MODULE_ROOT_DIR}/source/portable/Compiler/MSVC ) -include_directories( ${FREERTOS_KERNEL_DIR}/include ) -# Add the correct portable directory to include search paths. -if (WIN32) - include_directories( ${FREERTOS_KERNEL_DIR}/portable/MSVC-MingW ) -else() - include_directories( ${FREERTOS_KERNEL_DIR}/portable/ThirdParty/GCC/Posix ) -endif() -include_directories( ${TEST_DIR}/Common ) - -if( ${TEST_CONFIGURATION} STREQUAL "ENABLE_ALL" ) - include_directories( ${TEST_DIR}/AllEnable ) -elseif( ${TEST_CONFIGURATION} STREQUAL "DISABLE_ALL" ) - include_directories( ${TEST_DIR}/AllDisable ) -else() - include_directories( ${TEST_DIR}/DefaultConf ) -endif() - -# Pick the correct kernel port files for the platform. -if (WIN32) - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/MSVC-MingW/*.c") +add_library( freertos_plus_tcp_config_common INTERFACE ) +target_include_directories(freertos_plus_tcp_config_common INTERFACE Common ) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_disable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_disable INTERFACE AllDisable) +target_link_libraries(freertos_plus_tcp_config_all_disable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_enable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_enable INTERFACE AllEnable) +target_link_libraries(freertos_plus_tcp_config_all_enable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_default INTERFACE) +target_include_directories(freertos_plus_tcp_config_default INTERFACE DefaultConf) +target_link_libraries(freertos_plus_tcp_config_default INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +# Configuration for FreeRTOS-Kernel +if(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM" ) + # Check Config target is available. And then do nothing. + if(NOT TARGET freertos_config ) + message(FATAL_ERROR "FREERTOS_PLUS_TCP_TEST_CONFIGURATION = CUSTOM, but no freertos_config target defined.") + endif() +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "DISABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_disable) +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable) else() - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/utils/*.c") + add_library( freertos_config ALIAS freertos_plus_tcp_config_default) endif() -file(GLOB TCP_SOURCES "${MODULE_ROOT_DIR}/source/*.c" ) - -message(STATUS "${KERNEL_SOURCES}") -message(STATUS "${TCP_SOURCES}") - -add_executable(project ${KERNEL_SOURCES} - ${TCP_SOURCES} - ${FREERTOS_KERNEL_DIR}/portable/MemMang/heap_4.c - ${MODULE_ROOT_DIR}/source/portable/BufferManagement/BufferAllocation_2.c - ${TEST_DIR}/Common/main.c ) - -if (WIN32) - # Add preprocessor definitions to suppress warnings. - target_compile_definitions( project PRIVATE - _CRT_SECURE_NO_WARNINGS ) -else() - # Link pthread which is needed for POSIX port. - find_package( Threads REQUIRED ) - target_link_libraries( project Threads::Threads ) -endif() +add_executable(freertos_plus_tcp_build_test EXCLUDE_FROM_ALL) + +target_sources(freertos_plus_tcp_build_test + PRIVATE + Common/main.c +) + +target_compile_options(freertos_plus_tcp_build_test + PRIVATE + $<$:-Wno-cast-qual> + $<$:-Wno-format-nonliteral> + $<$:-Wno-implicit-function-declaration> + $<$:-Wno-missing-noreturn> + $<$:-Wno-missing-prototypes> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries(freertos_plus_tcp_build_test + PRIVATE + freertos_plus_tcp + freertos_kernel +) diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index 7d5de97dc4..a7f7d86bad 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -114,18 +114,11 @@ * functions. */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 -/* Assert call defined for debug builds. */ -void vAssertCalled( const char * pcFile, - uint32_t ulLine ); - -#define configASSERT( x ) - /* The function that implements FreeRTOS printf style output, and the macro * that maps the configPRINTF() macros to that function. */ #define configPRINTF( X ) /* Non-format version thread-safe print. */ -extern void vLoggingPrint( const char * pcMessage ); #define configPRINT( X ) /* Non-format version thread-safe print. */ @@ -219,7 +212,7 @@ extern void vLoggingPrint( const char * pcMessage ); #define configPROFILING ( 0 ) /* Pseudo random number generator used by some tasks. */ -extern uint32_t ulRand(); +extern uint32_t ulRand( void ); #define configRAND32() ulRand() /* The platform that FreeRTOS is running on. */ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index a60035f543..333f159c57 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -39,8 +39,17 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_DHCP.h" -#define mainHOST_NAME "Build Combination" +#include +#include +#define mainHOST_NAME "Build Combination" +#define mainDEVICE_NICK_NAME "Build_Combination" + +#if defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) + #define local_stricmp _stricmp +#else + #define local_stricmp strcasecmp +#endif /*-----------------------------------------------------------*/ /* Notes if the trace is running or not. */ @@ -157,11 +166,11 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) /* Determine if a name lookup is for this node. Two names are given * to this node: that returned by pcApplicationHostnameHook() and that set * by mainDEVICE_NICK_NAME. */ - if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) + if( local_stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) { xReturn = pdPASS; } - else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) + else if( local_stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) { xReturn = pdPASS; } @@ -190,9 +199,8 @@ void vApplicationIdleHook( void ) /* Exit. Just a stub. */ } /*-----------------------------------------------------------*/ - void vAssertCalled( const char * pcFile, - uint32_t ulLine ) + unsigned long ulLine ) { const uint32_t ulLongSleep = 1000UL; volatile uint32_t ulBlockVariable = 0UL; @@ -212,6 +220,17 @@ void vAssertCalled( const char * pcFile, } /*-----------------------------------------------------------*/ +void vLoggingPrintf( const char * pcFormat, + ... ) +{ + va_list arg; + + va_start( arg, pcFormat ); + vprintf( pcFormat, arg ); + va_end( arg ); +} +/*-----------------------------------------------------------*/ + void getUserCmd( char * pucUserCmd ) { /* Provide a stub for this function. */ @@ -235,6 +254,8 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) return pdTRUE; } +/*-----------------------------------------------------------*/ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t * pulIdleTaskStackSize ) @@ -242,6 +263,19 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Provide a stub for this function. */ } +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ + /* Provide a stub for this function. */ +} + +/*-----------------------------------------------------------*/ + +void vApplicationDaemonTaskStartupHook( void ) +{ + /* Provide a stub for this function. */ +} /* * Callback that provides the inputs necessary to generate a randomized TCP @@ -274,18 +308,6 @@ void vApplicationMallocFailedHook( void ) /* Provide a stub for this function. */ } -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t bReleaseAfterSend ) -{ - /* Provide a stub for this function. */ - return pdTRUE; -} - -BaseType_t xNetworkInterfaceInitialise( void ) -{ - /* Provide a stub for this function. */ - return pdTRUE; -} #if ( ( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_DHCP_HOOK != 0 ) ) eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, diff --git a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h index c908f0fcd3..313c401e6e 100644 --- a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h +++ b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h @@ -38,6 +38,10 @@ /* It is not sensible for this macro to have a default value as it is hardware * dependent. */ -#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN +#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN -#endif +/* The windows simulator cannot really simulate MAC interrupts, and needs to + * block occasionally to allow other tasks to run. */ +#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS ) + +#endif /* ifndef FREERTOS_IP_CONFIG_H */ diff --git a/test/build-combination/README.md b/test/build-combination/README.md index 0bbcba87d3..8d7aca4957 100644 --- a/test/build-combination/README.md +++ b/test/build-combination/README.md @@ -9,20 +9,20 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DISABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DEFAULT_CONF -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF +cmake --build build --target freertos_plus_tcp_build_test ``` ## Windows @@ -31,21 +31,21 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000..dfbbdc5b8a --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,37 @@ +add_library( freertos_plus_tcp_utilities STATIC ) + +target_sources( freertos_plus_tcp_utilities + PRIVATE + tcp_utilities/include/tcp_dump_packets.h + tcp_utilities/include/tcp_mem_stats.h + tcp_utilities/include/tcp_netstat.h + + tcp_utilities/tcp_dump_packets.c + tcp_utilities/tcp_mem_stats.c + tcp_utilities/tcp_netstat.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp_utilities SYSTEM + PUBLIC + tcp_utilities/include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp_utilities + PRIVATE + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-format> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-padded> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-function> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries( freertos_plus_tcp_utilities + PRIVATE + freertos_kernel + freertos_plus_tcp +) From 5b454cd6092a715a7d5bbbba90ce90c62d3536f3 Mon Sep 17 00:00:00 2001 From: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> Date: Sun, 26 Feb 2023 23:36:00 +0530 Subject: [PATCH 21/44] CMake: Fix GIT_REPOSITORY and GIT_TAG (#742) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71d0b56d0b..5e4ee7e8d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,8 +212,8 @@ add_compile_options( include(FetchContent) FetchContent_Declare( freertos_kernel - GIT_REPOSITORY https://github.com/phelter/FreeRTOS-Kernel.git #https://github.com/FreeRTOS/FreeRTOS-Kernel.git - GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master + GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git + GIT_TAG main ) FetchContent_Declare( cmock From 6a9f04fb042e14687a0e15bc8ebcbf123c12ba7a Mon Sep 17 00:00:00 2001 From: "Adam St. Amand" Date: Wed, 8 Mar 2023 14:15:38 -0800 Subject: [PATCH 22/44] Allow use of loopback addresses in IP stack (127.0.0.0/8) (#754) Authored-by: Adam St. Amand --- source/FreeRTOS_ARP.c | 6 ++- source/FreeRTOS_IP.c | 2 + source/include/FreeRTOS_IP_Private.h | 4 ++ .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 40 +++++++++++++++++++ .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 35 ++++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 453127dd1c..03156c97a7 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -413,7 +413,8 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw const IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - if( ( pxIPHeader->ulSourceIPAddress & xNetworkAddressing.ulNetMask ) == ( *ipLOCAL_IP_ADDRESS_POINTER & xNetworkAddressing.ulNetMask ) ) + if( ( ( pxIPHeader->ulSourceIPAddress & xNetworkAddressing.ulNetMask ) == ( *ipLOCAL_IP_ADDRESS_POINTER & xNetworkAddressing.ulNetMask ) ) && + ( ( pxIPHeader->ulDestinationIPAddress & ipLOOPBACK_NETMASK ) != ( ipLOOPBACK_ADDRESS & ipLOOPBACK_NETMASK ) ) ) { /* If the IP is on the same subnet and we do not have an ARP entry already, * then we should send out ARP for finding the MAC address. */ @@ -726,7 +727,8 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, * can be done. */ eReturn = eCantSendPacket; } - else if( *ipLOCAL_IP_ADDRESS_POINTER == *pulIPAddress ) + else if( ( *ipLOCAL_IP_ADDRESS_POINTER == *pulIPAddress ) || + ( ( *pulIPAddress & ipLOOPBACK_NETMASK ) == ( ipLOOPBACK_ADDRESS & ipLOOPBACK_NETMASK ) ) ) { /* The address of this device. May be useful for the loopback device. */ eReturn = eARPCacheHit; diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 9e7fdf0901..df777be9ab 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1446,6 +1446,8 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP else if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && /* Is it the global broadcast address 255.255.255.255 ? */ ( ulDestinationIPAddress != ipBROADCAST_IP_ADDRESS ) && + /* Is it a loopback address ? */ + ( ( ulDestinationIPAddress & ipLOOPBACK_NETMASK ) != ( ipLOOPBACK_ADDRESS & ipLOOPBACK_NETMASK ) ) && /* Is it a specific broadcast address 192.168.1.255 ? */ ( ulDestinationIPAddress != xNetworkAddressing.ulBroadcastAddress ) && #if ( ipconfigUSE_LLMNR == 1 ) diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index 542c28b247..e14c19098f 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -387,6 +387,10 @@ extern const BaseType_t xBufferAllocFixedSize; * rather than duplicated in its own variable. */ #define ipLOCAL_MAC_ADDRESS ( xDefaultPartUDPPacketHeader.ucBytes ) +/* The loopback address block is defined as part of rfc5735 */ +#define ipLOOPBACK_ADDRESS ( FreeRTOS_inet_addr_quick( 127, 0, 0, 0 ) ) +#define ipLOOPBACK_NETMASK ( FreeRTOS_inet_addr_quick( 255, 0, 0, 0 ) ) + /* ICMP packets are sent using the same function as UDP packets. The port * number is used to distinguish between the two, as 0 is an invalid UDP port. */ #define ipPACKET_CONTAINS_ICMP_DATA ( 0 ) diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index bcd3675681..ae48779853 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -945,6 +945,29 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_InCache( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } +void test_xCheckRequiresARPResolution_OnLocalNetwork_Loopback( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + + IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + + *ipLOCAL_IP_ADDRESS_POINTER = ipLOOPBACK_ADDRESS; + + /* Make sure there is a match on source IP and loopback address */ + pxIPHeader->ulDestinationIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; + pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER & xNetworkAddressing.ulNetMask; + + xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); +} + void test_ulARPRemoveCacheEntryByMac_NoMatch( void ) { @@ -1322,6 +1345,23 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void ) /* =================================================== */ } +void test_eARPGetCacheEntry_IPMatchesLoopbackAddr( void ) +{ + uint32_t ulIPAddress; + MACAddress_t xMACAddress; + eARPLookupResult_t eResult; + uint32_t ulSavedGatewayAddress; + + /* =================================================== */ + ulIPAddress = ipLOOPBACK_ADDRESS; + /* Not worried about what these functions do. */ + xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); + eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress ); + TEST_ASSERT_EQUAL_MESSAGE( eARPCacheHit, eResult, "Test 3" ); + TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &ipLOCAL_MAC_ADDRESS, &xMACAddress, sizeof( xMACAddress ), "Test 3" ); + /* =================================================== */ +} + void test_eARPGetCacheEntry_LocalIPIsZero( void ) { uint32_t ulIPAddress; diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index b955f6581b..d04c488a90 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2249,6 +2249,41 @@ void test_prvAllowIPPacket_IncorrectProtocolChecksum( void ) TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); } +void test_prvAllowIPPacket_LoopbackDest( void ) +{ + eFrameProcessingResult_t eResult; + IPPacket_t * pxIPPacket; + NetworkBufferDescriptor_t * pxNetworkBuffer, xNetworkBuffer; + UBaseType_t uxHeaderLength = 0; + uint8_t ucEthBuffer[ ipconfigTCP_MSS ]; + IPHeader_t * pxIPHeader; + + memset( ucEthBuffer, 0, ipconfigTCP_MSS ); + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pucEthernetBuffer = ucEthBuffer; + pxIPPacket = ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxIPHeader = &( pxIPPacket->xIPHeader ); + + *ipLOCAL_IP_ADDRESS_POINTER = 0xFFFFFFFF; + + pxIPHeader->ucVersionHeaderLength = 0x45; + + pxIPHeader->ulDestinationIPAddress = ipLOOPBACK_ADDRESS; + + memcpy( pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, &ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + + pxIPHeader->ulSourceIPAddress = 0xC0C00101; + + usGenerateChecksum_ExpectAndReturn( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ( size_t ) uxHeaderLength, ipCORRECT_CRC ); + + usGenerateProtocolChecksum_ExpectAndReturn( ( uint8_t * ) ( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE, ipCORRECT_CRC ); + + eResult = prvAllowIPPacket( pxIPPacket, pxNetworkBuffer, uxHeaderLength ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + void test_prvAllowIPPacket_HappyPath( void ) { eFrameProcessingResult_t eResult; From 8526fb3461212d0b178593a421c662deca4afd6e Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Thu, 9 Mar 2023 14:40:35 +0530 Subject: [PATCH 23/44] Add release candidate automation (#761) This is a minimal subset of release automation which only creates a tag and verifies it. Signed-off-by: Gaurav Aggarwal --- .github/workflows/release-candidate.yml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/release-candidate.yml diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml new file mode 100644 index 0000000000..832491ce5c --- /dev/null +++ b/.github/workflows/release-candidate.yml @@ -0,0 +1,35 @@ +name: Release Candidate Automation + +on: + workflow_dispatch: + inputs: + commit_id: + description: 'Commit ID to tag' + required: true + version_number: + description: 'Release Version Number (Eg, v1.0.0-rc1)' + required: true + +jobs: + tag-commit: + name: Tag commit + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.commit_id }} + - name: Configure git identity + run: | + git config --global user.name ${{ github.actor }} + git config --global user.email ${{ github.actor }}@users.noreply.github.com + - name: Tag Commit and Push to Remote + run: | + git tag ${{ github.event.inputs.version_number }} -a -m "FreeRTOS-Plus-TCP Library ${{ github.event.inputs.version_number }}" + git push origin --tags + - name: Verify tag on remote + run: | + git tag -d ${{ github.event.inputs.version_number }} + git remote update + git checkout tags/${{ github.event.inputs.version_number }} + git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }} From 0e58fdfa77cb1b5141c9ce3deb9647759d61c602 Mon Sep 17 00:00:00 2001 From: Kareem Khazem Date: Tue, 28 Feb 2023 22:19:17 +0000 Subject: [PATCH 24/44] Add CBMC-running GitHub Action; This commit adds a GitHub Action that runs the CBMC proofs in this repository upon pushes and pull requests --- .github/workflows/ci.yml | 15 +++ test/cbmc/proofs/lib | 143 ++++++++++++++++++++++++++++ test/cbmc/proofs/run-cbmc-proofs.py | 2 +- 3 files changed, 159 insertions(+), 1 deletion(-) create mode 100755 test/cbmc/proofs/lib diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fe0b79fdd..d755e4fcd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -178,3 +178,18 @@ jobs: run: | git-secrets --register-aws git-secrets --scan + proof_ci: + runs-on: cbmc_ubuntu-latest_16-core + steps: + - name: Set up CBMC runner + uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main + with: + cbmc_version: "5.61.0" + - run: | + git submodule update --init --checkout --recursive + sudo apt-get update + sudo apt-get install --yes --no-install-recommends gcc-multilib + - name: Run CBMC + uses: FreeRTOS/CI-CD-Github-Actions/run_cbmc@main + with: + proofs_dir: test/cbmc/proofs diff --git a/test/cbmc/proofs/lib b/test/cbmc/proofs/lib new file mode 100755 index 0000000000..50dbcc33ce --- /dev/null +++ b/test/cbmc/proofs/lib @@ -0,0 +1,143 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: MIT-0 + +import argparse +import json +import logging +import os +import sys + + +DESCRIPTION = """Print 2 tables in GitHub-flavored Markdown that summarize +an execution of CBMC proofs.""" + + +def get_args(): + """Parse arguments for summarize script.""" + parser = argparse.ArgumentParser(description=DESCRIPTION) + for arg in [{ + "flags": ["--run-file"], + "help": "path to the Litani run.json file", + "required": True, + }]: + flags = arg.pop("flags") + parser.add_argument(*flags, **arg) + return parser.parse_args() + + +def _get_max_length_per_column_list(data): + ret = [len(item) + 1 for item in data[0]] + for row in data[1:]: + for idx, item in enumerate(row): + ret[idx] = max(ret[idx], len(item) + 1) + return ret + + +def _get_table_header_separator(max_length_per_column_list): + line_sep = "" + for max_length_of_word_in_col in max_length_per_column_list: + line_sep += "|" + "-" * (max_length_of_word_in_col + 1) + line_sep += "|\n" + return line_sep + + +def _get_entries(max_length_per_column_list, row_data): + entries = [] + for row in row_data: + entry = "" + for idx, word in enumerate(row): + max_length_of_word_in_col = max_length_per_column_list[idx] + space_formatted_word = (max_length_of_word_in_col - len(word)) * " " + entry += "| " + word + space_formatted_word + entry += "|\n" + entries.append(entry) + return entries + + +def _get_rendered_table(data): + table = [] + max_length_per_column_list = _get_max_length_per_column_list(data) + entries = _get_entries(max_length_per_column_list, data) + for idx, entry in enumerate(entries): + if idx == 1: + line_sep = _get_table_header_separator(max_length_per_column_list) + table.append(line_sep) + table.append(entry) + table.append("\n") + return "".join(table) + + +def _get_status_and_proof_summaries(run_dict): + """Parse a dict representing a Litani run and create lists summarizing the + proof results. + + Parameters + ---------- + run_dict + A dictionary representing a Litani run. + + + Returns + ------- + A list of 2 lists. + The first sub-list maps a status to the number of proofs with that status. + The second sub-list maps each proof to its status. + """ + count_statuses = {} + proofs = [["Proof", "Status"]] + for proof_pipeline in run_dict["pipelines"]: + status_pretty_name = proof_pipeline["status"].title().replace("_", " ") + try: + count_statuses[status_pretty_name] += 1 + except KeyError: + count_statuses[status_pretty_name] = 1 + if proof_pipeline["name"] == "print_tool_versions": + continue + proofs.append([proof_pipeline["name"], status_pretty_name]) + statuses = [["Status", "Count"]] + for status, count in count_statuses.items(): + statuses.append([status, str(count)]) + return [statuses, proofs] + + +def print_proof_results(out_file): + """ + Print 2 strings that summarize the proof results. + When printing, each string will render as a GitHub flavored Markdown table. + """ + output = "## Summary of CBMC proof results\n\n" + with open(out_file, encoding='utf-8') as run_json: + run_dict = json.load(run_json) + status_table, proof_table = _get_status_and_proof_summaries(run_dict) + for summary in (status_table, proof_table): + output += _get_rendered_table(summary) + + print(output) + sys.stdout.flush() + + github_summary_file = os.getenv("GITHUB_STEP_SUMMARY") + if github_summary_file: + with open(github_summary_file, "a") as handle: + print(output, file=handle) + handle.flush() + else: + logging.warning( + "$GITHUB_STEP_SUMMARY not set, not writing summary file") + + msg = ( + "Click the 'Summary' button to view a Markdown table " + "summarizing all proof results") + if run_dict["status"] != "success": + logging.error("Not all proofs passed.") + logging.error(msg) + sys.exit(1) + logging.info(msg) + + +if __name__ == '__main__': + args = get_args() + logging.basicConfig(format="%(levelname)s: %(message)s") + try: + print_proof_results(args.run_file) + except Exception as ex: # pylint: disable=broad-except + logging.critical("Could not print results. Exception: %s", str(ex)) diff --git a/test/cbmc/proofs/run-cbmc-proofs.py b/test/cbmc/proofs/run-cbmc-proofs.py index f92d5ea663..de89bff6d2 100755 --- a/test/cbmc/proofs/run-cbmc-proofs.py +++ b/test/cbmc/proofs/run-cbmc-proofs.py @@ -152,7 +152,7 @@ def run_build(jobs): cmd = ["litani", "run-build"] if jobs: cmd.extend(["-j", str(jobs)]) - run_cmd(cmd, check=True) + run_cmd(cmd, check=True, timeout=3600) def add_proof_jobs(proof_directory, proof_root): From b879e29142225bdd0d4b5e5d7bc6bc2c39943a21 Mon Sep 17 00:00:00 2001 From: Kareem Khazem Date: Wed, 8 Mar 2023 14:16:44 +0000 Subject: [PATCH 25/44] Copy CBMC output directory to CI location This commit ensures that the output directory for CBMC proofs is in the correct location expected by the FreeRTOS CI-CD repository. --- test/cbmc/proofs/lib/print_tool_versions.py | 74 +++++++++++++++++++++ test/cbmc/proofs/{lib => lib/summarize.py} | 0 test/cbmc/proofs/run-cbmc-proofs.py | 10 ++- 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100755 test/cbmc/proofs/lib/print_tool_versions.py rename test/cbmc/proofs/{lib => lib/summarize.py} (100%) mode change 100755 => 100644 diff --git a/test/cbmc/proofs/lib/print_tool_versions.py b/test/cbmc/proofs/lib/print_tool_versions.py new file mode 100755 index 0000000000..bdeb429e3d --- /dev/null +++ b/test/cbmc/proofs/lib/print_tool_versions.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: MIT-0 + + +import logging +import pathlib +import shutil +import subprocess + + +_TOOLS = [ + "cadical", + "cbmc", + "cbmc-viewer", + "cbmc-starter-kit-update", + "kissat", + "litani", +] + + +def _format_versions(table): + lines = [ + "", + '', + ] + for tool, version in table.items(): + if version: + v_str = f'
{version}
' + else: + v_str = 'not found' + lines.append( + f'' + f'') + lines.append("
Tool Versions
{tool}:{v_str}
") + return "\n".join(lines) + + +def _get_tool_versions(): + ret = {} + for tool in _TOOLS: + err = f"Could not determine version of {tool}: " + ret[tool] = None + if not shutil.which(tool): + logging.error("%s'%s' not found on $PATH", err, tool) + continue + cmd = [tool, "--version"] + proc = subprocess.Popen(cmd, text=True, stdout=subprocess.PIPE) + try: + out, _ = proc.communicate(timeout=10) + except subprocess.TimeoutExpired: + logging.error("%s'%s --version' timed out", err, tool) + continue + if proc.returncode: + logging.error( + "%s'%s --version' returned %s", err, tool, str(proc.returncode)) + continue + ret[tool] = out.strip() + return ret + + +def main(): + exe_name = pathlib.Path(__file__).name + logging.basicConfig(format=f"{exe_name}: %(message)s") + + table = _get_tool_versions() + out = _format_versions(table) + print(out) + + +if __name__ == "__main__": + main() diff --git a/test/cbmc/proofs/lib b/test/cbmc/proofs/lib/summarize.py old mode 100755 new mode 100644 similarity index 100% rename from test/cbmc/proofs/lib rename to test/cbmc/proofs/lib/summarize.py diff --git a/test/cbmc/proofs/run-cbmc-proofs.py b/test/cbmc/proofs/run-cbmc-proofs.py index de89bff6d2..429d787342 100755 --- a/test/cbmc/proofs/run-cbmc-proofs.py +++ b/test/cbmc/proofs/run-cbmc-proofs.py @@ -152,7 +152,7 @@ def run_build(jobs): cmd = ["litani", "run-build"] if jobs: cmd.extend(["-j", str(jobs)]) - run_cmd(cmd, check=True, timeout=3600) + run_cmd(cmd, check=True) def add_proof_jobs(proof_directory, proof_root): @@ -301,7 +301,13 @@ def main(): if not args.no_standalone: run_build(args.parallel_jobs) + out_sym = pathlib.Path("/tmp")/"litani"/"runs"/"latest" + out_dir = out_sym.resolve() + + local_copy = pathlib.Path("output")/"latest" + local_copy.parent.mkdir(exist_ok=True) + local_copy.symlink_to(out_dir) + if __name__ == "__main__": main() - From 94655eb465416d98e76bac0673ae4fba7277bc9e Mon Sep 17 00:00:00 2001 From: sayyadumar Date: Tue, 14 Mar 2023 20:12:11 +0100 Subject: [PATCH 26/44] rx: Read mac address using FreeRTOS_GetMACAddress() rather than using the defines (#765) * Read mac address using FreeRTOS_GetMACAddress() rather than using the defines --------- Co-authored-by: GitHub Action --- .../NetworkInterface/RX/NetworkInterface.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/source/portable/NetworkInterface/RX/NetworkInterface.c b/source/portable/NetworkInterface/RX/NetworkInterface.c index 204588abdb..6b131930e5 100644 --- a/source/portable/NetworkInterface/RX/NetworkInterface.c +++ b/source/portable/NetworkInterface/RX/NetworkInterface.c @@ -422,15 +422,12 @@ static int InitializeNetwork( void ) ether_return_t eth_ret; BaseType_t return_code = pdFALSE; ether_param_t param; - uint8_t myethaddr[ 6 ] = - { - configMAC_ADDR0, - configMAC_ADDR1, - configMAC_ADDR2, - configMAC_ADDR3, - configMAC_ADDR4, - configMAC_ADDR5 - }; /*XXX Fix me */ + + /* Read the mac address after it has been initilized by the FreeRTOS IP Stack, rather than from defines + * as the mac address is usually read from the EEPROM, and it might be different to the mac address in + * the defines, especially in production environments + */ + const uint8_t * myethaddr = FreeRTOS_GetMACAddress(); R_ETHER_PinSet_CHANNEL_0(); R_ETHER_Initial(); From 4a22215f85cc8fbe82817ef2676242a3d2055da2 Mon Sep 17 00:00:00 2001 From: Paul Bartell Date: Tue, 14 Mar 2023 12:51:10 -0700 Subject: [PATCH 27/44] cmake: Remove add_subdirectory( cbmc ) call CBMC proofs cannot currently be run using CMake. fixes #753 --- test/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 97d4459107..fb71ba3463 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(build-combination) if(FREERTOS_PLUS_TCP_BUILD_TEST) - add_subdirectory(cbmc) add_subdirectory(Coverity) add_subdirectory(unit-test) endif() From 9066f6172690eb061b4816f4d0bc0f6e7bdb41a3 Mon Sep 17 00:00:00 2001 From: Paul Bartell Date: Tue, 14 Mar 2023 13:02:44 -0700 Subject: [PATCH 28/44] FreeRTOS_IP.h: Fix build error introduced by 55658e1 in FreeRTOS-Kernel --- source/include/FreeRTOS_IP.h | 28 +++++++++++++++++++++------- test/unit-test/CMakeLists.txt | 14 +++++++++++++- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index d8cdf2be1e..5114ac8f1d 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -276,14 +276,28 @@ uint32_t FreeRTOS_round_down( uint32_t a, #define pdMS_TO_MIN_TICKS( xTimeInMs ) ipMS_TO_MIN_TICKS( xTimeInMs ) #ifndef pdTRUE_SIGNED - /* Temporary solution: eventually the defines below will appear in 'Source\include\projdefs.h' */ - #define pdTRUE_SIGNED pdTRUE - #define pdFALSE_SIGNED pdFALSE - #define pdTRUE_UNSIGNED ( 1U ) + #define pdTRUE_SIGNED pdTRUE +#endif /* pdTRUE_SIGNED */ + +#ifndef pdFALSE_SIGNED + #define pdFALSE_SIGNED pdFALSE +#endif /* pdFALSE_SIGNED */ + +#ifndef pdTRUE_UNSIGNED + #define pdTRUE_UNSIGNED ( 1U ) +#endif /* pdTRUE_UNSIGNED */ + +#ifndef pdFALSE_UNSIGNED #define pdFALSE_UNSIGNED ( 0U ) - #define ipTRUE_BOOL ( 1 == 1 ) - #define ipFALSE_BOOL ( 1 == 2 ) -#endif +#endif /* pdFALSE_UNSIGNED */ + +#ifndef ipTRUE_BOOL + #define ipTRUE_BOOL ( 1 == 1 ) +#endif /* ipTRUE_BOOL */ + +#ifndef ipFALSE_BOOL + #define ipFALSE_BOOL ( 1 == 2 ) +#endif /* ipFALSE_BOOL */ /* * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index 18e868a61d..59c51ab2fb 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -113,8 +113,20 @@ foreach( file ${TCP_INCLUDES} ) execute_process( COMMAND mv ${CMAKE_BINARY_DIR}/Annexed_TCP/${MODIFIED_FILE}_tmp2.h ${CMAKE_BINARY_DIR}/Annexed_TCP/${MODIFIED_FILE}_tmp.h ) endif() + + # Use this tool to process all conditional declarations. - execute_process( COMMAND unifdefall -U${Guard} -USEND_REPEATED_COUNT -UpdTRUE_SIGNED -UFreeRTOS_htonl -D__COVERITY__ -DTEST -I ${MODULE_ROOT_DIR}/tools/CMock/vendor/unity/src + execute_process( COMMAND unifdefall -U${Guard} -USEND_REPEATED_COUNT + -UpdTRUE_SIGNED + -UpdFALSE_SIGNED + -UpdTRUE_UNSIGNED + -UpdFALSE_UNSIGNED + -UipTRUE_BOOL + -UipFALSE_BOOL + -UFreeRTOS_htonl + -D__COVERITY__ + -DTEST + -I ${MODULE_ROOT_DIR}/tools/CMock/vendor/unity/src -I ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include -I ${UNIT_TEST_DIR}/ConfigFiles -I ${MODULE_ROOT_DIR}/source/include From 176b24b6e1a28ade3c3c1de33268a508b1f77cee Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri, 17 Mar 2023 16:11:03 -0700 Subject: [PATCH 29/44] Add Nxp1060 network interface (#774) * Update PR template to include checkbox for ut change * Create NetworkInterface.c * Uncrustify: triggered by comment. * Address PR comments * Uncrustify: triggered by comment. * Update NetworkInterface.c * Uncrustify: triggered by comment. * Update copyright year * Refactor the init function. Add 'brief'. Cleanup. * Uncrustify: triggered by comment. * Update global link status only when the network is quiet * Uncrustify: triggered by comment. * Update copyright yeat * Update the driver to deal with network cable disconnects * Uncrustify: triggered by comment. * Update NetworkInterface.c * Clean up and address PR comments * More cleanup and address PR comments * Uncrustify: triggered by comment. * Empty-Commit * Address issue comments * Uncrustify: triggered by comment. * Empty-Commit to trigger workflow * Remove Full-Duplex restriction * Uncrustify: triggered by comment. * Empty-Commit to trigger workflow --------- Co-authored-by: GitHub Action --- .../NXP1060/NetworkInterface.c | 810 ++++++++++++++++++ 1 file changed, 810 insertions(+) create mode 100644 source/portable/NetworkInterface/NXP1060/NetworkInterface.c diff --git a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c new file mode 100644 index 0000000000..0c0d20bd97 --- /dev/null +++ b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c @@ -0,0 +1,810 @@ +/* + * FreeRTOS+TCP + * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + */ + +/** + * @file NetworkInterface.c + * @brief Implements the Network Interface driver for the NXP MIMXRT1060 board. + */ +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" + +#include "fsl_device_registers.h" +#include "fsl_debug_console.h" +#include "board.h" + +#include "fsl_phy.h" + +#include "fsl_phyksz8081.h" +#include "fsl_enet_mdio.h" +#include "fsl_enet.h" + +#include "NetworkInterface.h" + +#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1 + #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer +#else + #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) +#endif + +/* MDIO operations. */ +#define EXAMPLE_MDIO_OPS enet_ops + +/* PHY operations. */ +#define EXAMPLE_PHY_OPS phyksz8081_ops + +/* ENET clock frequency. */ +#define EXAMPLE_CLOCK_FREQ CLOCK_GetFreq( kCLOCK_IpgClk ) + +/* + * Padding of ethernet frames has to be disabled for zero-copy functionality + * since ENET driver requires the starting buffer addresses to be aligned. + */ +#if ETH_PAD_SIZE != 0 + #error "ETH_PAD_SIZE != 0" +#endif /* ETH_PAD_SIZE != 0 */ + +/******************************************************************************* + * Definitions + ******************************************************************************/ +#define ENET_RING_NUM ( 1 ) + +/* The length or RX buffer. */ +#ifndef ENET_RXBUFF_SIZE + #define ENET_RXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN ) +#endif + +/* ENET IRQ priority. Used in FreeRTOS. */ +/* Interrupt priorities. */ +#ifdef __CA7_REV + #ifndef ENET_PRIORITY + #define ENET_PRIORITY ( 21U ) + #endif + #ifndef ENET_1588_PRIORITY + #define ENET_1588_PRIORITY ( 20U ) + #endif +#else + #ifndef ENET_PRIORITY + #define ENET_PRIORITY ( 6U ) + #endif + #ifndef ENET_1588_PRIORITY + #define ENET_1588_PRIORITY ( 5U ) + #endif +#endif /* ifdef __CA7_REV */ + +/* The number of ENET buffers needed to receive frame of maximum length. */ +#define MAX_BUFFERS_PER_FRAME \ + ( ( ENET_FRAME_MAX_FRAMELEN / ENET_RXBUFF_SIZE ) + ( ( ENET_FRAME_MAX_FRAMELEN % ENET_RXBUFF_SIZE == 0 ) ? 0 : 1 ) ) + +/* The length or TX buffer. */ +#ifndef ENET_TXBUFF_SIZE + #define ENET_TXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN ) +#endif + +/* The number of buffer descriptors in ENET RX ring. */ +#ifndef ENET_RXBD_NUM + #define ENET_RXBD_NUM ( 5 ) +#endif + +/* Ring should be able to receive at least 1 frame with maximum length. */ +#if ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME + #error "ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME" +#endif + +/* The number of RX buffers. ENET_RXBD_NUM is always held by ENET driver. */ +#ifndef ENET_RXBUFF_NUM + #define ENET_RXBUFF_NUM ( ENET_RXBD_NUM * 2 ) +#endif + +/* At least ENET_RXBD_NUM number of buffers is always held by ENET driver + * for RX. */ +#if ENET_RXBUFF_NUM < ( ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME ) + #error "ENET_RXBUFF_NUM < (ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME)" +#endif + +/* The number of buffer descriptors in ENET TX ring. */ +#ifndef ENET_TXBD_NUM + #define ENET_TXBD_NUM ( 3 ) +#endif + +/* Set the timeout values such that the total timeout adds up to 4000ms. */ +#define MAX_AUTONEG_FAILURE_COUNT ( 40 ) +#define SINGLE_ITERATION_TIMEOUT ( 100 ) + +#if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL + #if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && \ + ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) + #if defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) + #define FSL_CACHE_LINESIZE_MAX MAX( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE, FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) + #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_CACHE_LINESIZE_MAX ) + #else + #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) + #endif + #elif defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) + #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) + #else + #define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT + #endif /* if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) */ +#else /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */ + #define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT +#endif /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */ + +/* A bigger value is chosen so that the previous notification values are + * not interfering with the driver ready notifications. */ +#define DRIVER_READY ( 0x40 ) +#define DRIVER_FATAL ( DRIVER_READY << 1 ) + +#if defined( ENET_ENHANCEDBUFFERDESCRIPTOR_MODE ) + #error "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is not supported by this driver" +#endif + +typedef uint8_t rx_buffer_t[ SDK_SIZEALIGN( ENET_RXBUFF_SIZE, FSL_ENET_BUFF_ALIGNMENT ) ]; +typedef uint8_t tx_buffer_t[ SDK_SIZEALIGN( ENET_TXBUFF_SIZE, FSL_ENET_BUFF_ALIGNMENT ) ]; + +/** + * @brief Used to wrap received data a buffer to be passed into the stack. + */ +typedef struct rx_pbuf_wrapper +{ + void * buffer; /*!< Original buffer wrapped. */ + volatile bool buffer_used; /*!< Wrapped buffer is used by ENET or FreeRTOS+TCP. */ +} rx_pbuf_wrapper_t; + +/** + * Helper structure to hold private data used to operate your Ethernet interface. + */ +struct ethernetif +{ + ENET_Type * base; + enet_handle_t handle; + enet_rx_bd_struct_t * RxBuffDescrip; + enet_tx_bd_struct_t * TxBuffDescrip; + rx_buffer_t * RxDataBuff; + tx_buffer_t * TxDataBuff; + rx_pbuf_wrapper_t RxPbufs[ ENET_RXBUFF_NUM ]; +}; + +typedef enum xEMAC_STATE +{ + xEMAC_SetupPHY, + xEMAC_WaitPHY, + xEMAC_Init, + xEMAC_Ready, +} EMACState_t; + +static EMACState_t eEMACState = xEMAC_SetupPHY; + +static mdio_handle_t mdioHandle = { .ops = &EXAMPLE_MDIO_OPS }; + +static phy_handle_t phyHandle = { .phyAddr = 0x00, .mdioHandle = &mdioHandle, .ops = &EXAMPLE_PHY_OPS }; + +/** + * The task-handle for deferred interrupt handler task that processes + * incoming packets. + */ +static TaskHandle_t receiveTaskHandle = NULL; + +static struct ethernetif EthernetInterface1; +static struct ethernetif * ethernetifLocal = &EthernetInterface1; + +static bool bGlobalLinkStatus = false; + +/*-----------------------------------------------------------*/ + +AT_NONCACHEABLE_SECTION_ALIGN( static enet_rx_bd_struct_t rxBuffDescrip_0[ ENET_RXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); +AT_NONCACHEABLE_SECTION_ALIGN( static enet_tx_bd_struct_t txBuffDescrip_0[ ENET_TXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); +SDK_ALIGN( static rx_buffer_t rxDataBuff_0[ ENET_RXBUFF_NUM ], FSL_ENET_BUFF_ALIGNMENT ); +SDK_ALIGN( static tx_buffer_t txDataBuff_0[ ENET_TXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); + +/*-----------------------------------------------------------*/ +/*-----------------------------------------------------------*/ +/*------------ PHY configuration parameters. ----------------*/ +static phy_config_t xConfig = +{ + .autoNeg = pdTRUE, /* Allow auto-negotiation. */ + .duplex = kPHY_FullDuplex, /* Use full duplex mode. In case + * auto-negotiation is turned on, + * this is not used. */ + .phyAddr = BOARD_ENET0_PHY_ADDRESS, /* The PHY address. */ + .speed = kPHY_Speed100M, /* Use 100 Mbps configuration (maximum possible + * for this PHY). In case auto-negotiation is + * turned on, this is not used. */ + .enableEEE = pdFALSE +}; /* Disable the energy efficient PHY. */ +/*-----------------------------------------------------------*/ +/*-----------------------------------------------------------*/ + +static void prvEMACHandlerTask( void * pvParameters ); + +static void ethernet_callback( ENET_Type * base, + enet_handle_t * handle, + enet_event_t event, + enet_frame_info_t * frameInfo, + void * userData ); + +static void prvProcessFrame( int length ); + +static status_t xSetupPHY( phy_config_t * pxConfig ); + +static status_t xWaitPHY( phy_config_t xConfig ); + +static status_t xEMACInit( phy_speed_t speed, + phy_duplex_t duplex ); + +BaseType_t xNetworkInterfaceInitialise( void ) +{ + status_t xStatus; + BaseType_t xResult = pdFAIL; + phy_speed_t speed; + phy_duplex_t duplex; + BaseType_t xTaskCreated; + static BaseType_t xFirstCall = pdTRUE; + + configASSERT( FSL_FEATURE_ENET_QUEUE == 1 ); + + switch( eEMACState ) + { + case xEMAC_SetupPHY: + xStatus = xSetupPHY( &xConfig ); + + if( xStatus != kStatus_Success ) + { + break; + } + else + { + eEMACState = xEMAC_WaitPHY; + } + + /* Fall through. */ + case xEMAC_WaitPHY: + FreeRTOS_printf( ( "Configuration successful. Waiting for link to go up" + " and auto-negotiation to complete." ) ); + + xStatus = xWaitPHY( xConfig ); + + if( xStatus == kStatus_Success ) + { + xStatus = PHY_GetLinkSpeedDuplex( &phyHandle, &speed, &duplex ); + } + + if( xStatus != kStatus_Success ) + { + break; + } + else + { + eEMACState = xEMAC_Init; + } + + /* Fall through. */ + case xEMAC_Init: + xStatus = xEMACInit( speed, duplex ); + + if( ( xFirstCall == pdTRUE ) || ( receiveTaskHandle == NULL ) ) + { + if( xStatus == kStatus_Success ) + { + /* The link is now up. */ + bGlobalLinkStatus = true; + + /* The handler task is created at the highest possible priority to + * ensure the interrupt handler can return directly to it. */ + xTaskCreated = xTaskCreate( prvEMACHandlerTask, + "EMAC-Handler", + configMINIMAL_STACK_SIZE * 3, + NULL, + configMAX_PRIORITIES - 1, + &receiveTaskHandle ); + + if( ( receiveTaskHandle == NULL ) || ( xTaskCreated != pdPASS ) ) + { + FreeRTOS_printf( ( "Failed to create the handler task." ) ); + break; + } + + /* Enable the interrupt and set its priority to the minimum + * interrupt priority. */ + NVIC_SetPriority( ENET_IRQn, ENET_PRIORITY ); + NVIC_EnableIRQ( ENET_IRQn ); + + eEMACState = xEMAC_Ready; + + /* After this, the task should not be created. */ + xFirstCall = pdFALSE; + } + else + { + break; + } + } + else + { + eEMACState = xEMAC_Ready; + } + + /* Fall through. */ + case xEMAC_Ready: + FreeRTOS_printf( ( "Driver ready for use." ) ); + + /* Kick the task once the driver is ready. */ + if( receiveTaskHandle != NULL ) + { + xTaskNotify( receiveTaskHandle, DRIVER_READY, eSetValueWithOverwrite ); + } + + xResult = pdPASS; + + break; + } + + return xResult; +} + +BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, + BaseType_t xReleaseAfterSend ) +{ + status_t result; + BaseType_t xReturn = pdFAIL; + + if( bGlobalLinkStatus == true ) + { + /* ENET_SendFrame copies the data before sending it. Therefore, the network buffer can + * be released without worrying about the buffer memory being used by the ENET_SendFrame + * function. */ + result = ENET_SendFrame( ethernetifLocal->base, + ðernetifLocal->handle, + pxNetworkBuffer->pucEthernetBuffer, + pxNetworkBuffer->xDataLength, + 0, + false, + NULL ); + + switch( result ) + { + case kStatus_ENET_TxFrameBusy: + FreeRTOS_printf( ( "Failed to send the frame - driver busy!" ) ); + break; + + case kStatus_Success: + iptraceNETWORK_INTERFACE_TRANSMIT(); + xReturn = pdPASS; + break; + } + } + + if( xReleaseAfterSend == pdTRUE ) + { + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + } + + return xReturn; +} + +static void prvEMACHandlerTask( void * parameter ) +{ + bool LinkUp = false; + status_t readStatus; + + /* Wait for the driver to finish starting. */ + ( void ) ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); + + while( pdTRUE ) + { + if( ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( 500 ) ) == pdFALSE ) + { + /* No RX packets for a bit so check for a link. */ + const IPStackEvent_t xNetworkEventDown = { .eEventType = eNetworkDownEvent, .pvData = NULL }; + + do + { + readStatus = PHY_GetLinkStatus( &phyHandle, &LinkUp ); + + if( readStatus == kStatus_Success ) + { + if( LinkUp == pdFALSE ) + { + /* The link is down. */ + bGlobalLinkStatus = false; + /* We need to setup the PHY again. */ + eEMACState = xEMAC_WaitPHY; + + FreeRTOS_printf( ( "Link down!" ) ); + + xSendEventStructToIPTask( &xNetworkEventDown, 0U ); + + /* Wait for the driver to finish initialization. */ + uint32_t ulNotificationValue; + + do + { + ulNotificationValue = ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); + } while( !( ulNotificationValue & DRIVER_READY ) ); + } + else + { + /* The link is still up. */ + bGlobalLinkStatus = true; + } + } + } while( bGlobalLinkStatus == false ); + } + else + { + BaseType_t receiving = pdTRUE; + + /* A packet was received, the link must be up. */ + bGlobalLinkStatus = true; + + while( receiving == pdTRUE ) + { + uint32_t length; + const status_t status = ENET_GetRxFrameSize( &( ethernetifLocal->handle ), &length, 0 ); + + switch( status ) + { + case kStatus_Success: /* there is a frame. process it */ + + if( length ) + { + prvProcessFrame( length ); + } + + break; + + case kStatus_ENET_RxFrameEmpty: /* Received an empty frame. Ignore it */ + receiving = pdFALSE; + break; + + case kStatus_ENET_RxFrameError: /* Received an error frame. Read & drop it */ + PRINTF( "RX Receive Error\n" ); + ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), NULL, 0, 0, NULL ); + /* Not sure if a trace is required. The MAC had an error and needed to dump bytes */ + break; + + default: + PRINTF( "RX Receive default" ); + break; + } + } + } + } +} + +/** + * @brief Callback for ENET interrupts. We have only enabled the Ethernet receive interrupts + * in the case of this driver. + */ +static void ethernet_callback( ENET_Type * base, + enet_handle_t * handle, + enet_event_t event, + enet_frame_info_t * frameInfo, + void * userData ) +{ + BaseType_t needsToYield = pdFALSE; + + ( void ) base; + ( void ) handle; + ( void ) frameInfo; + ( void ) userData; + + switch( event ) + { + case kENET_RxEvent: + vTaskNotifyGiveFromISR( receiveTaskHandle, &needsToYield ); + portEND_SWITCHING_ISR( needsToYield ); + break; + + default: + FreeRTOS_printf( ( "Unknown interrupt callback %u!", event ) ); + break; + } +} + +/** + * @brief This function verifies that the incoming frame needs processing. + * If the frame is deemed to be appropriate, then the frame is sent to the + * TCP stack for further processing. + * @param[in] length: The length of the incoming frame. This length should be read + * using a call to ENET_GetRxFrameSize. + */ +static void prvProcessFrame( int length ) +{ + NetworkBufferDescriptor_t * pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( length, 0 ); + + if( pxBufferDescriptor != NULL ) + { + ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), pxBufferDescriptor->pucEthernetBuffer, length, 0, NULL ); + pxBufferDescriptor->xDataLength = length; + + if( ipCONSIDER_FRAME_FOR_PROCESSING( pxBufferDescriptor->pucEthernetBuffer ) == eProcessBuffer ) + { + IPStackEvent_t xRxEvent; + xRxEvent.eEventType = eNetworkRxEvent; + xRxEvent.pvData = ( void * ) pxBufferDescriptor; + + if( xSendEventStructToIPTask( &xRxEvent, 0 ) == pdFALSE ) + { + vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor ); + iptraceETHERNET_RX_EVENT_LOST(); + FreeRTOS_printf( ( "RX Event Lost\n" ) ); + } + } + else + { + #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) + const EthernetHeader_t * pxEthernetHeader; + char ucSource[ 18 ]; + char ucDestination[ 18 ]; + + pxEthernetHeader = ( ( const EthernetHeader_t * ) pxBufferDescriptor->pucEthernetBuffer ); + + + FreeRTOS_EUI48_ntop( pxEthernetHeader->xSourceAddress.ucBytes, ucSource, 'A', ':' ); + FreeRTOS_EUI48_ntop( pxEthernetHeader->xDestinationAddress.ucBytes, ucDestination, 'A', ':' ); + + FreeRTOS_debug_printf( ( "Invalid target MAC: dropping frame from: %s to: %s", ucSource, ucDestination ) ); + #endif /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) */ + vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor ); + /* Not sure if a trace is required. The stack did not want this message */ + } + } + else + { + #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) + FreeRTOS_debug_printf( ( "No Buffer Available: dropping incoming frame!!" ) ); + #endif + ENET_ReadFrame( ENET, &( ethernetifLocal->handle ), NULL, length, 0, NULL ); + + /* No buffer available to receive this message */ + iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER(); + } +} + + +/** + * @brief This function is used to setup the PHY in auto-negotiation mode. + * + * @param[out] pxConfig: the configuration parameters. + * + * @return kStatus_Success if the PHY was initialized; error code otherwise. + */ +static status_t xSetupPHY( phy_config_t * pxConfig ) +{ + status_t xStatus; + + /* Set the clock frequency. MDIO handle is pointed to by the PHY handle. */ + mdioHandle.resource.csrClock_Hz = EXAMPLE_CLOCK_FREQ; + mdioHandle.resource.base = ( void * ) ENET_BASE; + + FreeRTOS_printf( ( "Starting PHY initialization." ) ); + + xStatus = PHY_Init( &phyHandle, pxConfig ); + + if( xStatus != kStatus_Success ) + { + FreeRTOS_printf( ( "Failed to initialize the PHY." ) ); + } + + return xStatus; +} + +/** + * @brief This function is used wait on the auto-negotiation completion. + * + * @param[in] xConfig: the configuration parameters. + * + * @return kStatus_Success if the PHY was initialized; error code otherwise. + */ +static status_t xWaitPHY( phy_config_t xConfig ) +{ + status_t xStatus; + bool LinkUp; + bool autoNegotiationComplete; + uint8_t ucCounter = 0; + + do + { + xStatus = PHY_GetLinkStatus( &phyHandle, &LinkUp ); + + if( LinkUp == true ) + { + break; + } + + /* Try for only a limited number of times. */ + if( ucCounter++ > MAX_AUTONEG_FAILURE_COUNT ) + { + break; + } + + vTaskDelay( pdMS_TO_TICKS( SINGLE_ITERATION_TIMEOUT ) ); + } + while( xStatus == kStatus_Success ); + + if( LinkUp == false ) + { + FreeRTOS_printf( ( "Failed to get the link up." ) ); + xStatus = kStatus_Fail; + } + else + { + FreeRTOS_printf( ( "Link up." ) ); + } + + if( ( xStatus == kStatus_Success ) && + ( LinkUp == true ) && + ( xConfig.autoNeg == true ) ) + { + /* Reset the counter for next use. */ + ucCounter = 0; + + FreeRTOS_printf( ( "Waiting for auto-negotiation to complete." ) ); + + do + { + xStatus = PHY_GetAutoNegotiationStatus( &phyHandle, &autoNegotiationComplete ); + + if( autoNegotiationComplete == true ) + { + break; + } + + /* Try for only a limited number of times. */ + if( ucCounter++ > MAX_AUTONEG_FAILURE_COUNT ) + { + break; + } + + vTaskDelay( pdMS_TO_TICKS( SINGLE_ITERATION_TIMEOUT ) ); + } + while( xStatus == kStatus_Success ); + + if( autoNegotiationComplete == false ) + { + FreeRTOS_printf( ( "Failed to complete auto-negotiation." ) ); + xStatus = kStatus_Fail; + } + else + { + /* Success in auto-negotiation and the link is up. */ + FreeRTOS_printf( ( "Auto-negotiation complete." ) ); + } + } + + return xStatus; +} + +/** + * @brief This function is used to initialize the ENET module. It initializes the network buffers + * and buffer descriptors. + * + * @param[in] speed: The speed of communication (either set by auto-negotiation or the default + * value). + * @param[in] duplex: The nature of the channel. This must be set to kPHY_FullDuplex by + * auto-negotiation. + * + * @return kStatus_Success if the ENET module was initialized; error code otherwise. + */ +static status_t xEMACInit( phy_speed_t speed, + phy_duplex_t duplex ) +{ + enet_config_t config; + uint32_t sysClock; + enet_buffer_config_t buffCfg[ ENET_RING_NUM ]; + status_t xStatus; + uint32_t instance; + static ENET_Type * const enetBases[] = ENET_BASE_PTRS; + static const IRQn_Type enetTxIrqId[] = ENET_Transmit_IRQS; + /*! @brief Pointers to enet receive IRQ number for each instance. */ + static const IRQn_Type enetRxIrqId[] = ENET_Receive_IRQS; + int i; + + ethernetifLocal->RxBuffDescrip = &( rxBuffDescrip_0[ 0 ] ); + ethernetifLocal->TxBuffDescrip = &( txBuffDescrip_0[ 0 ] ); + ethernetifLocal->RxDataBuff = &( rxDataBuff_0[ 0 ] ); + ethernetifLocal->TxDataBuff = &( txDataBuff_0[ 0 ] ); + ethernetifLocal->base = ( void * ) ENET_BASE; + + /* prepare the buffer configuration. */ + buffCfg[ 0 ].rxBdNumber = ENET_RXBD_NUM; /* Number of RX buffer descriptors. */ + buffCfg[ 0 ].txBdNumber = ENET_TXBD_NUM; /* Transmit buffer descriptor number. */ + buffCfg[ 0 ].rxBuffSizeAlign = sizeof( rx_buffer_t ); /* Aligned receive data buffer size. */ + buffCfg[ 0 ].txBuffSizeAlign = sizeof( tx_buffer_t ); /* Aligned transmit data buffer size. */ + buffCfg[ 0 ].rxBdStartAddrAlign = + &( rxBuffDescrip_0[ 0 ] ); /* Aligned receive buffer descriptor start address. */ + buffCfg[ 0 ].txBdStartAddrAlign = + &( txBuffDescrip_0[ 0 ] ); /* Aligned transmit buffer descriptor start address. */ + buffCfg[ 0 ].rxBufferAlign = + &( rxDataBuff_0[ 0 ][ 0 ] ); /* Receive data buffer start address. */ + buffCfg[ 0 ].txBufferAlign = &( txDataBuff_0[ 0 ][ 0 ] ); /* Transmit data buffer start address. */ + buffCfg[ 0 ].txFrameInfo = NULL; /* Transmit frame information start address. Set only if using zero-copy transmit. */ + buffCfg[ 0 ].rxMaintainEnable = true; /* Receive buffer cache maintain. */ + buffCfg[ 0 ].txMaintainEnable = true; /* Transmit buffer cache maintain. */ + + sysClock = phyHandle.mdioHandle->resource.csrClock_Hz; + + ENET_GetDefaultConfig( &config ); + + config.ringNum = ENET_RING_NUM; + config.rxBuffAlloc = NULL; + config.rxBuffFree = NULL; + config.userData = ethernetifLocal; + config.miiSpeed = ( enet_mii_speed_t ) speed; + config.miiDuplex = ( enet_mii_duplex_t ) duplex; + + /* Only get interrupt for incoming messages. */ + config.interrupt = kENET_RxFrameInterrupt; + config.callback = ethernet_callback; + + for( instance = 0; instance < ARRAY_SIZE( enetBases ); instance++ ) + { + if( enetBases[ instance ] == ethernetifLocal->base ) + { + NVIC_SetPriority( enetRxIrqId[ instance ], ENET_PRIORITY ); + NVIC_SetPriority( enetTxIrqId[ instance ], ENET_PRIORITY ); + break; + } + } + + configASSERT( instance != ARRAY_SIZE( enetBases ) ); + + if( instance == ARRAY_SIZE( enetBases ) ) + { + xStatus = kStatus_Fail; + } + else + { + for( i = 0; i < ENET_RXBUFF_NUM; i++ ) + { + ethernetifLocal->RxPbufs[ i ].buffer = &( ethernetifLocal->RxDataBuff[ i ][ 0 ] ); + ethernetifLocal->RxPbufs[ i ].buffer_used = false; + } + + /* Initialize the ENET module. */ + xStatus = ENET_Init( ethernetifLocal->base, + ðernetifLocal->handle, + &config, + &buffCfg[ 0 ], + ipLOCAL_MAC_ADDRESS, + sysClock ); + + if( xStatus == kStatus_Success ) + { + FreeRTOS_printf( ( "ENET initialized." ) ); + ENET_ActiveRead( ethernetifLocal->base ); + } + else + { + FreeRTOS_printf( ( "Failed to initialize ENET." ) ); + } + } + + return xStatus; +} From e5e84ef23bf410084facdda1f0ef7756b98440b2 Mon Sep 17 00:00:00 2001 From: Kody Stribrny <89810515+kstribrnAmzn@users.noreply.github.com> Date: Tue, 21 Mar 2023 09:32:59 -0700 Subject: [PATCH 30/44] Correct GCC warnings (#798) * Correct GCC warnings Corrects warnings with current GCC flags for GCC 7.5.0. The only suppressed warning pertains to function to object pointer conversion which is required and common for socket callbacks. * PR feedback --------- Co-authored-by: Ubuntu Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> --- CMakeLists.txt | 7 +--- source/CMakeLists.txt | 7 ++-- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_TCP_IP.c | 34 ++++++++++++------- source/FreeRTOS_UDP_IP.c | 3 +- .../BufferManagement/BufferAllocation_2.c | 3 +- .../build-combination/Common/FreeRTOSConfig.h | 11 ++++-- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e4ee7e8d5..ec0a264f01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,11 +161,6 @@ else() endif() endif() -######################################################################## -# Requirements -set(CMAKE_C_STANDARD 90) # Note FreeRTOS-Kernel uses C99 constructs. -set(CMAKE_C_STANDARD_REQUIRED ON) - ######################################################################## # Overall Compile Options # Note the compile option strategy is to error on everything and then @@ -195,9 +190,9 @@ add_compile_options( $<$:-Wall> $<$:-Wextra> - $<$:-Wpedantic> $<$:-Werror> $<$:-Weverything> + $<$:-Wpedantic> # TODO: Add in other Compilers here. ) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a990fe9478..bff59a3f4f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,7 @@ add_library( freertos_plus_tcp STATIC ) +set_property(TARGET freertos_plus_tcp PROPERTY C_STANDARD 90) + target_sources( freertos_plus_tcp PRIVATE include/FreeRTOS_ARP.h @@ -74,10 +76,7 @@ target_compile_options( freertos_plus_tcp $<$:-Wno-shorten-64-to-32> $<$:-Wno-sign-conversion> $<$:-Wno-unused-macros> - $<$:-Wno-unused-but-set-variable> - $<$:-Wno-unused-parameter> - $<$:-Wno-unused-variable> - $<$:-Wno-pedantic> + $<$:-Wno-unused-parameter> ) target_link_libraries( freertos_plus_tcp diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index df777be9ab..a77e7f4fbe 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1002,10 +1002,10 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) static uint16_t usSequenceNumber = 0; uint8_t * pucChar; size_t uxTotalLength; + BaseType_t xEnoughSpace; IPStackEvent_t xStackTxEvent = { eStackTxEvent, NULL }; uxTotalLength = uxNumberOfBytesToSend + sizeof( ICMPPacket_t ); - BaseType_t xEnoughSpace; if( uxNumberOfBytesToSend < ( ipconfigNETWORK_MTU - ( sizeof( IPHeader_t ) + sizeof( ICMPHeader_t ) ) ) ) { diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 995173573d..f586a15b65 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -634,28 +634,36 @@ /* Function might modify the parameter. */ NetworkBufferDescriptor_t * pxNetworkBuffer = pxDescriptor; - configASSERT( pxNetworkBuffer != NULL ); - configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); - /* Map the buffer onto a ProtocolHeaders_t struct for easy access to the fields. */ - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * ) - &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) ); + ProtocolHeaders_t * pxProtocolHeaders; FreeRTOS_Socket_t * pxSocket; - uint16_t ucTCPFlags = pxProtocolHeaders->xTCPHeader.ucTCPFlags; + uint16_t ucTCPFlags; uint32_t ulLocalIP; - uint16_t usLocalPort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usDestinationPort ); - uint16_t usRemotePort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usSourcePort ); + uint16_t usLocalPort; + uint16_t usRemotePort; uint32_t ulRemoteIP; - uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulSequenceNumber ); - uint32_t ulAckNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulAckNr ); + uint32_t ulSequenceNumber; + uint32_t ulAckNumber; BaseType_t xResult = pdPASS; const IPHeader_t * pxIPHeader; + configASSERT( pxNetworkBuffer != NULL ); + configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); + + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + pxProtocolHeaders = ( ( ProtocolHeaders_t * ) + &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) ); + + ucTCPFlags = pxProtocolHeaders->xTCPHeader.ucTCPFlags; + usLocalPort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usDestinationPort ); + usRemotePort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usSourcePort ); + ulSequenceNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulSequenceNumber ); + ulAckNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulAckNr ); + /* Check for a minimum packet size. */ if( pxNetworkBuffer->xDataLength < ( ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) + ipSIZE_OF_TCP_HEADER ) ) { diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index b5249e4302..43865d9e67 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -310,6 +310,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe { BaseType_t xReturn = pdPASS; FreeRTOS_Socket_t * pxSocket; + const UDPPacket_t * pxUDPPacket; configASSERT( pxNetworkBuffer != NULL ); configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); @@ -319,7 +320,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ - const UDPPacket_t * pxUDPPacket = ( ( const UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + pxUDPPacket = ( ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); /* Caller must check for minimum packet size. */ pxSocket = pxUDPSocketLookup( usPort ); diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index c3baacc3d3..e82fffaf8d 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -73,11 +73,10 @@ #define ASSERT_CONCAT_( a, b ) a ## b #define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b ) #define STATIC_ASSERT( e ) \ - ; enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) } + enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) } STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE ); #endif - /* A list of free (available) NetworkBufferDescriptor_t structures. */ static List_t xFreeBuffersList; diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index a7f7d86bad..30fea81c63 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -116,13 +116,18 @@ /* The function that implements FreeRTOS printf style output, and the macro * that maps the configPRINTF() macros to that function. */ -#define configPRINTF( X ) +void vLoggingPrintf( char const * pcFormat, + ... ); + +/* The function that implements FreeRTOS printf style output, and the macro + * that maps the configPRINTF() macros to that function. */ +#define configPRINTF( X ) vLoggingPrintf X /* Non-format version thread-safe print. */ -#define configPRINT( X ) +#define configPRINT( X ) vLoggingPrintf X /* Non-format version thread-safe print. */ -#define configPRINT_STRING( X ) +#define configPRINT_STRING( X ) vLoggingPrintf X /* Application specific definitions follow. **********************************/ From 69819556ee29331d01caf0f39ed22826c4033c44 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:22:02 -0700 Subject: [PATCH 31/44] Cleanup of NXP1060 network driver (#801) * Update PR template to include checkbox for ut change * Empty-Commit to trigger workflow * Fix issues pointed out in PR comments * Uncrustify: triggered by comment. * Empty-Commit to trigger workflow --------- Co-authored-by: GitHub Action --- .../NXP1060/NetworkInterface.c | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c index 0c0d20bd97..d1739d97cd 100644 --- a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c +++ b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c @@ -62,13 +62,6 @@ /* ENET clock frequency. */ #define EXAMPLE_CLOCK_FREQ CLOCK_GetFreq( kCLOCK_IpgClk ) -/* - * Padding of ethernet frames has to be disabled for zero-copy functionality - * since ENET driver requires the starting buffer addresses to be aligned. - */ -#if ETH_PAD_SIZE != 0 - #error "ETH_PAD_SIZE != 0" -#endif /* ETH_PAD_SIZE != 0 */ /******************************************************************************* * Definitions @@ -235,8 +228,9 @@ static phy_config_t xConfig = .speed = kPHY_Speed100M, /* Use 100 Mbps configuration (maximum possible * for this PHY). In case auto-negotiation is * turned on, this is not used. */ - .enableEEE = pdFALSE -}; /* Disable the energy efficient PHY. */ + .enableEEE = pdFALSE /* Disable the energy efficient PHY. */ +}; + /*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/ @@ -409,7 +403,7 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkB static void prvEMACHandlerTask( void * parameter ) { - bool LinkUp = false; + bool bLinkUp = false; status_t readStatus; /* Wait for the driver to finish starting. */ @@ -424,11 +418,11 @@ static void prvEMACHandlerTask( void * parameter ) do { - readStatus = PHY_GetLinkStatus( &phyHandle, &LinkUp ); + readStatus = PHY_GetLinkStatus( &phyHandle, &bLinkUp ); if( readStatus == kStatus_Success ) { - if( LinkUp == pdFALSE ) + if( bLinkUp == pdFALSE ) { /* The link is down. */ bGlobalLinkStatus = false; @@ -625,15 +619,15 @@ static status_t xSetupPHY( phy_config_t * pxConfig ) static status_t xWaitPHY( phy_config_t xConfig ) { status_t xStatus; - bool LinkUp; - bool autoNegotiationComplete; + bool bLinkUp; + bool bAutoNegotiationComplete; uint8_t ucCounter = 0; do { - xStatus = PHY_GetLinkStatus( &phyHandle, &LinkUp ); + xStatus = PHY_GetLinkStatus( &phyHandle, &bLinkUp ); - if( LinkUp == true ) + if( bLinkUp == true ) { break; } @@ -648,7 +642,7 @@ static status_t xWaitPHY( phy_config_t xConfig ) } while( xStatus == kStatus_Success ); - if( LinkUp == false ) + if( bLinkUp == false ) { FreeRTOS_printf( ( "Failed to get the link up." ) ); xStatus = kStatus_Fail; @@ -659,7 +653,7 @@ static status_t xWaitPHY( phy_config_t xConfig ) } if( ( xStatus == kStatus_Success ) && - ( LinkUp == true ) && + ( bLinkUp == true ) && ( xConfig.autoNeg == true ) ) { /* Reset the counter for next use. */ @@ -669,9 +663,9 @@ static status_t xWaitPHY( phy_config_t xConfig ) do { - xStatus = PHY_GetAutoNegotiationStatus( &phyHandle, &autoNegotiationComplete ); + xStatus = PHY_GetAutoNegotiationStatus( &phyHandle, &bAutoNegotiationComplete ); - if( autoNegotiationComplete == true ) + if( bAutoNegotiationComplete == true ) { break; } @@ -686,7 +680,7 @@ static status_t xWaitPHY( phy_config_t xConfig ) } while( xStatus == kStatus_Success ); - if( autoNegotiationComplete == false ) + if( bAutoNegotiationComplete == false ) { FreeRTOS_printf( ( "Failed to complete auto-negotiation." ) ); xStatus = kStatus_Fail; From a280275c32f36bb1a07609c82348d733e28979f1 Mon Sep 17 00:00:00 2001 From: Kody Stribrny <89810515+kstribrnAmzn@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:19:54 -0700 Subject: [PATCH 32/44] Fix Clang warnings (#809) Corrects several warnings from Clang flags for Clang 13. Inspired by @phelter's bug report https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/issues/558 --- .github/lexicon.txt | 3 + CMakeLists.txt | 1 - source/CMakeLists.txt | 18 -- source/FreeRTOS_ARP.c | 38 +-- source/FreeRTOS_DHCP.c | 20 +- source/FreeRTOS_DNS.c | 28 +- source/FreeRTOS_DNS_Cache.c | 16 +- source/FreeRTOS_DNS_Networking.c | 2 +- source/FreeRTOS_DNS_Parser.c | 28 +- source/FreeRTOS_ICMP.c | 6 +- source/FreeRTOS_IP.c | 88 +++--- source/FreeRTOS_IP_Timers.c | 24 +- source/FreeRTOS_IP_Utils.c | 88 +++--- source/FreeRTOS_Sockets.c | 278 +++++++++--------- source/FreeRTOS_Stream_Buffer.c | 54 ++-- source/FreeRTOS_TCP_IP.c | 21 +- source/FreeRTOS_TCP_Reception.c | 32 +- source/FreeRTOS_TCP_State_Handling.c | 36 +-- source/FreeRTOS_TCP_Transmission.c | 62 ++-- source/FreeRTOS_TCP_Utils.c | 8 +- source/FreeRTOS_TCP_WIN.c | 168 +++++------ source/FreeRTOS_Tiny_TCP.c | 50 ++-- source/FreeRTOS_UDP_IP.c | 8 +- source/include/FreeRTOS_IP_Private.h | 4 +- .../build-combination/Common/FreeRTOSConfig.h | 2 - 25 files changed, 532 insertions(+), 551 deletions(-) diff --git a/.github/lexicon.txt b/.github/lexicon.txt index 3e6d4d913d..13e137c8a9 100644 --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -275,6 +275,7 @@ esocketsetdeleteevent esocketsignalevent espressif estacktxevent +estatus esuccess etcpacceptevent etcpnetstat @@ -1339,6 +1340,7 @@ uxremainingtime uxremaningtime uxremoteport uxrequestedsizebytes +uxresult uxright uxrxstreamsize uxrxwinsize @@ -1520,6 +1522,7 @@ xlastalivetime xlastgratuitousarptime xlastround xlastsource +xleasetime xlength xlinkstatustimer xlistend diff --git a/CMakeLists.txt b/CMakeLists.txt index ec0a264f01..77ce61f834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,7 +192,6 @@ add_compile_options( $<$:-Wextra> $<$:-Werror> $<$:-Weverything> - $<$:-Wpedantic> # TODO: Add in other Compilers here. ) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index bff59a3f4f..4534583428 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -61,24 +61,6 @@ target_include_directories( freertos_plus_tcp SYSTEM include ) -#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. -target_compile_options( freertos_plus_tcp - PRIVATE - $<$:-Wno-bad-function-cast> - $<$:-Wno-cast-qual> - $<$:-Wno-conditional-uninitialized> - $<$:-Wno-covered-switch-default> - $<$:-Wno-documentation> - $<$:-Wno-extra-semi-stmt> - $<$:-Wno-implicit-int-conversion> - $<$:-Wno-missing-noreturn> - $<$:-Wno-reserved-identifier> - $<$:-Wno-shorten-64-to-32> - $<$:-Wno-sign-conversion> - $<$:-Wno-unused-macros> - $<$:-Wno-unused-parameter> -) - target_link_libraries( freertos_plus_tcp PUBLIC freertos_config diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 03156c97a7..974d42f26b 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -116,7 +116,7 @@ static TickType_t xLastGratuitousARPTime = 0U; /** * @brief Process the ARP packets. * - * @param[in] pxARPFrame: The ARP Frame (the ARP packet). + * @param[in] pxARPFrame The ARP Frame (the ARP packet). * * @return An enum which says whether to return the frame or to release it. */ @@ -311,8 +311,8 @@ eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame ) /** * @brief A device has sent an ARP reply, process it. - * @param[in] pxARPFrame: The ARP packet received. - * @param[in] ulSenderProtocolAddress: The IPv4 address involved. + * @param[in] pxARPFrame The ARP packet received. + * @param[in] ulSenderProtocolAddress The IPv4 address involved. */ static void vProcessARPPacketReply( const ARPPacket_t * pxARPFrame, uint32_t ulSenderProtocolAddress ) @@ -364,7 +364,7 @@ static void vProcessARPPacketReply( const ARPPacket_t * pxARPFrame, /** * @brief Check whether an IP address is in the ARP cache. * - * @param[in] ulAddressToLookup: The 32-bit representation of an IP address to + * @param[in] ulAddressToLookup The 32-bit representation of an IP address to * check for. * * @return When the IP-address is found: pdTRUE, else pdFALSE. @@ -399,7 +399,7 @@ BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup ) /** * @brief Check whether a packet needs ARP resolution if it is on local subnet. If required send an ARP request. * - * @param[in] pxNetworkBuffer: The network buffer with the packet to be checked. + * @param[in] pxNetworkBuffer The network buffer with the packet to be checked. * * @return pdTRUE if the packet needs ARP resolution, pdFALSE otherwise. */ @@ -467,9 +467,9 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw /** * @brief Add/update the ARP cache entry MAC-address to IP-address mapping. * - * @param[in] pxMACAddress: Pointer to the MAC address whose mapping is being + * @param[in] pxMACAddress Pointer to the MAC address whose mapping is being * updated. - * @param[in] ulIPAddress: 32-bit representation of the IP-address whose mapping + * @param[in] ulIPAddress 32-bit representation of the IP-address whose mapping * is being updated. */ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, @@ -649,8 +649,8 @@ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, /** * @brief Retrieve an entry from the cache table * - * @param[in] pxMACAddress: The MAC-address of the entry of interest. - * @param[out] pulIPAddress: set to the IP-address found, or unchanged when not found. + * @param[in] pxMACAddress The MAC-address of the entry of interest. + * @param[out] pulIPAddress set to the IP-address found, or unchanged when not found. * * @return Either eARPCacheMiss or eARPCacheHit. */ @@ -685,8 +685,8 @@ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, /** * @brief Look for ulIPAddress in the ARP cache. * - * @param[in,out] pulIPAddress: Pointer to the IP-address to be queried to the ARP cache. - * @param[in,out] pxMACAddress: Pointer to a MACAddress_t variable where the MAC address + * @param[in,out] pulIPAddress Pointer to the IP-address to be queried to the ARP cache. + * @param[in,out] pxMACAddress Pointer to a MACAddress_t variable where the MAC address * will be stored, if found. * * @return If the IP address exists, copy the associated MAC address into pxMACAddress, @@ -805,9 +805,9 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, /** * @brief Lookup an IP address in the ARP cache. * - * @param[in] ulAddressToLookup: The 32-bit representation of an IP address to + * @param[in] ulAddressToLookup The 32-bit representation of an IP address to * lookup. - * @param[out] pxMACAddress: A pointer to MACAddress_t variable where, if there + * @param[out] pxMACAddress A pointer to MACAddress_t variable where, if there * is an ARP cache hit, the MAC address corresponding to * the IP address will be stored. * @@ -927,7 +927,7 @@ void vARPSendGratuitous( void ) /** * @brief Create and send an ARP request packet. * - * @param[in] ulIPAddress: A 32-bit representation of the IP-address whose + * @param[in] ulIPAddress A 32-bit representation of the IP-address whose * physical (MAC) address is required. */ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) @@ -988,8 +988,8 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) * needed send an ARP request, and wait for a reply. This function is useful when * called before FreeRTOS_sendto(). * - * @param[in] ulIPAddress: The IP-address to look-up. - * @param[in] uxTicksToWait: The maximum number of clock ticks to wait for a reply. + * @param[in] ulIPAddress The IP-address to look-up. + * @param[in] uxTicksToWait The maximum number of clock ticks to wait for a reply. * * @return Zero when successful. */ @@ -1047,7 +1047,7 @@ BaseType_t xARPWaitResolution( uint32_t ulIPAddress, * @brief Generate an ARP request packet by copying various constant details to * the buffer. * - * @param[in,out] pxNetworkBuffer: Pointer to the buffer which has to be filled with + * @param[in,out] pxNetworkBuffer Pointer to the buffer which has to be filled with * the ARP request packet details. */ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) @@ -1143,8 +1143,8 @@ void FreeRTOS_ClearARP( void ) * If so, the packet will be passed to the IP-stack, who will answer it. * The function is to be called within the function xNetworkInterfaceOutput(). * - * @param[in] pxDescriptor: The network buffer which is to be checked for loop-back. - * @param[in] bReleaseAfterSend: pdTRUE: Driver is allowed to transfer ownership of descriptor. + * @param[in] pxDescriptor The network buffer which is to be checked for loop-back. + * @param[in] bReleaseAfterSend pdTRUE: Driver is allowed to transfer ownership of descriptor. * pdFALSE: Driver is not allowed to take ownership of descriptor, * make a copy of it. * diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index 90d14968ec..a45ba62f78 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -129,7 +129,7 @@ /** * @brief Check whether a given socket is the DHCP socket or not. * - * @param[in] xSocket: The socket to be checked. + * @param[in] xSocket The socket to be checked. * * @return If the socket given as parameter is the DHCP socket - return * pdTRUE, else pdFALSE. @@ -155,7 +155,7 @@ * @brief The application can indicate a preferred IP address by calling this function. * before starting up the IP-task by calling FreeRTOS_IPInit(). * - * @param[in] ulIPAddress: The preferred IP-address. + * @param[in] ulIPAddress The preferred IP-address. * * @return The previous value of ulPreferredIPAddress. */ @@ -181,8 +181,8 @@ /** * @brief Process the DHCP state machine based on current state. * - * @param[in] xReset: Is the DHCP state machine starting over? pdTRUE/pdFALSE. - * @param[in] eExpectedState: The function will only run if the state is expected. + * @param[in] xReset Is the DHCP state machine starting over? pdTRUE/pdFALSE. + * @param[in] eExpectedState The function will only run if the state is expected. */ void vDHCPProcess( BaseType_t xReset, eDHCPState_t eExpectedState ) @@ -680,7 +680,7 @@ * invariant parameters and valid (non broadcast and non localhost) * IP address being assigned to the device. * - * @param[in] pxDHCPMessage: The DHCP message. + * @param[in] pxDHCPMessage The DHCP message. * * @return pdPASS if the DHCP response has correct parameters; pdFAIL otherwise. */ @@ -710,7 +710,7 @@ /** * @brief Process the DHCP replies. * - * @param[in] xExpectedMessageType: The type of the message the DHCP state machine is expecting. + * @param[in] xExpectedMessageType The type of the message the DHCP state machine is expecting. * Messages of different type will be dropped. * * @return pdPASS: if DHCP options are received correctly; pdFAIL: Otherwise. @@ -980,10 +980,10 @@ /** * @brief Create a partial DHCP message by filling in all the 'constant' fields. * - * @param[out] pxAddress: Address to be filled in. - * @param[out] xOpcode: Opcode to be filled in the packet. Will always be 'dhcpREQUEST_OPCODE'. - * @param[in] pucOptionsArray: The options to be added to the packet. - * @param[in,out] pxOptionsArraySize: Byte count of the options. Its value might change. + * @param[out] pxAddress Address to be filled in. + * @param[out] xOpcode Opcode to be filled in the packet. Will always be 'dhcpREQUEST_OPCODE'. + * @param[in] pucOptionsArray The options to be added to the packet. + * @param[in,out] pxOptionsArraySize Byte count of the options. Its value might change. * * @return Ethernet buffer of the partially created DHCP packet. */ diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 3844001f4d..2d6367abc1 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -154,7 +154,7 @@ /** * @brief Get the IP-address corresponding to the given hostname. - * @param[in] pcHostName: The hostname whose IP address is being queried. + * @param[in] pcHostName The hostname whose IP address is being queried. * @return The IP-address corresponding to the hostname. 0 is returned in * case of failure. */ @@ -166,10 +166,10 @@ /** * @brief Get the IP-address corresponding to the given hostname. - * @param[in] pcHostName: The hostname whose IP address is being queried. - * @param[in] pCallback: The callback function which will be called upon DNS response. - * @param[in] pvSearchID: Search ID for the callback function. - * @param[in] uxTimeout: Timeout for the callback function. + * @param[in] pcHostName The hostname whose IP address is being queried. + * @param[in] pCallback The callback function which will be called upon DNS response. + * @param[in] pvSearchID Search ID for the callback function. + * @param[in] uxTimeout Timeout for the callback function. * @return The IP-address corresponding to the hostname. 0 is returned in case of * failure. */ @@ -187,10 +187,10 @@ /** * @brief Check if hostname is already known. If not, call prvGetHostByName() to send a DNS request. * - * @param[in] pcHostName: The hostname whose IP address is being queried. - * @param[in] pCallback: The callback function which will be called upon DNS response. - * @param[in] pvSearchID: Search ID for the callback function. - * @param[in] uxTimeout: Timeout for the callback function. + * @param[in] pcHostName The hostname whose IP address is being queried. + * @param[in] pCallback The callback function which will be called upon DNS response. + * @param[in] pvSearchID Search ID for the callback function. + * @param[in] uxTimeout Timeout for the callback function. * @return The IP-address corresponding to the hostname. */ static uint32_t prvPrepareLookup( const char * pcHostName, @@ -201,7 +201,7 @@ /** * @brief Check if hostname is already known. If not, call prvGetHostByName() to send a DNS request. - * @param[in] pcHostName: The hostname whose IP address is being queried. + * @param[in] pcHostName The hostname whose IP address is being queried. * @return The IP-address corresponding to the hostname. */ static uint32_t prvPrepareLookup( const char * pcHostName ) @@ -459,7 +459,7 @@ /*! * @brief prepare the buffer before sending - * @param [in] pcHostName + * @param [in] pcHostName hostname to be looked up * @param [in] uxIdentifier matches sent and received packets * @param [in] xDNSSocket a valid socket * @param [in] pxAddress address structure @@ -577,7 +577,7 @@ TickType_t uxIdentifier, Socket_t xDNSSocket ) { - uint32_t ulIPAddress; + uint32_t ulIPAddress = 0; BaseType_t xAttempt; for( xAttempt = 0; xAttempt < ipconfigDNS_REQUEST_ATTEMPTS; xAttempt++ ) @@ -755,7 +755,7 @@ /** * @brief Perform some preliminary checks and then parse the DNS packet. * - * @param[in] pxNetworkBuffer: The network buffer to be parsed. + * @param[in] pxNetworkBuffer The network buffer to be parsed. * * @return pdFAIL Always to indicate that the packet was not consumed and must * be released by the caller. @@ -793,7 +793,7 @@ /** * @brief Handle an NBNS packet. * - * @param[in] pxNetworkBuffer: The network buffer holding the NBNS packet. + * @param[in] pxNetworkBuffer The network buffer holding the NBNS packet. * * @return pdFAIL to show that the packet was not consumed. */ diff --git a/source/FreeRTOS_DNS_Cache.c b/source/FreeRTOS_DNS_Cache.c index 33113e5a18..e778932b77 100644 --- a/source/FreeRTOS_DNS_Cache.c +++ b/source/FreeRTOS_DNS_Cache.c @@ -145,11 +145,11 @@ /** * @brief process a DNS Cache request (get, update, or insert) * - * @param[in] pcName: the name of the host - * @param[in,out] pulIP: when doing a lookup, will be set, when doing an update, + * @param[in] pcName the name of the host + * @param[in,out] pulIP when doing a lookup, will be set, when doing an update, * will be read. - * @param[in] ulTTL: Time To Live (in seconds) - * @param[in] xLookUp: pdTRUE if a look-up is expected, pdFALSE, when the DNS cache must + * @param[in] ulTTL Time To Live (in seconds) + * @param[in] xLookUp pdTRUE if a look-up is expected, pdFALSE, when the DNS cache must * be updated. * @return whether the operation was successful * @post the global structure \a xDNSCache might be modified @@ -166,7 +166,7 @@ configASSERT( ( pcName != NULL ) ); - ulCurrentTimeSeconds = ( xCurrentTickCount / portTICK_PERIOD_MS ) / 1000U; + ulCurrentTimeSeconds = ( uint32_t ) ( ( xCurrentTickCount / portTICK_PERIOD_MS ) / 1000U ); xResult = prvFindEntryIndex( pcName, &uxIndex ); if( xResult == pdTRUE ) @@ -219,7 +219,7 @@ /** * @brief returns the index of the hostname entry in the dns cache. * @param[in] pcName find it in the cache - * @param [out] xResult index number + * @param [out] uxResult index number * @returns res pdTRUE if index in found else pdFALSE */ static BaseType_t prvFindEntryIndex( const char * pcName, @@ -249,7 +249,7 @@ /** * @brief get entry at \p index from the cache - * @param[in] uxIndex : index in the cache + * @param[in] uxIndex index in the cache * @param[out] pulIP fill it with the result * @param[in] ulCurrentTimeSeconds current time * @returns \c pdTRUE if the value is valid \c pdFALSE otherwise @@ -299,7 +299,7 @@ /** * @brief update entry at \p index in the cache - * @param[in] uxIndex : index in the cache + * @param[in] uxIndex index in the cache * @param[in] ulTTL time to live (in seconds) * @param[in] pulIP ip to update the cache with * @param[in] ulCurrentTimeSeconds current time diff --git a/source/FreeRTOS_DNS_Networking.c b/source/FreeRTOS_DNS_Networking.c index 7a49adba40..370fe723ee 100644 --- a/source/FreeRTOS_DNS_Networking.c +++ b/source/FreeRTOS_DNS_Networking.c @@ -144,7 +144,7 @@ /** * @brief perform a DNS network close - * @param xDNSSocket + * @param xDNSSocket the DNS socket to close */ void DNS_CloseSocket( Socket_t xDNSSocket ) { diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 5973f1172e..9ee558091a 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -52,10 +52,10 @@ /** * @brief Read the Name field out of a DNS response packet. * - * @param[in] pucByte: Pointer to the DNS response. - * @param[in] uxRemainingBytes: Length of the DNS response. - * @param[out] pcName: The pointer in which the name in the DNS response will be returned. - * @param[in] uxDestLen: Size of the pcName array. + * @param[in] pucByte Pointer to the DNS response. + * @param[in] uxRemainingBytes Length of the DNS response. + * @param[out] pcName The pointer in which the name in the DNS response will be returned. + * @param[in] uxDestLen Size of the pcName array. * * @return If a fully formed name was found, then return the number of bytes processed in pucByte. */ @@ -167,8 +167,8 @@ /** * @brief Simple routine that jumps over the NAME field of a resource record. * - * @param[in] pucByte: The pointer to the resource record. - * @param[in] uxLength: Length of the resource record. + * @param[in] pucByte The pointer to the resource record. + * @param[in] uxLength Length of the resource record. * * @return It returns the number of bytes read, or zero when an error has occurred. */ @@ -239,10 +239,10 @@ /** * @brief Process a response packet from a DNS server, or an LLMNR reply. * - * @param[in] pucUDPPayloadBuffer: The DNS response received as a UDP + * @param[in] pucUDPPayloadBuffer The DNS response received as a UDP * payload. - * @param[in] uxBufferLength: Length of the UDP payload buffer. - * @param[in] xExpected: indicates whether the identifier in the reply + * @param[in] uxBufferLength Length of the UDP payload buffer. + * @param[in] xExpected indicates whether the identifier in the reply * was expected, and thus if the DNS cache may be * updated with the reply. * @@ -730,8 +730,8 @@ /** * @brief Send a DNS message to be used in NBNS or LLMNR * - * @param[in] pxNetworkBuffer: The network buffer descriptor with the DNS message. - * @param[in] lNetLength: The length of the DNS message. + * @param[in] pxNetworkBuffer The network buffer descriptor with the DNS message. + * @param[in] lNetLength The length of the DNS message. */ void prepareReplyDNSMessage( NetworkBufferDescriptor_t * pxNetworkBuffer, BaseType_t lNetLength ) @@ -794,9 +794,9 @@ /** * @brief Respond to an NBNS query or an NBNS reply. * - * @param[in] pucPayload: the UDP payload of the NBNS message. - * @param[in] uxBufferLength: Length of the Buffer. - * @param[in] ulIPAddress: IP address of the sender. + * @param[in] pucPayload the UDP payload of the NBNS message. + * @param[in] uxBufferLength Length of the Buffer. + * @param[in] ulIPAddress IP address of the sender. */ void DNS_TreatNBNS( uint8_t * pucPayload, size_t uxBufferLength, diff --git a/source/FreeRTOS_ICMP.c b/source/FreeRTOS_ICMP.c index 660786dda7..743f2554a3 100644 --- a/source/FreeRTOS_ICMP.c +++ b/source/FreeRTOS_ICMP.c @@ -74,7 +74,7 @@ /** * @brief Process an ICMP packet. Only echo requests and echo replies are recognised and handled. * - * @param[in,out] pxICMPPacket: The IP packet that contains the ICMP message. + * @param[in,out] pxNetworkBuffer The IP packet that contains the ICMP message. * * @return eReleaseBuffer when the message buffer should be released, or eReturnEthernetFrame * when the packet should be returned. @@ -132,7 +132,7 @@ /** * @brief Process an ICMP echo request. * - * @param[in,out] pxICMPPacket: The IP packet that contains the ICMP message. + * @param[in,out] pxICMPPacket The IP packet that contains the ICMP message. */ static eFrameProcessingResult_t prvProcessICMPEchoRequest( ICMPPacket_t * const pxICMPPacket, const NetworkBufferDescriptor_t * const pxNetworkBuffer ) @@ -197,7 +197,7 @@ /** * @brief Process an ICMP echo reply. * - * @param[in] pxICMPPacket: The IP packet that contains the ICMP message. + * @param[in] pxICMPPacket The IP packet that contains the ICMP message. */ static void prvProcessICMPEchoReply( ICMPPacket_t * const pxICMPPacket ) { diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index a77e7f4fbe..0b174b0312 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -231,7 +231,7 @@ static BaseType_t xIPTaskInitialised = pdFALSE; * 'xNetworkEventQueue'. prvIPTask() is the only task which has access to * the data of the IP-stack, and so it has no need of using mutexes. * - * @param[in] pvParameters: Not used. + * @param[in] pvParameters Not used. */ /* MISRA Ref 8.13.1 [Not decorating a pointer to const parameter with const] */ @@ -561,7 +561,7 @@ BaseType_t xIsNetworkDownEventPending( void ) /** * @brief Handle the incoming Ethernet packets. * - * @param[in] pxBuffer: Linked/un-linked network buffer descriptor(s) + * @param[in] pxBuffer Linked/un-linked network buffer descriptor(s) * to be processed. */ static void prvHandleEthernetPacket( NetworkBufferDescriptor_t * pxBuffer ) @@ -659,8 +659,8 @@ BaseType_t FreeRTOS_NetworkDownFromISR( void ) /** * @brief Obtain a buffer big enough for a UDP payload of given size. * - * @param[in] uxRequestedSizeBytes: The size of the UDP payload. - * @param[in] uxBlockTimeTicks: Maximum amount of time for which this call + * @param[in] uxRequestedSizeBytes The size of the UDP payload. + * @param[in] uxBlockTimeTicks Maximum amount of time for which this call * can block. This value is capped internally. * * @return If a buffer was created then the pointer to that buffer is returned, @@ -709,11 +709,11 @@ void * FreeRTOS_GetUDPPayloadBuffer( size_t uxRequestedSizeBytes, /** * @brief Initialise the FreeRTOS-Plus-TCP network stack and initialise the IP-task. * - * @param[in] ucIPAddress: Local IP address. - * @param[in] ucNetMask: Local netmask. - * @param[in] ucGatewayAddress: Local gateway address. - * @param[in] ucDNSServerAddress: Local DNS server address. - * @param[in] ucMACAddress: MAC address of the node. + * @param[in] ucIPAddress Local IP address. + * @param[in] ucNetMask Local netmask. + * @param[in] ucGatewayAddress Local gateway address. + * @param[in] ucDNSServerAddress Local DNS server address. + * @param[in] ucMACAddress MAC address of the node. * * @return pdPASS if the task was successfully created and added to a ready * list, otherwise an error code defined in the file projdefs.h @@ -847,10 +847,10 @@ BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES * @brief Get the current address configuration. Only non-NULL pointers will * be filled in. * - * @param[out] pulIPAddress: The current IP-address assigned. - * @param[out] pulNetMask: The netmask used for current subnet. - * @param[out] pulGatewayAddress: The gateway address. - * @param[out] pulDNSServerAddress: The DNS server address. + * @param[out] pulIPAddress The current IP-address assigned. + * @param[out] pulNetMask The netmask used for current subnet. + * @param[out] pulGatewayAddress The gateway address. + * @param[out] pulDNSServerAddress The DNS server address. */ void FreeRTOS_GetAddressConfiguration( uint32_t * pulIPAddress, uint32_t * pulNetMask, @@ -885,10 +885,10 @@ void FreeRTOS_GetAddressConfiguration( uint32_t * pulIPAddress, * @brief Set the current network address configuration. Only non-NULL pointers will * be used. * - * @param[in] pulIPAddress: The current IP-address assigned. - * @param[in] pulNetMask: The netmask used for current subnet. - * @param[in] pulGatewayAddress: The gateway address. - * @param[in] pulDNSServerAddress: The DNS server address. + * @param[in] pulIPAddress The current IP-address assigned. + * @param[in] pulNetMask The netmask used for current subnet. + * @param[in] pulGatewayAddress The gateway address. + * @param[in] pulDNSServerAddress The DNS server address. */ void FreeRTOS_SetAddressConfiguration( const uint32_t * pulIPAddress, const uint32_t * pulNetMask, @@ -922,7 +922,7 @@ void FreeRTOS_SetAddressConfiguration( const uint32_t * pulIPAddress, /** * @brief Release the UDP payload buffer. * - * @param[in] pvBuffer: Pointer to the UDP buffer that is to be released. + * @param[in] pvBuffer Pointer to the UDP buffer that is to be released. */ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) { @@ -936,9 +936,9 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) * @brief Release the memory that was previously obtained by calling FreeRTOS_recv() * with the flag 'FREERTOS_ZERO_COPY'. * - * @param[in] xSocket: The socket that was read from. - * @param[in] pvBuffer: The buffer returned in the call to FreeRTOS_recv(). - * @param[in] xByteCount: The number of bytes that have been used. + * @param[in] xSocket The socket that was read from. + * @param[in] pvBuffer The buffer returned in the call to FreeRTOS_recv(). + * @param[in] xByteCount The number of bytes that have been used. * * @return pdPASS if the buffer was released successfully, otherwise pdFAIL is returned. */ @@ -984,9 +984,9 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) * @brief Send a ping request to the given IP address. After receiving a reply, * IP-task will call a user-supplied function 'vApplicationPingReplyHook()'. * - * @param[in] ulIPAddress: The IP address to which the ping is to be sent. - * @param[in] uxNumberOfBytesToSend: Number of bytes in the ping request. - * @param[in] uxBlockTimeTicks: Maximum number of ticks to wait. + * @param[in] ulIPAddress The IP address to which the ping is to be sent. + * @param[in] uxNumberOfBytesToSend Number of bytes in the ping request. + * @param[in] uxBlockTimeTicks Maximum number of ticks to wait. * * @return If successfully sent to IP task for processing then the sequence * number of the ping packet or else, pdFAIL. @@ -1078,7 +1078,7 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) /** * @brief Send an event to the IP task. It calls 'xSendEventStructToIPTask' internally. * - * @param[in] eEvent: The event to be sent. + * @param[in] eEvent The event to be sent. * * @return pdPASS if the event was sent (or the desired effect was achieved). Else, pdFAIL. */ @@ -1097,8 +1097,8 @@ BaseType_t xSendEventToIPTask( eIPEvent_t eEvent ) /** * @brief Send an event (in form of struct) to the IP task to be processed. * - * @param[in] pxEvent: The event to be sent. - * @param[in] uxTimeout: Timeout for waiting in case the queue is full. 0 for non-blocking calls. + * @param[in] pxEvent The event to be sent. + * @param[in] uxTimeout Timeout for waiting in case the queue is full. 0 for non-blocking calls. * * @return pdPASS if the event was sent (or the desired effect was achieved). Else, pdFAIL. */ @@ -1170,7 +1170,7 @@ BaseType_t xSendEventStructToIPTask( const IPStackEvent_t * pxEvent, /** * @brief Decide whether this packet should be processed or not based on the IP address in the packet. * - * @param[in] pucEthernetBuffer: The ethernet packet under consideration. + * @param[in] pucEthernetBuffer The ethernet packet under consideration. * * @return Enum saying whether to release or to process the packet. */ @@ -1236,7 +1236,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /** * @brief Process the Ethernet packet. * - * @param[in,out] pxNetworkBuffer: the network buffer containing the ethernet packet. If the + * @param[in,out] pxNetworkBuffer the network buffer containing the ethernet packet. If the * buffer is large enough, it may be reused to send a reply. */ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) @@ -1370,7 +1370,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor /** * @brief Is the IP address an IPv4 multicast address. * - * @param[in] ulIPAddress: The IP address being checked. + * @param[in] ulIPAddress The IP address being checked. * * @return pdTRUE if the IP address is a multicast address or else, pdFALSE. */ @@ -1395,9 +1395,9 @@ BaseType_t xIsIPv4Multicast( uint32_t ulIPAddress ) /** * @brief Check whether this IP packet is to be allowed or to be dropped. * - * @param[in] pxIPPacket: The IP packet under consideration. - * @param[in] pxNetworkBuffer: The whole network buffer. - * @param[in] uxHeaderLength: The length of the header. + * @param[in] pxIPPacket The IP packet under consideration. + * @param[in] pxNetworkBuffer The whole network buffer. + * @param[in] uxHeaderLength The length of the header. * * @return Whether the packet should be processed or dropped. */ @@ -1595,8 +1595,8 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP /** * @brief Process an IP-packet. * - * @param[in] pxIPPacket: The IP packet to be processed. - * @param[in] pxNetworkBuffer: The networkbuffer descriptor having the IP packet. + * @param[in] pxIPPacket The IP packet to be processed. + * @param[in] pxNetworkBuffer The networkbuffer descriptor having the IP packet. * * @return An enum to show whether the packet should be released/kept/processed etc. */ @@ -1823,8 +1823,8 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, * @brief Although the driver will take care of checksum calculations, the IP-task * will still check if the length fields are OK. * - * @param[in] pucEthernetBuffer: The Ethernet packet received. - * @param[in] uxBufferLength: The total number of bytes received. + * @param[in] pucEthernetBuffer The Ethernet packet received. + * @param[in] uxBufferLength The total number of bytes received. * * @return pdPASS when the length fields in the packet OK, pdFAIL when the packet * should be dropped. @@ -1871,7 +1871,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, break; } - ucVersionHeaderLength = ( ucVersionHeaderLength & ( uint8_t ) 0x0FU ) << 2; + ucVersionHeaderLength = ( uint16_t ) ( ( ucVersionHeaderLength & ( uint8_t ) 0x0FU ) << 2U ); uxIPHeaderLength = ( UBaseType_t ) ucVersionHeaderLength; /* Check if the complete IP-header is transferred. */ @@ -1955,8 +1955,8 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /** * @brief Send the Ethernet frame after checking for some conditions. * - * @param[in,out] pxNetworkBuffer: The network buffer which is to be sent. - * @param[in] xReleaseAfterSend: Whether this network buffer is to be released or not. + * @param[in,out] pxNetworkBuffer The network buffer which is to be sent. + * @param[in] xReleaseAfterSend Whether this network buffer is to be released or not. */ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, BaseType_t xReleaseAfterSend ) @@ -2048,7 +2048,7 @@ uint32_t FreeRTOS_GetIPAddress( void ) /** * @brief Sets the IP address of the NIC. * - * @param[in] ulIPAddress: IP address of the NIC to be set. + * @param[in] ulIPAddress IP address of the NIC to be set. */ void FreeRTOS_SetIPAddress( uint32_t ulIPAddress ) { @@ -2093,7 +2093,7 @@ uint32_t FreeRTOS_GetNetmask( void ) /** * @brief Update the MAC address. * - * @param[in] ucMACAddress: the MAC address to be set. + * @param[in] ucMACAddress the MAC address to be set. */ void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] ) { @@ -2116,7 +2116,7 @@ const uint8_t * FreeRTOS_GetMACAddress( void ) /** * @brief Set the netmask for the subnet. * - * @param[in] ulNetmask: The 32 bit netmask of the subnet. + * @param[in] ulNetmask The 32 bit netmask of the subnet. */ void FreeRTOS_SetNetmask( uint32_t ulNetmask ) { @@ -2127,7 +2127,7 @@ void FreeRTOS_SetNetmask( uint32_t ulNetmask ) /** * @brief Set the gateway address. * - * @param[in] ulGatewayAddress: The gateway address. + * @param[in] ulGatewayAddress The gateway address. */ void FreeRTOS_SetGatewayAddress( uint32_t ulGatewayAddress ) { diff --git a/source/FreeRTOS_IP_Timers.c b/source/FreeRTOS_IP_Timers.c index 16ff2a4481..0997706094 100644 --- a/source/FreeRTOS_IP_Timers.c +++ b/source/FreeRTOS_IP_Timers.c @@ -252,9 +252,9 @@ void vCheckNetworkTimers( void ) * @brief Start an IP timer. The IP-task has its own implementation of a timer * called 'IPTimer_t', which is based on the FreeRTOS 'TimeOut_t'. * - * @param[in] pxTimer: Pointer to the IP timer. When zero, the timer is marked + * @param[in] pxTimer Pointer to the IP timer. When zero, the timer is marked * as expired. - * @param[in] xTime: Time to be loaded into the IP timer. + * @param[in] xTime Time to be loaded into the IP timer. */ static void prvIPTimerStart( IPTimer_t * pxTimer, TickType_t xTime ) @@ -284,8 +284,8 @@ void vIPTimerStartARPResolution( TickType_t xTime ) /** * @brief Sets the reload time of an IP timer and restarts it. * - * @param[in] pxTimer: Pointer to the IP timer. - * @param[in] xTime: Time to be reloaded into the IP timer. + * @param[in] pxTimer Pointer to the IP timer. + * @param[in] xTime Time to be reloaded into the IP timer. */ static void prvIPTimerReload( IPTimer_t * pxTimer, TickType_t xTime ) @@ -314,7 +314,7 @@ void vARPTimerReload( TickType_t xTime ) /** * @brief Reload the DHCP timer. * - * @param[in] ulLeaseTime: The reload value. + * @param[in] xLeaseTime The reload value. */ void vDHCPTimerReload( TickType_t xLeaseTime ) { @@ -328,7 +328,7 @@ void vARPTimerReload( TickType_t xTime ) /** * @brief Reload the DNS timer. * - * @param[in] ulCheckTime: The reload value. + * @param[in] ulCheckTime The reload value. */ void vDNSTimerReload( uint32_t ulCheckTime ) { @@ -340,7 +340,7 @@ void vARPTimerReload( TickType_t xTime ) /** * @brief Check the IP timer to see whether an IP event should be processed or not. * - * @param[in] pxTimer: Pointer to the IP timer. + * @param[in] pxTimer Pointer to the IP timer. * * @return If the timer is expired then pdTRUE is returned. Else pdFALSE. */ @@ -385,7 +385,7 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ) /** * @brief Enable/disable the TCP timer. * - * @param[in] xExpiredState: pdTRUE - set as expired; pdFALSE - set as non-expired. + * @param[in] xExpiredState pdTRUE - set as expired; pdFALSE - set as non-expired. */ void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ) { @@ -406,7 +406,7 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ) /** * @brief Enable/disable the ARP timer. * - * @param[in] xEnableState: pdTRUE - enable timer; pdFALSE - disable timer. + * @param[in] xEnableState pdTRUE - enable timer; pdFALSE - disable timer. */ void vIPSetARPTimerEnableState( BaseType_t xEnableState ) { @@ -424,7 +424,7 @@ void vIPSetARPTimerEnableState( BaseType_t xEnableState ) /** * @brief Enable or disable the ARP resolution timer. * - * @param[in] xEnableState: pdTRUE if the timer must be enabled, pdFALSE otherwise. + * @param[in] xEnableState pdTRUE if the timer must be enabled, pdFALSE otherwise. */ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ) { @@ -444,7 +444,7 @@ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ) /** * @brief Enable/disable the DHCP timer. * - * @param[in] xEnableState: pdTRUE - enable timer; pdFALSE - disable timer. + * @param[in] xEnableState pdTRUE - enable timer; pdFALSE - disable timer. */ void vIPSetDHCPTimerEnableState( BaseType_t xEnableState ) { @@ -465,7 +465,7 @@ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ) /** * @brief Enable/disable the DNS timer. * - * @param[in] xEnableState: pdTRUE - enable timer; pdFALSE - disable timer. + * @param[in] xEnableState pdTRUE - enable timer; pdFALSE - disable timer. */ void vIPSetDNSTimerEnableState( BaseType_t xEnableState ) { diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 1b521e3b2a..d13dcf94ad 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -97,22 +97,22 @@ /** * Used in checksum calculation. */ -typedef union _xUnion32 +typedef union xUnion32 { uint32_t u32; /**< The 32-bit member of the union. */ uint16_t u16[ 2 ]; /**< The array of 2 16-bit members of the union. */ uint8_t u8[ 4 ]; /**< The array of 4 8-bit members of the union. */ -} xUnion32; +} xUnion32_t; /** * Used in checksum calculation. */ -typedef union _xUnionPtr +typedef union xUnionPtr { const uint32_t * u32ptr; /**< The pointer member to a 32-bit variable. */ const uint16_t * u16ptr; /**< The pointer member to a 16-bit variable. */ const uint8_t * u8ptr; /**< The pointer member to an 8-bit variable. */ -} xUnionPtr; +} xUnionPtr_t; /* * Returns the network buffer descriptor that owns a given packet buffer. @@ -149,8 +149,8 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void /** * @brief Set multicast MAC address. * - * @param[in] ulIPAddress: IP address. - * @param[out] pxMACAddress: Pointer to MAC address. + * @param[in] ulIPAddress IP address. + * @param[out] pxMACAddress Pointer to MAC address. */ void vSetMultiCastIPv4MacAddress( uint32_t ulIPAddress, MACAddress_t * pxMACAddress ) @@ -170,8 +170,8 @@ void vSetMultiCastIPv4MacAddress( uint32_t ulIPAddress, /** * @brief Duplicate the given network buffer descriptor with a modified length. * - * @param[in] pxNetworkBuffer: The network buffer to be duplicated. - * @param[in] uxNewLength: The length for the new buffer. + * @param[in] pxNetworkBuffer The network buffer to be duplicated. + * @param[in] uxNewLength The length for the new buffer. * * @return If properly duplicated, then the duplicate network buffer or else, NULL. */ @@ -212,8 +212,8 @@ NetworkBufferDescriptor_t * pxDuplicateNetworkBufferWithDescriptor( const Networ /** * @brief Get the network buffer descriptor from the packet buffer. * - * @param[in] pvBuffer: The pointer to packet buffer. - * @param[in] uxOffset: Additional offset (such as the packet length of UDP packet etc.). + * @param[in] pvBuffer The pointer to packet buffer. + * @param[in] uxOffset Additional offset (such as the packet length of UDP packet etc.). * * @return The network buffer descriptor if the alignment is correct. Else a NULL is returned. */ @@ -265,7 +265,7 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void /** * @brief Get the network buffer from the packet buffer. * - * @param[in] pvBuffer: Pointer to the packet buffer. + * @param[in] pvBuffer Pointer to the packet buffer. * * @return The network buffer if the alignment is correct. Else a NULL is returned. */ @@ -280,7 +280,7 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void /** * @brief Get the network buffer from the UDP Payload buffer. * - * @param[in] pvBuffer: Pointer to the UDP payload buffer. + * @param[in] pvBuffer Pointer to the UDP payload buffer. * * @return The network buffer if the alignment is correct. Else a NULL is returned. */ @@ -433,11 +433,11 @@ void vPreCheckConfigs( void ) * At the same time, the length of the packet and the length of the different layers * will be checked. * - * @param[in] pucEthernetBuffer: The Ethernet buffer for which the checksum is to be calculated + * @param[in] pucEthernetBuffer The Ethernet buffer for which the checksum is to be calculated * or checked. - * @param[in] uxBufferLength: the total number of bytes received, or the number of bytes written + * @param[in] uxBufferLength the total number of bytes received, or the number of bytes written * in the packet buffer. - * @param[in] xOutgoingPacket: Whether this is an outgoing packet or not. + * @param[in] xOutgoingPacket Whether this is an outgoing packet or not. * * @return When xOutgoingPacket is false: the error code can be either: ipINVALID_LENGTH, * ipUNHANDLED_PROTOCOL, ipWRONG_CRC, or ipCORRECT_CRC. @@ -485,7 +485,7 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header * Length field contains the length of the internet header in 32-bit words. */ ucVersionHeaderLength = pxIPPacket->xIPHeader.ucVersionHeaderLength; - ucVersionHeaderLength = ( ucVersionHeaderLength & ( uint8_t ) 0x0FU ) << 2; + ucVersionHeaderLength = ( uint16_t ) ( ( ucVersionHeaderLength & ( uint8_t ) 0x0FU ) << 2U ); uxIPHeaderLength = ( UBaseType_t ) ucVersionHeaderLength; /* Check for minimum packet size. */ @@ -817,9 +817,9 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, /** * @brief Calculates the 16-bit checksum of an array of bytes * - * @param[in] usSum: The initial sum, obtained from earlier data. - * @param[in] pucNextData: The actual data. - * @param[in] uxByteCount: The number of bytes. + * @param[in] usSum The initial sum, obtained from earlier data. + * @param[in] pucNextData The actual data. + * @param[in] uxByteCount The number of bytes. * * @return The 16-bit one's complement of the one's complement sum of all 16-bit * words in the header @@ -830,10 +830,10 @@ uint16_t usGenerateChecksum( uint16_t usSum, { /* MISRA/PC-lint doesn't like the use of unions. Here, they are a great * aid though to optimise the calculations. */ - xUnion32 xSum2; - xUnion32 xSum; - xUnion32 xTerm; - xUnionPtr xSource; + xUnion32_t xSum2; + xUnion32_t xSum; + xUnion32_t xTerm; + xUnionPtr_t xSource; uintptr_t uxAlignBits; uint32_t ulCarry = 0U; uint16_t usTemp; @@ -1080,9 +1080,9 @@ uint16_t usGenerateChecksum( uint16_t usSum, * @brief Utility function: Convert error number to a human readable * string. Declaration in FreeRTOS_errno_TCP.h. * - * @param[in] xErrnum: The error number. - * @param[in] pcBuffer: Buffer big enough to be filled with the human readable message. - * @param[in] uxLength: Maximum length of the buffer. + * @param[in] xErrnum The error number. + * @param[in] pcBuffer Buffer big enough to be filled with the human readable message. + * @param[in] uxLength Maximum length of the buffer. * * @return The buffer filled with human readable error string. */ @@ -1182,8 +1182,8 @@ const char * FreeRTOS_strerror_r( BaseType_t xErrnum, /** * @brief Get the highest value of two int32's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The highest of the two values. */ int32_t FreeRTOS_max_int32( int32_t a, @@ -1195,8 +1195,8 @@ int32_t FreeRTOS_max_int32( int32_t a, /** * @brief Get the highest value of two uint32_t's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The highest of the two values. */ uint32_t FreeRTOS_max_uint32( uint32_t a, @@ -1208,8 +1208,8 @@ uint32_t FreeRTOS_max_uint32( uint32_t a, /** * @brief Get the highest value of two size_t's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The highest of the two values. */ size_t FreeRTOS_max_size_t( size_t a, @@ -1221,8 +1221,8 @@ size_t FreeRTOS_max_size_t( size_t a, /** * @brief Get the lowest value of two int32_t's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The lowest of the two values. */ int32_t FreeRTOS_min_int32( int32_t a, @@ -1234,8 +1234,8 @@ int32_t FreeRTOS_min_int32( int32_t a, /** * @brief Get the lowest value of two uint32_t's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The lowest of the two values. */ uint32_t FreeRTOS_min_uint32( uint32_t a, @@ -1247,8 +1247,8 @@ uint32_t FreeRTOS_min_uint32( uint32_t a, /** * @brief Get the lowest value of two size_t's. - * @param[in] a: the first value. - * @param[in] b: the second value. + * @param[in] a the first value. + * @param[in] b the second value. * @return The lowest of the two values. */ size_t FreeRTOS_min_size_t( size_t a, @@ -1260,8 +1260,8 @@ size_t FreeRTOS_min_size_t( size_t a, /** * @brief Round-up a number to a multiple of 'd'. - * @param[in] a: the first value. - * @param[in] d: the second value. + * @param[in] a the first value. + * @param[in] d the second value. * @return A multiple of d. */ uint32_t FreeRTOS_round_up( uint32_t a, @@ -1282,8 +1282,8 @@ uint32_t FreeRTOS_round_up( uint32_t a, /** * @brief Round-down a number to a multiple of 'd'. - * @param[in] a: the first value. - * @param[in] d: the second value. + * @param[in] a the first value. + * @param[in] d the second value. * @return A multiple of d. */ uint32_t FreeRTOS_round_down( uint32_t a, @@ -1304,7 +1304,7 @@ uint32_t FreeRTOS_round_down( uint32_t a, /** * @brief Convert character array (of size 4) to equivalent 32-bit value. - * @param[in] pucPtr: The character array. + * @param[in] pucPtr The character array. * @return 32-bit equivalent value extracted from the character array. * * @note Going by MISRA rules, these utility functions should not be defined @@ -1322,7 +1322,7 @@ uint32_t ulChar2u32( const uint8_t * pucPtr ) /** * @brief Convert character array (of size 2) to equivalent 16-bit value. - * @param[in] pucPtr: The character array. + * @param[in] pucPtr The character array. * @return 16-bit equivalent value extracted from the character array. * * @note Going by MISRA rules, these utility functions should not be defined diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 972cb18c9d..91a7c268ff 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -224,9 +224,9 @@ List_t xBoundUDPSocketsList; /** * @brief Check whether the socket is valid or not. * - * @param[in] pxSocket: The socket being checked. - * @param[in] xProtocol: The protocol for which the socket was created. - * @param[in] xIsBound: pdTRUE when the socket should be bound, otherwise pdFALSE. + * @param[in] pxSocket The socket being checked. + * @param[in] xProtocol The protocol for which the socket was created. + * @param[in] xIsBound pdTRUE when the socket should be bound, otherwise pdFALSE. * * @return If the socket is valid, then pdPASS is returned or else, pdFAIL * is returned. @@ -281,10 +281,10 @@ void vNetworkSocketsInit( void ) /** * @brief Determine the socket size for the given protocol. * - * @param[in] xDomain: The domain for which the size of socket is being determined. - * @param[in] xType: Is this a datagram socket or a stream socket. - * @param[in] xProtocol: The protocol being used. - * @param[out] pxSocketSize: Pointer to a variable in which the size shall be returned + * @param[in] xDomain The domain for which the size of socket is being determined. + * @param[in] xType Is this a datagram socket or a stream socket. + * @param[in] xProtocol The protocol being used. + * @param[out] pxSocketSize Pointer to a variable in which the size shall be returned * if all checks pass. * * @return pdPASS if socket size was determined and put in the parameter pxSocketSize @@ -359,9 +359,9 @@ static BaseType_t prvDetermineSocketSize( BaseType_t xDomain, /** * @brief allocate and initialise a socket. * - * @param[in] xDomain: The domain in which the socket should be created. - * @param[in] xType: The type of the socket. - * @param[in] xProtocol: The protocol of the socket. + * @param[in] xDomain The domain in which the socket should be created. + * @param[in] xType The type of the socket. + * @param[in] xProtocol The protocol of the socket. * * @return FREERTOS_INVALID_SOCKET if the allocation failed, or if there was * a parameter error, otherwise a valid socket. @@ -569,7 +569,7 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, /** * @brief Delete a given socket set. * - * @param[in] xSocketSet: The socket set being deleted. + * @param[in] xSocketSet The socket set being deleted. */ void FreeRTOS_DeleteSocketSet( SocketSet_t xSocketSet ) { @@ -593,9 +593,9 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, /** * @brief Add a socket to a set. * - * @param[in] xSocket: The socket being added. - * @param[in] xSocketSet: The socket set being added to. - * @param[in] xBitsToSet: The event bits to set, a combination of the values defined + * @param[in] xSocket The socket being added. + * @param[in] xSocketSet The socket set being added to. + * @param[in] xBitsToSet The event bits to set, a combination of the values defined * in 'eSelectEvent_t', for read, write, exception, etc. */ void FreeRTOS_FD_SET( Socket_t xSocket, @@ -633,9 +633,9 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * @brief Clear select bits for a socket. If the mask becomes 0, * remove the socket from the set. * - * @param[in] xSocket: The socket whose select bits are being cleared. - * @param[in] xSocketSet: The socket set of the socket. - * @param[in] xBitsToClear: The bits to be cleared. Every '1' means that the + * @param[in] xSocket The socket whose select bits are being cleared. + * @param[in] xSocketSet The socket set of the socket. + * @param[in] xBitsToClear The bits to be cleared. Every '1' means that the * corresponding bit will be cleared. See 'eSelectEvent_t' for * the possible values. */ @@ -672,8 +672,8 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * @brief Test if a socket belongs to a socket-set and if so, which event bit(s) * are set. * - * @param[in] xSocket: The socket of interest. - * @param[in] xSocketSet: The socket set to which the socket belongs. + * @param[in] xSocket The socket of interest. + * @param[in] xSocketSet The socket set to which the socket belongs. * * @return If the socket belongs to the socket set: the event bits, otherwise zero. */ @@ -710,9 +710,9 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * @brief The select() statement: wait for an event to occur on any of the sockets * included in a socket set and return its event bits when the event occurs. * - * @param[in] xSocketSet: The socket set including the sockets on which we are + * @param[in] xSocketSet The socket set including the sockets on which we are * waiting for an event to occur. - * @param[in] xBlockTimeTicks: Maximum time ticks to wait for an event to occur. + * @param[in] xBlockTimeTicks Maximum time ticks to wait for an event to occur. * If the value is 'portMAX_DELAY' then the function will wait * indefinitely for an event to occur. * @@ -785,7 +785,7 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * @brief Send a message to the IP-task to have it check all sockets belonging to * 'pxSocketSet' * - * @param[in] pxSocketSet: The socket set being asked to check. + * @param[in] pxSocketSet The socket set being asked to check. */ static void prvFindSelectedSocket( SocketSelect_t * pxSocketSet ) { @@ -843,14 +843,14 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, * can only be used with connection-less sockets (UDP). For TCP sockets, * please use FreeRTOS_recv(). * - * @param[in] xSocket: The socket to which the data is sent i.e. the + * @param[in] xSocket The socket to which the data is sent i.e. the * listening socket. - * @param[out] pvBuffer: The buffer in which the data being received is to + * @param[out] pvBuffer The buffer in which the data being received is to * be stored. - * @param[in] uxBufferLength: The length of the buffer. - * @param[in] xFlags: The flags to indicate preferences while calling this function. - * @param[out] pxSourceAddress: The source address from which the data is being sent. - * @param[out] pxSourceAddressLength: This parameter is used only to adhere to Berkeley + * @param[in] uxBufferLength The length of the buffer. + * @param[in] xFlags The flags to indicate preferences while calling this function. + * @param[out] pxSourceAddress The source address from which the data is being sent. + * @param[out] pxSourceAddressLength This parameter is used only to adhere to Berkeley * sockets standard. It is not used internally. * * @return The number of bytes received. Or else, an error code is returned. When it @@ -1038,7 +1038,7 @@ int32_t FreeRTOS_recvfrom( const ConstSocket_t xSocket, /** * @brief Check if a socket is a valid UDP socket. In case it is not * yet bound, bind it to port 0 ( random port ). - * @param[in] pxSocket: The socket that must be bound to a port number. + * @param[in] pxSocket The socket that must be bound to a port number. * @return Returns pdTRUE if the socket was already bound, or if the * socket has been bound successfully. */ @@ -1065,13 +1065,13 @@ static BaseType_t prvMakeSureSocketIsBound( FreeRTOS_Socket_t * pxSocket ) * @brief Send data to a socket. The socket must have already been created by a * successful call to FreeRTOS_socket(). It works for UDP-sockets only. * - * @param[in] xSocket: The socket being sent to. - * @param[in] pvBuffer: Pointer to the data being sent. - * @param[in] uxTotalDataLength: Length (in bytes) of the data being sent. - * @param[in] xFlags: Flags used to communicate preferences to the function. + * @param[in] xSocket The socket being sent to. + * @param[in] pvBuffer Pointer to the data being sent. + * @param[in] uxTotalDataLength Length (in bytes) of the data being sent. + * @param[in] xFlags Flags used to communicate preferences to the function. * Possibly FREERTOS_MSG_DONTWAIT and/or FREERTOS_ZERO_COPY. - * @param[in] pxDestinationAddress: The address to which the data is to be sent. - * @param[in] xDestinationAddressLength: This parameter is present to adhere to the + * @param[in] pxDestinationAddress The address to which the data is to be sent. + * @param[in] xDestinationAddressLength This parameter is present to adhere to the * Berkeley sockets standard. Else, it is not used. * * @return When positive: the total number of bytes sent, when negative an error @@ -1232,10 +1232,10 @@ int32_t FreeRTOS_sendto( Socket_t xSocket, * will be performed by the IP-task to avoid mutual access to the * bound-socket-lists (xBoundUDPSocketsList or xBoundTCPSocketsList). * - * @param[in] xSocket: The socket being bound. - * @param[in] pxAddress: The address struct carrying the port number to which + * @param[in] xSocket The socket being bound. + * @param[in] pxAddress The address struct carrying the port number to which * this socket is to be bound. - * @param[in] xAddressLength: This parameter is not used internally. The + * @param[in] xAddressLength This parameter is not used internally. The * function signature is used to adhere to standard * Berkeley sockets API. * @@ -1318,10 +1318,10 @@ BaseType_t FreeRTOS_bind( Socket_t xSocket, * 'xInternal' is used for TCP sockets only: it allows to have several * (connected) child sockets bound to the same server port. * - * @param[in] pxSocket: The socket is to be bound. - * @param[in] pxBindAddress: The port to which this socket should be bound. - * @param[in] uxAddressLength: The address length. - * @param[in] xInternal: pdTRUE is calling internally, else pdFALSE. + * @param[in] pxSocket The socket is to be bound. + * @param[in] pxBindAddress The port to which this socket should be bound. + * @param[in] uxAddressLength The address length. + * @param[in] xInternal pdTRUE is calling internally, else pdFALSE. * * @return If the socket was bound to a port successfully, then a 0 is returned. * Or else, an error code is returned. @@ -1469,7 +1469,7 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket, * will actually close the socket, after receiving a 'eSocketCloseEvent' * message. * - * @param[in] xSocket: the socket being closed. + * @param[in] xSocket the socket being closed. * * @return There are three distinct values which can be returned: * 0: If the xSocket is NULL/invalid. @@ -1544,7 +1544,7 @@ BaseType_t FreeRTOS_closesocket( Socket_t xSocket ) * @brief This is the internal version of FreeRTOS_closesocket(). It will * be called by the IPtask only to avoid problems with synchronicity. * - * @param[in] pxSocket: The socket descriptor of the socket being closed. + * @param[in] pxSocket The socket descriptor of the socket being closed. * * @return Returns NULL, always. */ @@ -1661,7 +1661,7 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) * parent. When a listening parent socket is closed, make sure to close also * all orphaned child-sockets. * - * @param[in] pxSocketToDelete: The socket being closed. + * @param[in] pxSocketToDelete The socket being closed. */ /* MISRA Ref 17.2.1 [Sockets and limited recursion] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-172 */ @@ -1736,10 +1736,10 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) /** * @brief Set the value of receive/send buffer after some preliminary checks. * - * @param[in] pxSocket: The socket whose options are being set. - * @param[in] lOptionName: The option name: either FREERTOS_SO_SNDBUF or + * @param[in] pxSocket The socket whose options are being set. + * @param[in] lOptionName The option name: either FREERTOS_SO_SNDBUF or * FREERTOS_SO_SNDBUF. - * @param[in] pvOptionValue: The value of the option being set. + * @param[in] pvOptionValue The value of the option being set. * * @return If there is no error, then 0 is returned. Or a negative errno * value is returned. @@ -1793,12 +1793,12 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) /** * @brief Set the socket options for the given socket. * - * @param[in] xSocket: The socket for which the options are to be set. - * @param[in] lLevel: Not used. Parameter is used to maintain the Berkeley sockets + * @param[in] xSocket The socket for which the options are to be set. + * @param[in] lLevel Not used. Parameter is used to maintain the Berkeley sockets * standard. - * @param[in] lOptionName: The name of the option to be set. - * @param[in] pvOptionValue: The value of the option to be set. - * @param[in] uxOptionLength: Not used. Parameter is used to maintain the Berkeley + * @param[in] lOptionName The name of the option to be set. + * @param[in] pvOptionValue The value of the option to be set. + * @param[in] uxOptionLength Not used. Parameter is used to maintain the Berkeley * sockets standard. * * @return If the option can be set with the given value, then 0 is returned. Else, @@ -2186,7 +2186,7 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /** * @brief Find an available port number per https://tools.ietf.org/html/rfc6056. * - * @param[in] xProtocol: FREERTOS_IPPROTO_TCP/FREERTOS_IPPROTO_UDP. + * @param[in] xProtocol FREERTOS_IPPROTO_TCP/FREERTOS_IPPROTO_UDP. * * @return If an available protocol port is found then that port number is returned. * Or else, 0 is returned. @@ -2254,8 +2254,8 @@ static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol ) /** * @brief Find a list item associated with the wanted-item. * - * @param[in] pxList: The list through which the search is to be conducted. - * @param[in] xWantedItemValue: The wanted item whose association is to be found. + * @param[in] pxList The list through which the search is to be conducted. + * @param[in] xWantedItemValue The wanted item whose association is to be found. * * @return The list item holding the value being searched for. If nothing is found, * then a NULL is returned. @@ -2294,7 +2294,7 @@ static const ListItem_t * pxListFindListItemWithValue( const List_t * pxList, /** * @brief Find the UDP socket corresponding to the port number. * - * @param[in] uxLocalPort: The port whose corresponding bound UDP socket + * @param[in] uxLocalPort The port whose corresponding bound UDP socket * is to be found. * * @return The socket owning the port if found or else NULL. @@ -2329,8 +2329,8 @@ FreeRTOS_Socket_t * pxUDPSocketLookup( UBaseType_t uxLocalPort ) * notation after some checks. * A safe alternative is FreeRTOS_inet_ntop4(). * - * @param[in] ulIPAddress: 32-bit representation of the IP-address. - * @param[out] pcBuffer: The buffer where the dotted decimal representation will be + * @param[in] ulIPAddress 32-bit representation of the IP-address. + * @param[out] pcBuffer The buffer where the dotted decimal representation will be * stored if all checks pass. The buffer must be at least 16 * bytes long. * @@ -2400,11 +2400,11 @@ const char * FreeRTOS_inet_ntoa( uint32_t ulIPAddress, /** * @brief Convert the dotted decimal format of the IP-address to the 32-bit representation. * - * @param[in] xAddressFamily: The Address family to which the IP-address belongs to. Only + * @param[in] xAddressFamily The Address family to which the IP-address belongs to. Only * FREERTOS_AF_INET (IPv4) is supported. - * @param[in] pcSource: Pointer to the string holding the dotted decimal representation of + * @param[in] pcSource Pointer to the string holding the dotted decimal representation of * the IP-address. - * @param[out] pvDestination: The pointer to the address struct/variable where the converted + * @param[out] pvDestination The pointer to the address struct/variable where the converted * IP-address will be stored. The buffer must be 4 bytes long * in case of a IPv4 address. * @@ -2437,11 +2437,11 @@ BaseType_t FreeRTOS_inet_pton( BaseType_t xAddressFamily, * decimal format based on the Address Family. (Only FREERTOS_AF_INET * is allowed). * - * @param[in] xAddressFamily: The address family of the IP-address. - * @param[in] pvSource: Pointer to the 32-bit representation of IP-address. - * @param[out] pcDestination: The pointer to the character array where the dotted + * @param[in] xAddressFamily The address family of the IP-address. + * @param[in] pvSource Pointer to the 32-bit representation of IP-address. + * @param[out] pcDestination The pointer to the character array where the dotted * decimal address will be stored if every check does pass. - * @param[in] uxSize: Size of the character array. This value makes sure that the code + * @param[in] uxSize Size of the character array. This value makes sure that the code * doesn't write beyond it's bounds. * * @return If every check does pass, then the pointer to the pcDestination is returned @@ -2474,10 +2474,10 @@ const char * FreeRTOS_inet_ntop( BaseType_t xAddressFamily, /** * @brief Convert the 32-bit representation of the IP-address to the dotted decimal format. * - * @param[in] pvSource: The pointer to the 32-bit representation of the IP-address. - * @param[out] pcDestination: The pointer to a character array where the string of the + * @param[in] pvSource The pointer to the 32-bit representation of the IP-address. + * @param[out] pcDestination The pointer to a character array where the string of the * dotted decimal IP format. - * @param[in] uxSize: Size of the character array. This value makes sure that the code + * @param[in] uxSize Size of the character array. This value makes sure that the code * doesn't write beyond it's bounds. * * @return The pointer to the string holding the dotted decimal format of the IP-address. If @@ -2513,7 +2513,7 @@ const char * FreeRTOS_inet_ntop4( const void * pvSource, * @brief Convert an ASCII character to its corresponding hexadecimal value. * Accepted characters are 0-9, a-f, and A-F. * - * @param[in] cChar: The character to be converted. + * @param[in] cChar The character to be converted. * * @return The hexadecimal value, between 0 and 15. * When the character is not valid, socketINVALID_HEX_CHAR will be returned. @@ -2556,11 +2556,11 @@ static uint8_t ucASCIIToHex( char cChar ) /** * @brief This function converts a 48-bit MAC address to a human readable string. * - * @param[in] pucSource: A pointer to an array of 6 bytes. - * @param[out] pcTarget: A buffer that is 18 bytes long, it will contain the resulting string. - * @param[in] cTen: Either an 'A' or an 'a'. It determines whether the hex numbers will use + * @param[in] pucSource A pointer to an array of 6 bytes. + * @param[out] pcTarget A buffer that is 18 bytes long, it will contain the resulting string. + * @param[in] cTen Either an 'A' or an 'a'. It determines whether the hex numbers will use * capital or small letters. - * @param[in] cSeparator: The separator that should appear between the bytes, either ':' or '-'. + * @param[in] cSeparator The separator that should appear between the bytes, either ':' or '-'. */ void FreeRTOS_EUI48_ntop( const uint8_t * pucSource, char * pcTarget, @@ -2592,12 +2592,12 @@ void FreeRTOS_EUI48_ntop( const uint8_t * pucSource, if( ucNibble <= 0x09U ) { cResult = '0'; - cResult = cResult + ucNibble; + cResult = ( char ) ( ( uint8_t ) cResult + ucNibble ); } else { cResult = cTen; /* Either 'a' or 'A' */ - cResult = cResult + ( ucNibble - 10U ); + cResult = ( char ) ( ( uint8_t ) cResult + ( ucNibble - 10U ) ); } pcTarget[ uxTarget ] = cResult; @@ -2622,8 +2622,8 @@ void FreeRTOS_EUI48_ntop( const uint8_t * pucSource, * @brief This function converts a human readable string, representing an 48-bit MAC address, * into a 6-byte address. Valid inputs are e.g. "62:48:5:83:A0:b2" and "0-12-34-fe-dc-ba". * - * @param[in] pcSource: The null terminated string to be parsed. - * @param[out] pucTarget: A buffer that is 6 bytes long, it will contain the MAC address. + * @param[in] pcSource The null terminated string to be parsed. + * @param[out] pucTarget A buffer that is 6 bytes long, it will contain the MAC address. * * @return pdTRUE in case the string got parsed correctly, otherwise pdFALSE. */ @@ -2698,8 +2698,8 @@ BaseType_t FreeRTOS_EUI48_pton( const char * pcSource, * structure, then copies the network address structure to pvDestination. * pvDestination is written in network byte order. * - * @param[in] pcSource: The character string in holding the IP address. - * @param[out] pvDestination: The returned network address in 32-bit network-endian format. + * @param[in] pcSource The character string in holding the IP address. + * @param[out] pvDestination The returned network address in 32-bit network-endian format. * * @return pdPASS if the translation was successful or else pdFAIL. */ @@ -2822,7 +2822,7 @@ BaseType_t FreeRTOS_inet_pton4( const char * pcSource, /** * @brief Convert the IP address from "w.x.y.z" (dotted decimal) format to the 32-bit format. * - * @param[in] pcIPAddress: The character string pointer holding the IP-address in the "W.X.Y.Z" + * @param[in] pcIPAddress The character string pointer holding the IP-address in the "W.X.Y.Z" * (dotted decimal) format. * * @return The 32-bit representation of IP(v4) address. @@ -2846,8 +2846,8 @@ uint32_t FreeRTOS_inet_addr( const char * pcIPAddress ) /** * @brief Function to get the local address and IP port of the given socket. * - * @param[in] xSocket: Socket whose port is to be added to the pxAddress. - * @param[out] pxAddress: Structure in which the IP address and the port number + * @param[in] xSocket Socket whose port is to be added to the pxAddress. + * @param[out] pxAddress Structure in which the IP address and the port number * is returned. * * @return Size of the freertos_sockaddr structure. @@ -2871,7 +2871,7 @@ size_t FreeRTOS_GetLocalAddress( ConstSocket_t xSocket, /** * @brief Wake up the user of the given socket through event-groups. * - * @param[in] pxSocket: The socket whose user is to be woken up. + * @param[in] pxSocket The socket whose user is to be woken up. */ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) { @@ -2930,7 +2930,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * number. This is probably only useful in systems with a minimum of * RAM and when lots of anonymous broadcast messages come in. * - * @param[in] usPortNr: the port number to look for. + * @param[in] usPortNr the port number to look for. * * @return xFound if a socket with the port number is found. */ @@ -2959,7 +2959,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Check if it makes any sense to wait for a connect event. * - * @param[in] pxSocket: The socket trying to connect. + * @param[in] pxSocket The socket trying to connect. * * @return It may return: -EINPROGRESS, -EAGAIN, or 0 for OK. */ @@ -3007,8 +3007,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Called from #FreeRTOS_connect(): make some checks and if allowed, * send a message to the IP-task to start connecting to a remote socket. * - * @param[in] pxSocket: The socket attempting to connect to a remote port. - * @param[in] pxAddress: The address the socket is trying to connect to. + * @param[in] pxSocket The socket attempting to connect to a remote port. + * @param[in] pxAddress The address the socket is trying to connect to. * * @return 0 on successful checks or a negative error code. */ @@ -3089,9 +3089,9 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Connect to a remote port. * - * @param[in] xClientSocket: The socket initiating the connection. - * @param[in] pxAddress: The address of the remote socket. - * @param[in] xAddressLength: This parameter is not used. It is kept in + * @param[in] xClientSocket The socket initiating the connection. + * @param[in] pxAddress The address of the remote socket. + * @param[in] xAddressLength This parameter is not used. It is kept in * the function signature to adhere to the Berkeley * sockets standard. * @@ -3182,10 +3182,10 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Accept a connection on an listening socket. * - * @param[in] xServerSocket: The socket in listening mode. - * @param[out] pxAddress: The address of the machine trying to connect to this node + * @param[in] xServerSocket The socket in listening mode. + * @param[out] pxAddress The address of the machine trying to connect to this node * is returned in this pointer. - * @param[out] pxAddressLength: The length of the address of the remote machine. + * @param[out] pxAddressLength The length of the address of the remote machine. * * @return FreeRTOS_accept: can return a new connected socket if the server socket * is in listen mode and receives a connection request. The new socket will @@ -3335,11 +3335,11 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Read incoming data from a TCP socket. Only after the last * byte has been read, a close error might be returned. * - * @param[in] xSocket: The socket owning the connection. - * @param[out] pvBuffer: The buffer to store the incoming data in. - * @param[in] uxBufferLength: The length of the buffer so that the function + * @param[in] xSocket The socket owning the connection. + * @param[out] pvBuffer The buffer to store the incoming data in. + * @param[in] uxBufferLength The length of the buffer so that the function * does not do out of bound access. - * @param[in] xFlags: The flags for conveying preference. The values + * @param[in] xFlags The flags for conveying preference. The values * FREERTOS_MSG_DONTWAIT, FREERTOS_ZERO_COPY and/or * FREERTOS_MSG_PEEK can be used. * @@ -3552,8 +3552,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Called from FreeRTOS_send(): some checks which will be done before * sending a TCP packed. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in] uxDataLength: The length of the data to be sent. + * @param[in] pxSocket The socket owning the connection. + * @param[in] uxDataLength The length of the data to be sent. * * @return 0: representing OK, else a negative error code will be returned. */ @@ -3615,8 +3615,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Get a direct pointer to the circular transmit buffer. * - * @param[in] xSocket: The socket owning the buffer. - * @param[in] pxLength: This will contain the number of bytes that may be written. + * @param[in] xSocket The socket owning the buffer. + * @param[in] pxLength This will contain the number of bytes that may be written. * * @return Head of the circular transmit buffer if all checks pass. Or else, NULL * is returned. @@ -3666,12 +3666,12 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * connected already. Outgoing data will be stored and delivered as soon as * the socket gets connected. * - * @param[in] xSocket: The socket owning the connection. - * @param[in] pvBuffer: The buffer containing the data. The value of this pointer + * @param[in] xSocket The socket owning the connection. + * @param[in] pvBuffer The buffer containing the data. The value of this pointer * may be NULL in case zero-copy transmissions are used. * It is used in combination with 'FreeRTOS_get_tx_head()'. - * @param[in] uxDataLength: The length of the data to be added. - * @param[in] xFlags: This parameter is not used. (zero or FREERTOS_MSG_DONTWAIT). + * @param[in] uxDataLength The length of the data to be added. + * @param[in] xFlags This parameter is not used. (zero or FREERTOS_MSG_DONTWAIT). * * @return The number of bytes actually sent. Zero when nothing could be sent * or a negative error code in case an error occurred. @@ -3865,8 +3865,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Request to put a socket in listen mode. * - * @param[in] xSocket: the socket to be put in listening mode. - * @param[in] xBacklog: Maximum number of child sockets. + * @param[in] xSocket the socket to be put in listening mode. + * @param[in] xBacklog Maximum number of child sockets. * * @return 0 in case of success, or else a negative error code is * returned. @@ -3937,8 +3937,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * transmission, and also it will first wait to receive any missing * packets from the peer. * - * @param[in] xSocket: The socket owning the connection. - * @param[in] xHow: Not used. Just present to stick to Berkeley standard. + * @param[in] xSocket The socket owning the connection. + * @param[in] xHow Not used. Just present to stick to Berkeley standard. * * @return 0 on successful shutdown or else a negative error code. */ @@ -3988,7 +3988,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * - Send a keep-alive packet * - Check for timeout (in non-connected states only) * - * @param[in] xWillSleep: Whether the calling task is going to sleep. + * @param[in] xWillSleep Whether the calling task is going to sleep. * * @return Minimum amount of time before the timer shall expire. */ @@ -4089,10 +4089,10 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * For a socket in listening mode, the remote port and IP address * are both 0. * - * @param[in] ulLocalIP: Local IP address. Ignored for now. - * @param[in] uxLocalPort: Local port number. - * @param[in] ulRemoteIP: Remote (peer) IP address. - * @param[in] uxRemotePort: Remote (peer) port. + * @param[in] ulLocalIP Local IP address. Ignored for now. + * @param[in] uxLocalPort Local port number. + * @param[in] ulRemoteIP Remote (peer) IP address. + * @param[in] uxRemotePort Remote (peer) port. * * @return The socket which was found. */ @@ -4159,7 +4159,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief For the web server: borrow the circular Rx buffer for inspection. * HTML driver wants to see if a sequence of 13/10/13/10 is available. * - * @param[in] xSocket: The socket whose Rx stream is to be returned. + * @param[in] xSocket The socket whose Rx stream is to be returned. * * @return The Rx stream of the socket if all checks pass, else NULL. */ @@ -4187,8 +4187,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Create the stream buffer for the given socket. * - * @param[in] pxSocket: the socket to create the stream for. - * @param[in] xIsInputStream: Is this input stream? pdTRUE/pdFALSE? + * @param[in] pxSocket the socket to create the stream for. + * @param[in] xIsInputStream Is this input stream? pdTRUE/pdFALSE? * * @return The stream buffer. */ @@ -4297,10 +4297,10 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Add data to the RxStream. When uxOffset > 0, data has come in out-of-order * and will be put in front of the head so it can not be popped by the user. * - * @param[in] pxSocket: The socket to whose RxStream data is to be added. - * @param[in] uxOffset: Offset of the packet. - * @param[in] pcData: The data to be added to the RxStream. - * @param[in] ulByteCount: Number of bytes in the data. + * @param[in] pxSocket The socket to whose RxStream data is to be added. + * @param[in] uxOffset Offset of the packet. + * @param[in] pcData The data to be added to the RxStream. + * @param[in] ulByteCount Number of bytes in the data. * * @return The number of bytes actually added to the RxStream. Or else, a negative * error code is returned. @@ -4445,8 +4445,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Function to get the remote IP-address and port number. * - * @param[in] xSocket: Socket owning the connection. - * @param[out] pxAddress: The address pointer to which the address + * @param[in] xSocket Socket owning the connection. + * @param[out] pxAddress The address pointer to which the address * is to be added. * * @return The size of the address being returned. Or else a negative @@ -4488,7 +4488,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Check the number of bytes that may be added to txStream. * - * @param[in] xSocket: The socket to be checked. + * @param[in] xSocket The socket to be checked. * * @return the number of bytes that may be added to txStream or * else a negative error code. @@ -4535,7 +4535,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Get the number of bytes that can be written in the Tx buffer * of the given socket. * - * @param[in] xSocket: the socket to be checked. + * @param[in] xSocket the socket to be checked. * * @return The bytes that can be written. Or else an error code. */ @@ -4572,7 +4572,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Returns the number of bytes stored in the Tx buffer. * - * @param[in] xSocket: The socket to be checked. + * @param[in] xSocket The socket to be checked. * * @return The number of bytes stored in the Tx buffer of the socket. * Or an error code. @@ -4610,7 +4610,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Is the socket connected. * - * @param[in] xSocket: The socket being checked. + * @param[in] xSocket The socket being checked. * * @return pdTRUE if TCP socket is connected. */ @@ -4646,7 +4646,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Get the actual value of Maximum Segment Size ( MSS ) being used. * - * @param[in] xSocket: The socket whose MSS is to be returned. + * @param[in] xSocket The socket whose MSS is to be returned. * * @return the actual size of MSS being used or an error code. */ @@ -4680,7 +4680,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) * @brief Get the connection status. The values correspond to the members * of the enum 'eIPTCPState_t'. * - * @param[in] xSocket: Socket to get the connection status from. + * @param[in] xSocket Socket to get the connection status from. * * @return The connection status or an error code. * @@ -4713,7 +4713,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Returns the number of bytes which can be read from the RX stream buffer. * - * @param[in] xSocket: the socket to get the number of bytes from. + * @param[in] xSocket the socket to get the number of bytes from. * * @return Returns the number of bytes which can be read. Or an error * code is returned. @@ -4746,7 +4746,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /** * @brief Check whether a given socket is valid or not. Validity is defined * as the socket not being NULL and not being Invalid. - * @param[in] xSocket: The socket to be checked. + * @param[in] xSocket The socket to be checked. * @return pdTRUE if the socket is valid, else pdFALSE. * */ @@ -4771,7 +4771,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) /** * @brief Returns the number of packets that are stored in a UDP socket. * - * @param[in] xSocket: the socket to get the number of bytes from. + * @param[in] xSocket the socket to get the number of bytes from. * * @return Returns the number of packets that are stored. Use FreeRTOS_recvfrom() * to retrieve those packets. @@ -4817,8 +4817,8 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) /** * @brief Set the value of the SocketID of a socket. - * @param[in] xSocket: The socket whose ID should be set. - * @param[in] pvSocketID: The new value for the SocketID. + * @param[in] xSocket The socket whose ID should be set. + * @param[in] pvSocketID The new value for the SocketID. * @return Zero if the socket was valid, otherwise -EINVAL. */ BaseType_t xSocketSetSocketID( const Socket_t xSocket, @@ -4839,7 +4839,7 @@ BaseType_t xSocketSetSocketID( const Socket_t xSocket, /** * @brief Retrieve the SocketID that is associated with a socket. - * @param[in] xSocket: The socket whose ID should be returned. + * @param[in] xSocket The socket whose ID should be returned. * @return The current value of pvSocketID, or NULL in case * the socket pointer is not valid or when the ID was not * yet set. @@ -4948,7 +4948,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) * will check if an ongoing select() call must be interrupted because of an * event has occurred. * - * @param[in] pxSocketSet: The socket-set which is to be waited on for change. + * @param[in] pxSocketSet The socket-set which is to be waited on for change. */ void vSocketSelect( const SocketSelect_t * pxSocketSet ) { @@ -5140,7 +5140,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) * Any ongoing blocking API ( e.g. FreeRTOS_recv() ) will be terminated * and return the value -pdFREERTOS_ERRNO_EINTR ( -4 ). * - * @param[in] xSocket: The socket that will be signalled. + * @param[in] xSocket The socket that will be signalled. * * @return If xSocket is an invalid socket (NULL) or if the socket set is invalid (NULL) * and/or if event group is invalid/not created, then, -pdFREERTOS_ERRNO_EINVAL @@ -5186,7 +5186,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) * @brief The same as 'FreeRTOS_SignalSocket()', except that this function should * be called from an ISR context. * - * @param[in] xSocket: The socket that will be signalled. + * @param[in] xSocket The socket that will be signalled. * @param[in,out] pxHigherPriorityTaskWoken: will be set to non-zero in case a higher- * priority task has become runnable. */ diff --git a/source/FreeRTOS_Stream_Buffer.c b/source/FreeRTOS_Stream_Buffer.c index 3b44bbfca4..85ef3f0d5d 100644 --- a/source/FreeRTOS_Stream_Buffer.c +++ b/source/FreeRTOS_Stream_Buffer.c @@ -47,9 +47,9 @@ /** * @brief Get the space between lower and upper value provided to the function. - * @param[in] pxBuffer: The circular stream buffer. - * @param[in] uxLower: The lower value. - * @param[in] uxUpper: The upper value. + * @param[in] pxBuffer The circular stream buffer. + * @param[in] uxLower The lower value. + * @param[in] uxUpper The upper value. * @return The space between uxLower and uxUpper, which equals to the distance * minus 1. */ @@ -71,9 +71,9 @@ size_t uxStreamBufferSpace( const StreamBuffer_t * pxBuffer, /** * @brief Get the distance between lower and upper value provided to the function. - * @param[in] pxBuffer: The circular stream buffer. - * @param[in] uxLower: The lower value. - * @param[in] uxUpper: The upper value. + * @param[in] pxBuffer The circular stream buffer. + * @param[in] uxLower The lower value. + * @param[in] uxUpper The upper value. * @return The distance between uxLower and uxUpper. */ size_t uxStreamBufferDistance( const StreamBuffer_t * pxBuffer, @@ -95,7 +95,7 @@ size_t uxStreamBufferDistance( const StreamBuffer_t * pxBuffer, /** * @brief Get the number of items which can be added to the buffer at * the head before reaching the tail. - * @param[in] pxBuffer: The circular stream buffer. + * @param[in] pxBuffer The circular stream buffer. * @return The number of items which can still be added to uxHead * before hitting on uxTail */ @@ -110,7 +110,7 @@ size_t uxStreamBufferGetSpace( const StreamBuffer_t * pxBuffer ) /** * @brief Get the distance between the pointer in free space and the tail. - * @param[in] pxBuffer: The circular stream buffer. + * @param[in] pxBuffer The circular stream buffer. * @return Distance between uxFront and uxTail or the number of items * which can still be added to uxFront, before hitting on uxTail. */ @@ -126,7 +126,7 @@ size_t uxStreamBufferFrontSpace( const StreamBuffer_t * pxBuffer ) /** * @brief Get the number of items which can be read from the tail before * reaching the head. - * @param[in] pxBuffer: The circular stream buffer. + * @param[in] pxBuffer The circular stream buffer. * @return The number of items which can be read from the tail before * reaching the head. */ @@ -142,7 +142,7 @@ size_t uxStreamBufferGetSize( const StreamBuffer_t * pxBuffer ) /** * @brief Get the space between the mid pointer and the head in the stream * buffer. - * @param[in] pxBuffer: The circular stream buffer. + * @param[in] pxBuffer The circular stream buffer. * @return The space between the mid pointer and the head. */ size_t uxStreamBufferMidSpace( const StreamBuffer_t * pxBuffer ) @@ -156,7 +156,7 @@ size_t uxStreamBufferMidSpace( const StreamBuffer_t * pxBuffer ) /** * @brief Move Clear the stream buffer. - * @param[in] pxBuffer: The circular stream buffer. + * @param[in] pxBuffer The circular stream buffer. */ void vStreamBufferClear( StreamBuffer_t * pxBuffer ) { @@ -171,8 +171,8 @@ void vStreamBufferClear( StreamBuffer_t * pxBuffer ) /** * @brief Move the mid pointer forward by given byte count - * @param[in] pxBuffer: The circular stream buffer. - * @param[in] uxCount: The byte count by which the mid pointer is to be moved. + * @param[in] pxBuffer The circular stream buffer. + * @param[in] uxCount The byte count by which the mid pointer is to be moved. */ void vStreamBufferMoveMid( StreamBuffer_t * pxBuffer, size_t uxCount ) @@ -202,9 +202,9 @@ void vStreamBufferMoveMid( StreamBuffer_t * pxBuffer, * @brief Check whether the value in left is less than or equal to the * value in right from the perspective of the circular stream * buffer. - * @param[in] pxBuffer: The circular stream buffer. - * @param[in] uxLeft: The left pointer in the stream buffer. - * @param[in] uxRight: The right value pointer in the stream buffer. + * @param[in] pxBuffer The circular stream buffer. + * @param[in] uxLeft The left pointer in the stream buffer. + * @param[in] uxRight The right value pointer in the stream buffer. * @return pdTRUE if uxLeft <= uxRight, else pdFALSE. */ BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t * pxBuffer, @@ -227,8 +227,8 @@ BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t * pxBuffer, /** * @brief Get the pointer to data and the amount of data which can be read in one go. * - * @param[in] pxBuffer: The circular stream buffer. - * @param[out] ppucData: Pointer to the data pointer which will point to the + * @param[in] pxBuffer The circular stream buffer. + * @param[out] ppucData Pointer to the data pointer which will point to the * data which can be read. * * @return The number of bytes which can be read in one go (which might be less than @@ -250,12 +250,12 @@ size_t uxStreamBufferGetPtr( StreamBuffer_t * pxBuffer, /** * @brief Adds data to a stream buffer. * - * @param[in,out] pxBuffer: The buffer to which the bytes will be added. - * @param[in] uxOffset: If uxOffset > 0, data will be written at an offset from uxHead + * @param[in,out] pxBuffer The buffer to which the bytes will be added. + * @param[in] uxOffset If uxOffset > 0, data will be written at an offset from uxHead * while uxHead will not be moved yet. - * @param[in,out] pucData: A pointer to the data to be added. If 'pucData' equals NULL, + * @param[in,out] pucData A pointer to the data to be added. If 'pucData' equals NULL, * the function is called to advance the 'Head' only. - * @param[in] uxByteCount: The number of bytes to add. + * @param[in] uxByteCount The number of bytes to add. * * @return The number of bytes added to the buffer. */ @@ -351,11 +351,11 @@ size_t uxStreamBufferAdd( StreamBuffer_t * pxBuffer, /** * @brief Read bytes from stream buffer. * - * @param[in] pxBuffer: The buffer from which the bytes will be read. - * @param[in] uxOffset: can be used to read data located at a certain offset from 'lTail'. - * @param[in,out] pucData: If 'pucData' equals NULL, the function is called to advance 'lTail' only. - * @param[in] uxMaxCount: The number of bytes to read. - * @param[in] xPeek: if 'xPeek' is pdTRUE, or if 'uxOffset' is non-zero, the 'lTail' pointer will + * @param[in] pxBuffer The buffer from which the bytes will be read. + * @param[in] uxOffset can be used to read data located at a certain offset from 'lTail'. + * @param[in,out] pucData If 'pucData' equals NULL, the function is called to advance 'lTail' only. + * @param[in] uxMaxCount The number of bytes to read. + * @param[in] xPeek if 'xPeek' is pdTRUE, or if 'uxOffset' is non-zero, the 'lTail' pointer will * not be advanced. * * @return The count of the bytes read. diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index f586a15b65..59c3f11d66 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -116,7 +116,7 @@ /** @brief Close the socket another time. * - * @param[in] pxSocket: The socket to be checked. + * @param[in] pxSocket The socket to be checked. */ /* coverity[single_use] */ void vSocketCloseNextTime( FreeRTOS_Socket_t * pxSocket ) @@ -132,7 +132,7 @@ /** @brief Postpone a call to FreeRTOS_listen() to avoid recursive calls. * - * @param[in] pxSocket: The socket to be checked. + * @param[in] pxSocket The socket to be checked. */ /* coverity[single_use] */ void vSocketListenNextTime( FreeRTOS_Socket_t * pxSocket ) @@ -150,7 +150,7 @@ * @brief As soon as a TCP socket timer expires, this function will be called * (from xTCPTimerCheck). It can send a delayed ACK or new data. * - * @param[in] pxSocket: socket to be checked. + * @param[in] pxSocket socket to be checked. * * @return 0 on success, a negative error code on failure. A negative value will be * returned in case the hang-protection has put the socket in a wait-close state. @@ -260,7 +260,7 @@ /** * @brief 'Touch' the socket to keep it alive/updated. * - * @param[in] pxSocket: The socket to be updated. + * @param[in] pxSocket The socket to be updated. * * @note This is used for anti-hanging protection and TCP keep-alive messages. * Called in two places: after receiving a packet and after a state change. @@ -293,8 +293,8 @@ * that a socket has got (dis)connected, and setting bit to unblock a call to * FreeRTOS_select(). * - * @param[in] pxSocket: The socket whose state we are trying to change. - * @param[in] eTCPState: The state to which we want to change to. + * @param[in] pxSocket The socket whose state we are trying to change. + * @param[in] eTCPState The state to which we want to change to. */ void vTCPStateChange( FreeRTOS_Socket_t * pxSocket, enum eTCP_STATE eTCPState ) @@ -317,7 +317,7 @@ /* A socket was in the connecting phase but something * went wrong and it should be closed. */ FreeRTOS_debug_printf( ( "Move from %s to %s\n", - FreeRTOS_GetTCPStateName( xPreviousState ), + FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ), FreeRTOS_GetTCPStateName( eTCPState ) ) ); /* Set the flag to show that it was connected before and that the @@ -542,7 +542,7 @@ /** * @brief Calculate after how much time this socket needs to be checked again. * - * @param[in] pxSocket: The socket to be checked. + * @param[in] pxSocket The socket to be checked. * * @return The number of clock ticks before the timer expires. */ @@ -614,7 +614,7 @@ /** * @brief Process the received TCP packet. * - * @param[in] pxDescriptor: The descriptor in which the TCP packet is held. + * @param[in] pxDescriptor The descriptor in which the TCP packet is held. * * @return If the processing of the packet was successful, then pdPASS is returned * or else pdFAIL. @@ -635,7 +635,6 @@ NetworkBufferDescriptor_t * pxNetworkBuffer = pxDescriptor; /* Map the buffer onto a ProtocolHeaders_t struct for easy access to the fields. */ - ProtocolHeaders_t * pxProtocolHeaders; FreeRTOS_Socket_t * pxSocket; uint16_t ucTCPFlags; @@ -894,7 +893,7 @@ * @brief In the API accept(), the user asks is there is a new client? As API's can * not walk through the xBoundTCPSocketsList the IP-task will do this. * - * @param[in] pxSocket: The socket for which the bound socket list will be iterated. + * @param[in] pxSocket The socket for which the bound socket list will be iterated. * * @return if there is a new client, then pdTRUE is returned or else, pdFALSE. */ diff --git a/source/FreeRTOS_TCP_Reception.c b/source/FreeRTOS_TCP_Reception.c index 99c2b685b4..9ce1c08c4d 100644 --- a/source/FreeRTOS_TCP_Reception.c +++ b/source/FreeRTOS_TCP_Reception.c @@ -82,8 +82,8 @@ /** * @brief Parse the TCP option(s) received, if present. * - * @param[in] pxSocket: The socket handling the connection. - * @param[in] pxNetworkBuffer: The network buffer containing the TCP + * @param[in] pxSocket The socket handling the connection. + * @param[in] pxNetworkBuffer The network buffer containing the TCP * packet. * * @return: If the options are well formed and processed successfully @@ -125,7 +125,7 @@ } else { - ucLength = ( ( ( pxTCPHeader->ucTCPOffset >> 4U ) - 5U ) << 2U ); + ucLength = ( uint8_t ) ( ( ( pxTCPHeader->ucTCPOffset >> 4U ) - 5U ) << 2U ); uxOptionsLength = ( size_t ) ucLength; if( pxNetworkBuffer->xDataLength > uxOptionOffset ) @@ -180,10 +180,10 @@ * @brief Identify and deal with a single TCP header option, advancing the pointer to * the header. * - * @param[in] pucPtr: Pointer to the TCP packet options. - * @param[in] uxTotalLength: Length of the TCP packet options. - * @param[in] pxSocket: Socket handling the connection. - * @param[in] xHasSYNFlag: Whether the header has SYN flag or not. + * @param[in] pucPtr Pointer to the TCP packet options. + * @param[in] uxTotalLength Length of the TCP packet options. + * @param[in] pxSocket Socket handling the connection. + * @param[in] xHasSYNFlag Whether the header has SYN flag or not. * * @return This function returns index of the next option if the current option is * successfully processed and it is not the end of options whereafter the caller @@ -365,9 +365,9 @@ * @brief Skip past TCP header options when doing Selective ACK, until there are no * more options left. * - * @param[in] pucPtr: Pointer to the TCP packet options. - * @param[in] uxIndex: Index of options in the TCP packet options. - * @param[in] pxSocket: Socket handling the TCP connection. + * @param[in] pucPtr Pointer to the TCP packet options. + * @param[in] uxIndex Index of options in the TCP packet options. + * @param[in] pxSocket Socket handling the TCP connection. */ static void prvReadSackOption( const uint8_t * const pucPtr, size_t uxIndex, @@ -419,8 +419,8 @@ * first thing that will be done is find the TCP payload data * and check the length of this data. * - * @param[in] pxNetworkBuffer: The network buffer holding the received data. - * @param[out] ppucRecvData: It will point to first byte of the TCP payload. + * @param[in] pxNetworkBuffer The network buffer holding the received data. + * @param[out] ppucRecvData It will point to first byte of the TCP payload. * * @return Length of the received buffer. */ @@ -509,10 +509,10 @@ * The second thing is to do is check if the payload data may * be accepted. If so, they will be added to the reception queue. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in] pucRecvData: Pointer to received data. - * @param[in] pxNetworkBuffer: The network buffer descriptor. - * @param[in] ulReceiveLength: The length of the received data. + * @param[in] pxSocket The socket owning the connection. + * @param[in] pucRecvData Pointer to received data. + * @param[in] pxNetworkBuffer The network buffer descriptor. + * @param[in] ulReceiveLength The length of the received data. * * @return 0 on success, -1 on failure of storing data. */ diff --git a/source/FreeRTOS_TCP_State_Handling.c b/source/FreeRTOS_TCP_State_Handling.c index f1551959ef..fe893853d1 100644 --- a/source/FreeRTOS_TCP_State_Handling.c +++ b/source/FreeRTOS_TCP_State_Handling.c @@ -94,7 +94,7 @@ /** * @brief Check whether the socket is active or not. * - * @param[in] ucStatus: The status of the socket. + * @param[in] eStatus The status of the socket. * * @return pdTRUE if the socket must be checked. Non-active sockets * are waiting for user action, either connect() or close(). @@ -138,7 +138,7 @@ * This function checks if the socket is 'hanging', i.e. staying * too long in the same state. * - * @param[in] The socket to be checked. + * @param[in] pxSocket the socket to be checked. * * @return pdFALSE if no checks are needed, pdTRUE if checks were done, or negative * in case the socket has reached a critical time-out. The socket will go to @@ -230,8 +230,8 @@ * called, it has been checked that both reception and transmission * are complete. * - * @param[in] pxSocket: Socket owning the the connection. - * @param[in] pxNetworkBuffer: The network buffer carrying the TCP packet. + * @param[in] pxSocket Socket owning the the connection. + * @param[in] pxNetworkBuffer The network buffer carrying the TCP packet. * * @return Length of the packet to be sent. */ @@ -340,11 +340,11 @@ * from the states: eSYN_RECEIVED and eCONNECT_SYN. If the flags * received are correct, the socket will move to eESTABLISHED. * - * @param[in] pxSocket: The socket handling the connection. - * @param[in] pxNetworkBuffer: The pointer to the network buffer carrying + * @param[in] pxSocket The socket handling the connection. + * @param[in] pxNetworkBuffer The pointer to the network buffer carrying * the packet. - * @param[in] ulReceiveLength: Length in bytes of the data received. - * @param[in] uxOptionsLength: Length of the TCP options in bytes. + * @param[in] ulReceiveLength Length in bytes of the data received. + * @param[in] uxOptionsLength Length of the TCP options in bytes. * * @return Length of the data to be sent. */ @@ -489,10 +489,10 @@ * the code will check if it may be accepted, i.e. if all expected data has been * completely received. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in,out] ppxNetworkBuffer: Pointer to pointer to the network buffer. - * @param[in] ulReceiveLength: The length of the received packet. - * @param[in] uxOptionsLength: Length of TCP options. + * @param[in] pxSocket The socket owning the connection. + * @param[in,out] ppxNetworkBuffer Pointer to pointer to the network buffer. + * @param[in] ulReceiveLength The length of the received packet. + * @param[in] uxOptionsLength Length of TCP options. * * @return The send length of the packet to be sent. */ @@ -682,8 +682,8 @@ * @brief Check incoming packets for valid data and handle the state of the * TCP connection and respond according to the situation. * - * @param[in] pxSocket: The socket whose connection state is being handled. - * @param[in] ppxNetworkBuffer: The network buffer descriptor holding the + * @param[in] pxSocket The socket whose connection state is being handled. + * @param[in] ppxNetworkBuffer The network buffer descriptor holding the * packet received from the peer. * * @return If the data is correct and some packet was sent to the peer, then @@ -901,8 +901,8 @@ /** * @brief Handle 'listen' event on the given socket. * - * @param[in] pxSocket: The socket on which the listen occurred. - * @param[in] pxNetworkBuffer: The network buffer carrying the packet. + * @param[in] pxSocket The socket on which the listen occurred. + * @param[in] pxNetworkBuffer The network buffer carrying the packet. * * @return If a new socket/duplicate socket is created, then the pointer to * that socket is returned or else, a NULL pointer is returned. @@ -1030,8 +1030,8 @@ * the new socket to the same port as the listening socket. * Also, let the new socket inherit all properties from the listening socket. * - * @param[in] pxNewSocket: Pointer to the new socket. - * @param[in] pxSocket: Pointer to the socket being duplicated. + * @param[in] pxNewSocket Pointer to the new socket. + * @param[in] pxSocket Pointer to the socket being duplicated. * * @return If all steps all successful, then pdTRUE is returned. Else, pdFALSE. */ diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index bf1be23700..5a581e358d 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -82,7 +82,7 @@ /** * @brief Check if the outgoing connection is already prepared, if not * call prvTCPPrepareConnect() to continue the preparation. - * @param[in] pxSocket: The socket that wants to connect. + * @param[in] pxSocket The socket that wants to connect. * @return Returns pdTRUE if the connection is prepared, i.e. the MAC- * address of the peer is already known. */ static BaseType_t prvTCPMakeSurePrepared( FreeRTOS_Socket_t * pxSocket ) @@ -105,7 +105,7 @@ /** * @brief prvTCPSendPacket() will be called when the socket time-out has been reached. * - * @param[in] pxSocket: The socket owning the connection. + * @param[in] pxSocket The socket owning the connection. * * @return Number of bytes to be sent. * @@ -198,8 +198,8 @@ * long as there is data to be sent and as long as the transmit * window isn't full. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in,out] ppxNetworkBuffer: Pointer to pointer to the network buffer. + * @param[in] pxSocket The socket owning the connection. + * @param[in,out] ppxNetworkBuffer Pointer to pointer to the network buffer. * * @return Total number of bytes sent. */ @@ -245,10 +245,10 @@ * called 'xTCP.xPacket'. A temporary xNetworkBuffer will be used to pass * the data to the NIC. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in] pxDescriptor: The network buffer descriptor carrying the packet. - * @param[in] ulLen: Length of the packet being sent. - * @param[in] xReleaseAfterSend: pdTRUE if the ownership of the descriptor is + * @param[in] pxSocket The socket owning the connection. + * @param[in] pxDescriptor The network buffer descriptor carrying the packet. + * @param[in] ulLen Length of the packet being sent. + * @param[in] xReleaseAfterSend pdTRUE if the ownership of the descriptor is * transferred to the network interface. */ void prvTCPReturnPacket( FreeRTOS_Socket_t * pxSocket, @@ -552,7 +552,7 @@ /** * @brief Create the TCP window for the given socket. * - * @param[in] pxSocket: The socket for which the window is being created. + * @param[in] pxSocket The socket for which the window is being created. * * @note The SYN event is very important: the sequence numbers, which have a kind of * random starting value, are being synchronized. The sliding window manager @@ -587,7 +587,7 @@ * @brief Let ARP look-up the MAC-address of the peer and initialise the first SYN * packet. * - * @param[in] pxSocket: The socket owning the TCP connection. The first packet shall + * @param[in] pxSocket The socket owning the TCP connection. The first packet shall * be created in this socket. * * @return pdTRUE: if the packet was successfully created and the first SYN can be sent. @@ -741,7 +741,7 @@ /** * @brief Get the window scaling factor for the TCP connection. * - * @param[in] pxSocket: The socket owning the TCP connection. + * @param[in] pxSocket The socket owning the TCP connection. * * @return The scaling factor. */ @@ -778,9 +778,9 @@ * communicate what MSS (Maximum Segment Size) they intend to use, whether Selective * ACK's ( SACK ) are supported, and the size of the reception window ( WSOPT ). * - * @param[in] pxSocket: The socket being used for communication. It is used to set + * @param[in] pxSocket The socket being used for communication. It is used to set * the MSS. - * @param[in,out] pxTCPHeader: The TCP packet header being used in the SYN transmission. + * @param[in,out] pxTCPHeader The TCP packet header being used in the SYN transmission. * The MSS and corresponding options shall be set in this * header itself. * @@ -833,10 +833,10 @@ * @brief Check if the size of a network buffer is big enough to hold the outgoing message. * Allocate a new bigger network buffer when necessary. * - * @param[in] pxSocket: Socket whose buffer is being resized. - * @param[in] pxNetworkBuffer: The network buffer whose size is being increased. - * @param[in] lDataLen: Length of the data to be put in the buffer. - * @param[in] uxOptionsLength: Length of options. + * @param[in] pxSocket Socket whose buffer is being resized. + * @param[in] pxNetworkBuffer The network buffer whose size is being increased. + * @param[in] lDataLen Length of the data to be put in the buffer. + * @param[in] uxOptionsLength Length of options. * * @return If the resizing is successful: The new buffer with the size being asked for * with old data copied in it. @@ -939,9 +939,9 @@ /** * @brief Prepare an outgoing message, in case anything has to be sent. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in,out] ppxNetworkBuffer: Pointer to the pointer to the network buffer. - * @param[in] uxOptionsLength: The length of the TCP options. + * @param[in] pxSocket The socket owning the connection. + * @param[in,out] ppxNetworkBuffer Pointer to the pointer to the network buffer. + * @param[in] uxOptionsLength The length of the TCP options. * * @return Length of the data to be sent if everything is correct. Else, -1 * is returned in case of any error. @@ -1161,7 +1161,7 @@ * @brief The API FreeRTOS_send() adds data to the TX stream. Add * this data to the windowing system to it can be transmitted. * - * @param[in] pxSocket: The socket owning the connection. + * @param[in] pxSocket The socket owning the connection. */ void prvTCPAddTxData( FreeRTOS_Socket_t * pxSocket ) { @@ -1201,8 +1201,8 @@ /** * @brief Set the TCP options (if any) for the outgoing packet. * - * @param[in] pxSocket: The socket owning the connection. - * @param[in] pxNetworkBuffer: The network buffer holding the packet. + * @param[in] pxSocket The socket owning the connection. + * @param[in] pxNetworkBuffer The network buffer holding the packet. * * @return Length of the TCP options after they are set. */ @@ -1287,10 +1287,10 @@ * ipconfigUSE_TCP_WIN is defined, and if only an ACK must be sent, it will be * checked if it would better be postponed for efficiency. * - * @param[in] pxSocket: The socket owning the TCP connection. - * @param[in] ppxNetworkBuffer: Pointer to pointer to the network buffer. - * @param[in] ulReceiveLength: The length of the received buffer. - * @param[in] xByteCount: Length of the data to be sent. + * @param[in] pxSocket The socket owning the TCP connection. + * @param[in] ppxNetworkBuffer Pointer to pointer to the network buffer. + * @param[in] ulReceiveLength The length of the received buffer. + * @param[in] xByteCount Length of the data to be sent. * * @return The number of bytes actually sent. */ @@ -1441,8 +1441,8 @@ * @brief Common code for sending a TCP protocol control packet (i.e. no options, no * payload, just flags). * - * @param[in] pxNetworkBuffer: The network buffer received from the peer. - * @param[in] ucTCPFlags: The flags to determine what kind of packet this is. + * @param[in] pxNetworkBuffer The network buffer received from the peer. + * @param[in] ucTCPFlags The flags to determine what kind of packet this is. * * @return pdFAIL always indicating that the packet was not consumed. */ @@ -1491,7 +1491,7 @@ * case #3. In summary, an RST was received with a sequence number that is * unexpected but still within the window. * - * @param[in] pxNetworkBuffer: The network buffer descriptor with the packet. + * @param[in] pxNetworkBuffer The network buffer descriptor with the packet. * * @return Returns the value back from #prvTCPSendSpecialPacketHelper. */ @@ -1504,7 +1504,7 @@ /** * @brief Send a RST (Reset) to peer in case the packet cannot be handled. * - * @param[in] pxNetworkBuffer: The network buffer descriptor with the packet. + * @param[in] pxNetworkBuffer The network buffer descriptor with the packet. * * @return Returns the value back from #prvTCPSendSpecialPacketHelper. */ diff --git a/source/FreeRTOS_TCP_Utils.c b/source/FreeRTOS_TCP_Utils.c index 7b5f81c6a0..14ccf551e9 100644 --- a/source/FreeRTOS_TCP_Utils.c +++ b/source/FreeRTOS_TCP_Utils.c @@ -53,15 +53,15 @@ */ #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) + static char retString[ 10 ]; + /** * @brief Print out the value of flags in a human readable manner. * - * @param[in] xFlags: The TCP flags. + * @param[in] xFlags The TCP flags. * * @return The string containing the flags. */ - - static char retString[ 10 ]; const char * prvTCPFlagMeaning( UBaseType_t xFlags ) { size_t uxFlags = ( size_t ) xFlags; @@ -85,7 +85,7 @@ /** * @brief Set the MSS (Maximum segment size) associated with the given socket. * - * @param[in] pxSocket: The socket whose MSS is to be set. + * @param[in] pxSocket The socket whose MSS is to be set. */ void prvSocketSetMSS( FreeRTOS_Socket_t * pxSocket ) { diff --git a/source/FreeRTOS_TCP_WIN.c b/source/FreeRTOS_TCP_WIN.c index 863d70623d..a4aa300328 100644 --- a/source/FreeRTOS_TCP_WIN.c +++ b/source/FreeRTOS_TCP_WIN.c @@ -229,8 +229,8 @@ /** * @brief Check if a <= b. * - * @param[in] a: The value on the left-hand side. - * @param[in] b: The value on the right-hand side. + * @param[in] a The value on the left-hand side. + * @param[in] b The value on the right-hand side. * * @return pdTRUE when "( b - a ) < 0x80000000". Else, pdFALSE. */ @@ -256,8 +256,8 @@ /** * @brief Check if a < b. * - * @param[in] a: The value on the left-hand side. - * @param[in] b: The value on the right-hand side. + * @param[in] a The value on the left-hand side. + * @param[in] b The value on the right-hand side. * * @return pdTRUE when "( b - ( a + 1 ) ) < 0x80000000", else pdFALSE. */ @@ -280,8 +280,8 @@ /** * @brief Check if a > b. * - * @param[in] a: The value on the left-hand side. - * @param[in] b: The value on the right-hand side. + * @param[in] a The value on the left-hand side. + * @param[in] b The value on the right-hand side. * * @return pdTRUE when "( a - b ) < 0x80000000", else pdFALSE. */ @@ -307,8 +307,8 @@ /** * @brief Test if a>=b. This function is required since the sequence numbers can roll over. * - * @param[in] a: The first sequence number. - * @param[in] b: The second sequence number. + * @param[in] a The first sequence number. + * @param[in] b The second sequence number. * * @return pdTRUE if a>=b, else pdFALSE. */ @@ -334,8 +334,8 @@ /** * @brief Insert the given item in the list in FIFO manner. * - * @param[in] pxList: The list in which the item is to inserted. - * @param[in] pxNewListItem: The item to be inserted. + * @param[in] pxList The list in which the item is to inserted. + * @param[in] pxNewListItem The item to be inserted. */ static portINLINE void vListInsertFifo( List_t * const pxList, ListItem_t * const pxNewListItem ) @@ -350,7 +350,7 @@ /** * @brief Set the timer's "born" time. * - * @param[in] pxTimer: The TCP timer. + * @param[in] pxTimer The TCP timer. */ static portINLINE void vTCPTimerSet( TCPTimer_t * pxTimer ) { @@ -363,7 +363,7 @@ /** * @brief Get the timer age in milliseconds. * - * @param[in] pxTimer: The timer whose age is to be fetched. + * @param[in] pxTimer The timer whose age is to be fetched. * * @return The time in milliseconds since the timer was born. */ @@ -372,16 +372,16 @@ TickType_t uxNow = xTaskGetTickCount(); TickType_t uxDiff = uxNow - pxTimer->uxBorn; - return uxDiff * portTICK_PERIOD_MS; + return ( uint32_t ) ( uxDiff * portTICK_PERIOD_MS ); } /*-----------------------------------------------------------*/ /** * @brief Insert a new list item into a list. * - * @param[in] pxList: The list in which the item is to be inserted. - * @param[in] pxNewListItem: The item to be inserted. - * @param[in] pxWhere: Where should the item be inserted. + * @param[in] pxList The list in which the item is to be inserted. + * @param[in] pxNewListItem The item to be inserted. + * @param[in] pxWhere Where should the item be inserted. */ static void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewListItem, @@ -468,8 +468,8 @@ /** * @brief Find a segment with a given sequence number in the list of received segments. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulSequenceNumber: the sequence number to look-up + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulSequenceNumber the sequence number to look-up * * @return The address of the segment descriptor found, or NULL when not found. */ @@ -511,10 +511,10 @@ /** * @brief Allocate a new segment object, either for transmission or reception. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulSequenceNumber: The sequence number. - * @param[in] lCount: The number of bytes stored in this segment. - * @param[in] xIsForRx: True when this is a reception segment. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulSequenceNumber The sequence number. + * @param[in] lCount The number of bytes stored in this segment. + * @param[in] xIsForRx True when this is a reception segment. * * @return Allocate and initialise a segment descriptor, or NULL when none was available. */ @@ -589,7 +589,7 @@ /** * @brief See if the peer has more packets for this node, before allowing to shut down the connection. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. + * @param[in] pxWindow The descriptor of the TCP sliding windows. * * @return pdTRUE if the connection can be closed. Else, pdFALSE. */ @@ -631,7 +631,7 @@ /** * @brief Remove the head item of a list (generic function). * - * @param[in] pxList: The list of segment descriptors. + * @param[in] pxList The list of segment descriptors. * * @return The address of the segment descriptor, or NULL when not found. */ @@ -663,7 +663,7 @@ /** * @brief Return the head item of a list (generic function). * - * @param[in] pxList: The list of segment descriptors. + * @param[in] pxList The list of segment descriptors. * * @return The address of the segment descriptor, or NULL when the list is empty. */ @@ -693,7 +693,7 @@ /** * @brief Release a segment object, return it to the list of available segment holders. * - * @param[in] pxSegment: The segment descriptor that must be freed. + * @param[in] pxSegment The segment descriptor that must be freed. */ static void vTCPWindowFree( TCPSegment_t * pxSegment ) { @@ -727,7 +727,7 @@ /** * @brief Return all segment descriptor to the poll of descriptors, before deleting a socket. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. + * @param[in] pxWindow The descriptor of the TCP sliding windows. */ void vTCPWindowDestroy( TCPWindow_t const * pxWindow ) { @@ -766,12 +766,12 @@ /** * @brief Create a window for TCP. * - * @param[in] pxWindow: The window to be created. - * @param[in] ulRxWindowLength: The length of the receive window. - * @param[in] ulTxWindowLength: The length of the transmit window. - * @param[in] ulAckNumber: The first ACK number. - * @param[in] ulSequenceNumber: The first sequence number. - * @param[in] ulMSS: The MSS of the connection. + * @param[in] pxWindow The window to be created. + * @param[in] ulRxWindowLength The length of the receive window. + * @param[in] ulTxWindowLength The length of the transmit window. + * @param[in] ulAckNumber The first ACK number. + * @param[in] ulSequenceNumber The first sequence number. + * @param[in] ulMSS The MSS of the connection. */ void vTCPWindowCreate( TCPWindow_t * pxWindow, uint32_t ulRxWindowLength, @@ -814,10 +814,10 @@ /** * @brief Initialise a TCP window. * - * @param[in] pxWindow: The window to be initialised. - * @param[in] ulAckNumber: The number of the first ACK. - * @param[in] ulSequenceNumber: The first sequence number. - * @param[in] ulMSS: The MSS of the connection. + * @param[in] pxWindow The window to be initialised. + * @param[in] ulAckNumber The number of the first ACK. + * @param[in] ulSequenceNumber The first sequence number. + * @param[in] ulMSS The MSS of the connection. */ void vTCPWindowInit( TCPWindow_t * pxWindow, uint32_t ulAckNumber, @@ -915,9 +915,9 @@ /** * @brief A expected segment has been received, see if there is overlap with earlier segments. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulSequenceNumber: The sequence number of the segment that was received. - * @param[in] ulLength: The number of bytes that were received. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulSequenceNumber The sequence number of the segment that was received. + * @param[in] ulLength The number of bytes that were received. * * @return The first segment descriptor involved, or NULL when no matching descriptor was found. */ @@ -987,8 +987,8 @@ /** * @brief Data has been received with the correct ( expected ) sequence number. * It can be added to the RX stream buffer. - * @param[in] pxWindow: The TCP sliding window data of the socket. - * @param[in] ulLength: The number of bytes that can be added. + * @param[in] pxWindow The TCP sliding window data of the socket. + * @param[in] ulLength The number of bytes that can be added. */ static void prvTCPWindowRx_ExpectedRX( TCPWindow_t * pxWindow, uint32_t ulLength ) @@ -1063,9 +1063,9 @@ /** * @brief Data has been received with a non-expected sequence number. * This function will check if the RX data can be accepted. - * @param[in] pxWindow: The TCP sliding window data of the socket. - * @param[in] ulSequenceNumber: The sequence number at which the data should be placed. - * @param[in] ulLength: The number of bytes that can be added. + * @param[in] pxWindow The TCP sliding window data of the socket. + * @param[in] ulSequenceNumber The sequence number at which the data should be placed. + * @param[in] ulLength The number of bytes that can be added. * @return Return -1 if the data must be refused, otherwise it returns the * offset ( from the head ) at which the data can be placed. */ @@ -1174,11 +1174,11 @@ /** * @brief Check what to do with a new incoming packet: store or ignore. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulSequenceNumber: The sequence number of the packet received. - * @param[in] ulLength: The number of bytes received. - * @param[in] ulSpace: The available space in the RX stream buffer. - * @param[out] pulSkipCount: the number of bytes to skip in the receive buffer. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulSequenceNumber The sequence number of the packet received. + * @param[in] ulLength The number of bytes received. + * @param[in] ulSpace The available space in the RX stream buffer. + * @param[out] pulSkipCount the number of bytes to skip in the receive buffer. * * @return 0 or positive value indicating the offset at which the packet is to * be stored, -1 if the packet is to be ignored. @@ -1320,9 +1320,9 @@ /** * @brief Increment the position in a circular buffer of size 'lMax'. * - * @param[in] lPosition: The current index in the buffer. - * @param[in] lMax: The total number of items in this buffer. - * @param[in] lCount: The number of bytes that must be advanced. + * @param[in] lPosition The current index in the buffer. + * @param[in] lMax The total number of items in this buffer. + * @param[in] lCount The number of bytes that must be advanced. * * @return The new incremented position, or "( lPosition + lCount ) % lMax". */ @@ -1353,10 +1353,10 @@ * @brief Adding data to a segment that was already in the TX queue. It * will be filled-up to a maximum of MSS ( maximum segment size ). * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] pxSegment: The TX segment with the highest sequence number, + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] pxSegment The TX segment with the highest sequence number, * i.e. the "front segment". - * @param[in] lBytesLeft: The number of bytes that must be added. + * @param[in] lBytesLeft The number of bytes that must be added. * * @return lToWrite: the number of bytes added to the segment. */ @@ -1400,10 +1400,10 @@ /** * @brief Will add data to be transmitted to the front of the segment fifo. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulLength: The number of bytes that will be sent. - * @param[in] lPosition: The index in the TX stream buffer. - * @param[in] lMax: The size of the ( circular ) TX stream buffer. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulLength The number of bytes that will be sent. + * @param[in] lPosition The index in the TX stream buffer. + * @param[in] lMax The size of the ( circular ) TX stream buffer. * * @return The number of bytes added to the sliding window for transmission. * @@ -1492,7 +1492,7 @@ /** * @brief Returns true if there are no more outstanding TX segments. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. + * @param[in] pxWindow The descriptor of the TCP sliding windows. * * @return pdTRUE if there are no more outstanding Tx segments, else pdFALSE. */ @@ -1508,8 +1508,8 @@ /** * @brief Find out if the peer is able to receive more data. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulWindowSize: The number of bytes in this segment. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulWindowSize The number of bytes in this segment. * * @return True if the peer has space in it window to receive more data. */ @@ -1578,9 +1578,9 @@ /** * @brief Returns true if there is TX data that can be sent right now. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulWindowSize: The current size of the sliding RX window of the peer. - * @param[out] pulDelay: The delay before the packet may be sent. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulWindowSize The current size of the sliding RX window of the peer. + * @param[out] pulDelay The delay before the packet may be sent. * * @return pdTRUE if there is Tx data that can be sent, else pdFALSE. */ @@ -1669,7 +1669,7 @@ * @brief Three type of queues are used for transmission: priority, waiting, and * the normal TX queue of unsent data. Message in the waiting queue will * be sent when their timer has expired. - * @param[in] pxWindow: The descriptor of the TCP sliding windows. + * @param[in] pxWindow The descriptor of the TCP sliding windows. */ static TCPSegment_t * pxTCPWindowTx_GetWaitQueue( const TCPWindow_t * pxWindow ) { @@ -1720,8 +1720,8 @@ * @brief See if there is a transmission in the normal TX queue. It is the * first time these data are being sent. After sending they will move * the waiting queue. - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulWindowSize: The available space that the peer has in his + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulWindowSize The available space that the peer has in his * reception window. * @return Either a segment that has to be sent, or NULL. */ @@ -1787,9 +1787,9 @@ * @brief Get data that can be transmitted right now. There are three types of * outstanding segments: Priority queue, Waiting queue, Normal TX queue. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulWindowSize: The current size of the sliding RX window of the peer. - * @param[out] plPosition: The index within the TX stream buffer of the first byte to be sent. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulWindowSize The current size of the sliding RX window of the peer. + * @param[out] plPosition The index within the TX stream buffer of the first byte to be sent. * * @return The amount of data in bytes that can be transmitted right now. */ @@ -1891,8 +1891,8 @@ * of the round-trip time, and calculate the new timeout for transmissions. * More explanation in a comment here below. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] pxSegment: The segment that was just acknowledged. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] pxSegment The segment that was just acknowledged. */ static void prvTCPWindowTxCheckAck_CalcSRTT( TCPWindow_t * pxWindow, const TCPSegment_t * pxSegment ) @@ -1927,9 +1927,9 @@ * ( ( ulSequenceNumber >= ulFirst ) && ( ulSequenceNumber < ulLast ) in a contiguous block. * Note that the segments are stored in xTxSegments in a strict sequential order. * - * @param[in] pxWindow: The TCP-window object of the current connection. - * @param[in] ulFirst: The sequence number of the first byte that was acknowledged. - * @param[in] ulLast: The sequence number of the last byte ( minus one ) that was acknowledged. + * @param[in] pxWindow The TCP-window object of the current connection. + * @param[in] ulFirst The sequence number of the first byte that was acknowledged. + * @param[in] ulLast The sequence number of the last byte ( minus one ) that was acknowledged. * * @return number of bytes that the tail of txStream may be advanced. */ @@ -2081,8 +2081,8 @@ /** * @brief See if there are segments that need a fast retransmission. * - * @param[in] pxWindow: The descriptor of the TCP sliding windows. - * @param[in] ulFirst: The sequence number of the first segment that must be checked. + * @param[in] pxWindow The descriptor of the TCP sliding windows. + * @param[in] ulFirst The sequence number of the first segment that must be checked. * * @return The number of segments that need a fast retransmission. */ @@ -2158,8 +2158,8 @@ /** * @brief Receive a normal ACK. * - * @param[in] pxWindow: Window in which a data is receive. - * @param[in] ulSequenceNumber: The sequence number of the ACK. + * @param[in] pxWindow Window in which a data is receive. + * @param[in] ulSequenceNumber The sequence number of the ACK. * * @return The location where the packet should be added. */ @@ -2192,9 +2192,9 @@ /** * @brief Receive a SACK option. * - * @param[in] pxWindow: Window in which the data is received. - * @param[in] ulFirst: Index of starting position of options. - * @param[in] ulLast: Index of end position of the options. + * @param[in] pxWindow Window in which the data is received. + * @param[in] ulFirst Index of starting position of options. + * @param[in] ulLast Index of end position of the options. * * @return returns the number of bytes which have been acked starting from * the head position. diff --git a/source/FreeRTOS_Tiny_TCP.c b/source/FreeRTOS_Tiny_TCP.c index fc60c491a5..2778b7083b 100644 --- a/source/FreeRTOS_Tiny_TCP.c +++ b/source/FreeRTOS_Tiny_TCP.c @@ -77,8 +77,8 @@ /** * @brief Test if a>=b. This function is required since the sequence numbers can roll over. * - * @param[in] a: The first sequence number. - * @param[in] b: The second sequence number. + * @param[in] a The first sequence number. + * @param[in] b The second sequence number. * * @return pdTRUE if a>=b, else pdFALSE. */ @@ -102,7 +102,7 @@ /** * @brief Set the timer's "born" time. * - * @param[in] pxTimer: The TCP timer. + * @param[in] pxTimer The TCP timer. */ static portINLINE void vTCPTimerSet( TCPTimer_t * pxTimer ) { @@ -115,7 +115,7 @@ /** * @brief Get the timer age in milliseconds. * - * @param[in] pxTimer: The timer whose age is to be fetched. + * @param[in] pxTimer The timer whose age is to be fetched. * * @return The time in milliseconds since the timer was born. */ @@ -132,10 +132,10 @@ * @brief Data was received at 'ulSequenceNumber'. See if it was expected * and if there is enough space to store the new data. * - * @param[in] pxWindow: The window to be checked. - * @param[in] ulSequenceNumber: Sequence number of the data received. - * @param[in] ulLength: Length of the data received. - * @param[in] ulSpace: Space in the buffer. + * @param[in] pxWindow The window to be checked. + * @param[in] ulSequenceNumber Sequence number of the data received. + * @param[in] ulLength Length of the data received. + * @param[in] ulSpace Space in the buffer. * * @return A 0 is returned if there is enough space and the sequence number is correct, * if not then a -1 is returned. @@ -175,10 +175,10 @@ /** * @brief Add data to the Tx Window. * - * @param[in] pxWindow: The window to which the data is to be added. - * @param[in] ulLength: The length of the data to be added. - * @param[in] lPosition: Position in the stream. - * @param[in] lMax: Size of the Tx stream. + * @param[in] pxWindow The window to which the data is to be added. + * @param[in] ulLength The length of the data to be added. + * @param[in] lPosition Position in the stream. + * @param[in] lMax Size of the Tx stream. * * @return The data actually added. */ @@ -244,9 +244,9 @@ /** * @brief Fetches data to be sent. * - * @param[in] pxWindow: The window for the connection. - * @param[in] ulWindowSize: The size of the window. - * @param[out] plPosition: plPosition will point to a location with the circular data buffer: txStream. + * @param[in] pxWindow The window for the connection. + * @param[in] ulWindowSize The size of the window. + * @param[out] plPosition plPosition will point to a location with the circular data buffer: txStream. * * @return return the amount of data which may be sent along with the position in the txStream. */ @@ -295,7 +295,7 @@ /** * @brief Has the transmission completed. * - * @param[in] pxWindow: The window whose transmission window is to be checked. + * @param[in] pxWindow The window whose transmission window is to be checked. * * @return If there is no outstanding data then pdTRUE is returned, * else pdFALSE. @@ -326,8 +326,8 @@ /** * @brief Check if the window has space for one message. * - * @param[in] pxWindow: The window to be checked. - * @param[in] ulWindowSize: Size of the window. + * @param[in] pxWindow The window to be checked. + * @param[in] ulWindowSize Size of the window. * * @return pdTRUE if the window has space, pdFALSE otherwise. */ @@ -355,9 +355,9 @@ /** * @brief Check data to be sent and calculate the time period the process may sleep. * - * @param[in] pxWindow: The window to be checked. - * @param[in] ulWindowSize: Size of the window. - * @param[out] pulDelay: The time period (in ticks) that the process may sleep. + * @param[in] pxWindow The window to be checked. + * @param[in] ulWindowSize Size of the window. + * @param[out] pulDelay The time period (in ticks) that the process may sleep. * * @return pdTRUE if the process should sleep or pdFALSE. */ @@ -412,8 +412,8 @@ /** * @brief Receive a normal ACK. * - * @param[in] pxWindow: The window for this particular connection. - * @param[in] ulSequenceNumber: The sequence number of the packet. + * @param[in] pxWindow The window for this particular connection. + * @param[in] ulSequenceNumber The sequence number of the packet. * * @return Number of bytes to send. */ @@ -466,7 +466,7 @@ * @brief This function will be called as soon as a FIN is received to check * whether all transmit queues are empty or not. * - * @param[in] pxWindow: The window to be checked. + * @param[in] pxWindow The window to be checked. * * @return It will return true if there are no 'open' reception segments. */ @@ -485,7 +485,7 @@ /** * @brief Destroy a window. * - * @param[in] pxWindow: Pointer to the window to be destroyed. + * @param[in] pxWindow Pointer to the window to be destroyed. * * @return Always returns a NULL. */ diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index 43865d9e67..1438cb067e 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -89,7 +89,7 @@ UDPPacketHeader_t xDefaultPartUDPPacketHeader = * @brief Process the generated UDP packet and do other checks before sending the * packet such as ARP cache check and address resolution. * - * @param[in] pxNetworkBuffer: The network buffer carrying the packet. + * @param[in] pxNetworkBuffer The network buffer carrying the packet. */ void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) { @@ -297,9 +297,9 @@ void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuff /** * @brief Process the received UDP packet. * - * @param[in] pxNetworkBuffer: The network buffer carrying the UDP packet. - * @param[in] usPort: The port number on which this packet was received. - * @param[out] pxIsWaitingForARPResolution: If the packet is awaiting ARP resolution, + * @param[in] pxNetworkBuffer The network buffer carrying the UDP packet. + * @param[in] usPort The port number on which this packet was received. + * @param[out] pxIsWaitingForARPResolution If the packet is awaiting ARP resolution, * this pointer will be set to pdTRUE. pdFALSE otherwise. * * @return pdPASS in case the UDP packet could be processed. Else pdFAIL is returned. diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index e14c19098f..e92bbd31b5 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -400,10 +400,10 @@ extern const BaseType_t xBufferAllocFixedSize; #define SOCKET_EVENT_BIT_COUNT 8 #define vSetField16( pxBase, xType, xField, usValue ) \ - { \ + do { \ ( ( uint8_t * ) ( pxBase ) )[ offsetof( xType, xField ) + 0 ] = ( uint8_t ) ( ( usValue ) >> 8 ); \ ( ( uint8_t * ) ( pxBase ) )[ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( usValue ) & 0xffU ); \ - } + } while( ipFALSE_BOOL ) #define vSetField32( pxBase, xType, xField, ulValue ) \ { \ diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index 30fea81c63..017e08e715 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -119,8 +119,6 @@ void vLoggingPrintf( char const * pcFormat, ... ); -/* The function that implements FreeRTOS printf style output, and the macro - * that maps the configPRINTF() macros to that function. */ #define configPRINTF( X ) vLoggingPrintf X /* Non-format version thread-safe print. */ From a3f418a20dd05c5aecb362f52ee7344a606ac766 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Thu, 30 Mar 2023 04:08:45 +0000 Subject: [PATCH 33/44] uncrustify yml fix (#815) --- .github/workflows/ci.yml | 7 ++++--- .github/workflows/uncrustify.yml | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d755e4fcd2..83288878c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,11 +71,12 @@ jobs: formatting: # Use only 18.04 since we want the uncrustify version to # be 0.66.1_f to ensure proper formatting. - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 + container: ubuntu:18.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install Uncrustify - run: sudo apt-get install uncrustify + run: apt-get update && apt-get install uncrustify - name: Run Uncrustify run: | uncrustify --version diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml index 01bf905be4..2e492b8ba6 100644 --- a/.github/workflows/uncrustify.yml +++ b/.github/workflows/uncrustify.yml @@ -8,7 +8,8 @@ jobs: Uncrustify: name: Run_Uncrustify if: ${{ github.event.issue.pull_request && github.event.comment.body == '/bot run uncrustify' }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 + container: ubuntu:18.04 steps: - name: Dump GitHub context env: @@ -29,17 +30,16 @@ jobs: run: | echo ${{ steps.upstreamrepo.outputs.RemoteRepo }}:${{ steps.upstreambranch.outputs.branchname }} - name: Checkout upstream repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} ref: ${{ steps.upstreambranch.outputs.branchname }} - name: Install Uncrustify - run: sudo apt-get install uncrustify + run: apt-get update && apt-get install uncrustify - name: Run Uncrustify run: | uncrustify --version find . -iname "*.[hc]" -exec uncrustify -c tools/uncrustify.cfg --no-backup --replace {} + - find . -iname "*.[hc]" -exec uncrustify -c tools/uncrustify.cfg --no-backup --replace {} + - name: Push changes to upstream repository run: | git config --global user.name 'GitHub Action' From f7d6921321843ceaa5d190ebc1159d4bbb3ec81b Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 31 Mar 2023 15:15:39 +0000 Subject: [PATCH 34/44] Add NetworkDown notification to NetworkInterface.c [PR: #671] (#812) * Add NetworkDown notification to EMAC task * Add NetworkDown notification to NetworkInterface.c * Uncrustify: triggered by comment. * Introduce ipconfigSUPPORT_NETWORK_DOWN_EVENT compile flag * Fix formatting * Uncrustify: triggered by comment. --------- Co-authored-by: Filip Oleszek Co-authored-by: zipperowiec <35423392+zipperowiec@users.noreply.github.com> Co-authored-by: GitHub Action --- source/include/FreeRTOSIPConfigDefaults.h | 6 ++++++ .../NetworkInterface/STM32Fxx/NetworkInterface.c | 9 +++++++++ source/portable/NetworkInterface/STM32Fxx/readme.md | 1 + 3 files changed, 16 insertions(+) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index d830e03220..eae975a99b 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -1068,4 +1068,10 @@ #define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 0 #endif +/* Set to 1 if you want to receive eNetworkDown notification via vApplicationIPNetworkEventHook() callback. + * Not all drivers support this feature. */ +#ifndef ipconfigSUPPORT_NETWORK_DOWN_EVENT + #define ipconfigSUPPORT_NETWORK_DOWN_EVENT 0 +#endif + #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */ diff --git a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c index 9ab6a0d793..9ee73327f2 100644 --- a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c @@ -1308,6 +1308,15 @@ static void prvEMACHandlerTask( void * pvParameters ) { /* Something has changed to a Link Status, need re-check. */ prvEthernetUpdateConfig( pdFALSE ); + + #if ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) + { + if( xGetPhyLinkStatus() == pdFALSE ) + { + FreeRTOS_NetworkDown(); + } + } + #endif /* ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) */ } } } diff --git a/source/portable/NetworkInterface/STM32Fxx/readme.md b/source/portable/NetworkInterface/STM32Fxx/readme.md index 0b266875d8..e644a18706 100644 --- a/source/portable/NetworkInterface/STM32Fxx/readme.md +++ b/source/portable/NetworkInterface/STM32Fxx/readme.md @@ -81,6 +81,7 @@ Recommended settings for STM32Fxx Network Interface: #define ipconfigZERO_COPY_RX_DRIVER 1 #define ipconfigZERO_COPY_TX_DRIVER 1 #define ipconfigUSE_LINKED_RX_MESSAGES 1 +#define ipconfigSUPPORT_NETWORK_DOWN_EVENT 1 ``` **Defined in stm32f4xx_hal_conf.h** From 54583740a843255914652de2d4b044dcb9c1e357 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Mon, 3 Apr 2023 10:39:27 +0000 Subject: [PATCH 35/44] Uncrustify bot command fix (#816) * fix uncrustify run command * test uncrustify * Revert "test uncrustify" This reverts commit f660ab435fa741f8767f8a2849829f02a92ecca6. --- .github/workflows/uncrustify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml index 2e492b8ba6..15a5d9b20b 100644 --- a/.github/workflows/uncrustify.yml +++ b/.github/workflows/uncrustify.yml @@ -34,8 +34,8 @@ jobs: with: repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} ref: ${{ steps.upstreambranch.outputs.branchname }} - - name: Install Uncrustify - run: apt-get update && apt-get install uncrustify + - name: Install Uncrustify and Git + run: apt-get update && apt-get install uncrustify git-all - name: Run Uncrustify run: | uncrustify --version From 00346c383d27e52a812352ece988b64aab3d6054 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Mon, 3 Apr 2023 11:40:59 +0000 Subject: [PATCH 36/44] Fix uncrustify bot command - disable install prompt (#819) * fix uncrustify run command * test uncrustify * Revert "test uncrustify" This reverts commit f660ab435fa741f8767f8a2849829f02a92ecca6. * removing apt-get prompt while installing git --- .github/workflows/uncrustify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml index 15a5d9b20b..af09e802a8 100644 --- a/.github/workflows/uncrustify.yml +++ b/.github/workflows/uncrustify.yml @@ -35,7 +35,7 @@ jobs: repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} ref: ${{ steps.upstreambranch.outputs.branchname }} - name: Install Uncrustify and Git - run: apt-get update && apt-get install uncrustify git-all + run: apt-get update && apt-get --assume-yes install uncrustify git - name: Run Uncrustify run: | uncrustify --version From f7e07f806de2ed5cff6639be71a8de55d2d44657 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Tue, 4 Apr 2023 05:11:50 +0000 Subject: [PATCH 37/44] Removing deprecated set-output command from uncrustify bot run yml (#820) * fix uncrustify run command * test uncrustify * Revert "test uncrustify" This reverts commit f660ab435fa741f8767f8a2849829f02a92ecca6. * removing apt-get prompt while installing git * removing the deprecated set-output command from uncrustify bot run yml, use latest git --- .github/workflows/uncrustify.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml index af09e802a8..be550aa0a0 100644 --- a/.github/workflows/uncrustify.yml +++ b/.github/workflows/uncrustify.yml @@ -15,17 +15,23 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" + - name: Install Utils + run: | + apt-get update && apt-get --assume-yes install software-properties-common curl jq sed + add-apt-repository ppa:git-core/ppa + apt-get update && apt-get --assume-yes install git + git --version - name: get pullrequest url run: | echo ${{ github.event.issue.pull_request.url }} - name: get upstream repo id: upstreamrepo run: | - echo "::set-output name=RemoteRepo::$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.repo.full_name' | sed 's/\"//g')" + echo "RemoteRepo=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.repo.full_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT - name: get upstream branch id: upstreambranch run: | - echo "::set-output name=branchname::$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.ref' | sed 's/\"//g')" + echo "branchname=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.ref' | sed 's/\"//g')" >> $GITHUB_OUTPUT - name: echo upstream repo:branch run: | echo ${{ steps.upstreamrepo.outputs.RemoteRepo }}:${{ steps.upstreambranch.outputs.branchname }} @@ -34,14 +40,15 @@ jobs: with: repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} ref: ${{ steps.upstreambranch.outputs.branchname }} - - name: Install Uncrustify and Git - run: apt-get update && apt-get --assume-yes install uncrustify git + - name: Install Uncrustify + run: apt-get update && apt-get --assume-yes install uncrustify - name: Run Uncrustify run: | uncrustify --version find . -iname "*.[hc]" -exec uncrustify -c tools/uncrustify.cfg --no-backup --replace {} + - name: Push changes to upstream repository run: | + git config --global --add safe.directory '*' git config --global user.name 'GitHub Action' git config --global user.email 'action@github.com' git add -A From d7003598726cfaa4205f1a72e0546d1627d9b27e Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Wed, 17 May 2023 15:05:51 +0800 Subject: [PATCH 38/44] IPv4/Single: Let send() stop blocking after a connection reset (#561) * IPv4/Single: Let send() stop after a protocol error * Remove token need * Repaired unit-testing * Added the cunftion test_FreeRTOS_send_DisconnectionOccursDuringWait() * Added a comment for unit-test function test_FreeRTOS_send_DisconnectionOccursDuringWait() * Added an item to lexicon.txt * Restored original tcp_utilities * Restored original tcp_utilities, once more --------- Co-authored-by: Hein Tibosch Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> --- .github/lexicon.txt | 1 + source/FreeRTOS_Sockets.c | 10 ++++- .../FreeRTOS_Sockets_TCP_API_utest.c | 44 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/.github/lexicon.txt b/.github/lexicon.txt index 13e137c8a9..6b3eca5be7 100644 --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -720,6 +720,7 @@ prvtcpprepareconnect prvtcppreparesend prvtcpreturnpacket prvtcpsendchallengeack +prvtcpsendcheck prvtcpsendpacket prvtcpsendrepeated prvtcpsendreset diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 91a7c268ff..3b50f71c73 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -3826,8 +3826,16 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) ( void ) xEventGroupWaitBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_SEND | ( EventBits_t ) eSOCKET_CLOSED, pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); + xByteCount = ( BaseType_t ) prvTCPSendCheck( pxSocket, uxDataLength ); + + if( xByteCount < 0 ) + { + /* In a meanwhile, the connection has dropped, stop iterating. */ + break; + } + xByteCount = ( BaseType_t ) uxStreamBufferGetSpace( pxSocket->u.xTCP.txStream ); - } + } /* while( ipTRUE_BOOL ) */ /* How much was actually sent? */ xByteCount = ( ( BaseType_t ) uxDataLength ) - xBytesLeft; diff --git a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c index 65c354681e..8120234912 100644 --- a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c +++ b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c @@ -984,6 +984,7 @@ void test_FreeRTOS_send_LessSpaceInStreamBuffer_Timeout( void ) xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); vTaskSetTimeOutState_ExpectAnyArgs(); xEventGroupWaitBits_ExpectAndReturn( xSocket.xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, pdTRUE, pdFALSE, 100, pdFALSE ); + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( &xBoundTCPSocketsList ); /* Second Iteration. No space still. */ uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, 0 ); @@ -1026,6 +1027,7 @@ void test_FreeRTOS_send_LessSpaceInStreamBuffer_EventuallySpaceAvailable( void ) xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); vTaskSetTimeOutState_ExpectAnyArgs(); xEventGroupWaitBits_ExpectAndReturn( xSocket.xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, pdTRUE, pdFALSE, 100, pdFALSE ); + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( &xBoundTCPSocketsList ); /* Second Iteration. */ uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, 20 ); @@ -1068,6 +1070,7 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void ) xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); vTaskSetTimeOutState_ExpectAnyArgs(); xEventGroupWaitBits_ExpectAndReturn( xSocket.xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, pdTRUE, pdFALSE, 100, pdFALSE ); + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( &xBoundTCPSocketsList ); /* Second Iteration. */ uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, 10 ); @@ -1078,6 +1081,7 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void ) xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFALSE ); xEventGroupWaitBits_ExpectAndReturn( xSocket.xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, pdTRUE, pdFALSE, 100, pdFALSE ); + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( &xBoundTCPSocketsList ); /* Third iteration. No space still. */ uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, 0 ); @@ -1089,6 +1093,46 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void ) TEST_ASSERT_EQUAL( uxDataLength - 10, xReturn ); } +/* + * @brief While waiting for space, the socket gets disconnected. + */ +void test_FreeRTOS_send_DisconnectionOccursDuringWait( void ) +{ + BaseType_t xReturn; + FreeRTOS_Socket_t xSocket; + uint8_t pvBuffer[ ipconfigTCP_MSS ]; + size_t uxDataLength; + BaseType_t xFlags = 0; + StreamBuffer_t xLocalStreamBuffer; + + memset( &xSocket, 0, sizeof( xSocket ) ); + memset( pvBuffer, 0, ipconfigTCP_MSS ); + + xSocket.ucProtocol = FREERTOS_IPPROTO_TCP; + xSocket.u.xTCP.eTCPState = eESTABLISHED; + xSocket.u.xTCP.bits.bFinSent = pdFALSE_UNSIGNED; + xSocket.u.xTCP.txStream = &xLocalStreamBuffer; + xSocket.xSendBlockTime = 100; + + uxDataLength = 100; + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( &xBoundTCPSocketsList ); + uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, uxDataLength - 20 ); + uxStreamBufferAdd_ExpectAndReturn( xSocket.u.xTCP.txStream, 0U, pvBuffer, uxDataLength - 20, uxDataLength - 20 ); + xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); + xSendEventToIPTask_ExpectAndReturn( eTCPTimerEvent, pdFALSE ); + xIsCallingFromIPTask_ExpectAndReturn( pdFALSE ); + vTaskSetTimeOutState_ExpectAnyArgs(); + xEventGroupWaitBits_ExpectAndReturn( xSocket.xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, pdTRUE, pdFALSE, 100, pdFALSE ); + + /* Let `socketSOCKET_IS_BOUND()` return false, so that prvTCPSendCheck() + * returns en error, so that the loop is stopped. */ + listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( NULL ); + + xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags ); + + TEST_ASSERT_EQUAL( uxDataLength - 20, xReturn ); +} + /* * @brief IP task is calling send function with a NULL buffer. Also there are 20 bytes worth of space * less in the stream buffer as the data length. From 5ef383f94865736f09f1675819359c1f84f6f1c4 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 9 Jun 2023 10:25:23 +0530 Subject: [PATCH 39/44] Add logs to print random number generation failure (#908) Add logs to print random number generation failure for better debugging of issue. --- source/FreeRTOS_DHCP.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index a45ba62f78..d7646a12bb 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -670,7 +670,7 @@ } else { - /* There was a problem with the randomiser. */ + FreeRTOS_debug_printf( ( "prvInitialiseDHCP: failed to generate a random Transaction ID\n" ) ); } } /*-----------------------------------------------------------*/ From 62b6d1e22d499604d94b7db7721c433ab2d4bb56 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Mon, 12 Jun 2023 16:44:32 +0530 Subject: [PATCH 40/44] Update usage of uint64_t according to C90 standard (#907) Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com> --- source/include/FreeRTOS_IP_Private.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index e92bbd31b5..1ea544339d 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -536,15 +536,15 @@ BaseType_t xIPIsNetworkTaskReady( void ); { struct { - uint64_t ullAlignmentWord; /**< Increase the alignment of this union by adding a 64-bit variable. */ + uint32_t ullAlignmentWord; /**< Increase the alignment of this union by adding a 32-bit variable. */ } a; /**< A struct to increase alignment. */ struct { /* The next field only serves to give 'ucLastPacket' a correct - * alignment of 8 + 2. See comments in FreeRTOS_IP.h */ + * alignment of 4 + 2. See comments in FreeRTOS_IP.h */ uint8_t ucFillPacket[ ipconfigPACKET_FILLER_SIZE ]; uint8_t ucLastPacket[ sizeof( TCPPacket_t ) ]; - } u; /**< The structure to give an alignment of 8 + 2 */ + } u; /**< The structure to give an alignment of 4 + 2 */ } LastTCPPacket_t; /** @@ -709,14 +709,11 @@ typedef struct xSOCKET union { - IPUDPSocket_t xUDP; /**< Union member: UDP socket*/ + IPUDPSocket_t xUDP; /**< Union member: UDP socket*/ #if ( ipconfigUSE_TCP == 1 ) - IPTCPSocket_t xTCP; /**< Union member: TCP socket */ - - uint64_t ullTCPAlignment; /**< Make sure that xTCP is 8-bytes aligned by - * declaring a 64-bit variable in the same union */ + IPTCPSocket_t xTCP; /**< Union member: TCP socket */ #endif /* ipconfigUSE_TCP */ - } u; /**< Union of TCP/UDP socket */ + } u; /**< Union of TCP/UDP socket */ } FreeRTOS_Socket_t; #if ( ipconfigUSE_TCP == 1 ) From 06b98f47ea3a94bea678d406a40c7a5765c7656d Mon Sep 17 00:00:00 2001 From: Rahul Arasikere Date: Mon, 12 Jun 2023 17:48:44 -0400 Subject: [PATCH 41/44] Fix pragma pack in CCS compiler to push/pop (#906) `#pragma pack(1)` would make it so that all structs inserted after pack_struct_start.h was included for the TI arm compiler would be packed, leading to potential unaligned memory access error. Refer: https://www.ti.com/lit/ug/spnu151w/spnu151w.pdf SECTION 5.11.23 --- source/portable/Compiler/CCS/pack_struct_end.h | 2 ++ source/portable/Compiler/CCS/pack_struct_start.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/portable/Compiler/CCS/pack_struct_end.h b/source/portable/Compiler/CCS/pack_struct_end.h index 0a48709bdf..a6353c971b 100644 --- a/source/portable/Compiler/CCS/pack_struct_end.h +++ b/source/portable/Compiler/CCS/pack_struct_end.h @@ -25,6 +25,8 @@ * * Contains a semicolon to end the wrapped structure, * and resets warnings that were supressed in pack_struct_start.h. + * It also pops the previously pushed alignment of 1 byte of the stack. */ ; +#pragma pack(pop) #pragma diag_pop diff --git a/source/portable/Compiler/CCS/pack_struct_start.h b/source/portable/Compiler/CCS/pack_struct_start.h index ff2a0870dd..bd8eb30983 100644 --- a/source/portable/Compiler/CCS/pack_struct_start.h +++ b/source/portable/Compiler/CCS/pack_struct_start.h @@ -25,7 +25,8 @@ * * Also suppress an incorrect warning from the CCS compiler: * error #1916-D: definition at end of file not followed by a semicolon or a declarator + * Pushes the struct alignment of packed. */ #pragma diag_push #pragma diag_suppress=1916 -#pragma pack(1) +#pragma pack(push, 1) From f71fe91f52c726178010ffcbca41dc1ce0b207cc Mon Sep 17 00:00:00 2001 From: Xiaodong Li <85011700+ChaiTowKway@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:31:47 -0700 Subject: [PATCH 42/44] Modified libslirp backend file to cover different libslirp library versions (#929) Authored-by: Xiaodong Li --- .../libslirp/MBuffNetifBackendLibslirp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c index ae75ccfd81..e2af820774 100644 --- a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c +++ b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c @@ -197,8 +197,12 @@ void vMBuffNetifBackendInit( MessageBufferHandle_t * pxSendMsgBuffer, #if SLIRP_CHECK_VERSION( 4U, 7U, 0U ) xSlirpConfig.version = 4U; - #else + #elif SLIRP_CHECK_VERSION( 4U, 3U, 0U ) xSlirpConfig.version = 3U; + #elif SLIRP_CHECK_VERSION( 4U, 2U, 0U ) + xSlirpConfig.version = 2U; + #else + xSlirpConfig.version = 1U; #endif xSlirpConfig.restricted = false; @@ -227,7 +231,10 @@ void vMBuffNetifBackendInit( MessageBufferHandle_t * pxSendMsgBuffer, xSlirpConfig.disable_host_loopback = false; xSlirpConfig.enable_emu = false; - xSlirpConfig.disable_dns = false; + + #if SLIRP_CHECK_VERSION( 4U, 3U, 0U ) + xSlirpConfig.disable_dns = false; + #endif #if SLIRP_CHECK_VERSION( 4U, 7U, 0U ) xSlirpConfig.disable_dhcp = false; From 1ceb4f0361fffb3237c8db880ecad96dde253acf Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Mon, 3 Jul 2023 12:30:20 +0000 Subject: [PATCH 43/44] Update according to devIntegration --- source/FreeRTOS_Sockets.c | 4 - source/FreeRTOS_UDP_IP.c | 2 +- source/include/FreeRTOS_IP_Private.h | 4 - .../NXP1060/NetworkInterface.c | 804 ------------------ .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 23 - .../FreeRTOS_TCP_Transmission_utest.c | 27 - 6 files changed, 1 insertion(+), 863 deletions(-) delete mode 100644 source/portable/NetworkInterface/NXP1060/NetworkInterface.c diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index f9d4acd27c..c5a06ad6a2 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -57,10 +57,6 @@ #include "tcp_mem_stats.h" #endif -#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) - #include "tcp_mem_stats.h" -#endif - /* The ItemValue of the sockets xBoundSocketListItem member holds the socket's * port number. */ /** @brief Set the port number for the socket in the xBoundSocketListItem. */ diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index 3eafcfae93..c659b745bc 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -150,7 +150,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ - pxUDPPacket = ( ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const UDPPacket_t * pxUDPPacket = ( ( const UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); switch( pxUDPPacket->xEthernetHeader.usFrameType ) { diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index f28e9a82ab..51463f1ce9 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -371,10 +371,6 @@ extern struct xNetworkInterface * pxNetworkInterfaces; * rather than duplicated in its own variable. */ #define ipLOCAL_MAC_ADDRESS ( xDefaultPartUDPPacketHeader.ucBytes ) -/* The loopback address block is defined as part of rfc5735 */ -#define ipLOOPBACK_ADDRESS ( FreeRTOS_inet_addr_quick( 127, 0, 0, 0 ) ) -#define ipLOOPBACK_NETMASK ( FreeRTOS_inet_addr_quick( 255, 0, 0, 0 ) ) - /* ICMP packets are sent using the same function as UDP packets. The port * number is used to distinguish between the two, as 0 is an invalid UDP port. */ #define ipPACKET_CONTAINS_ICMP_DATA ( 0 ) diff --git a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c deleted file mode 100644 index d1739d97cd..0000000000 --- a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c +++ /dev/null @@ -1,804 +0,0 @@ -/* - * FreeRTOS+TCP - * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * https://www.FreeRTOS.org - * https://github.com/FreeRTOS - */ - -/** - * @file NetworkInterface.c - * @brief Implements the Network Interface driver for the NXP MIMXRT1060 board. - */ -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -#include "fsl_device_registers.h" -#include "fsl_debug_console.h" -#include "board.h" - -#include "fsl_phy.h" - -#include "fsl_phyksz8081.h" -#include "fsl_enet_mdio.h" -#include "fsl_enet.h" - -#include "NetworkInterface.h" - -#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1 - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#endif - -/* MDIO operations. */ -#define EXAMPLE_MDIO_OPS enet_ops - -/* PHY operations. */ -#define EXAMPLE_PHY_OPS phyksz8081_ops - -/* ENET clock frequency. */ -#define EXAMPLE_CLOCK_FREQ CLOCK_GetFreq( kCLOCK_IpgClk ) - - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define ENET_RING_NUM ( 1 ) - -/* The length or RX buffer. */ -#ifndef ENET_RXBUFF_SIZE - #define ENET_RXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN ) -#endif - -/* ENET IRQ priority. Used in FreeRTOS. */ -/* Interrupt priorities. */ -#ifdef __CA7_REV - #ifndef ENET_PRIORITY - #define ENET_PRIORITY ( 21U ) - #endif - #ifndef ENET_1588_PRIORITY - #define ENET_1588_PRIORITY ( 20U ) - #endif -#else - #ifndef ENET_PRIORITY - #define ENET_PRIORITY ( 6U ) - #endif - #ifndef ENET_1588_PRIORITY - #define ENET_1588_PRIORITY ( 5U ) - #endif -#endif /* ifdef __CA7_REV */ - -/* The number of ENET buffers needed to receive frame of maximum length. */ -#define MAX_BUFFERS_PER_FRAME \ - ( ( ENET_FRAME_MAX_FRAMELEN / ENET_RXBUFF_SIZE ) + ( ( ENET_FRAME_MAX_FRAMELEN % ENET_RXBUFF_SIZE == 0 ) ? 0 : 1 ) ) - -/* The length or TX buffer. */ -#ifndef ENET_TXBUFF_SIZE - #define ENET_TXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN ) -#endif - -/* The number of buffer descriptors in ENET RX ring. */ -#ifndef ENET_RXBD_NUM - #define ENET_RXBD_NUM ( 5 ) -#endif - -/* Ring should be able to receive at least 1 frame with maximum length. */ -#if ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME - #error "ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME" -#endif - -/* The number of RX buffers. ENET_RXBD_NUM is always held by ENET driver. */ -#ifndef ENET_RXBUFF_NUM - #define ENET_RXBUFF_NUM ( ENET_RXBD_NUM * 2 ) -#endif - -/* At least ENET_RXBD_NUM number of buffers is always held by ENET driver - * for RX. */ -#if ENET_RXBUFF_NUM < ( ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME ) - #error "ENET_RXBUFF_NUM < (ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME)" -#endif - -/* The number of buffer descriptors in ENET TX ring. */ -#ifndef ENET_TXBD_NUM - #define ENET_TXBD_NUM ( 3 ) -#endif - -/* Set the timeout values such that the total timeout adds up to 4000ms. */ -#define MAX_AUTONEG_FAILURE_COUNT ( 40 ) -#define SINGLE_ITERATION_TIMEOUT ( 100 ) - -#if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL - #if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && \ - ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) - #if defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) - #define FSL_CACHE_LINESIZE_MAX MAX( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE, FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) - #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_CACHE_LINESIZE_MAX ) - #else - #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) - #endif - #elif defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) - #define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE ) - #else - #define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT - #endif /* if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) */ -#else /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */ - #define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT -#endif /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */ - -/* A bigger value is chosen so that the previous notification values are - * not interfering with the driver ready notifications. */ -#define DRIVER_READY ( 0x40 ) -#define DRIVER_FATAL ( DRIVER_READY << 1 ) - -#if defined( ENET_ENHANCEDBUFFERDESCRIPTOR_MODE ) - #error "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is not supported by this driver" -#endif - -typedef uint8_t rx_buffer_t[ SDK_SIZEALIGN( ENET_RXBUFF_SIZE, FSL_ENET_BUFF_ALIGNMENT ) ]; -typedef uint8_t tx_buffer_t[ SDK_SIZEALIGN( ENET_TXBUFF_SIZE, FSL_ENET_BUFF_ALIGNMENT ) ]; - -/** - * @brief Used to wrap received data a buffer to be passed into the stack. - */ -typedef struct rx_pbuf_wrapper -{ - void * buffer; /*!< Original buffer wrapped. */ - volatile bool buffer_used; /*!< Wrapped buffer is used by ENET or FreeRTOS+TCP. */ -} rx_pbuf_wrapper_t; - -/** - * Helper structure to hold private data used to operate your Ethernet interface. - */ -struct ethernetif -{ - ENET_Type * base; - enet_handle_t handle; - enet_rx_bd_struct_t * RxBuffDescrip; - enet_tx_bd_struct_t * TxBuffDescrip; - rx_buffer_t * RxDataBuff; - tx_buffer_t * TxDataBuff; - rx_pbuf_wrapper_t RxPbufs[ ENET_RXBUFF_NUM ]; -}; - -typedef enum xEMAC_STATE -{ - xEMAC_SetupPHY, - xEMAC_WaitPHY, - xEMAC_Init, - xEMAC_Ready, -} EMACState_t; - -static EMACState_t eEMACState = xEMAC_SetupPHY; - -static mdio_handle_t mdioHandle = { .ops = &EXAMPLE_MDIO_OPS }; - -static phy_handle_t phyHandle = { .phyAddr = 0x00, .mdioHandle = &mdioHandle, .ops = &EXAMPLE_PHY_OPS }; - -/** - * The task-handle for deferred interrupt handler task that processes - * incoming packets. - */ -static TaskHandle_t receiveTaskHandle = NULL; - -static struct ethernetif EthernetInterface1; -static struct ethernetif * ethernetifLocal = &EthernetInterface1; - -static bool bGlobalLinkStatus = false; - -/*-----------------------------------------------------------*/ - -AT_NONCACHEABLE_SECTION_ALIGN( static enet_rx_bd_struct_t rxBuffDescrip_0[ ENET_RXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); -AT_NONCACHEABLE_SECTION_ALIGN( static enet_tx_bd_struct_t txBuffDescrip_0[ ENET_TXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); -SDK_ALIGN( static rx_buffer_t rxDataBuff_0[ ENET_RXBUFF_NUM ], FSL_ENET_BUFF_ALIGNMENT ); -SDK_ALIGN( static tx_buffer_t txDataBuff_0[ ENET_TXBD_NUM ], FSL_ENET_BUFF_ALIGNMENT ); - -/*-----------------------------------------------------------*/ -/*-----------------------------------------------------------*/ -/*------------ PHY configuration parameters. ----------------*/ -static phy_config_t xConfig = -{ - .autoNeg = pdTRUE, /* Allow auto-negotiation. */ - .duplex = kPHY_FullDuplex, /* Use full duplex mode. In case - * auto-negotiation is turned on, - * this is not used. */ - .phyAddr = BOARD_ENET0_PHY_ADDRESS, /* The PHY address. */ - .speed = kPHY_Speed100M, /* Use 100 Mbps configuration (maximum possible - * for this PHY). In case auto-negotiation is - * turned on, this is not used. */ - .enableEEE = pdFALSE /* Disable the energy efficient PHY. */ -}; - -/*-----------------------------------------------------------*/ -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void * pvParameters ); - -static void ethernet_callback( ENET_Type * base, - enet_handle_t * handle, - enet_event_t event, - enet_frame_info_t * frameInfo, - void * userData ); - -static void prvProcessFrame( int length ); - -static status_t xSetupPHY( phy_config_t * pxConfig ); - -static status_t xWaitPHY( phy_config_t xConfig ); - -static status_t xEMACInit( phy_speed_t speed, - phy_duplex_t duplex ); - -BaseType_t xNetworkInterfaceInitialise( void ) -{ - status_t xStatus; - BaseType_t xResult = pdFAIL; - phy_speed_t speed; - phy_duplex_t duplex; - BaseType_t xTaskCreated; - static BaseType_t xFirstCall = pdTRUE; - - configASSERT( FSL_FEATURE_ENET_QUEUE == 1 ); - - switch( eEMACState ) - { - case xEMAC_SetupPHY: - xStatus = xSetupPHY( &xConfig ); - - if( xStatus != kStatus_Success ) - { - break; - } - else - { - eEMACState = xEMAC_WaitPHY; - } - - /* Fall through. */ - case xEMAC_WaitPHY: - FreeRTOS_printf( ( "Configuration successful. Waiting for link to go up" - " and auto-negotiation to complete." ) ); - - xStatus = xWaitPHY( xConfig ); - - if( xStatus == kStatus_Success ) - { - xStatus = PHY_GetLinkSpeedDuplex( &phyHandle, &speed, &duplex ); - } - - if( xStatus != kStatus_Success ) - { - break; - } - else - { - eEMACState = xEMAC_Init; - } - - /* Fall through. */ - case xEMAC_Init: - xStatus = xEMACInit( speed, duplex ); - - if( ( xFirstCall == pdTRUE ) || ( receiveTaskHandle == NULL ) ) - { - if( xStatus == kStatus_Success ) - { - /* The link is now up. */ - bGlobalLinkStatus = true; - - /* The handler task is created at the highest possible priority to - * ensure the interrupt handler can return directly to it. */ - xTaskCreated = xTaskCreate( prvEMACHandlerTask, - "EMAC-Handler", - configMINIMAL_STACK_SIZE * 3, - NULL, - configMAX_PRIORITIES - 1, - &receiveTaskHandle ); - - if( ( receiveTaskHandle == NULL ) || ( xTaskCreated != pdPASS ) ) - { - FreeRTOS_printf( ( "Failed to create the handler task." ) ); - break; - } - - /* Enable the interrupt and set its priority to the minimum - * interrupt priority. */ - NVIC_SetPriority( ENET_IRQn, ENET_PRIORITY ); - NVIC_EnableIRQ( ENET_IRQn ); - - eEMACState = xEMAC_Ready; - - /* After this, the task should not be created. */ - xFirstCall = pdFALSE; - } - else - { - break; - } - } - else - { - eEMACState = xEMAC_Ready; - } - - /* Fall through. */ - case xEMAC_Ready: - FreeRTOS_printf( ( "Driver ready for use." ) ); - - /* Kick the task once the driver is ready. */ - if( receiveTaskHandle != NULL ) - { - xTaskNotify( receiveTaskHandle, DRIVER_READY, eSetValueWithOverwrite ); - } - - xResult = pdPASS; - - break; - } - - return xResult; -} - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t xReleaseAfterSend ) -{ - status_t result; - BaseType_t xReturn = pdFAIL; - - if( bGlobalLinkStatus == true ) - { - /* ENET_SendFrame copies the data before sending it. Therefore, the network buffer can - * be released without worrying about the buffer memory being used by the ENET_SendFrame - * function. */ - result = ENET_SendFrame( ethernetifLocal->base, - ðernetifLocal->handle, - pxNetworkBuffer->pucEthernetBuffer, - pxNetworkBuffer->xDataLength, - 0, - false, - NULL ); - - switch( result ) - { - case kStatus_ENET_TxFrameBusy: - FreeRTOS_printf( ( "Failed to send the frame - driver busy!" ) ); - break; - - case kStatus_Success: - iptraceNETWORK_INTERFACE_TRANSMIT(); - xReturn = pdPASS; - break; - } - } - - if( xReleaseAfterSend == pdTRUE ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - - return xReturn; -} - -static void prvEMACHandlerTask( void * parameter ) -{ - bool bLinkUp = false; - status_t readStatus; - - /* Wait for the driver to finish starting. */ - ( void ) ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); - - while( pdTRUE ) - { - if( ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( 500 ) ) == pdFALSE ) - { - /* No RX packets for a bit so check for a link. */ - const IPStackEvent_t xNetworkEventDown = { .eEventType = eNetworkDownEvent, .pvData = NULL }; - - do - { - readStatus = PHY_GetLinkStatus( &phyHandle, &bLinkUp ); - - if( readStatus == kStatus_Success ) - { - if( bLinkUp == pdFALSE ) - { - /* The link is down. */ - bGlobalLinkStatus = false; - /* We need to setup the PHY again. */ - eEMACState = xEMAC_WaitPHY; - - FreeRTOS_printf( ( "Link down!" ) ); - - xSendEventStructToIPTask( &xNetworkEventDown, 0U ); - - /* Wait for the driver to finish initialization. */ - uint32_t ulNotificationValue; - - do - { - ulNotificationValue = ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); - } while( !( ulNotificationValue & DRIVER_READY ) ); - } - else - { - /* The link is still up. */ - bGlobalLinkStatus = true; - } - } - } while( bGlobalLinkStatus == false ); - } - else - { - BaseType_t receiving = pdTRUE; - - /* A packet was received, the link must be up. */ - bGlobalLinkStatus = true; - - while( receiving == pdTRUE ) - { - uint32_t length; - const status_t status = ENET_GetRxFrameSize( &( ethernetifLocal->handle ), &length, 0 ); - - switch( status ) - { - case kStatus_Success: /* there is a frame. process it */ - - if( length ) - { - prvProcessFrame( length ); - } - - break; - - case kStatus_ENET_RxFrameEmpty: /* Received an empty frame. Ignore it */ - receiving = pdFALSE; - break; - - case kStatus_ENET_RxFrameError: /* Received an error frame. Read & drop it */ - PRINTF( "RX Receive Error\n" ); - ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), NULL, 0, 0, NULL ); - /* Not sure if a trace is required. The MAC had an error and needed to dump bytes */ - break; - - default: - PRINTF( "RX Receive default" ); - break; - } - } - } - } -} - -/** - * @brief Callback for ENET interrupts. We have only enabled the Ethernet receive interrupts - * in the case of this driver. - */ -static void ethernet_callback( ENET_Type * base, - enet_handle_t * handle, - enet_event_t event, - enet_frame_info_t * frameInfo, - void * userData ) -{ - BaseType_t needsToYield = pdFALSE; - - ( void ) base; - ( void ) handle; - ( void ) frameInfo; - ( void ) userData; - - switch( event ) - { - case kENET_RxEvent: - vTaskNotifyGiveFromISR( receiveTaskHandle, &needsToYield ); - portEND_SWITCHING_ISR( needsToYield ); - break; - - default: - FreeRTOS_printf( ( "Unknown interrupt callback %u!", event ) ); - break; - } -} - -/** - * @brief This function verifies that the incoming frame needs processing. - * If the frame is deemed to be appropriate, then the frame is sent to the - * TCP stack for further processing. - * @param[in] length: The length of the incoming frame. This length should be read - * using a call to ENET_GetRxFrameSize. - */ -static void prvProcessFrame( int length ) -{ - NetworkBufferDescriptor_t * pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( length, 0 ); - - if( pxBufferDescriptor != NULL ) - { - ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), pxBufferDescriptor->pucEthernetBuffer, length, 0, NULL ); - pxBufferDescriptor->xDataLength = length; - - if( ipCONSIDER_FRAME_FOR_PROCESSING( pxBufferDescriptor->pucEthernetBuffer ) == eProcessBuffer ) - { - IPStackEvent_t xRxEvent; - xRxEvent.eEventType = eNetworkRxEvent; - xRxEvent.pvData = ( void * ) pxBufferDescriptor; - - if( xSendEventStructToIPTask( &xRxEvent, 0 ) == pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor ); - iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "RX Event Lost\n" ) ); - } - } - else - { - #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) - const EthernetHeader_t * pxEthernetHeader; - char ucSource[ 18 ]; - char ucDestination[ 18 ]; - - pxEthernetHeader = ( ( const EthernetHeader_t * ) pxBufferDescriptor->pucEthernetBuffer ); - - - FreeRTOS_EUI48_ntop( pxEthernetHeader->xSourceAddress.ucBytes, ucSource, 'A', ':' ); - FreeRTOS_EUI48_ntop( pxEthernetHeader->xDestinationAddress.ucBytes, ucDestination, 'A', ':' ); - - FreeRTOS_debug_printf( ( "Invalid target MAC: dropping frame from: %s to: %s", ucSource, ucDestination ) ); - #endif /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) */ - vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor ); - /* Not sure if a trace is required. The stack did not want this message */ - } - } - else - { - #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) - FreeRTOS_debug_printf( ( "No Buffer Available: dropping incoming frame!!" ) ); - #endif - ENET_ReadFrame( ENET, &( ethernetifLocal->handle ), NULL, length, 0, NULL ); - - /* No buffer available to receive this message */ - iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER(); - } -} - - -/** - * @brief This function is used to setup the PHY in auto-negotiation mode. - * - * @param[out] pxConfig: the configuration parameters. - * - * @return kStatus_Success if the PHY was initialized; error code otherwise. - */ -static status_t xSetupPHY( phy_config_t * pxConfig ) -{ - status_t xStatus; - - /* Set the clock frequency. MDIO handle is pointed to by the PHY handle. */ - mdioHandle.resource.csrClock_Hz = EXAMPLE_CLOCK_FREQ; - mdioHandle.resource.base = ( void * ) ENET_BASE; - - FreeRTOS_printf( ( "Starting PHY initialization." ) ); - - xStatus = PHY_Init( &phyHandle, pxConfig ); - - if( xStatus != kStatus_Success ) - { - FreeRTOS_printf( ( "Failed to initialize the PHY." ) ); - } - - return xStatus; -} - -/** - * @brief This function is used wait on the auto-negotiation completion. - * - * @param[in] xConfig: the configuration parameters. - * - * @return kStatus_Success if the PHY was initialized; error code otherwise. - */ -static status_t xWaitPHY( phy_config_t xConfig ) -{ - status_t xStatus; - bool bLinkUp; - bool bAutoNegotiationComplete; - uint8_t ucCounter = 0; - - do - { - xStatus = PHY_GetLinkStatus( &phyHandle, &bLinkUp ); - - if( bLinkUp == true ) - { - break; - } - - /* Try for only a limited number of times. */ - if( ucCounter++ > MAX_AUTONEG_FAILURE_COUNT ) - { - break; - } - - vTaskDelay( pdMS_TO_TICKS( SINGLE_ITERATION_TIMEOUT ) ); - } - while( xStatus == kStatus_Success ); - - if( bLinkUp == false ) - { - FreeRTOS_printf( ( "Failed to get the link up." ) ); - xStatus = kStatus_Fail; - } - else - { - FreeRTOS_printf( ( "Link up." ) ); - } - - if( ( xStatus == kStatus_Success ) && - ( bLinkUp == true ) && - ( xConfig.autoNeg == true ) ) - { - /* Reset the counter for next use. */ - ucCounter = 0; - - FreeRTOS_printf( ( "Waiting for auto-negotiation to complete." ) ); - - do - { - xStatus = PHY_GetAutoNegotiationStatus( &phyHandle, &bAutoNegotiationComplete ); - - if( bAutoNegotiationComplete == true ) - { - break; - } - - /* Try for only a limited number of times. */ - if( ucCounter++ > MAX_AUTONEG_FAILURE_COUNT ) - { - break; - } - - vTaskDelay( pdMS_TO_TICKS( SINGLE_ITERATION_TIMEOUT ) ); - } - while( xStatus == kStatus_Success ); - - if( bAutoNegotiationComplete == false ) - { - FreeRTOS_printf( ( "Failed to complete auto-negotiation." ) ); - xStatus = kStatus_Fail; - } - else - { - /* Success in auto-negotiation and the link is up. */ - FreeRTOS_printf( ( "Auto-negotiation complete." ) ); - } - } - - return xStatus; -} - -/** - * @brief This function is used to initialize the ENET module. It initializes the network buffers - * and buffer descriptors. - * - * @param[in] speed: The speed of communication (either set by auto-negotiation or the default - * value). - * @param[in] duplex: The nature of the channel. This must be set to kPHY_FullDuplex by - * auto-negotiation. - * - * @return kStatus_Success if the ENET module was initialized; error code otherwise. - */ -static status_t xEMACInit( phy_speed_t speed, - phy_duplex_t duplex ) -{ - enet_config_t config; - uint32_t sysClock; - enet_buffer_config_t buffCfg[ ENET_RING_NUM ]; - status_t xStatus; - uint32_t instance; - static ENET_Type * const enetBases[] = ENET_BASE_PTRS; - static const IRQn_Type enetTxIrqId[] = ENET_Transmit_IRQS; - /*! @brief Pointers to enet receive IRQ number for each instance. */ - static const IRQn_Type enetRxIrqId[] = ENET_Receive_IRQS; - int i; - - ethernetifLocal->RxBuffDescrip = &( rxBuffDescrip_0[ 0 ] ); - ethernetifLocal->TxBuffDescrip = &( txBuffDescrip_0[ 0 ] ); - ethernetifLocal->RxDataBuff = &( rxDataBuff_0[ 0 ] ); - ethernetifLocal->TxDataBuff = &( txDataBuff_0[ 0 ] ); - ethernetifLocal->base = ( void * ) ENET_BASE; - - /* prepare the buffer configuration. */ - buffCfg[ 0 ].rxBdNumber = ENET_RXBD_NUM; /* Number of RX buffer descriptors. */ - buffCfg[ 0 ].txBdNumber = ENET_TXBD_NUM; /* Transmit buffer descriptor number. */ - buffCfg[ 0 ].rxBuffSizeAlign = sizeof( rx_buffer_t ); /* Aligned receive data buffer size. */ - buffCfg[ 0 ].txBuffSizeAlign = sizeof( tx_buffer_t ); /* Aligned transmit data buffer size. */ - buffCfg[ 0 ].rxBdStartAddrAlign = - &( rxBuffDescrip_0[ 0 ] ); /* Aligned receive buffer descriptor start address. */ - buffCfg[ 0 ].txBdStartAddrAlign = - &( txBuffDescrip_0[ 0 ] ); /* Aligned transmit buffer descriptor start address. */ - buffCfg[ 0 ].rxBufferAlign = - &( rxDataBuff_0[ 0 ][ 0 ] ); /* Receive data buffer start address. */ - buffCfg[ 0 ].txBufferAlign = &( txDataBuff_0[ 0 ][ 0 ] ); /* Transmit data buffer start address. */ - buffCfg[ 0 ].txFrameInfo = NULL; /* Transmit frame information start address. Set only if using zero-copy transmit. */ - buffCfg[ 0 ].rxMaintainEnable = true; /* Receive buffer cache maintain. */ - buffCfg[ 0 ].txMaintainEnable = true; /* Transmit buffer cache maintain. */ - - sysClock = phyHandle.mdioHandle->resource.csrClock_Hz; - - ENET_GetDefaultConfig( &config ); - - config.ringNum = ENET_RING_NUM; - config.rxBuffAlloc = NULL; - config.rxBuffFree = NULL; - config.userData = ethernetifLocal; - config.miiSpeed = ( enet_mii_speed_t ) speed; - config.miiDuplex = ( enet_mii_duplex_t ) duplex; - - /* Only get interrupt for incoming messages. */ - config.interrupt = kENET_RxFrameInterrupt; - config.callback = ethernet_callback; - - for( instance = 0; instance < ARRAY_SIZE( enetBases ); instance++ ) - { - if( enetBases[ instance ] == ethernetifLocal->base ) - { - NVIC_SetPriority( enetRxIrqId[ instance ], ENET_PRIORITY ); - NVIC_SetPriority( enetTxIrqId[ instance ], ENET_PRIORITY ); - break; - } - } - - configASSERT( instance != ARRAY_SIZE( enetBases ) ); - - if( instance == ARRAY_SIZE( enetBases ) ) - { - xStatus = kStatus_Fail; - } - else - { - for( i = 0; i < ENET_RXBUFF_NUM; i++ ) - { - ethernetifLocal->RxPbufs[ i ].buffer = &( ethernetifLocal->RxDataBuff[ i ][ 0 ] ); - ethernetifLocal->RxPbufs[ i ].buffer_used = false; - } - - /* Initialize the ENET module. */ - xStatus = ENET_Init( ethernetifLocal->base, - ðernetifLocal->handle, - &config, - &buffCfg[ 0 ], - ipLOCAL_MAC_ADDRESS, - sysClock ); - - if( xStatus == kStatus_Success ) - { - FreeRTOS_printf( ( "ENET initialized." ) ); - ENET_ActiveRead( ethernetifLocal->base ); - } - else - { - FreeRTOS_printf( ( "Failed to initialize ENET." ) ); - } - } - - return xStatus; -} diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index feb9dcb388..cf1bcaf643 100755 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1411,29 +1411,6 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_InCache( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } -void test_xCheckRequiresARPResolution_OnLocalNetwork_Loopback( void ) -{ - NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; - uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; - BaseType_t xResult; - - pxNetworkBuffer = &xNetworkBuffer; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; - - IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - - *ipLOCAL_IP_ADDRESS_POINTER = ipLOOPBACK_ADDRESS; - - /* Make sure there is a match on source IP and loopback address */ - pxIPHeader->ulDestinationIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; - pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER & xNetworkAddressing.ulNetMask; - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdFALSE, xResult ); -} - void test_ulARPRemoveCacheEntryByMac_NoMatch( void ) { diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index 578acc7208..b2194f5ec3 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -2444,33 +2444,6 @@ void test_prvTCPSendSpecialPacketHelper_flagSYN( void ) TEST_ASSERT_EQUAL( ulSequenceNumber + 1, FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulAckNr ) ); } -/* test prvTCPSendSpecialPacketHelper function */ -void test_prvTCPSendSpecialPacketHelper_flagSYN( void ) -{ - BaseType_t Return = pdTRUE; - const uint32_t ulSequenceNumber = 0xABC12300; - - pxSocket = &xSocket; - pxNetworkBuffer = &xNetworkBuffer; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; - TCPPacket_t * pxTCPPacket = ( ( const TCPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - - pxTCPPacket->xTCPHeader.ucTCPFlags = tcpTCP_FLAG_SYN; - pxTCPPacket->xTCPHeader.ucTCPOffset = 0; - pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); - - usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); - usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); - xNetworkInterfaceOutput_ExpectAnyArgsAndReturn( pdTRUE ); - - Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); - TEST_ASSERT_EQUAL( pdFALSE, Return ); - TEST_ASSERT_EQUAL( tcpTCP_FLAG_ACK, pxTCPPacket->xTCPHeader.ucTCPFlags ); - TEST_ASSERT_EQUAL( 0x50, pxTCPPacket->xTCPHeader.ucTCPOffset ); - TEST_ASSERT_EQUAL( ulSequenceNumber + 1, FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulAckNr ) ); -} - /* test prvTCPSendChallengeAck function */ void test_prvTCPSendChallengeAck( void ) { From ea1c201db50f5683075f9bafc7ba443f55278859 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Tue, 4 Jul 2023 10:04:32 +0000 Subject: [PATCH 44/44] Update links to point to main directory --- GettingStarted_4.0.0-rc3.md | 6 +++--- History.txt | 8 ++++---- README.md | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/GettingStarted_4.0.0-rc3.md b/GettingStarted_4.0.0-rc3.md index 9813ecc016..f8f7b5e122 100644 --- a/GettingStarted_4.0.0-rc3.md +++ b/GettingStarted_4.0.0-rc3.md @@ -1,7 +1,7 @@ Moving to 4.0.0-rc1/rc2/rc3 from 3.x.x: -------------------------------- -Version 4.0.0-rc1/rc2/rc3 adds new files to support IPv6 functionality, breaking each file into logically separated IPv4 and IPv6 files. The folder structure of FreeRTOS-Plus-TCP remains unchanged. Build separation is added to make the library modular, enabling users to compile and create a low-footprint binary with only the required functionalities. For more details on supported build combinations, see [History.txt](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/dev/IPv6_integration/History.txt) . +Version 4.0.0-rc1/rc2/rc3 adds new files to support IPv6 functionality, breaking each file into logically separated IPv4 and IPv6 files. The folder structure of FreeRTOS-Plus-TCP remains unchanged. Build separation is added to make the library modular, enabling users to compile and create a low-footprint binary with only the required functionalities. For more details on supported build combinations, see [History.txt](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/History.txt) . Some of the APIs have changed which is illustrated in the section below. However, there is a backward compatibility mode provided as well. @@ -67,9 +67,9 @@ Change 7: Running Demos: ------------- -The demos can be found at: https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo +The demos can be found on [this page](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo). In all the demos, there is a backward compatibility mode which can be enabled by setting the flag “ipconfigIPv4_BACKWARD_COMPATIBLE” to 1 in the header file “FreeRTOSIPConfigDefaults.h”. This flag is by default set to zero. -New IPv6 WinSim Demo: https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo +New IPv6 WinSim Demo can be found on [this page](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo). diff --git a/History.txt b/History.txt index 14e4077d79..1ca7103630 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,4 @@ -Changes between dev/ipv6_integration branch 4.0.0-RC3 and 4.0.0-RC2 releases: +Changes between 4.0.0-RC3 and 4.0.0-RC2 releases: + Added memory safety proofs for IPv6 using[ CBMC automated reasoning tool ] ( https:/*www.cprover.org/cbmc/) + Introduced build separation feature to achieve low memory footprint. Supported build combinations: 1. IPv4 + UDP @@ -8,13 +8,13 @@ Changes between dev/ipv6_integration branch 4.0.0-RC3 and 4.0.0-RC2 releases: 5. IPv4 + IPv6 + UDP 6. IPv4 + IPv6 + UDP + TCP -Changes between dev/ipv6_integration branch 4.0.0-RC2 and 4.0.0-RC1 releases: +Changes between 4.0.0-RC2 and 4.0.0-RC1 releases: + Added changes to fix IPv6 issues observed by Maxwell protocol tester. -Changes between dev/ipv6_integration branch RC1 and main branch V3.0.0 releases: +Changes between RC1 and V3.0.0 releases: + Unified code for IPv4 and IPv6 + Multiple Interface/Endpoint support - ((Reference: https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/freertostcp-multiple-interfaces.html). + (Reference: https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/freertostcp-multiple-interfaces.html). + New WinSim demo to support both IPv4 and IPv6. **Note**- This release does not support ESP32/ M487/ mw300_rd ports yet. This will be released soon. diff --git a/README.md b/README.md index 79619f41f0..ef61177be9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -## NOTE - Work In Progress +## Introduction This branch contains unified IPv4 and IPv6 functionalities. -Refer to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/dev/IPv6_integration/GettingStarted_4.0.0-rc3.md)) for more details. +Refer to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/GettingStarted_4.0.0-rc3.md)) for more details. ## FreeRTOS-Plus-TCP Library FreeRTOS-Plus-TCP is a lightweight TCP/IP stack for FreeRTOS. It provides a familiar Berkeley sockets interface, making it as simple to use and learn as possible. FreeRTOS-Plus-TCP's features and RAM footprint are fully scalable, making FreeRTOS-Plus-TCP equally applicable to smaller lower throughput microcontrollers as well as larger higher throughput microprocessors. @@ -9,8 +9,8 @@ FreeRTOS-Plus-TCP is a lightweight TCP/IP stack for FreeRTOS. It provides a fami This library has undergone static code analysis and checks for compliance with the [MISRA coding standard](https://www.misra.org.uk/). Any deviations from the MISRA C:2012 guidelines are documented under [MISRA Deviations](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md). The library is validated for memory safety and data structure invariance through the [CBMC automated reasoning tool](https://www.cprover.org/cbmc/) for the functions that parse data originating from the network. The library is also protocol tested using Maxwell protocol tester for both IPv4 and IPv6. ## Getting started -The easiest way to use the 4.0.0-rc3 version of FreeRTOS-Plus-TCP is to refer to to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/dev/IPv6_integration/GettingStarted_4.0.0-rc3.md)) -Another way is to start with the pre-configured demo application project (found in [this directory](https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator)). That way you will have the correct FreeRTOS source files included, and the correct include paths configured. Once a demo application is building and executing you can remove the demo application files, and start to add in your own application source files. See the [FreeRTOS Kernel Quick Start Guide](https://www.freertos.org/FreeRTOS-quick-start-guide.html) for detailed instructions and other useful links. +The easiest way to use the 4.0.0-rc3 version of FreeRTOS-Plus-TCP is to refer to to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/GettingStarted_4.0.0-rc3.md)) +Another way is to start with the pre-configured demo application project (found in [this directory](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator)). That way you will have the correct FreeRTOS source files included, and the correct include paths configured. Once a demo application is building and executing you can remove the demo application files, and start to add in your own application source files. See the [FreeRTOS Kernel Quick Start Guide](https://www.freertos.org/FreeRTOS-quick-start-guide.html) for detailed instructions and other useful links. Additionally, for FreeRTOS-Plus-TCP source code organization refer to the [Documentation](http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial.html), and [API Reference](https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html).