From 47610b88c85818a603eb7fb6f830a66aa4c5781e Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Thu, 13 Jul 2023 19:00:11 +0530 Subject: [PATCH 01/17] fix --- .../portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 7105ca26a..ee41e9d5b 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -412,7 +412,7 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 100U ); uint8_t * pucTXBuffer; - if( xGetPhyLinkStatus( pxInterface ) == = pdPASS ) + if( xSTM32H_GetPhyLinkStatus( pxInterface ) == pdPASS ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) /* Zero-copy method, pass the buffer. */ @@ -870,8 +870,6 @@ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkB } /*-----------------------------------------------------------*/ -#define __NOP() __ASM volatile ( "nop" ) - static void vClearOptionBit( volatile uint32_t * pulValue, uint32_t ulValue ) { @@ -994,7 +992,7 @@ static void prvEMACHandlerTask( void * pvParameters ) * The function xPhyCheckLinkStatus() returns pdTRUE if the * Link Status has changes since it was called the last time. */ - if( xGetPhyLinkStatus( pxMyInterface ) == pdFALSE ) + if( xSTM32H_GetPhyLinkStatus( pxMyInterface ) == pdFALSE ) { /* Stop the DMA transfer. */ HAL_ETH_Stop_IT( &( xEthHandle ) ); From e3f4288d9789cdc8ff10c6e3366531daa4d05915 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 14 Jul 2023 01:18:07 +0530 Subject: [PATCH 02/17] MAC filter updated for DAD and IPv6 all nodes multicast --- .../STM32Hxx/NetworkInterface.c | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index ee41e9d5b..58351191d 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -203,6 +203,30 @@ const PhyProperties_t xPHYProperties = }; /*-----------------------------------------------------------*/ +static void prvMACAddressConfig( ETH_HandleTypeDef * heth, + uint32_t ulIndex, + uint8_t * Addr ) +{ + uint32_t ulTempReg; + uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); + uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + + configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + + /* Calculate the selected MAC address high register. */ + ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; + + /* Load the selected MAC address high register. */ + ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; + + /* Calculate the selected MAC address low register. */ + ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ]; + + /* Load the selected MAC address low register */ + ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg; +} + +/*-----------------------------------------------------------*/ /******************************************************************************* @@ -232,6 +256,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt NetworkEndPoint_t * pxEndPoint; HAL_StatusTypeDef xHalEthInitStatus; size_t uxIndex = 0; + BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ if( xMacInitStatus == eMACInit ) { @@ -304,6 +329,55 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } + { + /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ + for( ; + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + { + #if ( ipconfigUSE_IPv6 != 0 ) + if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + else + #else /* if ( ipconfigUSE_IPv6 != 0 ) */ + { + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); + xMACEntry += 8; + } + } + #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ + + if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) + { + /* No more locations available. */ + break; + } + } + } + + #if ( ipconfigUSE_IPv6 != 0 ) + { + if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) + { + /* 33:33:00:00:00:01 */ + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + } + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + /* Initialize the MACB and set all PHY properties */ prvMACBProbePhy(); From 6a66c1191fba405056c8436c88901b5da027cdae Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:37:50 +0530 Subject: [PATCH 03/17] add more comments --- .../STM32Hxx/NetworkInterface.c | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 58351191d..b4a7a7213 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -205,14 +205,18 @@ const PhyProperties_t xPHYProperties = static void prvMACAddressConfig( ETH_HandleTypeDef * heth, uint32_t ulIndex, - uint8_t * Addr ) + const uint8_t * Addr ) { uint32_t ulTempReg; uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ + configASSERT(ulIndex <= ETH_MAC_ADDRESS3); + /* Calculate the selected MAC address high register. */ ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; @@ -329,6 +333,33 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } + #if ( ipconfigUSE_MDNS == 1 ) + { + /* Program the MDNS address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ipconfigUSE_LLMNR == 1 ) + { + /* Program the LLMNR address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); + xMACEntry += 8; + } + #endif + { /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ for( ; @@ -343,6 +374,9 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + + /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; } @@ -369,7 +403,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt { if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) { - /* 33:33:00:00:00:01 */ + /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); From e020d04c28f1ef962bfc9f6ca1a5aab841c56bec Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:39:02 +0530 Subject: [PATCH 04/17] fix formatting --- .../NetworkInterface/STM32Hxx/NetworkInterface.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index b4a7a7213..e39dee7ec 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -208,14 +208,14 @@ static void prvMACAddressConfig( ETH_HandleTypeDef * heth, const uint8_t * Addr ) { uint32_t ulTempReg; - uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); - uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + uint32_t ulETH_MAC_ADDR_HBASE = ( uint32_t ) &( heth->Instance->MACA0HR ); + uint32_t ulETH_MAC_ADDR_LBASE = ( uint32_t ) &( heth->Instance->MACA0LR ); /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ - configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + configASSERT( ulIndex >= ETH_MAC_ADDRESS1 ); /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ - configASSERT(ulIndex <= ETH_MAC_ADDRESS3); + configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); /* Calculate the selected MAC address high register. */ ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; @@ -363,8 +363,8 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt { /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ for( ; - pxEndPoint != NULL; - pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) { #if ( ipconfigUSE_IPv6 != 0 ) if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) @@ -375,8 +375,8 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address"of this endpoint - for Duplicate Address Detection (DAD) */ + /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + * for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; } From 221472e77c8a27c255ea5821d2c3c6400ee30cfa Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:46:45 +0530 Subject: [PATCH 05/17] fix comments --- source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index e39dee7ec..d56582dfd 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -375,7 +375,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; From c463e558c0233114896cebc44c671b35b478676a Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 14 Jul 2023 11:59:56 +0530 Subject: [PATCH 06/17] fix review comments --- .../STM32Hxx/NetworkInterface.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index d56582dfd..8515df855 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -391,6 +391,40 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt } #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ + switch( pxEndPoint->bits.bIPv6 ) + { + #if ( ipconfigUSE_IPv4 != 0 ) + case pdFALSE_UNSIGNED: + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); + xMACEntry += 8; + } + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + + #if ( ipconfigUSE_IPv6 != 0 ) + case pdTRUE_UNSIGNED: + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + + /* Allow traffic destined to Solicited-Node multicast address of this endpoint + * for Duplicate Address Detection (DAD) */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + break; + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + /* MISRA 16.4 Compliance */ + break; + } + if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) { /* No more locations available. */ From 38c21352ac2adfa752fe24acfaedde720b14f4c9 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 12:03:48 +0530 Subject: [PATCH 07/17] fix formatting --- .../STM32Hxx/NetworkInterface.c | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 8515df855..1ac323778 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -366,35 +366,11 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt pxEndPoint != NULL; pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) { - #if ( ipconfigUSE_IPv6 != 0 ) - if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - - /* Allow traffic destined to Solicited-Node multicast address of this endpoint - * for Duplicate Address Detection (DAD) */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } - else - #else /* if ( ipconfigUSE_IPv6 != 0 ) */ - { - if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) - { - prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); - xMACEntry += 8; - } - } - #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ - - switch( pxEndPoint->bits.bIPv6 ) + switch( pxEndPoint->bits.bIPv6 ) { #if ( ipconfigUSE_IPv4 != 0 ) case pdFALSE_UNSIGNED: + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); @@ -405,19 +381,19 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_IPv6 != 0 ) case pdTRUE_UNSIGNED: - { - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address of this endpoint + /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } - break; + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ default: From 7721d8d2a8da6da51eba75d62bd0382aa44c1aee Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 16:44:12 +0530 Subject: [PATCH 08/17] update review comments --- source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 1ac323778..6e319a021 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -214,7 +214,9 @@ static void prvMACAddressConfig( ETH_HandleTypeDef * heth, /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ configASSERT( ulIndex >= ETH_MAC_ADDRESS1 ); - /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ + /* STM32Hxx devices support 4 MAC address registers + * (ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3), make sure ulIndex is not + * more than that. */ configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); /* Calculate the selected MAC address high register. */ From 061765f2c773d6989da2ba0616718b00b3ae9661 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Sat, 15 Jul 2023 15:16:01 +0530 Subject: [PATCH 09/17] enable multicast packets in MAC --- .../STM32Hxx/NetworkInterface.c | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 6e319a021..4d67261cd 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -220,7 +220,7 @@ static void prvMACAddressConfig( ETH_HandleTypeDef * heth, configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); /* Calculate the selected MAC address high register. */ - ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; + ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; /* Load the selected MAC address high register. */ ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; @@ -263,6 +263,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt HAL_StatusTypeDef xHalEthInitStatus; size_t uxIndex = 0; BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ + ETH_MACFilterConfigTypeDef xFilterConfig; if( xMacInitStatus == eMACInit ) { @@ -292,6 +293,10 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* Only for inspection by debugger. */ ( void ) xHalEthInitStatus; + HAL_ETH_GetMACFilterConfig(&( xEthHandle ), &(xFilterConfig)); + xFilterConfig.PassAllMulticast = ENABLE; + HAL_ETH_SetMACFilterConfig(&( xEthHandle ), &(xFilterConfig)); + /* Configuration for HAL_ETH_Transmit(_IT). */ memset( &( xTxConfig ), 0, sizeof( ETH_TxPacketConfig ) ); xTxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CRCPAD; @@ -411,18 +416,18 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt } } - #if ( ipconfigUSE_IPv6 != 0 ) - { - if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) - { - /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; - - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } - } - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + // #if ( ipconfigUSE_IPv6 != 0 ) + // { + // if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) + // { + // /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ + // uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + + // prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + // xMACEntry += 8; + // } + // } + // #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* Initialize the MACB and set all PHY properties */ prvMACBProbePhy(); From 38fe1a013172562589ff2b27de0a7d0b77d4e9e5 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Mon, 17 Jul 2023 00:29:41 +0530 Subject: [PATCH 10/17] use multi cast MAC filter --- .../STM32Hxx/NetworkInterface.c | 138 +++++++++++------- 1 file changed, 84 insertions(+), 54 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 4d67261cd..701577e6a 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -69,6 +69,11 @@ #define EMAC_IF_TX_EVENT 2UL #define EMAC_IF_ERR_EVENT 4UL +/* + * Enable either Hash or Perfect Filter, Multicast filter - None, + * Enable Hash Multicast, and Enable Hash Unicast. + */ +#define ENABLE_MULTICAST_HASH_FILTER ( ( uint32_t ) 0x00000416U ) #ifndef niEMAC_HANDLER_TASK_NAME #define niEMAC_HANDLER_TASK_NAME "EMAC-task" @@ -203,33 +208,77 @@ const PhyProperties_t xPHYProperties = }; /*-----------------------------------------------------------*/ -static void prvMACAddressConfig( ETH_HandleTypeDef * heth, - uint32_t ulIndex, - const uint8_t * Addr ) +static uint32_t prvRevBits32(uint32_t ulValue) { - uint32_t ulTempReg; - uint32_t ulETH_MAC_ADDR_HBASE = ( uint32_t ) &( heth->Instance->MACA0HR ); - uint32_t ulETH_MAC_ADDR_LBASE = ( uint32_t ) &( heth->Instance->MACA0LR ); + uint32_t ulRev32; + int iIndex; + + ulRev32 = 0; + + for(iIndex=0; iIndex<32; iIndex++) + { + if (ulValue & (1 << iIndex)) + { + { + ulRev32 |= 1 << (31 - iIndex); + } + } + } + + return ulRev32; + +} + +static uint32_t prvComputeCRC32_MAC(const uint8_t *pucMAC) +{ + int iiIndex, ijIndex; + uint32_t ulCRC32 = 0xFFFFFFFF; + + for(ijIndex=0; ijIndex<6; ijIndex++) + { + ulCRC32 = ulCRC32 ^ (uint32_t)pucMAC[ijIndex]; + + for(iiIndex=0; iiIndex<8; iiIndex++) + { + if (ulCRC32 & 1) + { + ulCRC32 = (ulCRC32 >> 1) ^ prvRevBits32(0x04C11DB7); /* IEEE 802.3 CRC32 polynomial - 0x04C11DB7 */ + } + else + { + ulCRC32 = (ulCRC32 >> 1); + } + } + } - /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ - configASSERT( ulIndex >= ETH_MAC_ADDRESS1 ); + ulCRC32 = ~(ulCRC32); + return ulCRC32; - /* STM32Hxx devices support 4 MAC address registers - * (ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3), make sure ulIndex is not - * more than that. */ - configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); +} - /* Calculate the selected MAC address high register. */ - ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; +static uint32_t prvComputeEthernet_MACHash(const uint8_t *pucMAC) +{ + uint32_t ulCRC32; + uint32_t ulHash; + + ulCRC32 = prvComputeCRC32_MAC(pucMAC); + ulHash = prvRevBits32(ulCRC32); - /* Load the selected MAC address high register. */ - ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; + return (ulHash >> 26); +} - /* Calculate the selected MAC address low register. */ - ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ]; +static void prvSetMulitcastMAC_HashFilter(ETH_HandleTypeDef * pxEthHandle, const uint8_t *pucMAC) +{ + uint32_t ulHash; + ulHash = prvComputeEthernet_MACHash(pucMAC); - /* Load the selected MAC address low register */ - ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg; + if (ulHash < 32) + { + pxEthHandle->Instance->MACHT0R |= (1 << ulHash); + } else + { + pxEthHandle->Instance->MACHT1R |= (1 << (ulHash % 32)); + } } /*-----------------------------------------------------------*/ @@ -262,8 +311,6 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt NetworkEndPoint_t * pxEndPoint; HAL_StatusTypeDef xHalEthInitStatus; size_t uxIndex = 0; - BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ - ETH_MACFilterConfigTypeDef xFilterConfig; if( xMacInitStatus == eMACInit ) { @@ -293,9 +340,8 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* Only for inspection by debugger. */ ( void ) xHalEthInitStatus; - HAL_ETH_GetMACFilterConfig(&( xEthHandle ), &(xFilterConfig)); - xFilterConfig.PassAllMulticast = ENABLE; - HAL_ETH_SetMACFilterConfig(&( xEthHandle ), &(xFilterConfig)); + /* Update MAC filter settings */ + xEthHandle.Instance->MACPFR |= ENABLE_MULTICAST_HASH_FILTER; /* Configuration for HAL_ETH_Transmit(_IT). */ memset( &( xTxConfig ), 0, sizeof( ETH_TxPacketConfig ) ); @@ -343,27 +389,23 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_MDNS == 1 ) { /* Program the MDNS address. */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes); } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes); } #endif #if ( ipconfigUSE_LLMNR == 1 ) { /* Program the LLMNR address. */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes); } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes); } #endif @@ -380,8 +422,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { - prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, pxEndPoint->xMACAddress.ucBytes); } break; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -397,8 +438,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; + prvSetMulitcastMAC_HashFilter(&xEthHandle, ucMACAddress); } break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ @@ -408,26 +448,16 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt break; } - if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) - { - /* No more locations available. */ - break; - } } } - // #if ( ipconfigUSE_IPv6 != 0 ) - // { - // if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) - // { - // /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ - // uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; - - // prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - // xMACEntry += 8; - // } - // } - // #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + #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 }; + prvSetMulitcastMAC_HashFilter( &xEthHandle, ucMACAddress ); + } + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* Initialize the MACB and set all PHY properties */ prvMACBProbePhy(); From 5ef2ebf8faeeee173a7ab0e06a8e5fad32969c09 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 17 Jul 2023 00:34:23 +0530 Subject: [PATCH 11/17] fix formatting --- .../STM32Hxx/NetworkInterface.c | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 701577e6a..03565f503 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -65,12 +65,12 @@ #endif /* Interrupt events to process: reception, transmission and error handling. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL +#define EMAC_IF_RX_EVENT 1UL +#define EMAC_IF_TX_EVENT 2UL +#define EMAC_IF_ERR_EVENT 4UL -/* - * Enable either Hash or Perfect Filter, Multicast filter - None, +/* + * Enable either Hash or Perfect Filter, Multicast filter - None, * Enable Hash Multicast, and Enable Hash Unicast. */ #define ENABLE_MULTICAST_HASH_FILTER ( ( uint32_t ) 0x00000416U ) @@ -208,77 +208,78 @@ const PhyProperties_t xPHYProperties = }; /*-----------------------------------------------------------*/ -static uint32_t prvRevBits32(uint32_t ulValue) +static uint32_t prvRevBits32( uint32_t ulValue ) { uint32_t ulRev32; int iIndex; - + ulRev32 = 0; - - for(iIndex=0; iIndex<32; iIndex++) + + for( iIndex = 0; iIndex < 32; iIndex++ ) { - if (ulValue & (1 << iIndex)) + if( ulValue & ( 1 << iIndex ) ) { { - ulRev32 |= 1 << (31 - iIndex); + ulRev32 |= 1 << ( 31 - iIndex ); } } } - - return ulRev32; + return ulRev32; } -static uint32_t prvComputeCRC32_MAC(const uint8_t *pucMAC) +static uint32_t prvComputeCRC32_MAC( const uint8_t * pucMAC ) { int iiIndex, ijIndex; uint32_t ulCRC32 = 0xFFFFFFFF; - - for(ijIndex=0; ijIndex<6; ijIndex++) + + for( ijIndex = 0; ijIndex < 6; ijIndex++ ) { - ulCRC32 = ulCRC32 ^ (uint32_t)pucMAC[ijIndex]; - - for(iiIndex=0; iiIndex<8; iiIndex++) + ulCRC32 = ulCRC32 ^ ( uint32_t ) pucMAC[ ijIndex ]; + + for( iiIndex = 0; iiIndex < 8; iiIndex++ ) { - if (ulCRC32 & 1) + if( ulCRC32 & 1 ) { - ulCRC32 = (ulCRC32 >> 1) ^ prvRevBits32(0x04C11DB7); /* IEEE 802.3 CRC32 polynomial - 0x04C11DB7 */ + ulCRC32 = ( ulCRC32 >> 1 ) ^ prvRevBits32( 0x04C11DB7 ); /* IEEE 802.3 CRC32 polynomial - 0x04C11DB7 */ } else { - ulCRC32 = (ulCRC32 >> 1); + ulCRC32 = ( ulCRC32 >> 1 ); } } } - ulCRC32 = ~(ulCRC32); + ulCRC32 = ~( ulCRC32 ); return ulCRC32; - } -static uint32_t prvComputeEthernet_MACHash(const uint8_t *pucMAC) +static uint32_t prvComputeEthernet_MACHash( const uint8_t * pucMAC ) { uint32_t ulCRC32; uint32_t ulHash; - - ulCRC32 = prvComputeCRC32_MAC(pucMAC); - ulHash = prvRevBits32(ulCRC32); - return (ulHash >> 26); + ulCRC32 = prvComputeCRC32_MAC( pucMAC ); + ulHash = prvRevBits32( ulCRC32 ); + + return( ulHash >> 26 ); } -static void prvSetMulitcastMAC_HashFilter(ETH_HandleTypeDef * pxEthHandle, const uint8_t *pucMAC) +static void prvSetMulitcastMAC_HashFilter( ETH_HandleTypeDef * pxEthHandle, + const uint8_t * pucMAC ) { uint32_t ulHash; - ulHash = prvComputeEthernet_MACHash(pucMAC); - if (ulHash < 32) + ulHash = prvComputeEthernet_MACHash( pucMAC ); + + if( ulHash < 32 ) { - pxEthHandle->Instance->MACHT0R |= (1 << ulHash); - } else + pxEthHandle->Instance->MACHT0R |= ( 1 << ulHash ); + } + else { - pxEthHandle->Instance->MACHT1R |= (1 << (ulHash % 32)); - } + pxEthHandle->Instance->MACHT1R |= ( 1 << ( ulHash % 32 ) ); + } } /*-----------------------------------------------------------*/ @@ -389,23 +390,23 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_MDNS == 1 ) { /* Program the MDNS address. */ - prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes); + prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes); + prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); } #endif #if ( ipconfigUSE_LLMNR == 1 ) { /* Program the LLMNR address. */ - prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes); + prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMulitcastMAC_HashFilter(&xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes); + prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); } #endif @@ -422,7 +423,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { - prvSetMulitcastMAC_HashFilter(&xEthHandle, pxEndPoint->xMACAddress.ucBytes); + prvSetMulitcastMAC_HashFilter( &xEthHandle, pxEndPoint->xMACAddress.ucBytes ); } break; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -438,7 +439,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ - prvSetMulitcastMAC_HashFilter(&xEthHandle, ucMACAddress); + prvSetMulitcastMAC_HashFilter( &xEthHandle, ucMACAddress ); } break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ @@ -447,7 +448,6 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* MISRA 16.4 Compliance */ break; } - } } From 78730b22c59fa721da7d70f6b34ef62458c56cb1 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Mon, 17 Jul 2023 11:51:50 +0530 Subject: [PATCH 12/17] update naming and comments --- .../portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 18a4ea992..31ee9d09d 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -71,9 +71,9 @@ /* * Enable either Hash or Perfect Filter, Multicast filter - None, - * Enable Hash Multicast, and Enable Hash Unicast. + * Enable Hash Multicast (HMC), and Enable Hash Unicast (HUC). */ -#define ENABLE_MULTICAST_HASH_FILTER ( ( uint32_t ) 0x00000416U ) +#define ENABLE_HASH_FILTER_SETTINGS ( ( uint32_t ) 0x00000416U ) #ifndef niEMAC_HANDLER_TASK_NAME #define niEMAC_HANDLER_TASK_NAME "EMAC-task" @@ -312,7 +312,6 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt NetworkEndPoint_t * pxEndPoint; HAL_StatusTypeDef xHalEthInitStatus; size_t uxIndex = 0; - BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ if( xMacInitStatus == eMACInit ) { @@ -343,7 +342,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ( void ) xHalEthInitStatus; /* Update MAC filter settings */ - xEthHandle.Instance->MACPFR |= ENABLE_MULTICAST_HASH_FILTER; + xEthHandle.Instance->MACPFR |= ENABLE_HASH_FILTER_SETTINGS; /* Configuration for HAL_ETH_Transmit(_IT). */ memset( &( xTxConfig ), 0, sizeof( ETH_TxPacketConfig ) ); From 5527097babc8d081e57eae2eba0bad17f3a506ef Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 17 Jul 2023 12:05:53 +0530 Subject: [PATCH 13/17] update comments and formatting --- .../NetworkInterface/STM32Hxx/NetworkInterface.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 31ee9d09d..e9cf3d4f3 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -73,7 +73,7 @@ * Enable either Hash or Perfect Filter, Multicast filter - None, * Enable Hash Multicast (HMC), and Enable Hash Unicast (HUC). */ -#define ENABLE_HASH_FILTER_SETTINGS ( ( uint32_t ) 0x00000416U ) +#define ENABLE_HASH_FILTER_SETTINGS ( ( uint32_t ) 0x00000416U ) #ifndef niEMAC_HANDLER_TASK_NAME #define niEMAC_HANDLER_TASK_NAME "EMAC-task" @@ -208,6 +208,7 @@ const PhyProperties_t xPHYProperties = }; /*-----------------------------------------------------------*/ +/* Reverse the bits of a 32 bit unsigned integer */ static uint32_t prvRevBits32( uint32_t ulValue ) { uint32_t ulRev32; @@ -228,6 +229,7 @@ static uint32_t prvRevBits32( uint32_t ulValue ) return ulRev32; } +/* Compute the CRC32 of the given MAC address as per IEEE 802.3 CRC32 */ static uint32_t prvComputeCRC32_MAC( const uint8_t * pucMAC ) { int iiIndex, ijIndex; @@ -254,24 +256,35 @@ static uint32_t prvComputeCRC32_MAC( const uint8_t * pucMAC ) return ulCRC32; } +/* Compute the hash value of a given MAC address to index the bits in the Hash Table + * Registers (ETH_MACHT0R and ETH_MACHT1R) */ static uint32_t prvComputeEthernet_MACHash( const uint8_t * pucMAC ) { uint32_t ulCRC32; uint32_t ulHash; + /* Calculate the 32-bit CRC for the MAC */ ulCRC32 = prvComputeCRC32_MAC( pucMAC ); + + /* Perform bitwise reversal on the CRC32 */ ulHash = prvRevBits32( ulCRC32 ); + /* Take the upper 6 bits of the above result */ return( ulHash >> 26 ); } +/* Update the Hash Table Registers + * (ETH_MACHT0R and ETH_MACHT1R) with hash value of the given MAC address */ static void prvSetMulitcastMAC_HashFilter( ETH_HandleTypeDef * pxEthHandle, const uint8_t * pucMAC ) { uint32_t ulHash; + /* Compute the hash */ ulHash = prvComputeEthernet_MACHash( pucMAC ); + /* Use the upper (MACHT1R) or lower (MACHT0R) Hash Table Registers + * to set the required bit based on the ulHash */ if( ulHash < 32 ) { pxEthHandle->Instance->MACHT0R |= ( 1 << ulHash ); From 2cdab6e9d1171d7a21037033289f0b63db3575ac Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 17 Jul 2023 14:56:18 +0530 Subject: [PATCH 14/17] rename function --- .../NetworkInterface/STM32Hxx/NetworkInterface.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index e9cf3d4f3..c5059d0d3 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -275,7 +275,7 @@ static uint32_t prvComputeEthernet_MACHash( const uint8_t * pucMAC ) /* Update the Hash Table Registers * (ETH_MACHT0R and ETH_MACHT1R) with hash value of the given MAC address */ -static void prvSetMulitcastMAC_HashFilter( ETH_HandleTypeDef * pxEthHandle, +static void prvSetMAC_HashFilter( ETH_HandleTypeDef * pxEthHandle, const uint8_t * pucMAC ) { uint32_t ulHash; @@ -403,23 +403,23 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_MDNS == 1 ) { /* Program the MDNS address. */ - prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); } #endif #if ( ipconfigUSE_LLMNR == 1 ) { /* Program the LLMNR address. */ - prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMulitcastMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); } #endif @@ -436,7 +436,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { - prvSetMulitcastMAC_HashFilter( &xEthHandle, pxEndPoint->xMACAddress.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, pxEndPoint->xMACAddress.ucBytes ); } break; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -452,7 +452,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ - prvSetMulitcastMAC_HashFilter( &xEthHandle, ucMACAddress ); + prvSetMAC_HashFilter( &xEthHandle, ucMACAddress ); } break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ @@ -468,7 +468,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt { /* 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 }; - prvSetMulitcastMAC_HashFilter( &xEthHandle, ucMACAddress ); + prvSetMAC_HashFilter( &xEthHandle, ucMACAddress ); } #endif /* ( ipconfigUSE_IPv6 != 0 ) */ From 5e920428085b2de16bb70f1a7054e2564bdd599c Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 17 Jul 2023 15:01:00 +0530 Subject: [PATCH 15/17] fix formatting --- source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index c5059d0d3..55e4b633c 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -276,7 +276,7 @@ static uint32_t prvComputeEthernet_MACHash( const uint8_t * pucMAC ) /* Update the Hash Table Registers * (ETH_MACHT0R and ETH_MACHT1R) with hash value of the given MAC address */ static void prvSetMAC_HashFilter( ETH_HandleTypeDef * pxEthHandle, - const uint8_t * pucMAC ) + const uint8_t * pucMAC ) { uint32_t ulHash; From 5d94945ab064e5592386a4d9971c6c4ab3d4e7c8 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 7 Sep 2023 13:50:24 +0530 Subject: [PATCH 16/17] fix spell check --- .../NetworkInterface/STM32Hxx/NetworkInterface.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index d59e7d1fc..3ea88bfb0 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -405,23 +405,23 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_MDNS == 1 ) { /* Program the MDNS address. */ - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddress.ucBytes ); } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xMDNS_MacAddressIPv6.ucBytes ); } #endif #if ( ipconfigUSE_LLMNR == 1 ) { /* Program the LLMNR address. */ - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddress.ucBytes ); } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) { - prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); + prvSetMAC_HashFilter( &xEthHandle, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); } #endif @@ -619,7 +619,7 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa /* Memory barrier: Make sure that the data written to the packet buffer got written. */ __DSB(); - /* Get exclusive accces to the TX process. + /* Get exclusive access to the TX process. * Both the IP-task and the EMAC task will work on the TX process. */ if( xSemaphoreTake( xTransmissionMutex, xBlockTimeTicks ) != pdFAIL ) { From 3f875b41a68ee0e787d8d390200c081302dd1bef Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 7 Sep 2023 08:35:06 +0000 Subject: [PATCH 17/17] Uncrustify: triggered by comment --- .../STM32Hxx/NetworkInterface.c | 228 +++++++++--------- 1 file changed, 114 insertions(+), 114 deletions(-) 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 );