diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 3ea88bfb0..80b2b7abc 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -364,15 +364,15 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt xTxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CRCPAD; #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - /*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */ - xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM; - xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC; - } + { + /*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */ + xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM; + xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC; + } #else - { - xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE; - } + { + xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE; + } #endif xTxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT; @@ -389,40 +389,40 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt uint8_t * pucBuffer; #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE ); - configASSERT( pucBuffer != NULL ); - } + { + pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE ); + configASSERT( pucBuffer != NULL ); + } #else - { - pucBuffer = Rx_Buff[ uxIndex ]; - } + { + pucBuffer = Rx_Buff[ uxIndex ]; + } #endif HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } #if ( ipconfigUSE_MDNS == 1 ) - { - /* Program the MDNS address. */ - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddress.ucBytes ); - } + { + /* Program the MDNS address. */ + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddress.ucBytes ); + } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddressIPv6.ucBytes ); - } + { + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddressIPv6.ucBytes ); + } #endif #if ( ipconfigUSE_LLMNR == 1 ) - { - /* Program the LLMNR address. */ - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddress.ucBytes ); - } + { + /* Program the LLMNR address. */ + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddress.ucBytes ); + } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); - } + { + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); + } #endif { @@ -467,11 +467,11 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt } #if ( ipconfigUSE_IPv6 != 0 ) - { - /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ - const uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; - prvSetMAC_HashFilter( &xEthHandle, ucMACAddress ); - } + { + /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ + const uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + prvSetMAC_HashFilter( &xEthHandle, ucMACAddress ); + } #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* Initialize the MACB and set all PHY properties */ @@ -624,18 +624,18 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa if( xSemaphoreTake( xTransmissionMutex, xBlockTimeTicks ) != pdFAIL ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Do not release the buffer. */ - xReleaseAfterSend = pdFALSE; - } + { + /* Do not release the buffer. */ + xReleaseAfterSend = pdFALSE; + } #else - { - memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); + { + memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); - /* A memory barrier to make sure that the outgoing packets has been written - * to the physical memory. */ - __DSB(); - } + /* A memory barrier to make sure that the outgoing packets has been written + * to the physical memory. */ + __DSB(); + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ if( HAL_ETH_Transmit_IT( &( xEthHandle ), &( xTxConfig ) ) == HAL_OK ) @@ -726,13 +726,13 @@ static void prvEthernetUpdateConfig( BaseType_t xForce ) MACConf.Speed = speed; HAL_ETH_SetMACConfig( &( xEthHandle ), &( MACConf ) ); #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) - { - MACConf.ChecksumOffload = ENABLE; - } + { + MACConf.ChecksumOffload = ENABLE; + } #else - { - MACConf.ChecksumOffload = DISABLE; - } + { + MACConf.ChecksumOffload = DISABLE; + } #endif /* ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) */ /* Restart MAC interface */ @@ -770,30 +770,30 @@ static BaseType_t prvNetworkInterfaceInput( void ) xReturn++; #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Reserve the maximum length for the next reception. */ - uxLength = ETH_RX_BUF_SIZE; - - if( data_buffer.buffer != NULL ) - { - pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer ); - #if ( ipconfigTCP_IP_SANITY != 0 ) - { - configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 ); - } - #endif - } + { + /* Reserve the maximum length for the next reception. */ + uxLength = ETH_RX_BUF_SIZE; - if( pxReceivedBuffer == NULL ) + if( data_buffer.buffer != NULL ) + { + pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer ); + #if ( ipconfigTCP_IP_SANITY != 0 ) { - FreeRTOS_printf( ( "Strange: no descriptor received\n" ) ); + configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 ); } + #endif } - #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + + if( pxReceivedBuffer == NULL ) { - /* Reserve the length of the packet that was just received. */ - uxLength = uxDataLength; + FreeRTOS_printf( ( "Strange: no descriptor received\n" ) ); } + } + #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + { + /* Reserve the length of the packet that was just received. */ + uxLength = uxDataLength; + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( uxLength, 0u ); @@ -806,33 +806,33 @@ static BaseType_t prvNetworkInterfaceInput( void ) } #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) + { + if( pxBufferDescriptor == NULL ) { - if( pxBufferDescriptor == NULL ) - { - /* Can not receive this packet. Buffer will be re-used. */ - pxReceivedBuffer = NULL; - } - else if( pxReceivedBuffer != NULL ) - { - pxReceivedBuffer->xDataLength = uxDataLength; - } - else - { - /* Allocating a new buffer failed. */ - } + /* Can not receive this packet. Buffer will be re-used. */ + pxReceivedBuffer = NULL; + } + else if( pxReceivedBuffer != NULL ) + { + pxReceivedBuffer->xDataLength = uxDataLength; + } + else + { + /* Allocating a new buffer failed. */ } + } #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + { + if( pxBufferDescriptor != NULL ) { - if( pxBufferDescriptor != NULL ) - { - pxReceivedBuffer = pxBufferDescriptor; - /* The copy method. */ - memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength ); - pxReceivedBuffer->xDataLength = uxDataLength; - /* Make sure that the descriptor isn't used any more. */ - pxBufferDescriptor = NULL; - } + pxReceivedBuffer = pxBufferDescriptor; + /* The copy method. */ + memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength ); + pxReceivedBuffer->xDataLength = uxDataLength; + /* Make sure that the descriptor isn't used any more. */ + pxBufferDescriptor = NULL; } + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ { @@ -1092,36 +1092,36 @@ static void prvEMACHandlerTask( void * pvParameters ) BaseType_t xResult = 0; #if ( ipconfigHAS_PRINTF != 0 ) - { - size_t uxUsed; - size_t uxOwnCount; + { + size_t uxUsed; + size_t uxOwnCount; - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); - /* Some more statistics: number of free descriptors. */ - uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore ); + /* Some more statistics: number of free descriptors. */ + uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore ); - if( uxTXDescriptorsUsed < uxUsed ) - { - uxTXDescriptorsUsed = uxUsed; - FreeRTOS_printf( ( "TX descriptors %u/%u\n", - uxTXDescriptorsUsed, - ETH_TX_DESC_CNT ) ); - } + if( uxTXDescriptorsUsed < uxUsed ) + { + uxTXDescriptorsUsed = uxUsed; + FreeRTOS_printf( ( "TX descriptors %u/%u\n", + uxTXDescriptorsUsed, + ETH_TX_DESC_CNT ) ); + } - uxOwnCount = uxGetOwnCount( &( xEthHandle ) ); + uxOwnCount = uxGetOwnCount( &( xEthHandle ) ); - if( uxRXDescriptorsUsed > uxOwnCount ) - { - uxRXDescriptorsUsed = uxOwnCount; - FreeRTOS_printf( ( "RX descriptors %u/%u\n", - uxRXDescriptorsUsed, - ETH_RX_DESC_CNT ) ); - } + if( uxRXDescriptorsUsed > uxOwnCount ) + { + uxRXDescriptorsUsed = uxOwnCount; + FreeRTOS_printf( ( "RX descriptors %u/%u\n", + uxRXDescriptorsUsed, + ETH_RX_DESC_CNT ) ); } + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ ulTaskNotifyTake( pdFALSE, ulMaxBlockTime );